possibility to preview live/html sources

This commit is contained in:
jb-alvarado 2023-12-07 22:00:05 +01:00
parent fdba746ea3
commit 5102ff8780
6 changed files with 218 additions and 627 deletions

View File

@ -94,6 +94,7 @@ export const stringFormatter = () => {
}
function mediaType(path: string) {
const liveType = ['m3u8']
const videoType = [
'avi',
'flv',
@ -131,7 +132,9 @@ export const stringFormatter = () => {
const ext = path.split('.').pop()
if (ext) {
if (videoType.includes(ext)) {
if (liveType.includes(ext)) {
return 'live'
} else if (videoType.includes(ext)) {
return 'video'
} else if (audioType.includes(ext)) {
return 'audio'

View File

@ -9,6 +9,8 @@ export default defineNuxtConfig({
devProxy: {
'/api': { target: 'http://127.0.0.1:8787/api' },
'/auth': { target: 'http://127.0.0.1:8787/auth' },
'/live': { target: 'http://127.0.0.1:8787/live' },
'/file': { target: 'http://127.0.0.1:8787/file' },
},
},

777
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "ffplayout-frontend",
"version": "0.6.2",
"version": "0.6.3",
"description": "Web GUI for ffplayout",
"author": "Jonathan Baecker",
"private": true,
@ -16,7 +16,7 @@
"@nuxt/types": "^2.17.2",
"@pinia/nuxt": "^0.5.1",
"@popperjs/core": "^2.11.8",
"@vueuse/core": "^10.6.1",
"@vueuse/core": "^10.7.0",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.2",
"cookie-universal-nuxt": "^2.2.2",

View File

@ -13,10 +13,7 @@
:active="index === mediaStore.crumbs.length - 1"
@click="getPath(crumb.path)"
>
<a
v-if="mediaStore.crumbs.length > 1 && mediaStore.crumbs.length - 1 > index"
href="#"
>
<a v-if="mediaStore.crumbs.length > 1 && mediaStore.crumbs.length - 1 > index" href="#">
{{ crumb.text }}
</a>
<span v-else>{{ crumb.text }}</span>
@ -70,7 +67,8 @@
data-bs-toggle="modal"
data-bs-target="#deleteModal"
@click="
deleteName = `/${mediaStore.folderTree.source}/${folder.name}`.replace(
deleteName =
`/${mediaStore.folderTree.source}/${folder.name}`.replace(
/\/[/]+/g,
'/'
)
@ -272,7 +270,7 @@
type="button"
class="btn btn-primary"
title="Create Folder"
data-tooltip=tooltip
data-tooltip="tooltip"
data-bs-toggle="modal"
data-bs-target="#folderModal"
>
@ -282,7 +280,7 @@
type="button"
class="btn btn-primary"
title="Upload File"
data-tooltip=tooltip
data-tooltip="tooltip"
data-bs-toggle="modal"
data-bs-target="#uploadModal"
>
@ -446,10 +444,7 @@ onMounted(async () => {
extra_extensions = extra_extensions.split(',')
}
const exts = [
...config_extensions,
...extra_extensions,
].map((ext) => {
const exts = [...config_extensions, ...extra_extensions].map((ext) => {
return `.${ext}`
})
@ -482,10 +477,18 @@ function setPreviewData(path: string) {
}
previewName.value = fullPath.split('/').slice(-1)[0]
previewUrl.value = encodeURIComponent(`/file/${configStore.configGui[configStore.configID].id}${fullPath}`).replace(/%2F/g, '/')
previewUrl.value = encodeURIComponent(`/file/${configStore.configGui[configStore.configID].id}${fullPath}`).replace(
/%2F/g,
'/'
)
const ext = previewName.value.split('.').slice(-1)[0].toLowerCase()
const fileType = (mediaType(previewName.value) === 'audio') ? `audio/${ext}` : `video/${ext}`
const fileType =
mediaType(previewName.value) === 'audio'
? `audio/${ext}`
: mediaType(previewName.value) === 'live'
? 'application/x-mpegURL'
: `video/${ext}`
if (configStore.configPlayout.storage.extensions.includes(`${ext}`)) {
isVideo.value = true
@ -634,7 +637,7 @@ function upload(file: any): Promise<null | undefined> {
formData.append(file.name, file)
xhr.value = new XMLHttpRequest()
return new Promise(resolve => {
return new Promise((resolve) => {
xhr.value.open(
'PUT',
`/api/file/${configStore.configGui[configStore.configID].id}/upload/?path=${encodeURIComponent(
@ -662,7 +665,7 @@ function upload(file: any): Promise<null | undefined> {
}
xhr.value.send(formData)
});
})
}
async function onSubmitUpload(evt: any) {

View File

@ -980,10 +980,22 @@ function setPreviewData(path: string) {
}
previewName.value = fullPath.split('/').slice(-1)[0]
if (path.match(/^http/)) {
previewUrl.value = path
} else {
previewUrl.value = encodeURIComponent(`/file/${configStore.configGui[configStore.configID].id}${fullPath}`).replace(/%2F/g, '/')
}
const ext = previewName.value.split('.').slice(-1)[0].toLowerCase()
const fileType =
mediaType(previewName.value) === 'audio'
? `audio/${ext}`
: mediaType(previewName.value) === 'live'
? 'application/x-mpegURL'
: `video/${ext}`
if (configStore.configPlayout.storage.extensions.includes(`${ext}`)) {
isVideo.value = true
previewOpt.value = {
@ -994,7 +1006,7 @@ function setPreviewData(path: string) {
preload: 'auto',
sources: [
{
type: `video/${ext}`,
type: fileType,
src: previewUrl.value,
},
],