Skip to content

Commit

Permalink
Merge branch 'main' into xsalonx/MC/O2B-1162/update-display-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx authored Mar 1, 2024
2 parents e57667a + e13000e commit ed74930
Show file tree
Hide file tree
Showing 16 changed files with 685 additions and 5 deletions.
7 changes: 7 additions & 0 deletions lib/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { StatisticsPageModel } from './views/Statistics/StatisticsPageModel.js';
import { LhcPeriodsModel } from './views/lhcPeriods/LhcPeriodsModel.js';
import { HomePageModel } from './views/Home/Overview/HomePageModel.js';
import { DataPassesModel } from './views/DataPasses/DataPassesModel.js';
import { SimulationPassesModel } from './views/SimulationPasses/SimulationPassesModel.js';

/**
* Root of model tree
Expand Down Expand Up @@ -77,6 +78,9 @@ export default class Model extends Observable {
this.dataPasses = new DataPassesModel(this);
this.dataPasses.bubbleTo(this);

this.simulationPasses = new SimulationPassesModel(this);
this.simulationPasses.bubbleTo(this);

this.logs = new LogsModel(this);
this.logs.bubbleTo(this);

Expand Down Expand Up @@ -164,6 +168,9 @@ export default class Model extends Observable {
case 'data-passes-per-lhc-period-overview':
this.dataPasses.loadPerLhcPeriodOverview(this.router.params);
break;
case 'simulation-passes-per-lhc-period-overview':
this.simulationPasses.loadPerLhcPeriodOverview(this.router.params);
break;
case 'env-overview':
this.envs.loadOverview();
break;
Expand Down
19 changes: 19 additions & 0 deletions lib/public/utilities/formatting/formatItemsCount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

/**
* Format number to locale string
* @param {number} itemsCount number to be formatted
* @return {string} formatted number
*/
export const formatItemsCount = (itemsCount) => itemsCount.toLocaleString();
24 changes: 24 additions & 0 deletions lib/public/utilities/formatting/formatSizeInBytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

const DATA_SIZE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB'];

/**
* Format size in bytes as human readibly
* @param {number} size number of bytes to be formatted
* @return {string} formatted number
*/
export const formatSizeInBytes = (size) => {
const exponent = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
return `${Number((size / Math.pow(1024, exponent)).toFixed(2))} ${DATA_SIZE_UNITS[exponent]}`;
};
3 changes: 3 additions & 0 deletions lib/public/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { LhcPeriodsOverviewPage } from './views/lhcPeriods/Overview/LhcPeriodsOv
import { RunsPerLhcPeriodOverviewPage } from './views/Runs/RunPerPeriod/RunsPerLhcPeriodOverviewPage.js';
import { HomePage } from './views/Home/Overview/HomePage.js';
import { DataPassesPerLhcPeriodOverviewPage } from './views/DataPasses/PerLhcPeriodOverview/DataPassesPerLhcPeriodOverviewView.js';
import { SimulationPassesPerLhcPeriodOverviewPage }
from './views/SimulationPasses/PerLhcPeriodOverview/SimulationPassesPerLhcPeriodOverviewPage.js';
import { RunsPerDataPassOverviewPage } from './views/Runs/RunPerDataPass/RunsPerDataPassOverviewPage.js';
import { LogReplyPage } from './views/Logs/Create/LogReplyPage.js';

Expand All @@ -52,6 +54,7 @@ export default (model) => {
'lhc-period-overview': LhcPeriodsOverviewPage,

'data-passes-per-lhc-period-overview': DataPassesPerLhcPeriodOverviewPage,
'simulation-passes-per-lhc-period-overview': SimulationPassesPerLhcPeriodOverviewPage,

'log-overview': LogsOverview,
'log-detail': LogTreeViewPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const dataPassesActiveColumns = {
},

outputSize: {
name: 'Output Size [B]',
name: 'Output Size (B)',
visible: true,
format: (outputSize) => outputSize ? outputSize.toLocaleString('en-US') : '-',
sortable: true,
Expand Down
4 changes: 2 additions & 2 deletions lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,13 @@ export const runsActiveColumns = {
visible: false,
},
aliceL3Current: {
name: 'L3 [A]',
name: 'L3 (A)',
visible: true,
format: (_, run) => formatAliceCurrent(run.aliceL3Polarity, run.aliceL3Current),
profiles: ['runsPerLhcPeriod', 'runsPerDataPass'],
},
dipoleCurrent: {
name: 'Dipole [A]',
name: 'Dipole (A)',
visible: true,
format: (_, run) => formatAliceCurrent(run.aliceDipolePolarity, run.aliceDipoleCurrent),
profiles: ['runsPerLhcPeriod', 'runsPerDataPass'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

import { textFilter } from '../../../components/Filters/common/filters/textFilter.js';
import { absoluteFrontLink } from '../../../components/common/navigation/absoluteFrontLink.js';
import { externalLinks } from '../../../components/common/navigation/externalLinks.js';
import { formatItemsCount } from '../../../utilities/formatting/formatItemsCount.js';
import { formatSizeInBytes } from '../../../utilities/formatting/formatSizeInBytes.js';

/**
* List of active columns for a generic simulation passes table
*/
export const simulationPassesActiveColumns = {
name: {
name: 'Name',
visible: true,
sortable: true,
filter: ({ namesFilterModel }) => textFilter(
namesFilterModel,
{ class: 'w-75 mt1', placeholder: 'e.g. LHC23k5, ...' },
),
classes: 'w-15 f6',
},

description: {
name: 'Description',
visible: true,
sortable: false,
balloon: true,
},

jiraId: {
name: 'Jira',
visible: true,
format: (jiraId) => absoluteFrontLink(jiraId, `${externalLinks.ALICE_JIRA}/browse/${jiraId}`, { target: '_blank' }) ?? '-',
sortable: true,
classes: 'w-5 f6',
},

pwg: {
name: 'PWG',
format: (pwg) => pwg ?? '-',
visible: true,
sortable: true,
classes: 'w-5 f6',
},

requestedEventsCount: {
name: 'Requested Events',
format: (requestedEventsCount) => requestedEventsCount ? formatItemsCount(requestedEventsCount) : '-',
visible: true,
sortable: true,
classes: 'w-10 f6',
},

generatedEventsCount: {
name: 'Generated Events',
format: (generatedEventsCount) => generatedEventsCount ? formatItemsCount(generatedEventsCount) : '-',
visible: true,
sortable: true,
classes: 'w-10 f6',
},

outputSize: {
name: 'Output Size (B)',
visible: true,
format: (outputSize) => outputSize ? formatSizeInBytes(outputSize) : '-',
sortable: true,
classes: 'w-10 f6',
},

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
import { buildUrl } from '../../../utilities/fetch/buildUrl.js';
import { SortModel } from '../../../components/common/table/SortModel.js';
import { TextTokensFilterModel } from '../../../components/Filters/common/filters/TextTokensFilterModel.js';
import { OverviewPageModel } from '../../../models/OverviewModel.js';
import { RemoteData } from '/js/src/index.js';
import { ObservableData } from '../../../utilities/ObservableData.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';

/**
* Simulation Passes Per LHC Period overview model
*/
export class SimulationPassesPerLhcPeriodOverviewModel extends OverviewPageModel {
/**
* Constructor
*/
constructor() {
super();
this._sortModel = new SortModel();
this._sortModel.observe(() => {
this._pagination.silentlySetCurrentPage(1);
this.load();
});
this._sortModel.visualChange$.bubbleTo(this);

this._namesFilterModel = new TextTokensFilterModel();
this._registerFilter(this._namesFilterModel);

this._lhcPeriod = new ObservableData(RemoteData.notAsked());
this._lhcPeriod.bubbleTo(this);

this._lhcPeriodId = null;
}

/**
* Fetch LHC Period data which simulation passes are fetched
* @return {Promise<void>} promise
*/
async _fetchLhcPeriod() {
this._lhcPeriod.setCurrent(RemoteData.loading());
try {
const { data: lhcPeriodStatistics } = await getRemoteData(`/api/lhcPeriodsStatistics/${this._lhcPeriodId}`);
this._lhcPeriod.setCurrent(RemoteData.success(lhcPeriodStatistics.lhcPeriod));
} catch (error) {
this._lhcPeriod.setCurrent(RemoteData.failure(error));
}
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
async load() {
this._fetchLhcPeriod();
super.load();
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
getRootEndpoint() {
const params = {
filter: {
names: this._namesFilterModel.normalized,
lhcPeriodIds: [this._lhcPeriodId],
},
};

const { appliedOn: sortOn, appliedDirection: sortDirection } = this._sortModel;
if (sortOn && sortDirection) {
params[`sort[${sortOn}]`] = sortDirection;
}

return buildUrl('/api/simulationPasses', params);
}

/**
* Reset this model to its default
*
* @returns {void}
*/
reset() {
this._namesFilterModel.reset();
super.reset();
}

/**
* Set id of LHC Period which simulation passes are to be fetched
* @param {number} lhcPeriodId id of LHC Period
*/
set lhcPeriodId(lhcPeriodId) {
this._lhcPeriodId = lhcPeriodId;
}

/**
* Get current lhc period which simulation passes are fetched
*/
get lhcPeriod() {
return this._lhcPeriod.getCurrent();
}

/**
* Returns the model handling the overview page table sort
*
* @return {SortModel} the sort model
*/
get sortModel() {
return this._sortModel;
}

/**
* Returns simulation passes names filter model
* @return {TextTokensFilterModel} simulation passes names filter model
*/
get namesFilterModel() {
return this._namesFilterModel;
}

/**
* Register a new filter model
* @param {FilterModel} filterModel the filter model to register
* @return {void}
* @private
*/
_registerFilter(filterModel) {
filterModel.visualChange$.bubbleTo(this);
filterModel.observe(() => {
this._pagination.silentlySetCurrentPage(1);
this.load();
});
}

/**
* States whether any filter is active
* @return {boolean} true if any filter is active
*/
isAnyFilterActive() {
return !this._namesFilterModel.isEmpty();
}
}
Loading

0 comments on commit ed74930

Please sign in to comment.