From 451cb369745bb93dd1a71d90bb690d59ddce97f8 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Thu, 9 Apr 2020 18:30:28 +0200 Subject: [PATCH] add config --- ffplayout/frontend/pages/configure.vue | 100 +++++++++++++++++++++++++ ffplayout/frontend/pages/index.vue | 4 +- ffplayout/frontend/store/config.js | 39 ++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 ffplayout/frontend/pages/configure.vue create mode 100644 ffplayout/frontend/store/config.js diff --git a/ffplayout/frontend/pages/configure.vue b/ffplayout/frontend/pages/configure.vue new file mode 100644 index 00000000..2c8c40ed --- /dev/null +++ b/ffplayout/frontend/pages/configure.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/ffplayout/frontend/pages/index.vue b/ffplayout/frontend/pages/index.vue index 58568803..f2d4d6c1 100644 --- a/ffplayout/frontend/pages/index.vue +++ b/ffplayout/frontend/pages/index.vue @@ -137,7 +137,9 @@ Media Logging - Configure + + Configure + Logout diff --git a/ffplayout/frontend/store/config.js b/ffplayout/frontend/store/config.js new file mode 100644 index 00000000..fdfe2bfa --- /dev/null +++ b/ffplayout/frontend/store/config.js @@ -0,0 +1,39 @@ +export const state = () => ({ + config: null +}) + +export const mutations = { + UPDATE_CONFIG (state, config) { + state.config = config + } +} + +export const actions = { + async getConfig ({ commit, state, rootState }) { + const response = await this.$axios.get('api/config/?config', { headers: { Authorization: 'Bearer ' + rootState.auth.jwtToken } }) + + if (response.data) { + // post_ffmpeg_param is normally a object, for the form we convert it to a string + response.data.out.post_ffmpeg_param = JSON.stringify(response.data.out.post_ffmpeg_param).replace('{', '').replace('}', '').replace(/":/g, ' ').replace(/","/g, ' ').replace(/"/g, '') + commit('UPDATE_CONFIG', response.data) + } + }, + + async setConfig ({ commit, state, rootState }, obj) { + const ffmpegParam = new Map() + const newObj = JSON.parse(JSON.stringify(obj)) + const params = obj.out.post_ffmpeg_param.split(' ') + + for (let i = 0; i < params.length; i++) { + if (i % 2) { + continue + } else { + ffmpegParam.set(params[i], (params[i + 1]) ? params[i + 1] : null) + } + } + + newObj.out.post_ffmpeg_param = Object.fromEntries(ffmpegParam) + const response = await this.$axios.post('api/config/', { body: { name: 'andi', des: 'welcome' } }) + console.log(response) + } +}