From aad79bc79c37595e323e3f7d22d1a4f6e985e865 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Fri, 24 Apr 2020 13:55:51 +0200 Subject: [PATCH] add plugins --- ffplayout/frontend/nuxt.config.js | 4 ++- ffplayout/frontend/plugins/draggable.js | 5 ++++ ffplayout/frontend/plugins/helpers.js | 34 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ffplayout/frontend/plugins/draggable.js create mode 100644 ffplayout/frontend/plugins/helpers.js diff --git a/ffplayout/frontend/nuxt.config.js b/ffplayout/frontend/nuxt.config.js index b5ce293c..e4e7e3fa 100644 --- a/ffplayout/frontend/nuxt.config.js +++ b/ffplayout/frontend/nuxt.config.js @@ -47,7 +47,9 @@ export default { { src: '~plugins/video.js', ssr: false }, { src: '~plugins/scrollbar.js', ssr: false }, { src: '~plugins/splitpanes.js', ssr: false }, - { src: '~plugins/loading.js', ssr: false } + { src: '~plugins/loading.js', ssr: false }, + { src: '~/plugins/helpers.js' }, + { src: '~plugins/draggable.js', ssr: false } ], /* ** Nuxt.js dev-modules diff --git a/ffplayout/frontend/plugins/draggable.js b/ffplayout/frontend/plugins/draggable.js new file mode 100644 index 00000000..6e40b46b --- /dev/null +++ b/ffplayout/frontend/plugins/draggable.js @@ -0,0 +1,5 @@ +import Vue from 'vue' +import draggable from 'vuedraggable' + +Vue.use(draggable) +Vue.component('draggable', draggable) diff --git a/ffplayout/frontend/plugins/helpers.js b/ffplayout/frontend/plugins/helpers.js new file mode 100644 index 00000000..bd9ea9ee --- /dev/null +++ b/ffplayout/frontend/plugins/helpers.js @@ -0,0 +1,34 @@ +export default ({ app }, inject) => { + inject('processPlaylist', (day, list) => { + const [h, m, s] = day.split(':') + let begin = parseFloat(h) * 3600 + parseFloat(m) * 60 + parseFloat(s) + + for (const item of list) { + item.begin = begin + + if (!item.category) { + item.category = '' + } + + begin += (item.out - item.in) + } + return list + }) + // convert time (00:00:00) string to seconds + inject('timeToSeconds', (time) => { + const t = time.split(':') + return parseInt(t[0]) * 3600 + parseInt(t[1]) * 60 + parseInt(t[2]) + }) + + inject('secToHMS', (sec) => { + let hours = Math.floor(sec / 3600) + sec %= 3600 + let minutes = Math.floor(sec / 60) + let seconds = sec % 60 + + minutes = String(minutes).padStart(2, '0') + hours = String(hours).padStart(2, '0') + seconds = String(parseInt(seconds)).padStart(2, '0') + return hours + ':' + minutes + ':' + seconds + }) +}