diff --git a/arangopipe/arangopipe_frontend/app/src/actions/auth/index.js b/arangopipe/arangopipe_frontend/app/src/actions/auth/index.js index 1de8124..3845538 100755 --- a/arangopipe/arangopipe_frontend/app/src/actions/auth/index.js +++ b/arangopipe/arangopipe_frontend/app/src/actions/auth/index.js @@ -13,7 +13,19 @@ export const signin = (obj) => { return API(data).then(res => { localStorage.setItem('token', res.data.jwt); - return dispatch({ type: USER.SIGNED_IN, payload: res.data.username }) + let get_dbs = { + method: 'GET', + url: '_api/database/user?_='+Date.now() + } + + const username = res.data.user + + return AUTHAPI(get_dbs).then(res => { + return dispatch({ + type: USER.SIGNED_IN, + payload: { name: username, isAdmin: res.data.result.includes('_system') }}) + }) + }).catch(err => { message.error('Wrong ID or Password!'); throw err @@ -24,15 +36,27 @@ export const signin = (obj) => { export const currentUser = () => { return (dispatch) => { - let data = { + let get_token = { method: 'GET', url: '_admin/aardvark/whoAmI?_='+Date.now() } - return AUTHAPI(data).then(res => { - console.log('success') - return dispatch({ type: USER.SIGNED_IN, payload: res.data.user }) + + return AUTHAPI(get_token).then(res => { + + let get_dbs = { + method: 'GET', + url: '_api/database/user?_='+Date.now() + } + + const username = res.data.user + + return AUTHAPI(get_dbs).then(res => { + return dispatch({ + type: USER.SIGNED_IN, + payload: { name: username, isAdmin: res.data.result.includes('_system') }}) + }) + }).catch(err => { - console.log(err) localStorage.removeItem('token'); return dispatch({ type: USER.SIGNED_OUT }) }) diff --git a/arangopipe/arangopipe_frontend/app/src/actions/counter.js b/arangopipe/arangopipe_frontend/app/src/actions/counter.js deleted file mode 100755 index 765fb4d..0000000 --- a/arangopipe/arangopipe_frontend/app/src/actions/counter.js +++ /dev/null @@ -1,56 +0,0 @@ -export const DECREMENT = 'counter/DECREMENT'; -export const DECREMENT_REQUESTED = 'counter/DECREMENT_REQUESTED'; -export const INCREMENT = 'counter/INCREMENT'; -export const INCREMENT_REQUESTED = 'counter/INCREMENT_REQUESTED'; - -export const decrement = () => { - return dispatch => { - dispatch({ - type: DECREMENT_REQUESTED - }); - - dispatch({ - type: DECREMENT - }); - }; -}; - -export const decrementAsync = () => { - return dispatch => { - dispatch({ - type: DECREMENT_REQUESTED - }); - - return setTimeout(() => { - dispatch({ - type: DECREMENT - }); - }, 3000); - }; -}; - -export const increment = () => { - return dispatch => { - dispatch({ - type: INCREMENT_REQUESTED - }); - - dispatch({ - type: INCREMENT - }); - }; -}; - -export const incrementAsync = () => { - return dispatch => { - dispatch({ - type: INCREMENT_REQUESTED - }); - - return setTimeout(() => { - dispatch({ - type: INCREMENT - }); - }, 3000); - }; -}; diff --git a/arangopipe/arangopipe_frontend/app/src/actions/document/index.js b/arangopipe/arangopipe_frontend/app/src/actions/document/index.js index b6d7947..dce509a 100755 --- a/arangopipe/arangopipe_frontend/app/src/actions/document/index.js +++ b/arangopipe/arangopipe_frontend/app/src/actions/document/index.js @@ -1,4 +1,4 @@ -import { DOCUMENT, GRAPH } from '../../reducers/type' +import { DOCUMENT } from '../../reducers/type' import AUTHAPI from '../AUTHAPI' import moment from 'moment'; import { message } from 'antd' diff --git a/arangopipe/arangopipe_frontend/app/src/actions/query/index.js b/arangopipe/arangopipe_frontend/app/src/actions/query/index.js index eebff32..c1cb1f3 100644 --- a/arangopipe/arangopipe_frontend/app/src/actions/query/index.js +++ b/arangopipe/arangopipe_frontend/app/src/actions/query/index.js @@ -1,7 +1,5 @@ import { QUERY } from '../../reducers/type' import AUTHAPI from '../AUTHAPI' -import moment from 'moment'; -import { message } from 'antd' //Get Default Query diff --git a/arangopipe/arangopipe_frontend/app/src/components/Form/MetaSearchForm.jsx b/arangopipe/arangopipe_frontend/app/src/components/Form/MetaSearchForm.jsx index cd0b67b..748bded 100755 --- a/arangopipe/arangopipe_frontend/app/src/components/Form/MetaSearchForm.jsx +++ b/arangopipe/arangopipe_frontend/app/src/components/Form/MetaSearchForm.jsx @@ -7,7 +7,7 @@ import { } from '../../actions/document' -import { Form, Icon, Input, Button, Select } from 'antd'; +import { Form, Input, Button, Select } from 'antd'; import { FIND_OPTIONS, WITH_OPTIONS, DEPLOY_QUERY } from "../../constants/searchOptions"; const { Option } = Select; diff --git a/arangopipe/arangopipe_frontend/app/src/components/Modal/TreeGraph.jsx b/arangopipe/arangopipe_frontend/app/src/components/Modal/TreeGraph.jsx index e7dc93a..0b20d2f 100644 --- a/arangopipe/arangopipe_frontend/app/src/components/Modal/TreeGraph.jsx +++ b/arangopipe/arangopipe_frontend/app/src/components/Modal/TreeGraph.jsx @@ -13,8 +13,11 @@ const { Option } = Select; class TreeGraphForm extends React.Component { + state = { graph: null, + engine: 'dot', + format: 'svg', visible: 'hidden' } @@ -168,7 +171,7 @@ class TreeGraphForm extends React.Component { renderGraph(); } - componentWillMount() { + componentDidMount() { const d_tag = this.props.deploymentTag.trim() const queries = [] @@ -185,7 +188,7 @@ class TreeGraphForm extends React.Component { this.props.getGraphData(queries) } - componentWillReceiveProps(props, state){ + componentWillReceiveProps(props){ if (this.props != props) { let gdata = Object.assign([], props.gdata) @@ -212,28 +215,35 @@ class TreeGraphForm extends React.Component { }` this.setState({ - graph: tree + graph: tree, + visible: 'visible' }) + } } } - handleSubmit = e => { - e.preventDefault(); - this.props.form.validateFields((err, values) => { - if (!err) { - this.setState({ - visible: 'visible' - }) - this.drawGraph(values.engine, values.format, this.state.graph) - } - }); + + handleEngineChange = value => { + this.setState({ + engine: value + }) }; + handleFormatChange = value => { + this.setState({ + format: value + }) + }; + + render() { const { getFieldDecorator } = this.props.form; + if(this.state.graph != null) + this.drawGraph(this.state.engine, this.state.format, this.state.graph) + return (