-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathRunsPerLhcPeriodOverviewPage.js
More file actions
150 lines (139 loc) · 7.18 KB
/
Copy pathRunsPerLhcPeriodOverviewPage.js
File metadata and controls
150 lines (139 loc) · 7.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* @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 { 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 { runDetectorsQualitiesActiveColumns } from '../ActiveColumns/runDetectorsQualitiesActiveColumns.js';
import { inelasticInteractionRateActiveColumnsForProtonProton } from '../ActiveColumns/inelasticInteractionRateActiveColumnsForProtonProton.js';
import { inelasticInteractionRateActiveColumnsForPbPb } from '../ActiveColumns/inelasticInteractionRateActiveColumnsForPbPb.js';
import { isRunNotSubjectToQc } from '../../../components/qcFlags/isRunNotSubjectToQc.js';
import { runDetectorsSyncQcActiveColumns } from '../ActiveColumns/runDetectorsSyncQcActiveColumns.js';
import { tabbedPanelComponent } from '../../../components/TabbedPanel/tabbedPanelComponent.js';
import { RUNS_PER_LHC_PERIOD_PANELS_KEYS } from './RunsPerLhcPeriodOverviewModel.js';
import { PdpBeamType } from '../../../domain/enums/PdpBeamType.js';
import { filtersPanelPopover } from '../../../components/Filters/common/filtersPanelPopover.js';
import { runNumbersFilter } from '../../../components/Filters/RunsFilter/runNumbersFilter.js';
import { mergeRemoteData } from '../../../utilities/mergeRemoteData.js';
import errorAlert from '../../../components/common/errorAlert.js';
import spinner from '../../../components/common/spinner.js';
import { mcReproducibleAsNotBadToggle } from '../mcReproducibleAsNotBadToggle.js';
const TABLEROW_HEIGHT = 62;
// Estimate of the navbar and pagination elements height total; Needs to be updated in case of changes;
const PAGE_USED_HEIGHT = 215;
/**
* Return specific classes to style row of run which is not subject to QC
*
* @param {Run} run a run
* @return {string|null} css classes
*/
const getRowClasses = (run) => isRunNotSubjectToQc(run) ? '.danger' : null;
/**
* Render Runs Per LHC Period overview page
*
* @param {Model} model The overall model object.
* @param {Model} [model.runs.perLhcPeriodOverviewModel] model holding state for of the page
* @return {Component} The overview page
*/
export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel }, modalModel }) => {
perLhcPeriodOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(
TABLEROW_HEIGHT,
PAGE_USED_HEIGHT,
));
const {
items: remoteRuns,
detectors: remoteDetectors,
lhcPeriodStatistics: remoteLhcPeriodStatistics,
displayOptions,
sortModel,
tabbedPanelModel,
mcReproducibleAsNotBad,
} = perLhcPeriodOverviewModel;
/**
* Render runs table with given detectors' active columns configuration
*
* @param {object} activeColumns common acctivte column
* @param {object} detectorsActiveColumns detectors specific columns
* @return {Component} table with pagination
*/
const getTableWithGivenDetectorsColumns = (activeColumns, detectorsActiveColumns) =>
table(
/*
* Columns depends on detectors' list, it's not useful to render the table when detectors are missing
*/
remoteRuns,
{
...activeColumns,
...detectorsActiveColumns,
},
{ classes: getRowClasses },
{
profile: 'runsPerLhcPeriod',
...displayOptions,
singleWrapper: true,
},
{ sort: sortModel },
);
return h(
'.intermediate-flex-column',
{ onremove: () => perLhcPeriodOverviewModel.reset(false) },
mergeRemoteData([remoteLhcPeriodStatistics, remoteRuns, remoteDetectors]).match({
NotAsked: () => null,
Failure: (errors) => errorAlert(errors),
Loading: () => spinner(),
Success: ([lhcPeriodStatistics, runs, detectors]) => {
const activeColumns = {
...runsActiveColumns,
...runs.some((run) => run.pdpBeamType === PdpBeamType.LEAD_LEAD) ? inelasticInteractionRateActiveColumnsForPbPb : {},
...runs.some((run) => run.pdpBeamType === PdpBeamType.PROTON_PROTON)
? inelasticInteractionRateActiveColumnsForProtonProton : {},
};
return [
h('.flex-row.justify-between.items-center.g2', [
filtersPanelPopover(perLhcPeriodOverviewModel, activeColumns, { profile: 'runsPerLhcPeriod' }),
h('.pl2#runOverviewFilter', runNumbersFilter(perLhcPeriodOverviewModel.filteringModel.get('runNumbers'))),
h('h2', `Good, physics runs of ${lhcPeriodStatistics.lhcPeriod.name}`),
mcReproducibleAsNotBadToggle(
mcReproducibleAsNotBad,
() => perLhcPeriodOverviewModel.setMcReproducibleAsNotBad(!mcReproducibleAsNotBad),
),
exportRunsTriggerAndModal(perLhcPeriodOverviewModel, modalModel),
]),
...tabbedPanelComponent(
tabbedPanelModel,
{
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]: 'Qualities of detectors',
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]: 'Synchronous QC flags',
},
{
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]:
() => getTableWithGivenDetectorsColumns(
activeColumns,
runDetectorsQualitiesActiveColumns(detectors, { profiles: 'runsPerLhcPeriod' }),
),
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]: (remoteSynchronousQcSummary) =>
getTableWithGivenDetectorsColumns(activeColumns, runDetectorsSyncQcActiveColumns(detectors, {
profiles: 'runsPerLhcPeriod',
qcSummary: remoteSynchronousQcSummary?.match({ Success: (qcSummary) => qcSummary, Other: () => null }),
})),
},
{ panelClass: ['scroll-auto'] },
),
paginationComponent(perLhcPeriodOverviewModel.pagination),
];
},
}),
);
};