-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathQcFlagsForSimulationPassOverviewModel.js
More file actions
92 lines (84 loc) · 2.77 KB
/
QcFlagsForSimulationPassOverviewModel.js
File metadata and controls
92 lines (84 loc) · 2.77 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
/**
* @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';
/**
* Quality Control Flags For Simulation Pass overview model
*
* @implements {OverviewModel}
*/
export class QcFlagsForSimulationPassOverviewModel extends QcFlagsOverviewModel {
/**
* The constructor of the Overview model object
*/
constructor() {
super();
this._simulationPass$ = new ObservableData(RemoteData.notAsked());
this._simulationPass$.bubbleTo(this);
}
/**
* @inheritdoc
*/
getRootEndpoint() {
return buildUrl('/api/qcFlags/perSimulationPass', {
simulationPassId: this._simulationPassId,
runNumber: this._runNumber,
detectorId: this._detectorId,
});
}
/**
* @inheritdoc
*/
async load() {
await super.load();
this._fetchSimulationPass();
}
/**
* Fetch Simulation Pass data which QC flags are fetched
* @return {Promise<void>} promise
* @private
*/
async _fetchSimulationPass() {
this._simulationPass$.setCurrent(RemoteData.loading());
try {
const { data: simulationPass } = await getRemoteData(`/api/simulationPasses/${this._simulationPassId}`);
this._simulationPass$.setCurrent(RemoteData.success(simulationPass));
} catch (error) {
this._simulationPass$.setCurrent(RemoteData.failure(error));
}
}
/**
* Set id of simulation pass which for QC flags should be fetched
* @param {number} simulationPassId simulation pass id
*/
set simulationPassId(simulationPassId) {
this._simulationPassId = simulationPassId;
}
/**
* Get current simulation pass which QC flags are fetched
* @return {RemoteData<SimulationPass>} simulation pass remote data
*/
get simulationPass() {
return this._simulationPass$.getCurrent();
}
/**
* Return the id of the current simulation pass
*
* @return {number} the simulation pass id
*/
get simulationPassId() {
return this._simulationPassId;
}
}