forked from simwrapper/simwrapper
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dashboards learned "video" panel type (simwrapper#107)
* first attemp at video block * implemented logic to resolve video urls * fix video template * finished video tag Co-authored-by: Billy Charlton <charlton@vsp.tu-berlin.de>
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template lang="pug"> | ||
|
||
figure(class="video_container") | ||
|
||
video(:controls="controls" :loop='loop' :allowfullscreen='allowfullscreen') | ||
|
||
source(v-for="(src, type) in sources" :src="src" :type="type" :key="type") | ||
|
||
p(v-for="(src, type) in sources" :key="type") Video tag not supported. Download the video | ||
a(:href="src" target="_blank") here | ||
|
||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Component, Watch, Prop } from 'vue-property-decorator' | ||
import { FileSystemConfig } from '@/Globals' | ||
import HTTPFileSystem from '@/js/HTTPFileSystem' | ||
@Component({}) | ||
export default class VueComponent extends Vue { | ||
@Prop({ required: true }) fileSystemConfig!: FileSystemConfig | ||
@Prop({ required: true }) subfolder!: string | ||
@Prop({ required: true }) files!: string[] | ||
@Prop({ required: true }) config!: any | ||
private controls: string | null = null | ||
private loop: string | null = null | ||
private allowfullscreen: string | null = null | ||
private sources: { [key: string]: string } = {} | ||
// true for absolute URLs | ||
private r: RegExp = new RegExp('^(?:[a-z]+:)?//', 'i') | ||
private async mounted() { | ||
this.controls = this.config.controls | ||
this.loop = this.config.loop | ||
this.allowfullscreen = this.config.allowfullscreen | ||
this.sources = {} | ||
const fileApi = new HTTPFileSystem(this.fileSystemConfig) | ||
// Resolve relative URLs | ||
for (const k in this.config.sources) { | ||
var url = this.config.sources[k] | ||
if (!this.r.test(url)) url = fileApi.cleanURL(`${this.subfolder}/${url}`) | ||
this.sources[k] = url | ||
} | ||
this.$emit('isLoaded') | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import '@/styles.scss'; | ||
.dash-element { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
@media only screen and (max-width: 640px) { | ||
} | ||
</style> |