-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathQcFlagsForDataPassOverviewPage.js
More file actions
109 lines (103 loc) · 4.31 KB
/
QcFlagsForDataPassOverviewPage.js
File metadata and controls
109 lines (103 loc) · 4.31 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
/**
* @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 { table } from '../../../components/common/table/table.js';
import { qcFlagsActiveColumns } from '../ActiveColumns/qcFlagsActiveColumns.js';
import { qcFlagCreationPanelLink } from '../../../components/qcFlags/qcFlagCreationPanelLink.js';
import { qcFlagsChartComponent } from '../qcFlagsVisualization/qcFlagsChartComponent.js';
import { mergeRemoteData } from '../../../utilities/mergeRemoteData.js';
import { qcFlagsBreadcrumbs } from '../../../components/qcFlags/qcFlagsBreadcrumbs.js';
import errorAlert from '../../../components/common/errorAlert.js';
import spinner from '../../../components/common/spinner.js';
import { getRemoteDetectorUserHasAccessTo } from '../../../services/detectors/remoteDetectorUserHasAccessTo.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 Data Pass Overview page
* @param {Model} model The overall model object.
* @returns {Component} The overview page
*/
export const QcFlagsForDataPassOverviewPage = ({
qcFlags: { forDataPassOverviewModel: qcFlagsForDataPassOverviewModel },
detectorsUserHasAccessTo: remoteDetectorsUserHasAccessTo,
}) => {
const {
dataPass: remoteDataPass,
run: remoteRun,
detectorId,
detector: remoteDetector,
items: remoteQcFlags,
sortModel,
} = qcFlagsForDataPassOverviewModel;
qcFlagsForDataPassOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(
TABLEROW_HEIGHT,
PAGE_USED_HEIGHT,
));
const activeColumns = {
qcFlagId: {
name: 'Id',
visible: true,
format: (qcFlagId, { dataPassId, detectorId, runNumber }) =>
frontLink(
h('.btn.btn-primary.white', qcFlagId),
'qc-flag-details-for-data-pass',
{ id: qcFlagId, dataPassId, runNumber, detectorId },
),
classes: 'w-5',
},
...qcFlagsActiveColumns,
};
return h(
'.flex-column',
{ onremove: () => qcFlagsForDataPassOverviewModel.reset() },
mergeRemoteData([
remoteDataPass,
remoteRun,
remoteDetector,
getRemoteDetectorUserHasAccessTo(detectorId, remoteDetectorsUserHasAccessTo),
remoteQcFlags,
]).match({
NotAsked: () => null,
Failure: (errors) => errorAlert(errors),
Success: ([dataPass, run, detector, detectorUserHasAccessTo, flags]) => [
h('.flex-row.justify-between.items-center', [
qcFlagsBreadcrumbs({ dataPass, run, detector }),
qcFlagCreationPanelLink(
{ dataPass },
run,
detectorUserHasAccessTo,
),
]),
qcFlagsChartComponent(flags, run),
h('.w-100.flex-column', [
table(
flags,
activeColumns,
{
classes: (qcFlag) => ['.table-sm', qcFlag.deleted ? '.dimmed' : null]
.filter((classToken) => Boolean(classToken))
.join(''),
},
null,
{ sort: sortModel },
),
]),
],
Loading: () => spinner(),
}),
);
};