This repository was archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperiodsActiveColumns.js
More file actions
121 lines (111 loc) · 4.44 KB
/
Copy pathperiodsActiveColumns.js
File metadata and controls
121 lines (111 loc) · 4.44 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
/**
* @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 linkChip from '../../../components/chips/linkChip.js';
import { RCT } from '../../../config.js';
import { getClosestDefinedEnergy } from '../../../utils/dataProcessing/dataProcessingUtils.js';
import { buildHref } from '../../../utils/url/urlUtils.js';
const { dataReqParams: DRP, pageNames: PN, fieldNames: FN } = RCT;
const acceptableEnergyValues = RCT.mapping.energy.values;
const acceptableEnergyMargin = RCT.mapping.energy.acceptableMargin;
const fieldNames = FN.periods;
const noRelatedDataClass = 'bg-gray-light';
/**
* List of active columns for a generic periods table
*/
export const periodsActiveColumns = {
id: {
name: 'id',
visible: false,
},
name: {
name: 'name',
visible: true,
header: fieldNames.name.fieldName,
fieldName: fieldNames.name.fieldName,
filterInput: fieldNames.name.filterInput,
format: (navigation, period) => [
h('td.text-ellipsis', period.name),
h('td',
linkChip(
navigation,
['runs', h('sub', `[${period.runsCount}]`)],
buildHref({
page: PN.runsPerPeriod,
index: period.name,
[DRP.itemsPerPage]: navigation.model.userPreferences.itemsPerPage,
[DRP.pageNumber]: 1,
sorting: '-run_number',
}),
period.runsCount === 0 ? noRelatedDataClass : '',
),
linkChip(
navigation,
['data passes', h('sub', `[${period.dataPassesCount}]`)],
buildHref({
page: PN.dataPasses,
index: period.name,
[DRP.itemsPerPage]: navigation.model.userPreferences.itemsPerPage,
[DRP.pageNumber]: 1,
}),
period.dataPassesCount === 0 ? noRelatedDataClass : '',
),
linkChip(
navigation,
['MC', h('sub', `[${period.simulationPassesCount}]`)],
buildHref({
page: PN.mc,
index: period.name,
[DRP.itemsPerPage]: navigation.model.userPreferences.itemsPerPage,
[DRP.pageNumber]: 1,
}),
period.simulationPassesCount === 0 ? noRelatedDataClass : '',
)),
],
},
beamType: {
name: 'beamType',
visible: true,
header: fieldNames.beamType.fieldName,
fieldName: fieldNames.beamType.fieldName,
filterInput: fieldNames.beamType.filterInput,
format: (_, period) => period.beamType,
},
year: {
name: 'year',
visible: true,
header: fieldNames.year.fieldName,
fieldName: fieldNames.year.fieldName,
filterInput: fieldNames.year.filterInput,
format: (_, period) => period.year,
},
avgEnergy: {
name: 'avgEnergy',
visible: true,
header: fieldNames.avgEnergy.fieldName,
fieldName: fieldNames.avgEnergy.fieldName,
filterInput: fieldNames.avgEnergy.filterInput,
format: (_, period) => `${Number(period.avgEnergy).toFixed(2)}`,
},
distinctEnergies: {
name: 'distinctEnergies',
visible: true,
header: h('.center-of-mass-energy'),
fieldName: fieldNames.distinctEnergies.fieldName,
filterInput: fieldNames.distinctEnergies.filterInput,
format: (_, period) =>
h('', period.distinctEnergies.map((e) => getClosestDefinedEnergy(e, acceptableEnergyValues, acceptableEnergyMargin))
.filter((value, index, array) => array.indexOf(value) === index)
.reduce((toDisplay, currentValue) => `${toDisplay ? `${toDisplay}, ` : ''}${currentValue}`, '')),
},
};