Skip to content
Snippets Groups Projects
UploadModal.vue 5.31 KiB
Newer Older
  • Learn to ignore specific revisions
  • Georg Krause's avatar
    Georg Krause committed
      <modal
        class="small"
        :show="$store.state.channels.showUploadModal"
        @update:show="update"
      >
    
        <h4 class="header">
    
    Georg Krause's avatar
    Georg Krause committed
          <translate
            v-if="step === 1"
            key="1"
            translate-context="Popup/Channels/Title/Verb"
          >
            Publish audio
          </translate>
          <translate
            v-else-if="step === 2"
            key="2"
            translate-context="Popup/Channels/Title"
          >
            Files to upload
          </translate>
          <translate
            v-else-if="step === 3"
            key="3"
            translate-context="Popup/Channels/Title"
          >
            Upload details
          </translate>
          <translate
            v-else-if="step === 4"
            key="4"
            translate-context="Popup/Channels/Title"
          >
            Processing uploads
          </translate>
    
        <div class="scrolling content">
          <channel-upload-form
            ref="uploadForm"
    
    Georg Krause's avatar
    Georg Krause committed
            :channel="$store.state.channels.uploadModalConfig.channel"
    
            @step="step = $event"
            @loading="isLoading = $event"
            @published="$store.commit('channels/publish', $event)"
            @status="statusData = $event"
            @submittable="submittable = $event"
    
    Georg Krause's avatar
    Georg Krause committed
          />
    
        </div>
        <div class="actions">
          <div class="left floated text left align">
            <template v-if="statusData && step >= 2">
              {{ statusInfo.join(' · ') }}
            </template>
    
    Georg Krause's avatar
    Georg Krause committed
            <div class="ui very small hidden divider" />
    
            <template v-if="statusData && statusData.quotaStatus">
    
    Georg Krause's avatar
    Georg Krause committed
              <translate translate-context="Content/Library/Paragraph">
                Remaining storage space:
              </translate>
    
              {{ (statusData.quotaStatus.remaining * 1000 * 1000) - statusData.uploadedSize | humanSize }}
            </template>
          </div>
    
    Georg Krause's avatar
    Georg Krause committed
          <div class="ui hidden clearing divider mobile-only" />
          <button
            v-if="step === 1"
            class="ui basic cancel button"
          >
            <translate translate-context="*/*/Button.Label/Verb">
              Cancel
            </translate>
    
    Georg Krause's avatar
    Georg Krause committed
          <button
            v-else-if="step < 3"
            class="ui basic button"
            @click.stop.prevent="$refs.uploadForm.step -= 1"
          >
            <translate translate-context="*/*/Button.Label/Verb">
              Previous step
            </translate>
          </button>
          <button
            v-else-if="step === 3"
            class="ui basic button"
            @click.stop.prevent="$refs.uploadForm.step -= 1"
          >
            <translate translate-context="*/*/Button.Label/Verb">
              Update
            </translate>
          </button>
          <button
            v-if="step === 1"
            class="ui primary button"
            @click.stop.prevent="$refs.uploadForm.step += 1"
          >
            <translate translate-context="*/*/Button.Label">
              Next step
            </translate>
          </button>
          <div
            v-if="step === 2"
            class="ui primary buttons"
          >
    
            <button
              :class="['ui', 'primary button', {loading: isLoading}]"
              type="submit"
              :disabled="!statusData || !statusData.canSubmit"
    
    Georg Krause's avatar
    Georg Krause committed
              @click.prevent.stop="$refs.uploadForm.publish"
            >
              <translate translate-context="*/Channels/Button.Label">
                Publish
              </translate>
    
    Georg Krause's avatar
    Georg Krause committed
            <button
              ref="dropdown"
              v-dropdown
              class="ui floating dropdown icon button"
              :disabled="!statusData || !statusData.canSubmit"
            >
              <i class="dropdown icon" />
    
              <div class="menu">
                <div
                  role="button"
    
    Georg Krause's avatar
    Georg Krause committed
                  class="basic item"
    
                  @click="update(false)"
    
    Georg Krause's avatar
    Georg Krause committed
                >
                  <translate translate-context="Content/*/Button.Label/Verb">
                    Finish later
                  </translate>
    
    Georg Krause's avatar
    Georg Krause committed
          <button
            v-if="step === 4"
            class="ui basic cancel button"
            @click="update(false)"
          >
            <translate translate-context="*/*/Button.Label/Verb">
              Close
            </translate>
          </button>
    
    Georg Krause's avatar
    Georg Krause committed
    import Modal from '@/components/semantic/Modal.vue'
    import ChannelUploadForm from '@/components/channels/UploadForm.vue'
    
    Georg Krause's avatar
    Georg Krause committed
    import { humanSize } from '@/filters'
    
    
    export default {
      components: {
        Modal,
        ChannelUploadForm
      },
      data () {
        return {
          step: 1,
          isLoading: false,
          submittable: true,
    
    Georg Krause's avatar
    Georg Krause committed
          statusData: null
    
        }
      },
      computed: {
        labels () {
          return {}
        },
        statusInfo () {
          if (!this.statusData) {
            return []
          }
    
    Georg Krause's avatar
    Georg Krause committed
          const info = []
    
          if (this.statusData.totalSize) {
            info.push(humanSize(this.statusData.totalSize))
          }
          if (this.statusData.totalFiles) {
    
    Georg Krause's avatar
    Georg Krause committed
            const msg = this.$npgettext('*/*/*', '%{ count } file', '%{ count } files', this.statusData.totalFiles)
    
    Georg Krause's avatar
    Georg Krause committed
              this.$gettextInterpolate(msg, { count: this.statusData.totalFiles })
    
            )
          }
          if (this.statusData.progress) {
            info.push(`${this.statusData.progress}%`)
          }
          if (this.statusData.speed) {
            info.push(`${humanSize(this.statusData.speed)}/s`)
          }
          return info
        }
      },
      watch: {
        '$store.state.route.path' () {
    
    Georg Krause's avatar
    Georg Krause committed
          this.$store.commit('channels/showUploadModal', { show: false })
        }
      },
      methods: {
        update (v) {
          this.$store.commit('channels/showUploadModal', { show: v })
        }