Skip to content
Snippets Groups Projects
FileManager.vue 3.18 KiB
Newer Older
  • Learn to ignore specific revisions
  • Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
      <b-container>
    
        <PageHeader :title="$t('filePlaylistManager.title')">
          <show-selector :callback="showHasSwitched" />
        </PageHeader>
    
        <template v-if="!loaded.shows">
          <div class="tw-text-center">
            {{ $t('loading') }}
          </div>
        </template>
    
        <template v-else-if="selectedShow">
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
          <jumbotron />
    
          <!-- All the UI for uploading and editing files is only shown if the user
    
                choose to edit files in the jumbotron above -->
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
          <div v-if="mode === 'files'">
            <files />
          </div>
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
          <!-- All the UI for creating and editing playlists is only shown if the user
    
                choose to edit playlists in the jumbotron above -->
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
          <div v-if="mode === 'playlists'">
            <playlists />
          </div>
        </template>
      </b-container>
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
    import { mapGetters } from 'vuex'
    import showSelector from '../components/ShowSelector.vue'
    import jumbotron from '../components/filemanager/Jumbotron.vue'
    import files from '../components/filemanager/Files.vue'
    import playlists from '../components/filemanager/Playlists.vue'
    
    import PageHeader from '@/components/PageHeader.vue'
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
    
    export default {
      components: {
    
        PageHeader,
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
        'show-selector': showSelector,
        jumbotron: jumbotron,
        files: files,
        playlists: playlists,
      },
    
      // the data this component will be handling: mostly flags and local versions
      // of the data fetched from the AuRa tank API
      data() {
        return {
          adminUrl: `${import.meta.env.VUE_APP_BASEURI_STEERING}/admin`,
    
          // for formatting the buttons - this way we could customize it later
          button: {
            files: 'info',
            playlists: 'outline-info',
          },
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
      },
    
      computed: {
        ...mapGetters({
          selectedShow: 'shows/selectedShow',
          mode: 'fileManagerMode',
        }),
    
        loaded() {
          return {
            shows: this.$store.state.shows.loaded.shows,
          }
        },
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
      },
    
      // Right after this component is set up, we want to fetch all available shows
      // from the AuRa tank module. This works quite similar to the ShowManager.
      // We also want to load the files and playlists as soon as the shows are
      // loaded.
      created() {
        this.$store.dispatch('shows/fetchShows', {
          callback: () => {
            if (!this.selectedShow) {
              return
            }
    
            this.$nextTick(() => {
              this.showHasSwitched()
            })
          },
        })
      },
    
      // Now for our hotchpotch of methods, mostly for fetching data from and
      // posting/updating data to the AuRa tank API
      methods: {
        // This switches the UI elements to reflect another show and fetches all
        // relevent data from the tank API.
        showHasSwitched() {
          this.$store.dispatch('files/fetchFiles', {
            slug: this.selectedShow.slug,
          })
          this.$store.dispatch('playlists/fetch', {
            slug: this.selectedShow.slug,
          })
        },
      },
    }
    
    Konrad Mohrfeldt's avatar
    Konrad Mohrfeldt committed
    div.filelistbox {
      border: 1px solid #e9ecef;
      border-radius: 0.3rem;
      padding: 1rem 2rem;
    }
    
    .stateNew {
      color: red;
      font-weight: bold;
    }
    
    .stateRunning {
      color: darkgreen;
    }
    
    .stateUndefined {
      color: orange;
      font-weight: bold;
    }
    
    .upDownArrows {
      font-size: 1.15rem;
    }
    
    .modalPlaylistRows {
      padding: 0.2rem 0;
    }