diff options
Diffstat (limited to 'frontend/views')
| -rw-r--r-- | frontend/views/graph/graph.container.js | 66 | ||||
| -rw-r--r-- | frontend/views/graph/graph.css | 3 | ||||
| -rw-r--r-- | frontend/views/index.js | 1 | ||||
| -rw-r--r-- | frontend/views/index/components/graph.form.js | 2 | ||||
| -rw-r--r-- | frontend/views/index/graph.reducer.js | 2 | ||||
| -rw-r--r-- | frontend/views/index/index.container.js | 15 | ||||
| -rw-r--r-- | frontend/views/site/site.actions.js | 9 | ||||
| -rw-r--r-- | frontend/views/site/site.reducer.js | 20 | ||||
| -rw-r--r-- | frontend/views/upload/upload.container.js | 5 |
9 files changed, 106 insertions, 17 deletions
diff --git a/frontend/views/graph/graph.container.js b/frontend/views/graph/graph.container.js new file mode 100644 index 0000000..40e2e6a --- /dev/null +++ b/frontend/views/graph/graph.container.js @@ -0,0 +1,66 @@ +import React, { Component } from 'react' +import { Route } from 'react-router-dom' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import './graph.css' + +import actions from '../../actions' +import { Loader } from '../../common' + +// import * as uploadActions from './upload.actions' + +// import GraphIndex from './containers/graph.index' + +class GraphContainer extends Component { + componentDidMount() { + if (this.shouldShowGraph()) this.load() + } + componentDidUpdate(prevProps) { + if (this.shouldLoadGraph(prevProps)) this.load() + } + shouldShowGraph() { + const { graph_name, page_name } = this.props.match.params + return (graph_name && !page_name && graph_name !== 'index') + } + shouldLoadGraph(prevProps) { + const { graph, location } = this.props + const { key } = location + if (key === prevProps.location.key) return false + if (!this.shouldShowGraph()) return false + return (graph.show.name === prevProps.graph.show.name) + } + load() { + actions.site.setSiteTitle("loading " + this.props.match.params.graph_name + "...") + actions.graph.show('name/' + this.props.match.params.graph_name) + .then(data => { + actions.site.setSiteTitle(data.res.title) + }) + } + render() { + if (!this.shouldShowGraph()) return null + if (this.props.graph.show.loading) { + return ( + <div className='index'> + <Loader /> + </div> + ) + } + console.log(this.props.graph.show) + return ( + <div className='index'> + </div> + ) + } +} + + // <Route exact path='/:graph_name' component={GraphView} /> +const mapStateToProps = state => ({ + graph: state.graph, +}) + +const mapDispatchToProps = dispatch => ({ + // uploadActions: bindActionCreators({ ...uploadActions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(GraphContainer) diff --git a/frontend/views/graph/graph.css b/frontend/views/graph/graph.css new file mode 100644 index 0000000..0a490f9 --- /dev/null +++ b/frontend/views/graph/graph.css @@ -0,0 +1,3 @@ +* { + +}
\ No newline at end of file diff --git a/frontend/views/index.js b/frontend/views/index.js index 69bb70e..07e7284 100644 --- a/frontend/views/index.js +++ b/frontend/views/index.js @@ -1,2 +1,3 @@ export { default as index } from './index/index.container' +export { default as graph } from './graph/graph.container' export { default as upload } from './upload/upload.container' diff --git a/frontend/views/index/components/graph.form.js b/frontend/views/index/components/graph.form.js index a6a0dd6..50f9773 100644 --- a/frontend/views/index/components/graph.form.js +++ b/frontend/views/index/components/graph.form.js @@ -22,7 +22,7 @@ export default class GraphForm extends Component { componentDidMount() { const { data, isNew } = this.props - const title = isNew ? 'new graph' : 'editing ' + data.title + const title = isNew ? 'new project' : 'editing ' + data.title const submitTitle = isNew ? "Create Graph" : "Save Changes" this.setState({ title, diff --git a/frontend/views/index/graph.reducer.js b/frontend/views/index/graph.reducer.js index 20aed8e..612ac14 100644 --- a/frontend/views/index/graph.reducer.js +++ b/frontend/views/index/graph.reducer.js @@ -11,7 +11,7 @@ const initialState = crudState('graph', { const reducer = crudReducer('graph') export default function graphReducer(state = initialState, action) { - console.log(action.type, action) + // console.log(action.type, action) state = reducer(state, action) switch (action.type) { default: diff --git a/frontend/views/index/index.container.js b/frontend/views/index/index.container.js index 0e7127a..1e2326b 100644 --- a/frontend/views/index/index.container.js +++ b/frontend/views/index/index.container.js @@ -5,7 +5,7 @@ import { connect } from 'react-redux' import './index.css' -// import actions from '../../actions' +import actions from '../../actions' // import * as uploadActions from './upload.actions' import GraphIndex from './containers/graph.index' @@ -13,6 +13,9 @@ import GraphNew from './containers/graph.new' import GraphEdit from './containers/graph.edit' class Container extends Component { + componentDidMount() { + actions.site.setSiteTitle("swimmer") + } render() { return ( <div className='index'> @@ -24,12 +27,4 @@ class Container extends Component { } } -const mapStateToProps = state => ({ - // upload: state.upload, -}) - -const mapDispatchToProps = dispatch => ({ - // uploadActions: bindActionCreators({ ...uploadActions }, dispatch), -}) - -export default connect(mapStateToProps, mapDispatchToProps)(Container) +export default Container diff --git a/frontend/views/site/site.actions.js b/frontend/views/site/site.actions.js new file mode 100644 index 0000000..74ce72d --- /dev/null +++ b/frontend/views/site/site.actions.js @@ -0,0 +1,9 @@ +import * as types from '../../types' +import { store, history } from '../../store' +import { api, post, pad, preloadImage } from '../../util' +import actions from '../../actions' +import { session } from '../../session' + +export const setSiteTitle = title => dispatch => ( + dispatch({ type: types.site.set_site_title, payload: title }) +)
\ No newline at end of file diff --git a/frontend/views/site/site.reducer.js b/frontend/views/site/site.reducer.js new file mode 100644 index 0000000..c9a25dd --- /dev/null +++ b/frontend/views/site/site.reducer.js @@ -0,0 +1,20 @@ +import * as types from '../../types' +// import { session, getDefault, getDefaultInt } from '../../session' + +const initialState = { + 'siteTitle': 'swimmer', +} + +export default function graphReducer(state = initialState, action) { + // console.log(action.type, action) + switch (action.type) { + case types.site.set_site_title: + return { + ...state, + siteTitle: action.payload, + } + + default: + return state + } +} diff --git a/frontend/views/upload/upload.container.js b/frontend/views/upload/upload.container.js index 0096b4f..ea9df5a 100644 --- a/frontend/views/upload/upload.container.js +++ b/frontend/views/upload/upload.container.js @@ -25,11 +25,6 @@ class Container extends Component { } } -/* - <Route exact path='/collection/:id/show/' component={CollectionShow} /> - <Route exact path='/collection/' component={CollectionIndex} /> -*/ - const mapStateToProps = state => ({ upload: state.upload, searchOptions: state.search.options, |
