-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathRunsPerSimulationPassOverviewModel.js
More file actions
127 lines (112 loc) · 3.81 KB
/
Copy pathRunsPerSimulationPassOverviewModel.js
File metadata and controls
127 lines (112 loc) · 3.81 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
123
124
125
126
127
/**
* @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 { ObservableData } from '../../../utilities/ObservableData.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
import { rctDetectorsProvider } from '../../../services/detectors/detectorsProvider.js';
import { FixedPdpBeamTypeRunsOverviewModel } from '../Overview/FixedPdpBeamTypeRunsOverviewModel.js';
/**
* Runs Per Simulation Pass overview model
*/
export class RunsPerSimulationPassOverviewModel extends FixedPdpBeamTypeRunsOverviewModel {
/**
* Constructor
* @param {Model} model global model
*/
constructor(model) {
super(model);
this._simulationPass$ = new ObservableData(RemoteData.notAsked());
this._detectors$ = rctDetectorsProvider.qc$;
this.registerObervablesQcSummaryDependesOn([this._detectors$]);
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
this.registerDetectorsForQcFlagsDataExport(this._detectors$);
this._detectors$.bubbleTo(this);
this._simulationPass$.bubbleTo(this);
}
/**
* Fetch Simulation Pass data which data passes are fetched
* @return {Promise<void>} promise
*/
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));
}
}
/**
* @inheritdoc
*/
async load() {
if (!this._simulationPassId) {
return;
}
this._fetchSimulationPass().then(() => {
this._simulationPass$.getCurrent().match({
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
Other: () => null,
});
});
super.load();
}
/**
* @inheritdoc
*/
getRootEndpoint() {
const params = {
filter: {
simulationPassIds: [this._simulationPassId],
},
};
return buildUrl(super.getRootEndpoint(), params);
}
/**
* Set id of current simulation pass which runs are fetched
* @param {number} simulationPassId simulation pass id
*/
set simulationPassId(simulationPassId) {
if (simulationPassId !== this._simulationPassId) {
this.reset(false);
}
this._simulationPassId = simulationPassId;
}
/**
* Get id of current simulation pass which runs are fetched
* @return {number} simulationPassId simulation pass id
*/
get simulationPassId() {
return this._simulationPassId;
}
/**
* Get current simulation pass which runs are fetched
* @return {RemoteData<SimulationPass>} simulation pass remote data
*/
get simulationPass() {
return this._simulationPass$.getCurrent();
}
/**
* Get all detectors
* @return {RemoteData<DplDetector[]>} detectors
*/
get detectors() {
return this._detectors$.getCurrent();
}
/**
* @inheritdoc
*/
get qcSummaryScope() {
return { simulationPassId: this._simulationPassId };
}
}