diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-16 17:07:58 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-17 17:06:50 +0200 |
| commit | d9e65dceb38cdb8dc4e464d388755f9456620566 (patch) | |
| tree | dbc369de8c4a0effce95ca4a54ff6dbfad2b47f5 /opendc-web/opendc-web-ui/src/sagas/scenarios.js | |
| parent | 1edbae1a0224e30bafb98638f419e1f967a9286f (diff) | |
ui: Restructure OpenDC frontend
This change updates the structure of the OpenDC frontend in order to
improve the maintainability of the frontend.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/sagas/scenarios.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/sagas/scenarios.js | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/opendc-web/opendc-web-ui/src/sagas/scenarios.js b/opendc-web/opendc-web-ui/src/sagas/scenarios.js deleted file mode 100644 index 59223610..00000000 --- a/opendc-web/opendc-web-ui/src/sagas/scenarios.js +++ /dev/null @@ -1,65 +0,0 @@ -import { call, put, select } from 'redux-saga/effects' -import { addPropToStoreObject, addToStore } from '../actions/objects' -import { getProject } from '../api/routes/projects' -import { fetchAndStoreAllSchedulers, fetchAndStoreAllTraces } from './objects' -import { fetchAndStoreAllTopologiesOfProject } from './topology' -import { addScenario, deleteScenario, updateScenario } from '../api/routes/scenarios' -import { fetchPortfolioWithScenarios, watchForPortfolioResults } from './portfolios' - -export function* onOpenScenarioSucceeded(action) { - try { - const project = yield call(getProject, action.projectId) - yield put(addToStore('project', project)) - yield fetchAndStoreAllTopologiesOfProject(project._id) - yield fetchAndStoreAllSchedulers() - yield fetchAndStoreAllTraces() - yield fetchPortfolioWithScenarios(action.portfolioId) - - // TODO Fetch scenario-specific metrics - } catch (error) { - console.error(error) - } -} - -export function* onAddScenario(action) { - try { - const scenario = yield call(addScenario, action.scenario.portfolioId, action.scenario) - yield put(addToStore('scenario', scenario)) - - const scenarioIds = yield select((state) => state.objects.portfolio[action.scenario.portfolioId].scenarioIds) - yield put( - addPropToStoreObject('portfolio', action.scenario.portfolioId, { - scenarioIds: scenarioIds.concat([scenario._id]), - }) - ) - yield watchForPortfolioResults() - } catch (error) { - console.error(error) - } -} - -export function* onUpdateScenario(action) { - try { - const scenario = yield call(updateScenario, action.scenario._id, action.scenario) - yield put(addToStore('scenario', scenario)) - } catch (error) { - console.error(error) - } -} - -export function* onDeleteScenario(action) { - try { - yield call(deleteScenario, action.id) - - const currentPortfolioId = yield select((state) => state.currentPortfolioId) - const scenarioIds = yield select((state) => state.objects.portfolio[currentPortfolioId].scenarioIds) - - yield put( - addPropToStoreObject('scenario', currentPortfolioId, { - scenarioIds: scenarioIds.filter((id) => id !== action.id), - }) - ) - } catch (error) { - console.error(error) - } -} |
