-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathLhcFillsOverviewModel.js
More file actions
122 lines (108 loc) · 3.57 KB
/
LhcFillsOverviewModel.js
File metadata and controls
122 lines (108 loc) · 3.57 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
/**
* @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 { buildUrl } from '/js/src/index.js';
import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js';
import { StableBeamFilterModel } from '../../../components/Filters/LhcFillsFilter/StableBeamFilterModel.js';
import { RawTextFilterModel } from '../../../components/Filters/common/filters/RawTextFilterModel.js';
import { OverviewPageModel } from '../../../models/OverviewModel.js';
import { addStatisticsToLhcFill } from '../../../services/lhcFill/addStatisticsToLhcFill.js';
import { TextComparisonFilterModel } from '../../../components/Filters/common/filters/TextComparisonFilterModel.js';
/**
* Model for the LHC fills overview page
*
* @implements {OverviewModel}
*/
export class LhcFillsOverviewModel extends OverviewPageModel {
/**
* Constructor
*
* @param {boolean} [stableBeamsOnly=false] if true, overview will load stable beam only
*/
constructor(stableBeamsOnly = false) {
super();
this._filteringModel = new FilteringModel({
fillNumbers: new RawTextFilterModel(),
beamDuration: new TextComparisonFilterModel(),
runDuration: new TextComparisonFilterModel(),
hasStableBeams: new StableBeamFilterModel(),
});
this._filteringModel.observe(() => this._applyFilters());
this._filteringModel.visualChange$.bubbleTo(this);
this.reset(false);
if (stableBeamsOnly) {
this._filteringModel.get('hasStableBeams').setStableBeamsOnly(true);
}
}
/**
* @inheritDoc
*/
processItems(items) {
for (const item of items) {
addStatisticsToLhcFill(item);
}
return items;
}
/**
* @inheritDoc
*/
getRootEndpoint() {
const params = {
filter: this.filteringModel.normalized,
};
return buildUrl('/api/lhcFills', params);
}
/**
* Returns all filtering, sorting and pagination settings to their default values
* @param {boolean} [fetch = true] whether to refetch all data after filters have been reset
* @return {void}
*/
reset(fetch = true) {
super.reset();
this.resetFiltering(fetch);
}
/**
* Reset all filtering models
* @param {boolean} fetch Whether to refetch all data after filters have been reset
* @return {void}
*/
resetFiltering(fetch = true) {
this._filteringModel.reset();
if (fetch) {
this._applyFilters();
}
}
/**
* Checks if any filter value has been modified from their default (empty)
* @return {Boolean} If any filter is active
*/
isAnyFilterActive() {
return this._filteringModel.isAnyFilterActive();
}
/**
* Return the filtering model
*
* @return {FilteringModel} the filtering model
*/
get filteringModel() {
return this._filteringModel;
}
/**
* Apply the current filtering and update the remote data list
*
* @return {void}
*/
_applyFilters() {
this._pagination.currentPage = 1;
this.load();
}
}