Skip to content

Commit

Permalink
Merge pull request #44 from arangoml/test
Browse files Browse the repository at this point in the history
Completed Query Page
  • Loading branch information
rbh6 authored Oct 3, 2019
2 parents 3d97a6c + 96da360 commit 8cfe6c2
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 127 deletions.
36 changes: 30 additions & 6 deletions arangopipe/arangopipe_frontend/app/src/actions/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 })
})
Expand Down
56 changes: 0 additions & 56 deletions arangopipe/arangopipe_frontend/app/src/actions/counter.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 0 additions & 2 deletions arangopipe/arangopipe_frontend/app/src/actions/query/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { QUERY } from '../../reducers/type'
import AUTHAPI from '../AUTHAPI'
import moment from 'moment';
import { message } from 'antd'


//Get Default Query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ const { Option } = Select;


class TreeGraphForm extends React.Component {

state = {
graph: null,
engine: 'dot',
format: 'svg',
visible: 'hidden'
}

Expand Down Expand Up @@ -168,7 +171,7 @@ class TreeGraphForm extends React.Component {
renderGraph();
}

componentWillMount() {
componentDidMount() {
const d_tag = this.props.deploymentTag.trim()
const queries = []

Expand All @@ -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)
Expand All @@ -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 (
<div className="graph">
<Modal
Expand All @@ -245,13 +255,13 @@ class TreeGraphForm extends React.Component {
style={{ top: 20 }}
footer={[]}
>
<Form layout="inline" onSubmit={this.handleSubmit} style={{textAlign:'center'}}>
<Form layout="inline" style={{textAlign:'center'}}>
<Form.Item label='Engine'>
{getFieldDecorator('engine', {
initialValue: 'dot',
rules: [{ required: true, message: 'Please input your Password!' }],
})(
<Select style={{ width: 250 }}>
<Select style={{ width: 250 }} onChange={this.handleEngineChange}>
<Option value="circo">circo</Option>
<Option value="dot">dot</Option>
<Option value="fdp">fdp</Option>
Expand All @@ -266,7 +276,7 @@ class TreeGraphForm extends React.Component {
initialValue: 'svg',
rules: [{ required: true, message: 'Please input your Password!' }],
})(
<Select style={{ width: 250 }}>
<Select style={{ width: 250 }} onChange={this.handleFormatChange}>
<Option value="svg">svg</Option>
<Option value="png-image-element">png-image-element</Option>
<Option value="json">json</Option>
Expand All @@ -277,11 +287,7 @@ class TreeGraphForm extends React.Component {
)}
</Form.Item>

<Form.Item>
<Button type="primary" htmlType="submit" icon='line-chart'>
Generate
</Button>
</Form.Item>

</Form>
<Divider style={{marginTop: 10}}/>
<div id="review" style={{visibility: this.state.visible}}>
Expand Down
43 changes: 25 additions & 18 deletions arangopipe/arangopipe_frontend/app/src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,31 @@ class Sidebar extends React.Component{
<span>Home</span>
</Link>
</Menu.Item>
<Menu.Item key="user">
<Link to="/user">
<Icon type="user" />
<span>User</span>
</Link>
</Menu.Item>
<Menu.Item key="deployment">
<Link to="/deployment">
<Icon type="desktop" />
<span>Deployment</span>
</Link>
</Menu.Item>
<Menu.Item key="project">
<Link to="/project">
<Icon type="pie-chart" />
<span>Project</span>
</Link>
</Menu.Item>
{this.props.isAdmin &&
<Menu.Item key="user">
<Link to="/user">
<Icon type="user" />
<span>User</span>
</Link>
</Menu.Item>
}

{this.props.isAdmin &&
<Menu.Item key="deployment">
<Link to="/deployment">
<Icon type="desktop" />
<span>Deployment</span>
</Link>
</Menu.Item>
}
{this.props.isAdmin &&
<Menu.Item key="project">
<Link to="/project">
<Icon type="pie-chart" />
<span>Project</span>
</Link>
</Menu.Item>
}
<Menu.Item key="query">
<Link to="/query">
<Icon type="fire" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Table, Button } from 'antd';
import { Table } from 'antd';

const capitalizeFLetter = (str) => {
return str[0].toUpperCase() +
Expand Down
10 changes: 5 additions & 5 deletions arangopipe/arangopipe_frontend/app/src/containers/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import Project from '../Project/Project';
import Query from '../Query/Query';

import './App.css'
import config from '../../utils/config'

import { Layout, Menu, Avatar, Affix, Drawer, Button, Icon, Breadcrumb, Input } from 'antd';
const { Header, Content, Footer, Sider } = Layout;
import { Layout, Menu, Avatar, Affix, Drawer, Button, Icon, Input } from 'antd';
const { Header, Content, Footer } = Layout;
const { SubMenu } = Menu;
const { Search } = Input;

Expand Down Expand Up @@ -50,7 +49,7 @@ class App extends React.Component{
await this.props.currentUser()
}

componentWillMount(){
componentDidMount(){
if(!this.props.auth.is_authed){
window.location = '/login'
} else {
Expand All @@ -60,13 +59,14 @@ class App extends React.Component{

render() {
const username = this.props.auth.user || '';
const isAdmin = this.props.auth.isAdmin || false;
const avatarPath = require('../../assets/avatar.jpeg')

const currentPage = this.props.location.pathname.split('/')[1]

return (
<Layout style={{ minHeight: '100vh' }}>
<Sidebar collapsed={this.state.collapsed} currentPage={currentPage}/>
<Sidebar collapsed={this.state.collapsed} currentPage={currentPage} isAdmin={isAdmin}/>
<Layout>

<Header className="header">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import {
getUploadedDocuments,
processDocument,
deleteDocument,
saveToCSV,
clearDB
} from '../../actions/document'

import { Table, Input, Button, Icon, Row, Col, Card, Divider, Modal } from 'antd';
import Highlighter from 'react-highlight-words';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';


import brace from 'brace';
import AceEditor from 'react-ace';
Expand All @@ -20,9 +20,8 @@ import {
explainQuery
} from '../../actions/query'

import { Table, Input, Button, Icon, Row, Col, Popconfirm, Alert,
Tag, Divider, Card, Menu, Tooltip, notification, Switch } from 'antd';
import Highlighter from 'react-highlight-words';
import { Button, Icon, Row, Col, Popconfirm, Alert,
Tag, Card, Menu, Tooltip, notification, Switch } from 'antd';


class Query extends React.Component {
Expand Down
Loading

0 comments on commit 8cfe6c2

Please sign in to comment.