summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src')
-rw-r--r--opendc-web/opendc-web-ui/src/api/schedulers.js2
-rw-r--r--opendc-web/opendc-web-ui/src/api/traces.js2
-rw-r--r--opendc-web/opendc-web-ui/src/containers/app/sidebars/project/ScenarioListContainer.js4
-rw-r--r--opendc-web/opendc-web-ui/src/data/experiments.js11
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/objects.js2
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/objects.js19
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/portfolios.js7
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/projects.js3
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/scenarios.js3
9 files changed, 14 insertions, 39 deletions
diff --git a/opendc-web/opendc-web-ui/src/api/schedulers.js b/opendc-web/opendc-web-ui/src/api/schedulers.js
index 1b69f1a1..0b8b8153 100644
--- a/opendc-web/opendc-web-ui/src/api/schedulers.js
+++ b/opendc-web/opendc-web-ui/src/api/schedulers.js
@@ -22,6 +22,6 @@
import { request } from './index'
-export function getAllSchedulers(auth) {
+export function fetchSchedulers(auth) {
return request(auth, 'schedulers/')
}
diff --git a/opendc-web/opendc-web-ui/src/api/traces.js b/opendc-web/opendc-web-ui/src/api/traces.js
index df03a2dd..fd637ac3 100644
--- a/opendc-web/opendc-web-ui/src/api/traces.js
+++ b/opendc-web/opendc-web-ui/src/api/traces.js
@@ -22,6 +22,6 @@
import { request } from './index'
-export function getAllTraces(auth) {
+export function fetchTraces(auth) {
return request(auth, 'traces/')
}
diff --git a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/ScenarioListContainer.js b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/ScenarioListContainer.js
index c474c56e..7acc13ee 100644
--- a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/ScenarioListContainer.js
+++ b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/ScenarioListContainer.js
@@ -11,8 +11,8 @@ import { useSchedulers, useTraces } from '../../../../data/experiments'
const ScenarioListContainer = ({ portfolioId }) => {
const scenarios = useScenarios(portfolioId)
const topologies = useProjectTopologies()
- const traces = useTraces()
- const schedulers = useSchedulers()
+ const traces = useTraces().data ?? []
+ const schedulers = useSchedulers().data ?? []
const dispatch = useDispatch()
const [isVisible, setVisible] = useState(false)
diff --git a/opendc-web/opendc-web-ui/src/data/experiments.js b/opendc-web/opendc-web-ui/src/data/experiments.js
index aef512e5..4797bacb 100644
--- a/opendc-web/opendc-web-ui/src/data/experiments.js
+++ b/opendc-web/opendc-web-ui/src/data/experiments.js
@@ -20,18 +20,23 @@
* SOFTWARE.
*/
-import { useSelector } from 'react-redux'
+import { useQuery } from 'react-query'
+import { fetchTraces } from '../api/traces'
+import { useAuth } from '../auth'
+import { fetchSchedulers } from '../api/schedulers'
/**
* Return the available traces to experiment with.
*/
export function useTraces() {
- return useSelector((state) => Object.values(state.objects.trace))
+ const auth = useAuth()
+ return useQuery('traces', () => fetchTraces(auth))
}
/**
* Return the available schedulers to experiment with.
*/
export function useSchedulers() {
- return useSelector((state) => Object.values(state.objects.scheduler))
+ const auth = useAuth()
+ return useQuery('schedulers', () => fetchSchedulers(auth))
}
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/objects.js b/opendc-web/opendc-web-ui/src/redux/reducers/objects.js
index a2483b43..f8f577ac 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/objects.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/objects.js
@@ -20,8 +20,6 @@ export const objects = combineReducers({
tile: object('tile'),
room: object('room'),
topology: object('topology'),
- trace: object('trace'),
- scheduler: object('scheduler'),
portfolio: object('portfolio'),
scenario: object('scenario'),
prefab: object('prefab'),
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/objects.js b/opendc-web/opendc-web-ui/src/redux/sagas/objects.js
index 5523dd57..fe826014 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/objects.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/objects.js
@@ -1,7 +1,7 @@
import { call, put, select, getContext } from 'redux-saga/effects'
import { addToStore } from '../actions/objects'
-import { getAllSchedulers } from '../../api/schedulers'
-import { getAllTraces } from '../../api/traces'
+import { fetchSchedulers } from '../../api/schedulers'
+import { fetchTraces } from '../../api/traces'
import { getTopology, updateTopology } from '../../api/topologies'
import { uuid } from 'uuidv4'
@@ -210,18 +210,3 @@ export const getRackById = function* (id, keepIds) {
})),
}
}
-
-export const fetchAndStoreAllTraces = function* () {
- const auth = yield getContext('auth')
- return yield fetchAndStoreObjects('trace', call(getAllTraces, auth))
-}
-
-export const fetchAndStoreAllSchedulers = function* () {
- const auth = yield getContext('auth')
- const objects = yield call(getAllSchedulers, auth)
- for (let object of objects) {
- object._id = object.name
- yield put(addToStore('scheduler', object))
- }
- return objects
-}
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/portfolios.js b/opendc-web/opendc-web-ui/src/redux/sagas/portfolios.js
index c32fcdc0..68956225 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/portfolios.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/portfolios.js
@@ -2,8 +2,6 @@ import { call, put, select, delay, getContext } from 'redux-saga/effects'
import { addToStore } from '../actions/objects'
import { addPortfolio, deletePortfolio, getPortfolio, updatePortfolio } from '../../api/portfolios'
import { fetchProject } from '../../api/projects'
-import { fetchAndStoreAllSchedulers, fetchAndStoreAllTraces } from './objects'
-import { fetchAndStoreAllTopologiesOfProject } from './topology'
import { getScenario } from '../../api/scenarios'
export function* onOpenPortfolioSucceeded(action) {
@@ -15,8 +13,6 @@ export function* onOpenPortfolioSucceeded(action) {
)
yield fetchAndStoreAllTopologiesOfProject(action.projectId)
yield fetchPortfoliosOfProject(project)
- yield fetchAndStoreAllSchedulers()
- yield fetchAndStoreAllTraces()
yield watchForPortfolioResults(action.portfolioId)
} catch (error) {
@@ -55,9 +51,6 @@ export function* getCurrentUnfinishedScenarios(portfolioId) {
export function* fetchPortfoliosOfProject(project) {
try {
- yield fetchAndStoreAllSchedulers()
- yield fetchAndStoreAllTraces()
-
for (const i in project.portfolioIds) {
yield fetchPortfolioWithScenarios(project.portfolioIds[i])
}
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/projects.js b/opendc-web/opendc-web-ui/src/redux/sagas/projects.js
index 96a4323c..6dc3c682 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/projects.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/projects.js
@@ -1,6 +1,5 @@
import { call, getContext } from 'redux-saga/effects'
import { fetchAndStoreAllTopologiesOfProject } from './topology'
-import { fetchAndStoreAllSchedulers, fetchAndStoreAllTraces } from './objects'
import { fetchPortfoliosOfProject } from './portfolios'
import { fetchProject } from '../../api/projects'
@@ -14,8 +13,6 @@ export function* onOpenProjectSucceeded(action) {
yield fetchAndStoreAllTopologiesOfProject(action.id, true)
yield fetchPortfoliosOfProject(project)
- yield fetchAndStoreAllSchedulers()
- yield fetchAndStoreAllTraces()
} catch (error) {
console.error(error)
}
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/scenarios.js b/opendc-web/opendc-web-ui/src/redux/sagas/scenarios.js
index 3fe12981..10ab3547 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/scenarios.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/scenarios.js
@@ -1,7 +1,6 @@
import { call, put, select, getContext } from 'redux-saga/effects'
import { addPropToStoreObject, addToStore } from '../actions/objects'
import { fetchProject } from '../../api/projects'
-import { fetchAndStoreAllSchedulers, fetchAndStoreAllTraces } from './objects'
import { fetchAndStoreAllTopologiesOfProject } from './topology'
import { addScenario, deleteScenario, updateScenario } from '../../api/scenarios'
import { fetchPortfolioWithScenarios, watchForPortfolioResults } from './portfolios'
@@ -15,8 +14,6 @@ export function* onOpenScenarioSucceeded(action) {
)
yield put(addToStore('project', project))
yield fetchAndStoreAllTopologiesOfProject(project._id)
- yield fetchAndStoreAllSchedulers()
- yield fetchAndStoreAllTraces()
yield fetchPortfolioWithScenarios(action.portfolioId)
// TODO Fetch scenario-specific metrics