funkwhale/front/src/components/channels/UploadModal.vue

156 wiersze
4.6 KiB
Vue
Czysty Zwykły widok Historia

2022-06-30 22:07:54 +00:00
<script setup lang="ts">
2022-07-20 18:49:11 +00:00
import SemanticModal from '~/components/semantic/Modal.vue'
2022-06-30 22:07:54 +00:00
import ChannelUploadForm from '~/components/channels/UploadForm.vue'
import { humanSize } from '~/utils/filters'
import { useRouter } from 'vue-router'
import { useStore } from '~/store'
import { ref, computed } from 'vue'
2022-09-08 14:32:45 +00:00
import { useI18n } from 'vue-i18n'
2022-06-30 22:07:54 +00:00
const store = useStore()
const router = useRouter()
router.beforeEach(() => store.commit('channels/showUploadModal', { show: false }))
const update = (value: boolean) => store.commit('channels/showUploadModal', { show: value })
2022-09-08 14:32:45 +00:00
const { t } = useI18n()
2022-06-30 22:07:54 +00:00
2022-07-04 22:52:53 +00:00
const uploadForm = ref()
2022-06-30 22:07:54 +00:00
const statusData = ref()
const statusInfo = computed(() => {
if (!statusData.value) {
return []
}
const info = []
if (statusData.value.totalSize) {
info.push(humanSize(statusData.value.totalSize))
}
if (statusData.value.totalFiles) {
2022-11-27 22:45:12 +00:00
info.push(t('components.channels.UploadModal.meta.files', statusData.value.totalFiles))
2022-06-30 22:07:54 +00:00
}
if (statusData.value.progress) {
info.push(`${statusData.value.progress}%`)
}
if (statusData.value.speed) {
info.push(`${humanSize(statusData.value.speed)}/s`)
}
return info
})
const step = ref(1)
const isLoading = ref(false)
</script>
<template>
2022-07-20 18:49:11 +00:00
<semantic-modal
2022-05-01 11:45:07 +00:00
v-model:show="$store.state.channels.showUploadModal"
2021-12-06 10:35:20 +00:00
class="small"
>
<h4 class="header">
2022-11-26 23:16:46 +00:00
<span v-if="step === 1">
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.header.publish') }}
2022-09-15 23:01:21 +00:00
</span>
2022-11-26 23:16:46 +00:00
<span v-else-if="step === 2">
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.header.uploadFiles') }}
2022-09-15 23:01:21 +00:00
</span>
2022-11-26 23:16:46 +00:00
<span v-else-if="step === 3">
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.header.uploadDetails') }}
2022-09-15 23:01:21 +00:00
</span>
2022-11-26 23:16:46 +00:00
<span v-else-if="step === 4">
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.header.processing') }}
2022-09-15 23:01:21 +00:00
</span>
</h4>
<div class="scrolling content">
<channel-upload-form
ref="uploadForm"
2022-07-31 23:42:59 +00:00
:channel="$store.state.channels.uploadModalConfig.channel ?? null"
@step="step = $event"
@loading="isLoading = $event"
@status="statusData = $event"
2021-12-06 10:35:20 +00:00
/>
</div>
<div class="actions">
<div class="left floated text left align">
<template v-if="statusData && step >= 2">
{{ statusInfo.join(' · ') }}
</template>
2021-12-06 10:35:20 +00:00
<div class="ui very small hidden divider" />
<template v-if="statusData && statusData.quotaStatus">
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.meta.quota', humanSize((statusData.quotaStatus.remaining - statusData.uploadedSize) * 1000 * 1000)) }}
</template>
</div>
2021-12-06 10:35:20 +00:00
<div class="ui hidden clearing divider mobile-only" />
<button
v-if="step === 1"
class="ui basic cancel button"
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.cancel') }}
</button>
2021-12-06 10:35:20 +00:00
<button
v-else-if="step < 3"
class="ui basic button"
2022-07-04 22:52:53 +00:00
@click.stop.prevent="uploadForm.step -= 1"
2021-12-06 10:35:20 +00:00
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.previous') }}
2021-12-06 10:35:20 +00:00
</button>
<button
v-else-if="step === 3"
class="ui basic button"
2022-07-04 22:52:53 +00:00
@click.stop.prevent="uploadForm.step -= 1"
2021-12-06 10:35:20 +00:00
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.update') }}
2021-12-06 10:35:20 +00:00
</button>
<button
v-if="step === 1"
class="ui primary button"
2022-07-04 22:52:53 +00:00
@click.stop.prevent="uploadForm.step += 1"
2021-12-06 10:35:20 +00:00
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.next') }}
2021-12-06 10:35:20 +00:00
</button>
<div
v-if="step === 2"
class="ui primary buttons"
>
<button
:class="['ui', 'primary button', {loading: isLoading}]"
type="submit"
2022-06-30 22:07:54 +00:00
:disabled="!statusData?.canSubmit || undefined"
2022-07-04 22:52:53 +00:00
@click.prevent.stop="uploadForm.publish"
2021-12-06 10:35:20 +00:00
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.publish') }}
</button>
2021-12-06 10:35:20 +00:00
<button
ref="dropdown"
v-dropdown
class="ui floating dropdown icon button"
2022-06-30 22:07:54 +00:00
:disabled="!statusData?.canSubmit || undefined"
2021-12-06 10:35:20 +00:00
>
<i class="dropdown icon" />
<div class="menu">
<div
role="button"
2021-12-06 10:35:20 +00:00
class="basic item"
@click="update(false)"
2021-12-06 10:35:20 +00:00
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.finishLater') }}
</div>
</div>
</button>
</div>
2021-12-06 10:35:20 +00:00
<button
v-if="step === 4"
class="ui basic cancel button"
@click="update(false)"
>
2022-09-22 23:26:59 +00:00
{{ $t('components.channels.UploadModal.button.close') }}
2021-12-06 10:35:20 +00:00
</button>
</div>
2022-07-20 18:49:11 +00:00
</semantic-modal>
</template>