FileManager.vue 38.8 KB
Newer Older
1001
1002
      this.currentShow = index
      this.currentShowID = this.shows[this.currentShow].id
1003
      this.fetchShow(this.shows[this.currentShow].slug)
1004
    },
1005
1006
1007

    // This function is used to visually switch between the files and playlists
    // editing mode.
1008
1009
1010
1011
    switchMode: function (mode) {
      if (this.mode !== mode) {
        this.mode = mode
        for (var b in this.button) {
1012
1013
          if (b === mode) { this.button[b] = 'info' }
          else { this.button[b] = 'outline-info' }
1014
1015
1016
        }
      }
    },
1017
1018
1019
1020
1021

    // This function fetches all running imports for a given show. It should
    // be called periodically to reflect the upload/import progress. When no
    // more active imports are available the corresponding updateInterval
    // should be cleared again.
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
    fetchImports: function (slug){
      var uri = process.env.VUE_APP_API_TANK + 'shows/' + slug + '/imports'
      axios.get(uri, {
        withCredentials: true,
        headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
      }).then(response => {
        // if all imports are done, we will receive an empty result set and stop
        // polling the server again. now we can also refetch all file statuses.
        if (response.data.results === null) {
          clearInterval(this.uploadInterval)
          this.uploadInterval = null
          this.fetchShow(slug)
        } else {
          for (var i in response.data.results) {
            var f = this.getFileById(response.data.results[i].id)
            if (f) {
              f.source.import.progress = {
                progress: response.data.results[i].progress.progress,
                step: response.data.results[i].progress.step
              }
            }
            var p = '[import]'
            p += ' id: ' + response.data.results[i].id
            p += ', progress: ' + response.data.results[i].progress.progress
            p += ', step: ' + response.data.results[i].progress.step
            console.log(p)
            this.$refs.filesTable.refresh()
          }
        }
      }).catch(error => {
        console.log(error)
        alert('There was an error fetching current imports. See console for details.')
      })
    },
1056
1057

    // Just a wrapper to fetch both, files and playlists information.
1058
1059
1060
1061
    fetchShow: function (slug) {
      this.fetchFiles(slug)
      this.fetchPlaylists(slug)
    },
1062
1063

    // Fetch all files for a given show from the AuRa tank API
1064
    fetchFiles: function (slug) {
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
      this.loaded.files = false
      var uri = process.env.VUE_APP_API_TANK + 'shows/' + slug + '/files'
      axios.get(uri, {
        withCredentials: true,
        headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
      }).then(response => {
        // we don't have to check separately, if there are files, because tank
        // always provides an empty array if there are no files (or even if there is no corresponding show)
        this.files = response.data.results
        this.loaded.files = true
      }).catch(error => {
        alert('There was an error fetching files from tank: ' + error)
      })
1078
    },
1079
1080

    // Fetch all playlists for a given show from the AuRa tank API
1081
1082
1083
    fetchPlaylists: function (slug) {
      this.loaded.playlists = false
      var uri = process.env.VUE_APP_API_TANK + 'shows/' + slug + '/playlists'
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
      axios.get(uri, {
        withCredentials: true,
        headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
      }).then(response => {
        // we don't have to check separately, if there are playlists, because tank
        // always provides an empty array if there are no playlists (or even if there is no corresponding show)
        this.playlists = response.data.results
        this.loaded.playlists = true
      }).catch(error => {
        alert('There was an error fetching playlists from tank: ' + error)
      })
1095
1096
1097
    }
  }
}
1098
1099
1100
</script>

<style>
1101
1102
1103
1104
1105
div.filelistbox {
  border: 1px solid #e9ecef;
  border-radius: 0.3rem;
  padding: 1rem 2rem;
}
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
.stateNew {
  color: red;
  font-weight: bold;
}
.stateRunning {
  color: darkgreen;
}
.stateUndefined {
  color: orange;
  font-weight: bold;
}
1117
1118
1119
1120
1121
1122
.upDownArrows {
  font-size: 1.15rem;
}
.modalPlaylistRows {
  padding: 0.2rem 0;
}
1123
</style>
For faster browsing, not all history is shown. View entire blame