-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathQcFlagsForSimulationPassOverviewPage.js
More file actions
106 lines (100 loc) · 4.3 KB
/
QcFlagsForSimulationPassOverviewPage.js
File metadata and controls
106 lines (100 loc) · 4.3 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
/**
* @license
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
* All rights not expressly granted are reserved.
*
* This software is distributed under the terms of the GNU General Public
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
*
* 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 { frontLink } from '../../../components/common/navigation/frontLink.js';
import { estimateDisplayableRowsCount } from '../../../utilities/estimateDisplayableRowsCount.js';
import { qcFlagsActiveColumns } from '../ActiveColumns/qcFlagsActiveColumns.js';
import { table } from '../../../components/common/table/table.js';
import { paginationComponent } from '../../../components/Pagination/paginationComponent.js';
import { qcFlagCreationPanelLink } from '../../../components/qcFlags/qcFlagCreationPanelLink.js';
import { qcFlagsBreadcrumbs } from '../../../components/qcFlags/qcFlagsBreadcrumbs.js';
import { getRemoteDetectorUserHasAccessTo } from '../../../services/detectors/remoteDetectorUserHasAccessTo.js';
import { mergeRemoteData } from '../../../utilities/mergeRemoteData.js';
import errorAlert from '../../../components/common/errorAlert.js';
import spinner from '../../../components/common/spinner.js';
const TABLEROW_HEIGHT = 35;
// Estimate of the navbar and pagination elements height total; Needs to be updated in case of changes;
const PAGE_USED_HEIGHT = 215;
/**
* Render Quality Control Flags For Simulation Pass Overview page
* @param {Model} model The overall model object.
* @returns {Component} The overview page
*/
export const QcFlagsForSimulationPassOverviewPage = ({
qcFlags: { forSimulationPassOverviewModel: qcFlagsForSimulationPassOverviewModel },
detectorsUserHasAccessTo: remoteDetectorsUserHasAccessTo,
}) => {
const {
simulationPass: remoteSimulationPass,
run: remoteRun,
detectorId,
detector: remoteDetector,
items: remoteQcFlags,
sortModel,
pagination: paginationModel,
} = qcFlagsForSimulationPassOverviewModel;
qcFlagsForSimulationPassOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(
TABLEROW_HEIGHT,
PAGE_USED_HEIGHT,
));
const activeColumns = {
qcFlagId: {
name: 'Id',
visible: true,
format: (qcFlagId, { simulationPassId, detectorId, runNumber }) =>
frontLink(
h('.btn.btn-primary.white', qcFlagId),
'qc-flag-details-for-simulation-pass',
{ id: qcFlagId, simulationPassId, runNumber, detectorId },
),
classes: 'w-5',
},
...qcFlagsActiveColumns,
};
return h(
'',
{ onremove: () => qcFlagsForSimulationPassOverviewModel.reset() },
mergeRemoteData([
remoteSimulationPass,
remoteRun,
remoteDetector,
getRemoteDetectorUserHasAccessTo(detectorId, remoteDetectorsUserHasAccessTo),
])
.match({
NotAsked: () => null,
Failure: (errors) => errorAlert(errors),
Success: ([simulationPass, run, detector, detectorUserHasAccessTo]) => [
h('.flex-row.justify-between.items-center', [
qcFlagsBreadcrumbs({ simulationPass, run, detector }),
qcFlagCreationPanelLink(
{ simulationPass },
run,
detectorUserHasAccessTo,
),
]),
h('.w-100.flex-column', [
table(
remoteQcFlags,
activeColumns,
{ classes: '.table-sm' },
null,
{ sort: sortModel },
),
paginationComponent(paginationModel),
]),
],
Loading: () => spinner(),
}),
);
};