Skip to content

Commit

Permalink
[O2B-1116] Implement runs per data pass view (#1333)
Browse files Browse the repository at this point in the history
* rename

* reduce test data size

* docs

* refactor

* typo

* typo

* docs

* rename

* docs

* cleanup

* remove dead code

* add service

* cleanup

* add filtering by periods

* add data passes seeders

* rename

* add data passes service tests

* test

* revoke unfound changes

* add controllers

* rename

* refactor

* refactor

* refactor

* no dependency

* refactor

* refactor

* refactor:

* reaname'

* rename

* cleanup

* docs

* reaname

* refactor

* add router

* restore

* amend test

* expose api

* add test

* add tests

* amend

* docs

* amend test

* amend

* add Data Passes page

* expose page

* styling

* add reset method

* rename

* use sorting

* add unit

* docs

* add filtering by data pass id

* add test

* amend test

* amend test

* init

* use name instead of id

* amend test

* rename

* use name instead of id

* put instance

* add to view and model

* page openable

* amend profiles

* show qualities

* refactor

* cleanup

* rename

* rename

* use filtering by name

* add test

* use generic model

* aboid undefined destruciton error

* use proper method

* amend cell expected content

* use in RunsOverviewModel

* rename

* rename

* touched getAllRuns

* extend pai

* add styling and css

* rename

* amend test

* cleanup

* linter

* make uppercase

* amend test

* add test

* use correct page

* amend dtest

* amend test

* amend tst

* cleanup

* amend

* use id

* use builder

* refactor, add spinner

* reset exportableItems

* corrent condition

* refactor

* cleanup

* replace build href

* cleanup

* correct filter values:

* fixes

* cleanup

* make detectors fetching prvate

* refactor

* rename

* rename

* change error store

* refactor

* wip

* cleanup

* amend view

* cleanup

* unify title styling

* unify title styling in RunsPerLhcPeriod

* rename

* docs correct

* refactor

* docs

* amend test

* fix

* modify cell value checking

* modify width

* add badge

* amend tests

* amend test

* docs

* use apply

* revoke

* no by lambda

* revoke change

* amend apply

* amend apply

* refactor

* refactor

* use match

* cleanup

* rename

* rename

* revoke export changes

* cleanup

* refactor

* correct docs

* change load

* typo

* add export test

* refactor

* refactor

* test title

* Revert "add export test"

This reverts commit 7ff5833.

* add reverted file

* remove reloadPage

* linter

* add logs

* Revert "add logs"

This reverts commit 15f4ce9.

* change selectors

* simplify

* amed test WIP

* cleanup

* amed test WIP

* add title

* change title

* add export test

* Revert "add export test"

This reverts commit 79e805f.

* fix test

* add spinner

* typo
  • Loading branch information
xsalonx authored Feb 9, 2024
1 parent d749d57 commit 93689a7
Show file tree
Hide file tree
Showing 20 changed files with 579 additions and 56 deletions.
3 changes: 3 additions & 0 deletions lib/database/adapters/DataPassAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class DataPassAdapter {
lastRunNumber,
} = databaseObject;

const runsCount = databaseObject.get('runsCount');

return {
id,
name,
description,
outputSize,
reconstructedEventsCount,
lastRunNumber,
runsCount,
};
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export default class Model extends Observable {
case 'runs-per-lhc-period':
this.runs.loadPerLhcPeriodOverview(this.router.params);
break;
case 'runs-per-data-pass':
this.runs.loadPerDataPassOverview(this.router.params);
break;
case 'run-detail':
this.runs.loadDetails(this.router.params);
break;
Expand Down
2 changes: 2 additions & 0 deletions lib/public/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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 { RunsPerDataPassOverviewPage } from './views/Runs/RunPerDataPass/RunsPerDataPassOverviewPage.js';

/**
* Main view layout
Expand Down Expand Up @@ -64,6 +65,7 @@ export default (model) => {
'run-overview': RunsOverviewPage,
'run-detail': RunDetailsPage,
'runs-per-lhc-period': RunsPerLhcPeriodOverviewPage,
'runs-per-data-pass': RunsPerDataPassOverviewPage,

statistics: StatisticsPage,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
* or submit itself to any jurisdiction.
*/

import { h } from '/js/src/index.js';
import { textFilter } from '../../../components/Filters/common/filters/textFilter.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';

/**
* List of active columns for a generic data passes table
Expand All @@ -20,12 +22,27 @@ export const dataPassesActiveColumns = {
name: {
name: 'Name',
visible: true,
format: (name) => name,
sortable: true,
filter: ({ namesFilterModel }) => textFilter(
namesFilterModel,
{ class: 'w-75 mt1', placeholder: 'e.g. LHC22a_apass1, ...' },
),
classes: 'w-20',
balloon: true,
},

associatedRuns: {
name: 'Runs',
visible: true,
format: (_, { id, runsCount }) =>
runsCount === 0
? 'No runs'
: frontLink(
h('.flex-row.g3', [h('.f6.badge.bg-gray-light.black', runsCount), 'Runs']),
'runs-per-data-pass',
{ dataPassId: id },
),
classes: 'w-10',
},

description: {
Expand All @@ -39,13 +56,15 @@ export const dataPassesActiveColumns = {
format: (reconstructedEventsCount) => reconstructedEventsCount ? reconstructedEventsCount.toLocaleString('en-US') : '-',
visible: true,
sortable: true,
classes: 'w-15',
},

outputSize: {
name: 'Output Size [B]',
visible: true,
format: (outputSize) => outputSize ? outputSize.toLocaleString('en-US') : '-',
sortable: true,
classes: 'w-15',
},

};
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { formatDetectorQuality } from '../format/formatDetectorQuality.js';
/**
* Factory for detectors related active columns configuration
* @param {Detector[]} detectors detectors list
* @param {object} [options] additional options
* @param {object|string|string[]} [options.profiles] profiles to which the column is restricted to
* @return {object} active columns configuration
*/
export const createRunDetectorsActiveColumns = (detectors) => Object.fromEntries(detectors?.map(({ name: detectorName }) => [
export const createRunDetectorsActiveColumns = (detectors, { profiles } = {}) => Object.fromEntries(detectors?.map(({ name: detectorName }) => [
detectorName, {
name: detectorName.toUpperCase(),
visible: true,
format: (_, run) => formatDetectorQuality(run.detectorsQualities.find(({ name }) => name === detectorName)?.quality),
profiles: ['runsPerLhcPeriod'],
profiles,
},
]) ?? []);
27 changes: 24 additions & 3 deletions lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ export const runsActiveColumns = {
],
),
profiles: {
home: true,
lhcFill: true,
environment: true,
runsPerLhcPeriod: {
classes: 'w-7 f6 w-wrapped',
},
home: true,
runsPerDataPass: {
classes: 'w-7 f6 w-wrapped',
},
},
},
detectors: {
Expand Down Expand Up @@ -120,6 +123,9 @@ export const runsActiveColumns = {
runsPerLhcPeriod: {
classes: 'w-2 f6',
},
runsPerDataPass: {
classes: 'w-2 f6',
},
},
classes: 'w-5 f6',
format: (fill, run) => fill !== null && run.lhcBeamMode === BeamModes.STABLE_BEAMS
Expand Down Expand Up @@ -152,6 +158,10 @@ export const runsActiveColumns = {
runsPerLhcPeriod: {
classes: 'f6 w-wrapped',
},
runsPerDataPass: {
classes: 'f6 w-wrapped',
},

},
},
timeO2End: {
Expand All @@ -172,6 +182,9 @@ export const runsActiveColumns = {
runsPerLhcPeriod: {
classes: 'f6 w-wrapped',
},
runsPerDataPass: {
classes: 'f6 w-wrapped',
},
},
},
timeTrgStart: {
Expand All @@ -185,6 +198,10 @@ export const runsActiveColumns = {
visible: true,
classes: 'f6 w-wrapped',
},
runsPerDataPass: {
visible: true,
classes: 'f6 w-wrapped',
},
},
},
timeTrgEnd: {
Expand All @@ -198,6 +215,10 @@ export const runsActiveColumns = {
visible: true,
classes: 'f6 w-wrapped',
},
runsPerDataPass: {
visible: true,
classes: 'f6 w-wrapped',
},
},
},
timeSincePreviousRun: {
Expand Down Expand Up @@ -405,12 +426,12 @@ export const runsActiveColumns = {
name: 'L3 [A]',
visible: true,
format: (_, run) => formatAliceCurrent(run.aliceL3Polarity, run.aliceL3Current),
profiles: ['runsPerLhcPeriod'],
profiles: ['runsPerLhcPeriod', 'runsPerDataPass'],
},
dipoleCurrent: {
name: 'Dipole [A]',
visible: true,
format: (_, run) => formatAliceCurrent(run.aliceDipolePolarity, run.aliceDipoleCurrent),
profiles: ['runsPerLhcPeriod'],
profiles: ['runsPerLhcPeriod', 'runsPerDataPass'],
},
};
113 changes: 113 additions & 0 deletions lib/public/views/Runs/RunPerDataPass/RunsPerDataPassOverviewModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* @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 { RemoteData } from '/js/src/index.js';
import { buildUrl } from '../../../utilities/fetch/buildUrl.js';
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
import { RunsOverviewModel } from '../Overview/RunsOverviewModel.js';
import { ObservableData } from '../../../utilities/ObservableData.js';
import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js';

/**
* Runs Per Data Pass overview model
*/
export class RunsPerDataPassOverviewModel extends RunsOverviewModel {
/**
* Constructor
* @param {Model} model global model
*/
constructor(model) {
super(model);
this._detectors = new ObservableData(RemoteData.notAsked());
this._detectors.bubbleTo(this);
this._dataPass = new ObservableData(RemoteData.notAsked());
this._dataPass.bubbleTo(this);
}

/**
* Retrieve a list of detector types from detectorsProvider
*
* @return {Promise<void>} resolves once the data has been fetched
* @private
*/
async _fetchDetectors() {
this._detectors.setCurrent(RemoteData.loading());
try {
this._detectors.setCurrent(RemoteData.success(await detectorsProvider.getAll()));
} catch (error) {
this._detectors.setCurrent(RemoteData.failure(error));
}
}

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

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
async load() {
if (!this._dataPassId) {
return;
}
this._fetchDetectors();
this._fetchDataPass();
super.load();
}

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

/**
* Set id of data pass which runs are to be fetched
* @param {number} dataPassId id of Data Pass
*/
set dataPassId(dataPassId) {
this._dataPassId = dataPassId;
}

/**
* Get current data pass which runs are fetched
*/
get dataPass() {
return this._dataPass.getCurrent();
}

/**
* Get all detectors
* @return {RemoteData<Detector[]>} detectors
*/
get detectors() {
return this._detectors.getCurrent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @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 { table } from '../../../components/common/table/table.js';
import { createRunDetectorsActiveColumns } from '../ActiveColumns/runDetectorsActiveColumns.js';
import { paginationComponent } from '../../../components/Pagination/paginationComponent.js';
import { estimateDisplayableRowsCount } from '../../../utilities/estimateDisplayableRowsCount.js';
import { exportRunsTriggerAndModal } from '../Overview/exportRunsTriggerAndModal.js';
import { runsActiveColumns } from '../ActiveColumns/runsActiveColumns.js';
import spinner from '../../../components/common/spinner.js';

const TABLEROW_HEIGHT = 59;
// Estimate of the navbar and pagination elements height total; Needs to be updated in case of changes;
const PAGE_USED_HEIGHT = 215;

/**
* Render Runs Per LHC Period overview page
* @param {Model} model The overall model object.
* @param {Model} [model.runs.perDataPassOverviewModel] model holding state for of the page
* @return {Component} The overview page
*/
export const RunsPerDataPassOverviewPage = ({ runs: { perDataPassOverviewModel }, modalModel }) => {
perDataPassOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(
TABLEROW_HEIGHT,
PAGE_USED_HEIGHT,
));

const { items: runs, detectors, dataPass } = perDataPassOverviewModel;

const activeColumns = {
...runsActiveColumns,
...createRunDetectorsActiveColumns(detectors.match({
Success: (payload) => payload,
Other: () => [],
}), { profiles: 'runsPerDataPass' }),
};

return h('', [
h('.flex-row.justify-between.items-center', [
dataPass.match({
Success: (payload) => h('h2', `Good, physics runs of ${payload.name}`),
Failure: () => h('h2.danger', 'Failed to fetch Data Pass information'),
Loading: () => h('.p1', spinner({ size: 2, absolute: false })),
NotAsked: () => h('h2', 'Good, physics runs'),
}),
exportRunsTriggerAndModal(perDataPassOverviewModel, modalModel),
]),
h('.flex-column.w-100', [
table(runs, activeColumns, null, { profile: 'runsPerDataPass' }),
paginationComponent(perDataPassOverviewModel.pagination),
]),
]);
};
Loading

0 comments on commit 93689a7

Please sign in to comment.