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

Commit

Permalink
Merge branch 'graph-improvements' of github.com:multinet-app/multinet…
Browse files Browse the repository at this point in the history
… into graph-improvements
  • Loading branch information
jjnesbitt committed Mar 4, 2020
2 parents aab1260 + d90f209 commit 0f1554e
Show file tree
Hide file tree
Showing 15 changed files with 1,417 additions and 1,347 deletions.
6 changes: 6 additions & 0 deletions client/.env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Usually auto-injected
VUE_APP_GIT_SHA=
VUE_APP_GA_TAG=

# Must contain protocol prefix (http://, https://, etc.)
VUE_APP_MULTINET_HOST=
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"axios": "^0.18.1",
"core-js": "^2.6.5",
"material-design-icons-iconfont": "^5.0.1",
"multinet": "0.8.0",
"multinet": "0.10.0",
"vue": "^2.6.10",
"vue-gtag": "^1.2.1",
"vue-router": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions client/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ -e server.pid ]; then
exit 1
fi

FLASK_SERVE_PORT=5000 nohup yarn serve --port 8080 >server.out &
nohup yarn serve --port 8080 >server.out &
echo $! >server.pid

# Loop until the client is up.
Expand All @@ -15,7 +15,7 @@ count=0

echo -n "waiting for client to come up"
while [ ${started} = 0 ] && [ ${count} -lt 30 ]; do
headers=$(curl -s -I --max-time 0.5 http://localhost:8080/api/workspaces)
headers=$(curl -s -I --max-time 0.5 http://localhost:8080)
curl_status=$?

if [ ${curl_status} = 0 ]; then
Expand Down
7 changes: 2 additions & 5 deletions client/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { multinetApi } from 'multinet';
import { host } from '@/environment';

function getApiRoot() {
return `${window.location.origin}/api`;
}

const api = multinetApi(getApiRoot());
const api = multinetApi(`${host}/api`);

export default api;
3 changes: 1 addition & 2 deletions client/src/components/AboutDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
import Vue from 'vue';
import AExt from '@/components/AExt.vue';
declare const GIT_SHA: string;
import { gitSha as GIT_SHA } from '@/environment';
export default Vue.extend({
components: {
Expand Down
171 changes: 171 additions & 0 deletions client/src/components/DownloadDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<template>

<v-dialog
v-model="dialog"
width="400"
v-if="nonZeroSelection"
>
<template v-slot:activator="{ on: dialog }">
<v-tooltip left>
<template v-slot:activator="{ on: tooltip }">
<v-scroll-x-transition>
<v-btn
icon
small
text
@click="dialog.click"
v-on="tooltip"
>
<v-icon color="primary" size="22px">save_alt</v-icon>
</v-btn>
</v-scroll-x-transition>
</template>
<span>Download selected</span>
</v-tooltip>
</template>

<v-card class="pa-0">
<v-card-title
class="pa-4"
primary-title
>
Download the following {{ selection.length > 1 ? selection.length : '' }} {{downloadType}}{{plural}}?
</v-card-title>

<v-card-text class="pa-0">
<v-list
class="pa-0"
color="grey lighten-5"
dense
>
<template v-for="item in selection">
<v-divider />
<v-list-item :key="item">
<v-list-item-icon>
<v-icon
color="green accent-4"
size="18"
>
check
</v-icon>
</v-list-item-icon>
{{ item }}
</v-list-item>
</template>

</v-list>
</v-card-text>

<v-divider />
<v-progress-linear indeterminate :active="loading" />

<v-card-actions class="px-4 py-3">
<v-spacer />
<v-btn
depressed
color="primary"
@click="execute"
:disabled="disabled"
>
yes
</v-btn>

<v-btn
depressed
@click="dialog = false"
>
cancel
</v-btn>
</v-card-actions>

</v-card>

</v-dialog>

</template>

<script lang="ts">
import Vue, { PropType } from 'vue';
import api from '@/api';
export default Vue.extend({
props: {
selection: {
type: Array as PropType<string[]>,
required: true,
},
workspace: {
type: String as PropType<string>,
required: true,
},
downloadType: {
type: String as PropType<string>,
required: true,
},
},
data() {
return {
dialog: false,
disabled: false,
timeout: undefined as number | undefined,
loading: false,
};
},
computed: {
// This workaround is necessary because of https://github.com/vuejs/vue/issues/10455
plural(this: any) {
return this.selection.length > 1 ? 's' : '';
},
nonZeroSelection(): boolean {
return this.selection.length > 0;
},
downloadEnpoint() {
switch (this.downloadType) {
case 'table':
return api.downloadTable.bind(api);
break;
case 'network':
default:
return api.downloadGraph.bind(api);
break;
}
},
},
methods: {
async execute() {
const {
selection,
workspace,
} = this;
this.loading = true;
for (const name of selection) {
const { data, headers: {'content-type': contentType } } = await this.downloadEnpoint(workspace, name);
const blobData = data instanceof Object ? JSON.stringify(data, null, 2) : data;
const blob = new Blob([blobData], {type: contentType});
const extension = contentType.split('/')[1];
const filename = `${name}.${extension}`;
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = filename;
link.click();
URL.revokeObjectURL(link.href);
}
this.$emit('downloaded');
this.loading = false;
this.dialog = false;
},
},
});
</script>
9 changes: 7 additions & 2 deletions client/src/components/ItemPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@

<v-spacer />

<slot name="downloader"
:selection="selection"
:workspace="workspace"
>
</slot>
<slot name="deleter"
:selection="selection"
:workspace="workspace"
:selection="selection"
:workspace="workspace"
>
</slot>

Expand Down
3 changes: 3 additions & 0 deletions client/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const host: string = process.env.VUE_APP_MULTINET_HOST || 'http://localhost:5000';
export const gaTag: string = process.env.VUE_APP_GA_TAG || '';
export const gitSha: string = process.env.VUE_APP_GIT_SHA || '';
52 changes: 34 additions & 18 deletions client/src/views/WorkspaceDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,29 @@
:workspace="workspace"
route-type="graph"
icon="timeline"
>
<graph-dialog
:node-tables="nodeTables"
:edge-tables="edgeTables"
:workspace="workspace"
@success="update"
/>
<template v-slot:deleter="deleter">
<delete-graph-dialog
:selection="deleter.selection"
:workspace="deleter.workspace"
@deleted="update"
/>
</template>
>
<graph-dialog
:node-tables="nodeTables"
:edge-tables="edgeTables"
:workspace="workspace"
@success="update"
/>
<template v-slot:deleter="deleter">
<delete-graph-dialog
:selection="deleter.selection"
:workspace="deleter.workspace"
@deleted="update"
/>
</template>
<template v-slot:downloader="downloader">
<download-dialog
:selection="downloader.selection"
:workspace="downloader.workspace"
downloadType="network"
@downloaded="update"
/>
</template>
</item-panel>

</v-card>
</v-flex>
<v-flex
Expand All @@ -125,16 +132,23 @@
<table-dialog
:workspace="workspace"
@success="update"
/>
/>
<template v-slot:deleter="deleter">
<delete-table-dialog
:selection="deleter.selection"
:workspace="deleter.workspace"
@deleted="update"
/>
/>
</template>
<template v-slot:downloader="downloader">
<download-dialog
:selection="downloader.selection"
:workspace="downloader.workspace"
downloadType="table"
@downloaded="update"
/>
</template>
</item-panel>

</v-card>
</v-flex>
</v-layout>
Expand All @@ -151,6 +165,7 @@ import GraphDialog from '@/components/GraphDialog.vue';
import DeleteGraphDialog from '@/components/DeleteGraphDialog.vue';
import TableDialog from '@/components/TableDialog.vue';
import DeleteTableDialog from '@/components/DeleteTableDialog.vue';
import DownloadDialog from '@/components/DownloadDialog.vue';
export default Vue.extend({
name: 'WorkspaceDetail',
Expand All @@ -160,6 +175,7 @@ export default Vue.extend({
DeleteGraphDialog,
TableDialog,
DeleteTableDialog,
DownloadDialog,
},
props: ['workspace', 'title'],
data() {
Expand Down
7 changes: 3 additions & 4 deletions client/src/vuegtag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import Vue from 'vue';
import VueGtag from 'vue-gtag';

import router from '@/router';
import { gaTag } from '@/environment';

declare const GA_TAG: string;

if (GA_TAG) {
if (gaTag) {
Vue.use(VueGtag, {
config: {
id: GA_TAG,
id: gaTag,
},
}, router);
}

0 comments on commit 0f1554e

Please sign in to comment.