Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Added new design for diagram with steps
Browse files Browse the repository at this point in the history
  • Loading branch information
quintesse committed Jul 30, 2018
1 parent 1696f16 commit 8a52170
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Dimmer, Loader } from 'semantic-ui-react';
import './App.css';
import TMainPage from './t-design/MainPage';
import DiagramWithTemplate from './t2-design/DiagramWithTemplate';
import DiagramWithSteps from './t2-design/DiagramWithSteps';
import GMainPage from './g-design/MainPage';
import Home from './pages/Home';
import BoosterMatrix from './pages/BoosterMatrix';
Expand Down Expand Up @@ -32,6 +33,7 @@ class App extends Component {
<Route exact path='/' component={Home}/>
<Route path='/t-design' component={TMainPage}/>
<Route path='/t2-design' component={DiagramWithTemplate}/>
<Route path='/t3-design' component={DiagramWithSteps}/>
<Route path='/g-design' component={GMainPage}/>
<Route path='/matrix' component={BoosterMatrix}/>
</Switch>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const Home = () => (
<Button primary size='huge' as="a" href="/t-design">Start with T<Icon name='right arrow' /></Button>
<Divider horizontal>Or</Divider>
<Button primary size='huge' as="a" href="/t2-design">Start with T2<Icon name='right arrow' /></Button>
<Divider horizontal>Or</Divider>
<Button primary size='huge' as="a" href="/t3-design">Start with T3<Icon name='right arrow' /></Button>
<Divider horizontal>Or</Divider>
<Button primary size='huge' as="a" href="/g-design">Start with G<Icon name='right arrow' /></Button>
</Container>
Expand Down
19 changes: 19 additions & 0 deletions src/t2-design/DiagramWithSteps.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.t3-design-withsteps {
display: flex;
width: 100%;
height: 100%;
}

.t3-design-withsteps table {
width: 100%;
height: 100%;
}

.t3-design-withsteps td {
padding: 0px;
margin: 0px;
}

.stepscell {
width: 30%;
}
260 changes: 260 additions & 0 deletions src/t2-design/DiagramWithSteps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
import React from 'react';
import classNames from 'classnames';
import _ from "lodash";

import {Checkbox, Form, Step} from 'semantic-ui-react'

import Topology from "./components/Topology";

import './DiagramWithSteps.css';

const step1 = {
nodes: {
s1: {type: 'service', name: 'Message Broker: AMQ', suggested: true},
cm1: {type: 'configmap', name: 'Message Broker Auth', suggested: true},
},
edges: {
l1: {from: 's1', to: 'cm1', suggested: true},
}
};

const step2 = {
nodes: {
s1: {type: 'service', name: 'Message Broker: AMQ'},
cm1: {type: 'configmap', name: 'Message Broker Auth'},
s2: {type: 'service', name: 'Listener: to Database', suggested: true},
},
edges: {
l1: {from: 's1', to: 'cm1'},
l2: {from: 's2', to: 'cm1', suggested: true},
}
};

const step3 = {
nodes: {
s1: {type: 'service', name: 'Message Broker: AMQ'},
cm1: {type: 'configmap', name: 'Message Broker Auth'},
s2: {type: 'service', name: 'Listener: to Database'},
s3: {type: 'service', name: 'Database: PostgreSQL', suggested: true},
cm2: {type: 'configmap', name: 'Database Auth', suggested: true},
v1: {type: 'storage', name: 'Database Storage', suggested: true},
},
edges: {
l1: {from: 's1', to: 'cm1'},
l2: {from: 's2', to: 'cm1'},
l3: {from: 's3', to: 'cm2', suggested: true},
l4: {from: 's3', to: 'v1', suggested: true},
l5: {from: 's2', to: 'cm2', suggested: true},
}
};

const step4 = {
nodes: {
s1: {type: 'service', name: 'Message Broker: AMQ'},
cm1: {type: 'configmap', name: 'Message Broker Auth'},
s2: {type: 'service', name: 'Listener: to Database'},
s3: {type: 'service', name: 'Database: PostgreSQL'},
cm2: {type: 'configmap', name: 'Database Auth'},
v1: {type: 'storage', name: 'Database Storage'},
},
edges: {
l1: {from: 's1', to: 'cm1'},
l2: {from: 's2', to: 'cm1'},
l3: {from: 's3', to: 'cm2'},
l4: {from: 's3', to: 'v1'},
l5: {from: 's2', to: 'cm2'},
}
};

class DiagramWithTemplate extends React.Component {

constructor(props) {
super(props);
this.state = {
selectedItemId: null,
layout: {
nodes: {
r1: {type: 'route', belongsTo: 's1'},
s1: {type: 'service', name: 'Placeholder'},
d1: {type: 'storage', belongsTo: 's1'},
},
edges: {
l1: {from: 'r1', to: 's1'},
l2: {from: 's1', to: 'd1'},
}
}
};
}

startStep = () => (
<Step onClick={() => this.setState({layout: step1})}>
<Step.Content>
<Step.Title>A Messaging App</Step.Title>
<Step.Description>Let's create a messaging application</Step.Description>
<Step.Description><a>Click here to Start</a></Step.Description>
</Step.Content>
</Step>
)

amqStep = () => (
<Step onClick={() => this.setState({layout: step1})}>
<Step.Content>
<Step.Title>Message Broker: AMQ</Step.Title>
<Step.Description>A message broker based on Red Hat AMQ.</Step.Description>
<Form>
<Form.Field>
<Checkbox
radio
label='Queue (one listener)'
name='queue'
value='this'
/>
</Form.Field>
<Form.Field>
<Checkbox
radio
label='Topic (many listeners)'
name='topic'
value='this'
/>
</Form.Field>
</Form>
</Step.Content>
</Step>
)

listenerStep = () => (
<Step onClick={() => this.setState({layout: step2})}>
<Step.Content>
<Step.Title>Listener</Step.Title>
<Step.Description>What kind of listener do you want for your messages?</Step.Description>
<Form>
<Form.Field>
<Checkbox
radio
label='Write messages to log'
name='simple'
value='this'
/>
</Form.Field>
<Form.Field>
<Checkbox
radio
label='Write messages to database'
name='database'
value='this'
/>
</Form.Field>
<Form.Field>
<Checkbox
radio
label='Some other message sinkn'
name='other'
value='this'
/>
</Form.Field>
</Form>
</Step.Content>
</Step>
)

dbStep = () => (
<Step>
<Step.Content>
<Step.Title>Database</Step.Title>
<Step.Description>What database do you want to use?</Step.Description>
<Form>
<Form.Field>
<Checkbox
radio
label='Create local database'
name='create'
value='this'
/>
</Form.Field>
<Form.Field>
<Checkbox
radio
label='Connect to local database'
name='local'
value='this'
/>
</Form.Field>
<Form.Field>
<Checkbox
radio
label='Connect to external database'
name='other'
value='this'
/>
</Form.Field>
</Form>
</Step.Content>
</Step>
)

dbCreateStep = () => (
<Step onClick={() => this.setState({layout: step3})}>
<Step.Content>
<Step.Title>Database</Step.Title>
<Step.Description>What database do you want to use?</Step.Description>
<Form>
<Form.Select label="Type" options={[
{ key: 'psql', text: 'PostgresQL', value: 'postgresql' },
{ key: 'mysql', text: 'mySQL', value: 'mysql' },
]} placeholder="Database" required />
<Form.Input label="Name" placeholder="Name" required />
<Form.Button label="Schema">Import...</Form.Button>
<Form.Input label="User" placeholder="User" required />
<Form.Input label="Password" type="password" required />
</Form>
</Step.Content>
</Step>
)

generateStep = () => (
<Step onClick={() => this.setState({layout: step4})}>
<Step.Content>
<Step.Title>Database</Step.Title>
<Step.Description>What database do you want to use?</Step.Description>
<Form>
<Form.Field>
<Form.Button>Generate</Form.Button>
</Form.Field>
</Form>
</Step.Content>
</Step>
)

onSelectItem = (id, item) => {
this.setState({selectedItemId: id});
}

render() {
return (
<div className={classNames("t3-design-withsteps")}>
<table>
<tbody>
<tr>
<td className={classNames("stepscell")}>
<Step.Group fluid vertical>
{ this.startStep() }
{ this.amqStep() }
{ this.listenerStep() }
{ this.dbStep() }
{ this.dbCreateStep() }
{ this.generateStep() }
</Step.Group>
</td>
<td className={classNames("topocell")}>
<Topology layout={this.state.layout} onSelect={this.onSelectItem}/>
</td>
</tr>
</tbody>
</table>
</div>
);
}
}

export default DiagramWithTemplate;

0 comments on commit 8a52170

Please sign in to comment.