From 8511c4cdff0ace8bab6bd38c30b07cf7ebbe2340 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 4 Jul 2022 18:00:56 +0200 Subject: [PATCH] change api routes and functions to support new API --- .eslintrc.js | 48 ++++++++++++++++++------------------ pages/logging.vue | 2 +- pages/media.vue | 39 +++++++++++++++++------------ pages/player.vue | 30 +++++++++++----------- store/config.js | 4 +-- store/playlist.js | 2 +- test.html | 63 ----------------------------------------------- 7 files changed, 66 insertions(+), 122 deletions(-) delete mode 100644 test.html diff --git a/.eslintrc.js b/.eslintrc.js index 5851bea9..6c00ac14 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,27 +1,27 @@ module.exports = { - root: true, - env: { - browser: true, - node: true - }, - parserOptions: { - parser: '@babel/eslint-parser', - requireConfigFile: false, - babelOptions: { - presets: ["@babel/preset-react"] + root: true, + env: { + browser: true, + node: true + }, + parserOptions: { + parser: '@babel/eslint-parser', + requireConfigFile: false, + babelOptions: { + presets: ['@babel/preset-react'] + } + }, + extends: [ + '@nuxtjs', + 'plugin:nuxt/recommended' + ], + // add your custom rules here + rules: { + 'vue/html-indent': ['error', 4], + 'vue/html-closing-bracket-newline': 'off', + indent: [2, 4], + 'no-tabs': 'off', + 'no-console': 0, + camelcase: ['error', { properties: 'never' }] } - }, - extends: [ - '@nuxtjs', - 'plugin:nuxt/recommended' - ], - // add your custom rules here - rules: { - 'vue/html-indent': ['error', 4], - 'vue/html-closing-bracket-newline': 'off', - 'indent': [2, 4], - 'no-tabs': 'off', - "no-console": 0, - "camelcase": ["error", {properties: "never"}] - } } diff --git a/pages/logging.vue b/pages/logging.vue index d2ab9b36..7b9d6e60 100644 --- a/pages/logging.vue +++ b/pages/logging.vue @@ -88,7 +88,7 @@ export default { } const response = await this.$axios.get( - `api/log/${this.$store.state.config.configGui[this.$store.state.config.configID].id}/${date}`) + `api/log/${this.$store.state.config.configGui[this.$store.state.config.configID].id}?date=${date}`) if (response.data) { this.currentLog = response.data diff --git a/pages/media.vue b/pages/media.vue index 6ae53b58..ce017bef 100644 --- a/pages/media.vue +++ b/pages/media.vue @@ -71,7 +71,7 @@ @@ -79,10 +79,10 @@ - {{ file }} + {{ file.name }} - + @@ -90,12 +90,12 @@ {{ file.duration | toMin }} - + - + @@ -309,7 +309,11 @@ export default { }, mounted () { - this.extensions = [...this.configPlayout.storage.extensions, ...this.configGui[this.configID].extra_extensions].join(',') + const exts = [...this.configPlayout.storage.extensions, ...this.configGui[this.configID].extra_extensions].map((ext) => { + return `.${ext}` + }) + + this.extensions = exts.join(',') this.getPath(this.extensions, '') }, @@ -358,7 +362,7 @@ export default { async onSubmitCreateFolder (evt) { evt.preventDefault() - const path = this.crumbs.map(e => e.text).join('/') + '/' + this.folderName + const path = (this.crumbs[this.crumbs.length - 1].path + '/' + this.folderName).replace(/\/[/]+/, '/') await this.$axios.post( `api/file/${this.configGui[this.configID].id}/create-folder/`, { source: path } @@ -396,12 +400,13 @@ export default { this.currentProgress = progress } - const channel = this.configGui[this.configID].id - for (const [i, file] of this.inputFiles.entries()) { this.uploadTask = file.name this.currentNumber = i + 1 + const formData = new FormData() + formData.append(file.name, file) + const config = { onUploadProgress: uploadProgress(file.name), cancelToken: this.cancelTokenSource.token, @@ -409,8 +414,8 @@ export default { } await this.$axios.put( - `api/player/media/upload/${encodeURIComponent(file.name)}?path=${encodeURIComponent(this.crumbs.map(e => e.text).join('/'))}&channel=${channel}`, - file, + `api/file/${this.configGui[this.configID].id}/upload/?path=${encodeURIComponent(this.crumbs[this.crumbs.length - 1].path)}`, + formData, config ) .then((res) => { @@ -503,9 +508,9 @@ export default { this.deleteSource = src if (type === 'File') { - this.previewName = src.split('/').slice(-1)[0] + this.previewName = src.split('/').slice(-1)[0].replace('//', '/') } else { - this.previewName = src + this.previewName = src.replace('//', '/') } this.deleteType = type @@ -520,12 +525,14 @@ export default { file = this.deleteSource.split('/').slice(-1)[0] pathName = this.deleteSource.substring(0, this.deleteSource.lastIndexOf('/') + 1) } else { - file = null + file = '' pathName = this.deleteSource } - await this.$axios.delete( - `api/player/media/op/?file=${encodeURIComponent(file)}&path=${encodeURIComponent(pathName)}&channel=${this.configGui[this.configID].id}`) + const source = `${pathName}/${file}`.replace('//', '/') + + await this.$axios.post( + `api/file/${this.configGui[this.configID].id}/remove/`, { source }) .catch(err => console.log(err)) this.$root.$emit('bv::hide::modal', 'delete-modal') diff --git a/pages/player.vue b/pages/player.vue index eb1d834a..ed63b5f2 100644 --- a/pages/player.vue +++ b/pages/player.vue @@ -6,7 +6,7 @@