Browse Source

Remove download dialog from dataset page

pull/1719/head
Hironsan 2 years ago
parent
commit
451b6f2473
2 changed files with 1 additions and 130 deletions
  1. 121
      frontend/components/example/FormDownload.vue
  2. 10
      frontend/pages/projects/_id/dataset/index.vue

121
frontend/components/example/FormDownload.vue

@ -1,121 +0,0 @@
<template>
<base-card
:disabled="!valid"
title="Export Data"
agree-text="Export"
cancel-text="Cancel"
@agree="downloadRequest"
@cancel="cancel"
>
<template #content>
<v-overlay :value="isProcessing">
<v-progress-circular
indeterminate
size="64"
/>
</v-overlay>
<v-form
ref="form"
v-model="valid"
>
<h2>{{ $t('dataset.importDataMessage1') }}</h2>
<v-radio-group
ref="format"
v-model="selectedFormat"
:rules="fileFormatRules($t('rules.fileFormatRules'))"
>
<v-radio
v-for="(format, i) in formats"
:key="i"
:label="format.name"
:value="format"
/>
</v-radio-group>
<v-sheet
v-if="selectedFormat"
:dark="!$vuetify.theme.dark"
:light="$vuetify.theme.dark"
class="mb-5 pa-5"
>
<pre>{{ selectedFormat.example.trim() }}</pre>
</v-sheet>
<h2>{{ $t('dataset.exportDataMessage2') }}</h2>
<v-checkbox
v-model="exportApproved"
label="Export only approved documents"
hide-details
/>
</v-form>
</template>
</base-card>
</template>
<script lang="ts">
import Vue from 'vue'
import BaseCard from '@/components/utils/BaseCard.vue'
import { fileFormatRules } from '@/rules/index'
import { FormatDTO } from '~/services/application/download/formatData'
export default Vue.extend({
components: {
BaseCard
},
data() {
return {
file: null,
fileFormatRules,
exportApproved: false,
selectedFormat: null as any,
formats: [] as FormatDTO[],
taskId: '',
polling: null,
valid: false,
isProcessing: false,
}
},
computed: {
projectId() {
return this.$route.params.id
}
},
async created() {
this.formats = await this.$services.downloadFormat.list(this.projectId)
},
beforeDestroy() {
// @ts-ignore
clearInterval(this.polling)
},
methods: {
cancel() {
(this.$refs.format as HTMLFormElement).reset()
this.taskId = ''
this.exportApproved = false
this.selectedFormat = null
this.isProcessing = false
this.$emit('cancel')
},
async downloadRequest() {
this.isProcessing = true
this.taskId = await this.$services.download.request(this.projectId, this.selectedFormat.name, this.exportApproved)
this.pollData()
},
pollData() {
// @ts-ignore
this.polling = setInterval(async() => {
if (this.taskId) {
const res = await this.$services.taskStatus.get(this.taskId)
if (res.ready) {
this.$services.download.download(this.projectId, this.taskId)
this.cancel()
}
}
}, 1000)
},
}
})
</script>

10
frontend/pages/projects/_id/dataset/index.vue

@ -3,7 +3,7 @@
<v-card-title v-if="isProjectAdmin">
<action-menu
@upload="$router.push('dataset/import')"
@download="dialogDownload=true"
@download="$router.push('dataset/export')"
/>
<v-btn
class="text-capitalize ms-2"
@ -36,11 +36,6 @@
@remove="removeAll"
/>
</v-dialog>
<v-dialog v-model="dialogDownload">
<form-download
@cancel="dialogDownload=false"
/>
</v-dialog>
</v-card-title>
<image-list
v-if="isImageTask"
@ -79,7 +74,6 @@ import _ from 'lodash'
import DocumentList from '@/components/example/DocumentList.vue'
import FormDelete from '@/components/example/FormDelete.vue'
import FormDeleteBulk from '@/components/example/FormDeleteBulk.vue'
import FormDownload from '@/components/example/FormDownload.vue'
import ImageList from '~/components/example/ImageList.vue'
import AudioList from '~/components/example/AudioList.vue'
import { ExampleListDTO, ExampleDTO } from '~/services/application/example/exampleData'
@ -95,7 +89,6 @@ export default Vue.extend({
ImageList,
FormDelete,
FormDeleteBulk,
FormDownload,
},
layout: 'project',
@ -109,7 +102,6 @@ export default Vue.extend({
return {
dialogDelete: false,
dialogDeleteAll: false,
dialogDownload: false,
project: {} as ProjectDTO,
item: {} as ExampleListDTO,
selected: [] as ExampleDTO[],

Loading…
Cancel
Save