Skip to content

Commit

Permalink
Merge branch 'main' into mboulais/O2B-1204/improvements-for-on-call-t…
Browse files Browse the repository at this point in the history
…emplate
  • Loading branch information
martinboulais authored Apr 10, 2024
2 parents c08d19f + dac7be0 commit c9b8497
Show file tree
Hide file tree
Showing 36 changed files with 1,238 additions and 44 deletions.
10 changes: 10 additions & 0 deletions lib/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { HomePageModel } from './views/Home/Overview/HomePageModel.js';
import { DataPassesModel } from './views/DataPasses/DataPassesModel.js';
import { SimulationPassesModel } from './views/SimulationPasses/SimulationPassesModel.js';
import { QcFlagTypesModel } from './views/QcFlagTypes/QcFlagTypesModel.js';
import { QcFlagsModel } from './views/QcFlags/QcFlagsModel.js';

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

this.qcFlags = new QcFlagsModel();
this.qcFlags.bubbleTo(this);

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

Expand Down Expand Up @@ -187,6 +191,12 @@ export default class Model extends Observable {
case 'qc-flag-type-creation':
this.qcFlagTypes.loadCreation();
break;
case 'qc-flags-for-data-pass':
this.qcFlags.loadForDataPassOverview(this.router.params);
break;
case 'qc-flags-for-simulation-pass':
this.qcFlags.loadForSimulationPassOverview(this.router.params);
break;
case 'anchored-simulation-passes-overview':
this.simulationPasses.loadAnchoredOverview(this.router.params);
break;
Expand Down
90 changes: 90 additions & 0 deletions lib/public/services/detectors/dplDetectorsProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* @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 { Observable, RemoteData } from '/js/src/index.js';
import { getRemoteData } from '../../utilities/fetch/getRemoteData.js';
import { ObservableData } from '../../utilities/ObservableData.js';

const TST_DETECTOR_NAME = 'TST';

/**
* Service class to fetch DPL detectors from the backend
*/
export class DplDetectorsProvider extends Observable {
/**
* Constructor
*/
constructor() {
super();
this._all$ = new ObservableData(RemoteData.notAsked());
this._physical$ = ObservableData.builder()
.source(this._all$)
.apply((remoteDetectors) => remoteDetectors.apply({
Success: (detectors) => detectors.filter(({ name }) => name && name !== TST_DETECTOR_NAME),
}))
.build();
}

/**
* Return all DPL detectors observable data
*
* @return {ObservableData<RemoteData<DplDetector[], ApiError>>} the observable DPL detectors list
*/
get all$() {
if (this._isStale()) {
this._load();
}
return this._all$;
}

/**
* Return physical (meaning actual detectors, for example excluding TST) DPL detectors list observable data
*
* @return {ObservableData<RemoteData<Detector[], ApiError>>} the observable physical DPL detectors list
*/
get physical$() {
if (this._isStale()) {
this._load();
}
return this._physical$;
}

/**
* States if the cached detectors list need to be created or updated
*
* @return {boolean} true if the detectors list must be refreshed
* @private
*/
_isStale() {
return this._all$.getCurrent().match({
NotAsked: () => true,
Other: () => false,
});
}

/**
* Load all the detectors and feed the observable data
*
* @return {void}
* @private
*/
_load() {
this._all$.setCurrent(RemoteData.loading());
getRemoteData('/api/dpl-detectors').then(
({ data: detectors }) => this._all$.setCurrent(RemoteData.success(detectors)),
(error) => this._all$.setCurrent(RemoteData.failure(error)),
);
}
}

export const dplDetectorsProvider = new DplDetectorsProvider();
5 changes: 5 additions & 0 deletions lib/public/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import { LogReplyPage } from './views/Logs/Create/LogReplyPage.js';
import { QcFlagTypeCreationPage } from './views/QcFlagTypes/Create/QcFlagTypeCreationPage.js';
import { RunsPerSimulationPassOverviewPage } from './views/Runs/RunsPerSimulationPass/RunsPerSimulationPassOverviewPage.js';
import { QcFlagTypesOverviewPage } from './views/QcFlagTypes/Overview/QcFlagTypesOverviewPage.js';
import { QcFlagsForDataPassOverviewPage } from './views/QcFlags/ForDataPass/QcFlagsForDataPassOverviewPage.js';
import { QcFlagsForSimulationPassOverviewPage } from './views/QcFlags/ForSimulationPass/QcFlagsForSimulationPassOverviewPage.js';

/**
* Main view layout
Expand Down Expand Up @@ -84,6 +86,9 @@ export default (model) => {
'qc-flag-type-creation': QcFlagTypeCreationPage,
'qc-flag-types-overview': QcFlagTypesOverviewPage,

'qc-flags-for-data-pass': QcFlagsForDataPassOverviewPage,
'qc-flags-for-simulation-pass': QcFlagsForSimulationPassOverviewPage,

statistics: StatisticsPage,

'flp-overview': FlpOverview,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
} from '../../../../components/common/form/magnetsConfiguration/aliceMagnetsConfigurationsSnapshotsForm.js';
import { table } from '../../../../components/common/table/table.js';
import { runsActiveColumns } from '../../../Runs/ActiveColumns/runsActiveColumns.js';
import { createRunDetectorsActiveColumns } from '../../../Runs/ActiveColumns/runDetectorsActiveColumns.js';
import { formatTimeAndEfficiencyLoss } from '../../../../utilities/formatting/formatTimeAndEfficiencyLoss.js';
import { createRunDetectorsSyncQcActiveColumns } from '../../../Runs/ActiveColumns/runDetectorsSyncQcActiveColumns.js';

/**
* On call template configuration
Expand Down Expand Up @@ -115,7 +115,7 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
runsToCheck,
{
...runsActiveColumns,
...createRunDetectorsActiveColumns(
...createRunDetectorsSyncQcActiveColumns(
template.physicalDetectors.match({
Success: (payload) => payload,
Other: () => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { checkboxes } from '../../../components/Filters/common/filters/checkboxF
*/
export const qcFlagTypesActiveColumns = {
id: {
visible: false,
primary: true,
name: 'Id',
visible: true,
sortable: true,
},
name: {
name: 'Name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class QcFlagTypeCreationModel extends CreationModel {
*/
_initOrResetData() {
this.formData = {
id: null,
name: '',
method: '',
color: null,
Expand All @@ -70,6 +71,6 @@ export class QcFlagTypeCreationModel extends CreationModel {
* @inheritDoc
*/
isValid() {
return this.formData.name.length > 0 && this.formData.method.length > 0;
return this.formData.id && this.formData.name.length > 0 && this.formData.method.length > 0;
}
}
12 changes: 11 additions & 1 deletion lib/public/views/QcFlagTypes/Create/QcFlagTypeCreationPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ import { LabelPanelHeaderComponent } from '../../../components/common/panel/Labe
* @return {Component} Return the view of the inputs
*/
const qcFlagTypeCreationComponent = (qcFlagTypeCreationModel) => {
const { name, method, color, bad } = qcFlagTypeCreationModel.formData;
const { id, name, method, color, bad } = qcFlagTypeCreationModel.formData;

const panel = [
h(PanelComponent, [
h(LabelPanelHeaderComponent, { for: 'id' }, 'Id'),
h('input#id.form-control.mb2', {
placeholder: 'Enter the QC Flag Type id ...',
value: id,
min: 1,
type: 'number',
oninput: (e) => qcFlagTypeCreationModel.patchFormData({ id: e.target.value }),
}),
]),
h(PanelComponent, [
h(LabelPanelHeaderComponent, { for: 'name' }, 'Name'),
h('input#name.form-control.mb2', {
Expand Down
71 changes: 71 additions & 0 deletions lib/public/views/QcFlags/ActiveColumns/qcFlagsActiveColumns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* @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 { h } from '/js/src/index.js';
import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
import { qcFlagTypeColoredBadge } from '../common/qcFlagTypeColoredBadge.js';

/**
* Active columns configuration for QC flags table
*/
export const qcFlagsActiveColumns = {
id: {
name: 'Id',
visible: false,
},

flagType: {
name: 'Type',
visible: true,
format: (flagType) => h('.flex-row.g1', [flagType.name, qcFlagTypeColoredBadge(flagType)]),
},

from: {
name: 'From',
visible: true,
format: (timestamp) => timestamp
? formatTimestamp(timestamp, false)
: 'Whole run coverage',
},

to: {
name: 'To',
visible: true,
format: (timestamp) => timestamp
? formatTimestamp(timestamp, false)
: 'Whole run coverage',
},

comment: {
name: 'Comment',
visible: true,
},

createdBy: {
name: 'Created by',
visible: true,
format: (createdBy) => createdBy?.name || '-',
},

createdAt: {
name: 'Created at',
visible: true,
format: (timestamp) => formatTimestamp(timestamp, false),
},

updatedAt: {
name: 'Updated at',
visible: true,
format: (timestamp) => formatTimestamp(timestamp, false),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* @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 { RemoteData } from '/js/src/index.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
import { QcFlagsOverviewModel } from '../Overview/QcFlagsOverviewModel.js';
import { ObservableData } from '../../../utilities/ObservableData.js';

/**
* Quality Control Flags for data pass overview model
*
* @implements {OverviewModel}
*/
export class QcFlagsForDataPassOverviewModel extends QcFlagsOverviewModel {
/**
* The constructor of the Overview model object
*/
constructor() {
super();
this._dataPass$ = new ObservableData(RemoteData.notAsked());
this._dataPass$.bubbleTo(this);
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
getRootEndpoint() {
const params = {
filter: {
dataPassIds: [this._dataPassId],
},
};
return buildUrl(super.getRootEndpoint(), params);
}

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

/**
* Fetch data pass data which QC glags are fetched
* @return {Promise<void>} promise
*/
async _fetchDataPass() {
this._dataPass$.setCurrent(RemoteData.loading());
try {
const { data: [dataPass] } = await getRemoteData(`/api/dataPasses/?filter[ids][]=${this._dataPassId}`);
this._dataPass$.setCurrent(RemoteData.success(dataPass));
} catch (error) {
this._dataPass$.setCurrent(RemoteData.failure(error));
}
}

/**
* Set id of data pass which for QC flags should be fetched
* @param {number} dataPassId data pass id
*/
set dataPassId(dataPassId) {
this._dataPassId = dataPassId;
}

/**
* Get current data pass which QC flags are fetched
* @return {RemoteData<SimulationPass>} data pass remote data
*/
get dataPass() {
return this._dataPass$.getCurrent();
}
}
Loading

0 comments on commit c9b8497

Please sign in to comment.