-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into xsalonx/MC/O2B-1162/update-display-rules
- Loading branch information
Showing
16 changed files
with
685 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
lib/public/views/SimulationPasses/ActiveColumns/simulationPassesActiveColumns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
|
||
}; |
152 changes: 152 additions & 0 deletions
152
.../views/SimulationPasses/PerLhcPeriodOverview/SimulationPassesPerLhcPeriodOverviewModel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.