index.js.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: index.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: index.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/** @module AutoMate */
  20. // Import dependencies
  21. import React from 'react'
  22. import ReactDOM from 'react-dom'
  23. import { browserHistory, Router, Route, IndexRoute } from 'react-router'
  24. import { createStore, combineReducers, bindActionCreators, compose } from 'redux'
  25. import { Provider, connect } from 'react-redux'
  26. import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
  27. // Import the main module and the CSS.
  28. import Main from './Main'
  29. import './index.css'
  30. // Import the submodules.
  31. import project from './project'
  32. import registermap from './registermap'
  33. import demo_module from './demo_module'
  34. /**
  35. * Redux Section
  36. **/
  37. /** The root reducer is combined from all sub-module reducers. */
  38. const rootReducer = combineReducers({
  39. project: project.reducer,
  40. registermap: registermap.reducer,
  41. demo_module: demo_module.reducer,
  42. routing: routerReducer
  43. })
  44. console.log('Root reducer:', rootReducer)
  45. /** The default state is combined from all sub-module states. */
  46. const defaultState = {
  47. project: project.state,
  48. registermap: registermap.state,
  49. demo_module: demo_module.state
  50. }
  51. console.log('Default state:', defaultState)
  52. /** The enhancer allows to use Redux development tools in Chrome. */
  53. const enhancers = compose(
  54. window.devToolsExtension ? window.devToolsExtension() : f => f
  55. )
  56. console.log('Enhancers:', enhancers)
  57. /** Build the Redux store from the rootReducer, the defualtState and the enhancers. */
  58. const store = createStore(rootReducer, defaultState, enhancers)
  59. console.log('store:', store)
  60. const history = syncHistoryWithStore(browserHistory, store)
  61. console.log('history:', history)
  62. /** Collect the action creators from all modules in actionCreators */
  63. const actionCreators = { project: project.actions, registermap: registermap.actions, demo_module: demo_module.actionCreators }
  64. /** Creates a function */
  65. function mapStateToProps (state) {
  66. const propState = {}
  67. Object.keys(state).forEach(key => {
  68. propState[key] = state[key]
  69. })
  70. console.log('Mapping state to props:', state, propState)
  71. return propState
  72. }
  73. function mapDispatchToProps (dispatch) {
  74. const boundActionCreators = {}
  75. Object.keys(actionCreators).forEach(key => {
  76. boundActionCreators[`${key}Actions`] = bindActionCreators(actionCreators[key], dispatch)
  77. })
  78. console.log('Mapping dispatch to props:', dispatch, boundActionCreators)
  79. return boundActionCreators
  80. }
  81. const App = connect(mapStateToProps, mapDispatchToProps)(Main)
  82. /**
  83. * React-Router Section
  84. **/
  85. /** Combine the routes from all modules. */
  86. const router = (
  87. &lt;Provider store={store}>
  88. &lt;Router history={history}>
  89. &lt;Route component={App}>
  90. &lt;Route path='/'>
  91. &lt;IndexRoute component={demo_module.components.DemoModule} />
  92. &lt;Route path='/project/:projectId' component={project.components.Project} />
  93. &lt;Route path='/project' component={project.components.Project} />
  94. &lt;Route path='/registermap/:registermapId' component={registermap.components.Registermap} />
  95. &lt;Route path='/registermap' component={registermap.components.Registermap} />
  96. &lt;/Route>
  97. {demo_module.routes}
  98. &lt;Route path='/login' />
  99. &lt;/Route>
  100. &lt;/Router>
  101. &lt;/Provider>
  102. )
  103. /**
  104. * Render the app
  105. **/
  106. ReactDOM.render(
  107. router,
  108. document.getElementById('root')
  109. )
  110. </code></pre>
  111. </article>
  112. </section>
  113. </div>
  114. <nav>
  115. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-AutoMate.html">AutoMate</a></li><li><a href="module-demo_module.html">demo_module</a></li><li><a href="module-demo_module_components_index.html">demo_module/components/index</a></li><li><a href="module-demo_module_constants.html">demo_module/constants</a></li><li><a href="module-demo_module_initialData.html">demo_module/initialData</a></li><li><a href="module-demo_module_state.html">demo_module/state</a></li><li><a href="module-project.html">project</a></li><li><a href="module-project_components.html">project/components</a></li><li><a href="module-project_state.html">project/state</a></li><li><a href="module-registermap.html">registermap</a></li></ul>
  116. </nav>
  117. <br class="clear">
  118. <footer>
  119. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Mar 14 2017 18:34:23 GMT+0100 (W. Europe Standard Time)
  120. </footer>
  121. <script> prettyPrint(); </script>
  122. <script src="scripts/linenumber.js"> </script>
  123. </body>
  124. </html>