+
-
@@ -483,7 +499,7 @@
'/'
),
true
- )
+ ),
]
"
>
@@ -550,11 +566,11 @@ const mediaStore = useMedia()
const playlistStore = usePlaylist()
definePageMeta({
- middleware: ['auth']
+ middleware: ['auth'],
})
useHead({
- title: 'Player | ffplayout'
+ title: 'Player | ffplayout',
})
const { configID } = storeToRefs(useConfig())
@@ -575,12 +591,12 @@ const selectedFolders = ref([] as string[])
const generateFromAll = ref(false)
const browserSortOptions = ref({
group: { name: 'playlist', pull: 'clone', put: false },
- sort: false
+ sort: false,
})
const playlistSortOptions = ref({
group: 'playlist',
animation: 100,
- handle: '.grabbing'
+ handle: '.grabbing',
})
const newSource = ref({
begin: 0,
@@ -591,7 +607,7 @@ const newSource = ref({
custom_filter: '',
source: '',
audio: '',
- uid: ''
+ uid: '',
} as PlaylistItem)
onMounted(() => {
@@ -674,7 +690,7 @@ function cloneClip(event: any) {
source: sourcePath,
in: 0,
out: mediaStore.folderTree.files[o].duration,
- duration: mediaStore.folderTree.files[o].duration
+ duration: mediaStore.folderTree.files[o].duration,
})
playlistStore.playlist = processPlaylist(
@@ -719,9 +735,9 @@ function setPreviewData(path: string) {
sources: [
{
type: `video/${ext}`,
- src: previewUrl.value
- }
- ]
+ src: previewUrl.value,
+ },
+ ],
}
} else {
isVideo.value = false
@@ -760,7 +776,7 @@ function processSource(evt: any) {
custom_filter: '',
source: '',
audio: '',
- uid: ''
+ uid: '',
}
}
@@ -775,7 +791,7 @@ function clearNewSource() {
custom_filter: '',
source: '',
audio: '',
- uid: genUID()
+ uid: genUID(),
}
}
@@ -791,7 +807,7 @@ function editPlaylistItem(i: number) {
custom_filter: playlistStore.playlist[i].custom_filter,
source: playlistStore.playlist[i].source,
audio: playlistStore.playlist[i].audio,
- uid: playlistStore.playlist[i].uid
+ uid: playlistStore.playlist[i].uid,
}
}
@@ -811,7 +827,7 @@ function loopClips() {
const tempList = []
let length = 0
- while (length < configStore.playlistLength) {
+ while (length < configStore.playlistLength && playlistStore.playlist.length > 0) {
for (const item of playlistStore.playlist) {
if (length < configStore.playlistLength) {
tempList.push($_.cloneDeep(item))
@@ -843,7 +859,7 @@ async function onSubmitImport(evt: any) {
{
method: 'PUT',
headers: authStore.authHeader,
- body: formData
+ body: formData,
}
)
.then(() => {
@@ -878,7 +894,7 @@ async function generatePlaylist() {
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/generate/${listDate.value}`, {
method: 'POST',
headers: { ...contentType, ...authStore.authHeader },
- body: (selectedFolders.value.length > 0 && !generateFromAll.value) ? { paths: selectedFolders.value } : null
+ body: selectedFolders.value.length > 0 && !generateFromAll.value ? { paths: selectedFolders.value } : null,
})
.then((response: any) => {
playlistStore.playlist = processPlaylist(
@@ -909,6 +925,10 @@ async function generatePlaylist() {
}
async function savePlaylist(saveDate: string) {
+ if (playlistStore.playlist.length === 0) {
+ return
+ }
+
playlistStore.playlist = processPlaylist(
configStore.startInSec,
configStore.playlistLength,
@@ -923,8 +943,8 @@ async function savePlaylist(saveDate: string) {
body: JSON.stringify({
channel: configStore.configGui[configStore.configID].name,
date: saveDate,
- program: saveList
- })
+ program: saveList,
+ }),
})
.then((response: any) => {
indexStore.alertVariant = 'alert-success'
@@ -959,7 +979,7 @@ async function savePlaylist(saveDate: string) {
async function deletePlaylist(playlistDate: string) {
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/${playlistDate}`, {
method: 'DELETE',
- headers: { ...contentType, ...authStore.authHeader }
+ headers: { ...contentType, ...authStore.authHeader },
}).then(() => {
playlistStore.playlist = []
diff --git a/stores/config.ts b/stores/config.ts
index d820a736..dde02e04 100644
--- a/stores/config.ts
+++ b/stores/config.ts
@@ -9,7 +9,7 @@ import { useIndex } from '~/stores/index'
interface GuiConfig {
id: number
config_path: string
- extra_extensions: string
+ extra_extensions: string | string[]
name: string
preview_url: string
service: string
@@ -38,42 +38,6 @@ export const useConfig = defineStore('config', {
getters: {},
actions: {
- updateConfigID(id: number) {
- this.configID = id
- },
-
- updateConfigCount(count: number) {
- this.configCount = count
- },
-
- updateGuiConfig(config: GuiConfig[]) {
- this.configGui = config
- },
-
- updateGuiConfigRaw(config: GuiConfig[]) {
- this.configGuiRaw = config
- },
-
- updateStartTime(sec: number) {
- this.startInSec = sec
- },
-
- updatePlaylistLength(sec: number) {
- this.playlistLength = sec
- },
-
- setCurrentUser(user: string) {
- this.currentUser = user
- },
-
- updateUserConfig(config: User) {
- this.configUser = config
- },
-
- updateUtcOffset(offset: number) {
- this.utcOffset = offset
- },
-
async nuxtClientInit() {
const authStore = useAuth()
@@ -102,10 +66,10 @@ export const useConfig = defineStore('config', {
})
.then((response) => response.json())
.then((objs) => {
- this.updateUtcOffset(objs[0].utc_offset)
- this.updateGuiConfig(objs)
- this.updateGuiConfigRaw(_.cloneDeep(objs))
- this.updateConfigCount(objs.length)
+ this.utcOffset = objs[0].utc_offset
+ this.configGui = objs
+ this.configGuiRaw = _.cloneDeep(objs)
+ this.configCount = objs.length
})
.catch((e) => {
if (statusCode === 401) {
@@ -116,7 +80,7 @@ export const useConfig = defineStore('config', {
navigateTo('/')
}
- this.updateGuiConfig([
+ this.configGui = [
{
id: 1,
config_path: '',
@@ -126,7 +90,7 @@ export const useConfig = defineStore('config', {
service: '',
uts_offset: 0,
},
- ])
+ ]
indexStore.alertMsg = e
indexStore.alertVariant = 'alert-danger'
@@ -164,9 +128,9 @@ export const useConfig = defineStore('config', {
}
}
- this.updateGuiConfig(guiConfigs)
- this.updateGuiConfigRaw(_.cloneDeep(guiConfigs))
- this.updateConfigCount(guiConfigs.length)
+ this.configGui = guiConfigs
+ this.configGuiRaw = _.cloneDeep(guiConfigs)
+ this.configCount = guiConfigs.length
await this.getPlayoutConfig()
}
@@ -186,13 +150,11 @@ export const useConfig = defineStore('config', {
.then((response) => response.json())
.then((data) => {
if (data.playlist.day_start) {
- const start = timeToSeconds(data.playlist.day_start)
- this.updateStartTime(start)
+ this.startInSec = timeToSeconds(data.playlist.day_start)
}
if (data.playlist.length) {
- const length = timeToSeconds(data.playlist.length)
- this.updatePlaylistLength(length)
+ this.playlistLength = timeToSeconds(data.playlist.length)
}
if (data.storage.extensions) {
@@ -213,7 +175,12 @@ export const useConfig = defineStore('config', {
const channel = this.configGui[this.configID].id
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
- obj.storage.extensions = obj.storage.extensions.replace(' ', '').split(/,|;/)
+ this.startInSec = timeToSeconds(obj.playlist.day_start)
+ this.playlistLength = timeToSeconds(obj.playlist.length)
+
+ if (typeof obj.storage.extensions === 'string') {
+ obj.storage.extensions = obj.storage.extensions.replace(' ', '').split(/,|;/)
+ }
const update = await fetch(`/api/playout/config/${channel}`, {
method: 'PUT',
@@ -233,8 +200,8 @@ export const useConfig = defineStore('config', {
})
.then((response) => response.json())
.then((data) => {
- this.setCurrentUser(data.username)
- this.updateUserConfig(data)
+ this.currentUser = data.username
+ this.configUser = data
})
},
diff --git a/stores/media.ts b/stores/media.ts
index dfc81a06..44dc2a04 100644
--- a/stores/media.ts
+++ b/stores/media.ts
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { useAuth } from '~/stores/auth'
import { useConfig } from '~/stores/config'
+import { useIndex } from '~/stores/index'
export const useMedia = defineStore('media', {
state: () => ({
@@ -17,6 +18,7 @@ export const useMedia = defineStore('media', {
async getTree(path: string, foldersOnly: boolean = false) {
const authStore = useAuth()
const configStore = useConfig()
+ const indexStore = useIndex()
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
const channel = configStore.configGui[configStore.configID].id
const crumbs: Crumb[] = []
@@ -27,7 +29,23 @@ export const useMedia = defineStore('media', {
headers: { ...contentType, ...authStore.authHeader },
body: JSON.stringify({ source: path, folders_only: foldersOnly }),
})
- .then((response) => response.json())
+ .then((response) => {
+
+ if (response.status === 200) {
+ return response.json()
+ } else {
+ indexStore.alertVariant = 'alert-danger'
+ indexStore.alertMsg = `Storage not exist!`
+ indexStore.showAlert = true
+
+ return {
+ source: '',
+ parent: '',
+ folders: [],
+ files: [],
+ }
+ }
+ })
.then((data) => {
const pathStr = 'Home/' + data.source
const pathArr = pathStr.split('/')