From 8bde46a080e7e4c1613e99d5335a0a814bde5af7 Mon Sep 17 00:00:00 2001 From: Jens Stigaard Date: Wed, 20 May 2020 22:01:35 +0200 Subject: [PATCH] Added input duration progress --- src/App.vue | 14 +++++--- src/components/SwitcherButton.vue | 59 +++++++++++++++++++++++++++++-- src/utility.ts | 9 +++++ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 src/utility.ts diff --git a/src/App.vue b/src/App.vue index a3020ba..a3797fe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,7 +16,7 @@ // Program row program-row(:inputs="switcherInputs" :total-number-of-inputs="inputs.length") // Transition progress line - v-progress-linear(:value="transitionProgress" height="3").mt-5.mb-3 + v-progress-linear(:value="transitionProgress" height="3").my-3 // Preview row preview-row(:inputs="switcherInputs" :total-number-of-inputs="inputs.length") @@ -38,7 +38,7 @@ import PreviewRow from './PreviewRow.vue' import ProgramRow from './ProgramRow.vue' import TransitionButtons from './TransitionButtons.vue' -const FETCH_XML_DATA_INTERVAL: number = 2000 // ms +const FETCH_XML_DATA_INTERVAL: number = 1500 // ms const TRANSITION_STEP: number = 100 // ms const LIMIT_NUMBER_OF_INPUTS: number = 8 @@ -102,7 +102,12 @@ export default class App extends Vue { const xmlContent = XmlApiDataParser.parse(xmlRawData) const inputs = Object.values( - XmlInputMapper.mapInputs(XmlInputMapper.extractInputsFromXML(xmlContent), ['title']) + XmlInputMapper.mapInputs(XmlInputMapper.extractInputsFromXML(xmlContent), [ + 'title', + 'state', + 'duration', + 'position' + ]) ) const overlayChannels = XmlOverlayChannels.extract(xmlContent) @@ -216,9 +221,8 @@ hr #connection-status text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5) - .rotated-header - /* Rotate from top left corner (not default) */ + // Rotate from top left corner (not default) transform-origin: 0 0 transform: rotate(90deg) // letter-spacing: 2px diff --git a/src/components/SwitcherButton.vue b/src/components/SwitcherButton.vue index 7b47386..f263da1 100644 --- a/src/components/SwitcherButton.vue +++ b/src/components/SwitcherButton.vue @@ -8,7 +8,7 @@ v-col.ma-1 v-long-press="500" @long-press-start="onLongPressStart" @long-press-stop="onLongPressStop" - ).px-0 + ).px-0.elevation-1 v-col v-badge( v-if="badgeLeft" @@ -28,7 +28,17 @@ v-col.ma-1 ) big {{ number }} div(v-else): big {{ number }} - div(style="font-size: 7pt") {{ input.title }} + div.switch-button-title-text {{ title }} + div + div(v-if="hasDuration").switch-button-title-text {{ elapsedText }} + div(v-else): p + + v-progress-linear( + v-if="hasDuration" + :value="position" + :height="progressBarHeight" + :color="progressBarColor" + ).mt-1 + + diff --git a/src/utility.ts b/src/utility.ts new file mode 100644 index 0000000..54fd816 --- /dev/null +++ b/src/utility.ts @@ -0,0 +1,9 @@ +// +export function durationNice(duration: number): string { + const minutes = Math.floor(duration / 60) + + const sec = duration % 60 + const seconds = `${sec < 10 ? '0' : ''}${sec}` + + return `${minutes}:${seconds}` +}