summaryrefslogtreecommitdiff
path: root/frontend/views/page/page.actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/views/page/page.actions.js')
-rw-r--r--frontend/views/page/page.actions.js32
1 files changed, 29 insertions, 3 deletions
diff --git a/frontend/views/page/page.actions.js b/frontend/views/page/page.actions.js
index cfd0f98..941bd9b 100644
--- a/frontend/views/page/page.actions.js
+++ b/frontend/views/page/page.actions.js
@@ -1,13 +1,39 @@
import * as types from '../../types'
+import { store } from '../../store'
+import actions from '../../actions'
export const showAddTileForm = () => dispatch => {
- dispatch({ type: types.graph.show_add_tile_form })
+ dispatch({ type: types.page.show_add_tile_form })
}
export const hideAddTileForm = () => dispatch => {
- dispatch({ type: types.graph.hide_add_tile_form })
+ dispatch({ type: types.page.hide_add_tile_form })
}
export const updatePageTile = tile => dispatch => {
- dispatch({ type: types.graph.update_graph_tile, tile })
+ dispatch({ type: types.page.update_graph_tile, tile })
}
+
+export const showGraphAndPageIfUnloaded = ({ graph_name, page_name }) => dispatch => (
+ new Promise((resolve, reject) => {
+ showGraphIfUnloaded({ graph_name })(dispatch)
+ .then(graph => (
+ actions.page.show('name/' + graph_name + '/' + page_name)
+ .then(resolve)
+ .catch(reject)
+ ))
+ .catch(reject)
+ })
+)
+
+export const showGraphIfUnloaded = ({ graph_name }) => dispatch => (
+ new Promise((resolve, reject) => {
+ const { res: graph } = store.getState().graph.show
+ if (graph && graph.path === graph_name) {
+ return resolve(graph)
+ }
+ actions.graph.show('name/' + graph_name)
+ .then(resolve)
+ .catch(reject)
+ })
+) \ No newline at end of file