mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
use new simulation model data manager for initialising simulator data store (closes #169)
This commit is contained in:
parent
67c4bbc791
commit
1c76184ccd
2 changed files with 28 additions and 32 deletions
|
@ -20,5 +20,31 @@
|
|||
******************************************************************************/
|
||||
|
||||
import RestDataManager from './rest-data-manager';
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
|
||||
export default new RestDataManager('simulationModel', '/models');
|
||||
class SimulationModelDataManager extends RestDataManager {
|
||||
constructor() {
|
||||
super('simulationModel', '/models');
|
||||
|
||||
this.onLoad = this.onModelsLoad;
|
||||
}
|
||||
|
||||
onModelsLoad(data) {
|
||||
if (!Array.isArray(data))
|
||||
data = [ data ];
|
||||
|
||||
for (let model of data)
|
||||
this.loadModelData(model);
|
||||
}
|
||||
|
||||
loadModelData(model) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulatorData/prepare',
|
||||
inputLength: parseInt(model.inputLength, 10),
|
||||
outputLength: parseInt(model.outputLength, 10),
|
||||
id: model.simulator
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new SimulationModelDataManager();
|
||||
|
|
|
@ -20,35 +20,5 @@
|
|||
******************************************************************************/
|
||||
|
||||
import RestDataManager from './rest-data-manager';
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
|
||||
class SimulationsDataManager extends RestDataManager {
|
||||
constructor() {
|
||||
super('simulation', '/simulations', [ '_id', 'name', 'projects', 'models' ]);
|
||||
|
||||
this.onLoad = this.onSimulationsLoad;
|
||||
}
|
||||
|
||||
onSimulationsLoad(data) {
|
||||
if (Array.isArray(data)) {
|
||||
for (let simulation of data) {
|
||||
this.loadSimulationData(simulation);
|
||||
}
|
||||
} else {
|
||||
this.loadSimulationData(data);
|
||||
}
|
||||
}
|
||||
|
||||
loadSimulationData(simulation) {
|
||||
for (let model of simulation.models) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulatorData/prepare',
|
||||
inputLength: parseInt(model.inputLength, 10),
|
||||
outputLength: parseInt(model.outputLength, 10),
|
||||
id: model.simulator
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new SimulationsDataManager();
|
||||
export default new RestDataManager('simulation', '/simulations', [ '_id', 'name', 'projects', 'models' ]);
|
||||
|
|
Loading…
Add table
Reference in a new issue