-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathQcFlagsForDataPassOverviewModel.js
More file actions
97 lines (89 loc) · 2.93 KB
/
QcFlagsForDataPassOverviewModel.js
File metadata and controls
97 lines (89 loc) · 2.93 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
/**
* @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, RemoteData } from '/js/src/index.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
import { QcFlagsOverviewModel } from '../Overview/QcFlagsOverviewModel.js';
import { ObservableData } from '../../../utilities/ObservableData.js';
import { DetectorType } from '../../../domain/enums/DetectorTypes.js';
/**
* Quality Control Flags for data pass overview model
*
* @implements {OverviewModel}
*/
export class QcFlagsForDataPassOverviewModel extends QcFlagsOverviewModel {
/**
* The constructor of the Overview model object
*/
constructor() {
super();
this._dataPass$ = new ObservableData(RemoteData.notAsked());
this._dataPass$.bubbleTo(this);
}
/**
* @inheritdoc
*/
getRootEndpoint() {
return buildUrl('/api/qcFlags/perDataPass', {
dataPassId: this._dataPassId,
runNumber: this._runNumber,
detectorId: this._detectorId,
filter: this.detector.match({
Success: ({ type }) => [DetectorType.AOT_GLO, DetectorType.AOT_EVENT, DetectorType.MUON_GLO].includes(type)
? { createdBy: { names: 'Anonymous', operator: 'none' } }
: {},
Other: () => {},
}),
});
}
/**
* @inheritdoc
*/
async load() {
await super.load();
this._fetchDataPass();
}
/**
* Fetch data pass data which QC flags are fetched
* @return {Promise<void>} promise
*/
async _fetchDataPass() {
this._dataPass$.setCurrent(RemoteData.loading());
try {
const { data: [dataPass] } = await getRemoteData(`/api/dataPasses/?filter[ids][]=${this._dataPassId}`);
this._dataPass$.setCurrent(RemoteData.success(dataPass));
} catch (error) {
this._dataPass$.setCurrent(RemoteData.failure(error));
}
}
/**
* Set id of data pass which for QC flags should be fetched
* @param {number} dataPassId data pass id
*/
set dataPassId(dataPassId) {
this._dataPassId = dataPassId;
}
/**
* Get current data pass which QC flags are fetched
* @return {RemoteData<DataPass>} data pass remote data
*/
get dataPass() {
return this._dataPass$.getCurrent();
}
/**
* Data pass id getter
* @return {number} current data pass id
*/
get dataPassId() {
return this._dataPassId;
}
}