-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathRunsPerDataPassOverviewPage.js
More file actions
321 lines (308 loc) · 16.6 KB
/
Copy pathRunsPerDataPassOverviewPage.js
File metadata and controls
321 lines (308 loc) · 16.6 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/**
* @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 { DropdownComponent, h, iconWarning, sessionService, switchCase } 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 spinner from '../../../components/common/spinner.js';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { breadcrumbs } from '../../../components/common/navigation/breadcrumbs.js';
import { createRunDetectorsAsyncQcActiveColumns } from '../ActiveColumns/runDetectorsAsyncQcActiveColumns.js';
import { inelasticInteractionRateActiveColumnsForPbPb } from '../ActiveColumns/inelasticInteractionRateActiveColumnsForPbPb.js';
import { inelasticInteractionRateActiveColumnsForProtonProton } from '../ActiveColumns/inelasticInteractionRateActiveColumnsForProtonProton.js';
import { filtersPanelPopover } from '../../../components/Filters/common/filtersPanelPopover.js';
import { runNumbersFilter } from '../../../components/Filters/RunsFilter/runNumbersFilter.js';
import { qcSummaryLegendTooltip } from '../../../components/qcFlags/qcSummaryLegendTooltip.js';
import { isRunNotSubjectToQc } from '../../../components/qcFlags/isRunNotSubjectToQc.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
import { getQcSummaryDisplay } from '../ActiveColumns/getQcSummaryDisplay.js';
import errorAlert from '../../../components/common/errorAlert.js';
import { switchInput } from '../../../components/common/form/switchInput.js';
import { PdpBeamType } from '../../../domain/enums/PdpBeamType.js';
import { SkimmingStage } from '../../../domain/enums/SkimmingStage.js';
import { badge } from '../../../components/common/badge.js';
import { Color } from '../../../components/common/colors.js';
import { mergeRemoteData } from '../../../utilities/mergeRemoteData.js';
import { numericalComparisonFilter } from '../../../components/Filters/common/filters/numericalComparisonFilter.js';
import { iconCaretBottom } from '/js/src/icons.js';
import { BkpRoles } from '../../../domain/enums/BkpRoles.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;
/**
* 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;
/**
* Display a toggle switch to change interpretation of MC.Reproducible flag type from bad to not-bad
*
* @param {boolean} value current value
* @param {function} onChange to be called when switching
* @returns {Component} the toggle switch
*/
const mcReproducibleAsNotBadToggle = (value, onChange) => h('#mcReproducibleAsNotBadToggle', switchInput(
value,
onChange,
{ labelAfter: h('em', 'MC.R as not-bad') },
));
/**
* Render (if applies to type of current data pass) button to mark current data pass as skimmable,
* if it's skimmable already, badge with this information is rendered instead
*
* @param {DataPass} dataPass data pass
* @param {function} onclick onclick action
* @param {RemoteData} requestResult remote data of result of request for marking data pass as skimmable
* @return {Component} badge or button
*/
const skimmableControl = (dataPass, onclick, requestResult) => {
const { name, pdpBeamType, skimmingStage } = dataPass;
const skimmableIndicator = badge('Skimmable', { color: Color.SUCCESS });
if (skimmingStage === SkimmingStage.SKIMMABLE) {
return skimmableIndicator;
}
const validSkimmableProductionNameRegex = /_apass\d+(?!.*(skimming|skimmed|debug|test))/;
if (validSkimmableProductionNameRegex.test(name) && pdpBeamType === PdpBeamType.PROTON_PROTON) {
const buttonContent = 'Mark as skimmable';
return requestResult.match({
Success: () => skimmableIndicator,
Failure: () => h('button.btn.primary', { onclick }, [tooltip(iconWarning(), 'Error occurred when sending request'), buttonContent]),
Loading: () => h('button.btn.primary', { disabled: true }, h('.flex-row', ['Sending request...'])),
NotAsked: () => h('button.btn.primary', { onclick }, buttonContent),
});
}
};
/**
* Render Runs Per LHC Period overview page
* @param {Model} model The overall model object.
* @param {RunsPerDataPassOverviewModel} [model.runs.perDataPassOverviewModel] model holding state for of the page
* @return {Component} The overview page
*/
export const RunsPerDataPassOverviewPage = ({
runs: { perDataPassOverviewModel },
dplDetectorsUserHasAccessTo: remoteDplDetectorsUserHasAccessTo,
modalModel,
}) => {
perDataPassOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(
TABLEROW_HEIGHT,
PAGE_USED_HEIGHT,
));
const {
items: remoteRuns,
detectors: remoteDetectors,
dataPass: remoteDataPass,
qcSummary: remoteQcSummary,
gaqSummary: remoteGaqSummary,
displayOptions,
dataPassId,
sortModel,
mcReproducibleAsNotBad,
pdpBeamType,
markAsSkimmableRequestResult,
skimmableRuns: remoteSkimmableRuns,
freezeOrUnfreezeActionState,
discardAllQcFlagsActionState,
} = perDataPassOverviewModel;
const commonTitle = h('h2#breadcrumb-header', { style: 'white-space: nowrap;' }, 'Physics Runs');
const runDetectorsSelectionIsEmpty = perDataPassOverviewModel.runDetectorsSelectionModel.selectedQueryString.length === 0;
return h(
'.intermediate-flex-column',
{ onremove: () => perDataPassOverviewModel.reset(false) },
mergeRemoteData([remoteDataPass, remoteRuns, remoteDetectors, remoteQcSummary, remoteGaqSummary]).match({
NotAsked: () => null,
Failure: (errors) => errorAlert(errors),
Success: ([dataPass, runs, detectors, qcSummary, gaqSummary]) => {
const activeColumns = {
...runsActiveColumns,
...switchCase(
pdpBeamType,
{
[PdpBeamType.PROTON_PROTON]: inelasticInteractionRateActiveColumnsForProtonProton,
[PdpBeamType.LEAD_LEAD]: inelasticInteractionRateActiveColumnsForPbPb,
},
{
...inelasticInteractionRateActiveColumnsForProtonProton,
...inelasticInteractionRateActiveColumnsForPbPb,
},
),
...dataPass.skimmingStage === SkimmingStage.SKIMMABLE
? {
readyForSkimming: {
name: 'Ready for skimming',
visible: true,
format: (_, { runNumber }) => remoteSkimmableRuns.match({
Success: (skimmableRuns) => switchInput(
skimmableRuns[runNumber],
() => perDataPassOverviewModel.changeReadyForSkimmingFlagForRun({
runNumber,
readyForSkimming: !skimmableRuns[runNumber],
}),
{
labelAfter: skimmableRuns[runNumber]
? badge('ready', { color: Color.GREEN })
: badge('not ready', { color: Color.WARNING_DARKER }),
},
),
Loading: () => h('.mh3.ph4', '... ...'),
Failure: () => tooltip(iconWarning(), 'Error occurred'),
NotAsked: () => tooltip(iconWarning(), 'Not asked for data'),
}),
profiles: ['runsPerDataPass'],
},
}
: {},
globalAggregatedQuality: {
name: 'GAQ',
information: h(
'',
h('', 'Global aggregated flag based on critical detectors.'),
h('', 'Default detectors: FT0, ITS, TPC (and ZDC for heavy-ion runs)'),
),
visible: true,
format: (_, { runNumber }) => {
const runGaqSummary = gaqSummary[runNumber];
const gaqDisplay = runGaqSummary?.undefinedQualityPeriodsCount === 0
? getQcSummaryDisplay(runGaqSummary)
: h('button.btn.btn-primary.w-100', 'GAQ');
return frontLink(gaqDisplay, 'gaq-flags', { dataPassId, runNumber });
},
filter: ({ gaqNotBadFractionFilterModel }) => numericalComparisonFilter(
gaqNotBadFractionFilterModel,
{ step: 0.0001, selectorPrefix: 'gaqNotBadFraction' },
),
filterTooltip: 'expressed as a percentage',
profiles: ['runsPerDataPass'],
},
...createRunDetectorsAsyncQcActiveColumns(
perDataPassOverviewModel.runDetectorsSelectionModel,
detectors,
remoteDplDetectorsUserHasAccessTo,
{ dataPass },
{
profiles: 'runsPerDataPass',
qcSummary,
mcReproducibleAsNotBad,
},
),
};
return [
h('.flex-row.justify-between.items-center.g2', [
filtersPanelPopover(perDataPassOverviewModel, activeColumns, { profile: 'runsPerDataPass' }),
h('.pl2#runOverviewFilter', runNumbersFilter(perDataPassOverviewModel.filteringModel.get('runNumbers'))),
h(
'.flex-row.g1.items-center',
h('.flex-row.items-center.g1', [
breadcrumbs([commonTitle, h('h2#breadcrumb-data-pass-name', dataPass.name)]),
h('#skimmableControl', skimmableControl(
dataPass,
() => {
if (confirm('The data pass is going to be set as skimmable. Do you want to continue?')) {
perDataPassOverviewModel.markDataPassAsSkimmable();
}
},
markAsSkimmableRequestResult,
)),
]),
),
mcReproducibleAsNotBadToggle(
mcReproducibleAsNotBad,
() => perDataPassOverviewModel.setMcReproducibleAsNotBad(!mcReproducibleAsNotBad),
),
h('.mlauto', qcSummaryLegendTooltip()),
h('#actions-dropdown-button', DropdownComponent(
h('button.btn.btn-primary', h('.flex-row.g2', ['Actions', iconCaretBottom()])),
h('.flex-column.p2.g2', [
exportRunsTriggerAndModal(perDataPassOverviewModel, modalModel, { autoMarginLeft: false }),
frontLink(
h('button.btn.btn-primary.w-100.h2}#set-qc-flags-trigger', {
disabled: runDetectorsSelectionIsEmpty,
}, 'Set QC Flags'),
'qc-flag-creation-for-data-pass',
{
runNumberDetectorsMap: perDataPassOverviewModel.runDetectorsSelectionModel.selectedQueryString,
dataPassId,
},
),
sessionService.hasAccess([BkpRoles.DPG_ASYNC_QC_ADMIN]) && [
h(
'button.btn.btn-danger',
{
...freezeOrUnfreezeActionState.match({
Loading: () => ({
disabled: true,
title: 'Loading',
}),
Other: () => ({}),
}),
onclick: () => dataPass.isFrozen
? perDataPassOverviewModel.unfreezeDataPass()
: perDataPassOverviewModel.freezeDataPass(),
},
`${dataPass.isFrozen ? 'Unfreeze' : 'Freeze'} the data pass`,
),
h(
'button.btn.btn-danger',
{
...discardAllQcFlagsActionState.match({
Loading: () => ({
disabled: true,
title: 'Loading',
}),
Other: () => ({}),
}),
onclick: () => {
if (confirm('Are you sure you want to delete ALL the QC flags for this data pass?')) {
perDataPassOverviewModel.discardAllQcFlags();
}
},
},
'Delete ALL QC flags',
),
],
]),
{ alignment: 'right' },
)),
]),
markAsSkimmableRequestResult.match({
Failure: (errors) => errorAlert(errors),
Other: () => null,
}),
freezeOrUnfreezeActionState.match({
Failure: (errors) => errorAlert(errors),
Other: () => null,
}),
discardAllQcFlagsActionState.match({
Failure: (errors) => errorAlert(errors),
Other: () => null,
}),
table(
runs,
activeColumns,
{ classes: getRowClasses },
{
profile: 'runsPerDataPass',
...displayOptions,
},
{ sort: sortModel },
),
paginationComponent(perDataPassOverviewModel.pagination),
];
},
Loading: () => spinner(),
}),
);
};