import './styles/bootstrap.less'; import './styles/styles.less'; import React from 'react'; import Router from 'react-router'; import Fluxxor from 'fluxxor'; import {isObject} from 'lodash'; import actions from './actions'; import routes from './routes'; import AppStore from './stores/app_store'; import RouteStore from './stores/route_store'; import SearchStore from './stores/search_store'; import AuditStore from './stores/audit_store'; import ResourcesStore from './stores/resources_store'; import GraphStore from './stores/graph_store'; import UserStore from './stores/user_store'; import GroupStore from './stores/group_store'; import HostStore from './stores/host_store'; import LayerStore from './stores/layer_store'; import VariableStore from './stores/variable_store'; import PolicyStore from './stores/policy_store'; let router = Router.create({ routes: routes, location: Router.HistoryLocation }); let stores = { app: new AppStore(), route: new RouteStore(), search: new SearchStore(), audit: new AuditStore(), resources: new ResourcesStore(), graph: new GraphStore(), user: new UserStore(), group: new GroupStore(), host: new HostStore(), layer: new LayerStore(), variable: new VariableStore(), policy: new PolicyStore() }; let flux = new Fluxxor.Flux(stores, actions); flux.on('dispatch', function(type, payload) { /*eslint-disable no-console */ if (console && console.log) { console.log('[Dispatch]', type, payload); } /*eslint-enable no-console */ }); Promise.all([ new Promise((resolve) => { if (window.addEventListener) { window.addEventListener('DOMContentLoaded', resolve); } else { window.attachEvent('onload', resolve); } }) ]).then(() => { router.run(function(Handler, state) { if (flux.actions.getRManager().isLogged || (isObject(state.routes[0]) && ( state.routes[1].name === 'login' || state.routes[1].name === 'logout'))) { flux.actions.routes.transition(state.params); React.render( , document.getElementById('wrapper') ); } else { this.transitionTo('login', {}, { returnTo: state.path }); } }); });