This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'graph-improvements' of github.com:multinet-app/multinet…
… into graph-improvements
- Loading branch information
Showing
15 changed files
with
1,417 additions
and
1,347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 || ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.