Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #76 from multinet-app/sidebar-component
Browse files Browse the repository at this point in the history
Sidebar component
  • Loading branch information
jtomeck committed Jul 12, 2019
2 parents 44165c6 + ccebbcd commit 828e03f
Show file tree
Hide file tree
Showing 11 changed files with 445 additions and 252 deletions.
1 change: 0 additions & 1 deletion client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ export default {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
margin-top: 60px;
}
</style>
85 changes: 85 additions & 0 deletions client/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<v-navigation-drawer
app
fixed
permanent
stateless
value="true"
>
<v-toolbar
color="grey lighten-2"
>
<v-toolbar-title>multinet</v-toolbar-title>
<v-spacer />
<v-btn icon>
<v-avatar
color="grey lighten-4"
size="36px"
>
<v-icon color="grey">account_circle</v-icon>
</v-avatar>
</v-btn>
</v-toolbar>

<WorkspaceDialog
@created="addWorkspace"
/>

<v-list subheader>
<v-subheader>Your Workspaces</v-subheader>

<v-divider></v-divider>

<v-list-tile
active-class="grey lighten-4"
avatar
ripple
:key="space"
:to="`/workspaces/${space}/`"
v-for="space in workspaces"
>
<v-list-tile-avatar>
<v-icon color="primary">library_books</v-icon>
</v-list-tile-avatar>

<v-list-tile-content>
<v-list-tile-title>{{space}}</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
</template>

<script>
import api from '@/api'
import WorkspaceDialog from '@/components/WorkspaceDialog'
export default {
data () {
return {
newWorkspace: '',
workspaces: [],
right: null
}
},
components: {
WorkspaceDialog
},
methods: {
route (workspace) {
this.$router.push(`/workspaces/${workspace}`);
},
addWorkspace (workspace) {
const workspaces = this.workspaces.concat([workspace]);
this.workspaces = workspaces.sort();
},
},
async created () {
const response = await api().post('multinet/graphql', {query: `query {
workspaces { name }
}`});
this.workspaces = response.data.data.workspaces.map(space => space.name);
}
}
</script>
87 changes: 87 additions & 0 deletions client/src/components/WorkspaceDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<v-dialog
v-model="dialog"
width="500"
>
<template v-slot:activator="{ on }">
<v-btn
class="ws-btn ma-0 pa-4"
block
color="grey darken-3"
dark
depressed
large
v-on="on"
>
New Workspace
<v-spacer />
<v-icon right dark>add_circle</v-icon>
</v-btn>
</template>

<v-card>
<v-card-title
class="headline pb-0 pt-3"
primary-title
>
Create Workspace
</v-card-title>

<v-card-text class="px-4 pt-4 pb-1">
<v-text-field
box
label="Workspace name"
v-model="newWorkspace"
/>
</v-card-text>

<v-divider></v-divider>

<v-card-actions class="px-4 py-3">
<v-spacer></v-spacer>
<v-btn
color="grey darken-3"
dark
depressed
@click="create"
>
Create Workspace
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script>
import api from '@/api'
export default {
data () {
return {
dialog: false
}
},
methods: {
async create () {
if (this.newWorkspace) {
const response = await api().post('multinet/graphql', {query: `mutation {
workspace (name: "${this.newWorkspace}" )
}`});
if (response.data.data) {
this.$router.push(`/workspaces/${this.newWorkspace}`);
this.$emit('created', this.newWorkspace);
this.dialog = false;
}
}
},
}
}
</script>

<style scoped>
.ws-btn.v-btn {
border-radius: 0;
height: auto;
}
</style>
8 changes: 2 additions & 6 deletions client/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Workspaces from '@/views/Workspaces'
import FrontPage from '@/views/FrontPage'
import WorkspaceDetail from '@/views/WorkspaceDetail'
import TableDetail from '@/views/TableDetail'
import GraphDetail from '@/views/GraphDetail'
Expand All @@ -11,11 +11,7 @@ import NodeDetail from '@/views/NodeDetail'
const routes = [
{
path: '/',
redirect: '/workspaces'
},
{
path: '/workspaces',
component: Workspaces
component: FrontPage
},
{
path: '/workspaces/:workspace',
Expand Down
57 changes: 57 additions & 0 deletions client/src/views/FrontPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<v-container
fill-height
fluid
>
<sidebar />

<v-content>
<div class="getting-started">
<v-icon
class="gs-icon"
color="blue-grey lighten-3"
>
outlined_flag
</v-icon>
<div class="gs-content">
<h1 class="gs-title">Getting Started...</h1>
<p class="gs-text">Use the sidebar to the left to create a workspace or select an existing one.</p>
</div>
</div>
</v-content>
</v-container>
</template>

<script>
import Sidebar from '@/components/Sidebar'
export default {
components: {
Sidebar
}
}
</script>

<style>
.getting-started {
align-items: flex-start;
display: flex;
justify-content: center;
margin: 0 auto 100px;
max-width: 600px;
}
.v-icon.gs-icon {
font-size: 86px;
margin-right: 15px;
}
.gs-title {
color: #b0bec5;
font-size: 36px;
}
.gs-text {
font-size: 20px;
}
</style>
88 changes: 48 additions & 40 deletions client/src/views/GraphDetail.vue
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
<template>
<div>
<h1>Graph: {{`${this.workspace}/${this.graph}`}}</h1>
<div id="graph-details">
<div style="border-style: solid; width: 100%;">
<label>Node Types</label>
<ul>
<li v-for="table in nodeTypes" :key="table.name">
<router-link :to="`/workspaces/${workspace}/table/${table.name}`">{{table.name}}</router-link>
</li>
</ul>
</div>
<div style="border-style: solid; width: 100%">
<label>Edge Types</label>
<ul>
<li v-for="table in edgeTypes" :key="table.name">
<router-link :to="`/workspaces/${workspace}/table/${table.name}`">{{table.name}}</router-link>
</li>
</ul>
<v-container fluid>
<sidebar />

<v-content>
<h1>Graph: {{`${this.workspace}/${this.graph}`}}</h1>
<div id="graph-details">
<div style="border-style: solid; width: 100%;">
<label>Node Types</label>
<ul>
<li v-for="table in nodeTypes" :key="table.name">
<router-link :to="`/workspaces/${workspace}/table/${table.name}`">{{table.name}}</router-link>
</li>
</ul>
</div>
<div style="border-style: solid; width: 100%">
<label>Edge Types</label>
<ul>
<li v-for="table in edgeTypes" :key="table.name">
<router-link :to="`/workspaces/${workspace}/table/${table.name}`">{{table.name}}</router-link>
</li>
</ul>
</div>
<div style="border-style: solid; width: 100%">
<label>Apps</label>
<ul>
<li v-for="app in apps" :key="app.name">
<a :href="`${app.url}/?workspace=${workspace}&graph=${graph}`" target="_blank">{{app.name}}</a>
</li>
</ul>
</div>
</div>
<div style="border-style: solid; width: 100%">
<label>Apps</label>
<div style="border-style: solid;">
<label>Nodes</label>
<br/>
<br/>
<div style="display: flex; flex-flow: row nowrap; justify-content: space-around">
<div v-if="prev" v-on:click="firstPage()">first</div>
<div v-if="prev" v-on:click="turnPage(false)">previous</div>
<div v-if="next" v-on:click="turnPage(true)">next</div>
<div v-if="next" v-on:click="lastPage()">last</div>
</div>
<ul>
<li v-for="app in apps" :key="app.name">
<a :href="`${app.url}/?workspace=${workspace}&graph=${graph}`" target="_blank">{{app.name}}</a>
<li v-for="node in nodes" :key="node">
<router-link :to="`/workspaces/${workspace}/graph/${graph}/node/${node}`">{{node}}</router-link>
</li>
</ul>
</div>
</div>
<div style="border-style: solid;">
<label>Nodes</label>
<br/>
<br/>
<div style="display: flex; flex-flow: row nowrap; justify-content: space-around">
<div v-if="prev" v-on:click="firstPage()">first</div>
<div v-if="prev" v-on:click="turnPage(false)">previous</div>
<div v-if="next" v-on:click="turnPage(true)">next</div>
<div v-if="next" v-on:click="lastPage()">last</div>
</div>
<ul>
<li v-for="node in nodes" :key="node">
<router-link :to="`/workspaces/${workspace}/graph/${graph}/node/${node}`">{{node}}</router-link>
</li>
</ul>
</div>
</div>
</v-content>
</v-container>
</template>

<script>
import api from '@/api'
import Sidebar from '@/components/Sidebar'
export default {
name: 'GraphDetail',
Expand All @@ -56,6 +61,9 @@ export default {
return `${url}/?workspace=${this.workspace}&graph=${this.graph}`;
},
},
components: {
Sidebar
},
props: ['workspace', 'graph', 'apps'],
data () {
return {
Expand Down

0 comments on commit 828e03f

Please sign in to comment.