fix api routes, dayjs plugin and type errors
This commit is contained in:
parent
3674e1865f
commit
8878cff71d
@ -313,7 +313,7 @@ async function deleteFileOrFolder() {
|
||||
/*
|
||||
Delete function, works for files and folders.
|
||||
*/
|
||||
await fetch(`api/file/${configStore.configGui[configStore.configID].id}/remove/`, {
|
||||
await fetch(`/api/file/${configStore.configGui[configStore.configID].id}/remove/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ source: deleteName.value }),
|
||||
@ -349,7 +349,7 @@ async function onSubmitRenameFile(evt: any) {
|
||||
*/
|
||||
evt.preventDefault()
|
||||
|
||||
await fetch(`api/file/${configStore.configGui[configStore.configID].id}/rename/`, {
|
||||
await fetch(`/api/file/${configStore.configGui[configStore.configID].id}/rename/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ source: renameOldName.value, target: renameNewName.value }),
|
||||
|
@ -249,7 +249,7 @@ async function playoutStatus() {
|
||||
*/
|
||||
const channel = configStore.configGui[configStore.configID].id
|
||||
|
||||
await $fetch(`api/control/${channel}/process/`, {
|
||||
await $fetch(`/api/control/${channel}/process/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ command: 'status' }),
|
||||
@ -273,7 +273,7 @@ async function controlProcess(state: string) {
|
||||
*/
|
||||
const channel = configStore.configGui[configStore.configID].id
|
||||
|
||||
await $fetch(`api/control/${channel}/process/`, {
|
||||
await $fetch(`/api/control/${channel}/process/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ command: state }),
|
||||
@ -294,7 +294,7 @@ async function controlPlayout(state: string) {
|
||||
*/
|
||||
const channel = configStore.configGui[configStore.configID].id
|
||||
|
||||
await $fetch(`api/control/${channel}/playout/`, {
|
||||
await $fetch(`/api/control/${channel}/playout/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ command: state }),
|
||||
|
@ -149,7 +149,7 @@ async function deleteChannel() {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetch(`api/channel/${id}`, {
|
||||
const response = await fetch(`/api/channel/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
|
@ -13,8 +13,8 @@ export default defineNuxtConfig({
|
||||
},
|
||||
|
||||
ignore: ['**/public/tv-media**', '**/public/Videos**', '**/public/live**', '**/public/home**'],
|
||||
|
||||
ssr: false,
|
||||
// debug: true,
|
||||
|
||||
app: {
|
||||
head: {
|
||||
@ -44,14 +44,23 @@ export default defineNuxtConfig({
|
||||
},
|
||||
|
||||
modules: ['@pinia/nuxt'],
|
||||
css: ['@/assets/scss/main.scss'],
|
||||
|
||||
vite: {
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
additionalData: '@import "@/assets/scss/main.scss";',
|
||||
additionalData: '@import "@/assets/scss/_variables.scss";',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
experimental: {
|
||||
payloadExtraction: false,
|
||||
},
|
||||
|
||||
// build: {
|
||||
// chunkSizeWarningLimit: 800000,
|
||||
// },
|
||||
})
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "ffplayout-frontend-n3",
|
||||
"name": "ffplayout-frontend",
|
||||
"version": "0.1.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ffplayout-frontend",
|
||||
"version": "0.1.1",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@nuxt/types": "^2.15.8",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ffplayout-frontend",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Web GUI for ffplayout",
|
||||
"author": "Jonathan Baecker",
|
||||
"private": true,
|
||||
|
@ -24,14 +24,21 @@ useHead({
|
||||
title: 'Logging | ffplayout'
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getLog()
|
||||
})
|
||||
|
||||
const { $dayjs } = useNuxtApp()
|
||||
const authStore = useAuth()
|
||||
const configStore = useConfig()
|
||||
const currentLog = ref('')
|
||||
const listDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
|
||||
const configID = ref(configStore.configID)
|
||||
const { formatLog } = stringFormatter()
|
||||
|
||||
watch([listDate, configStore.configID], () => {
|
||||
getLog()
|
||||
})
|
||||
|
||||
async function getLog() {
|
||||
let date = listDate.value
|
||||
|
||||
@ -39,7 +46,7 @@ async function getLog() {
|
||||
date = ''
|
||||
}
|
||||
|
||||
await fetch(`api/log/${configStore.configGui[configStore.configID].id}?date=${date}`, {
|
||||
await fetch(`/api/log/${configStore.configGui[configStore.configID].id}?date=${date}`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -51,16 +58,6 @@ async function getLog() {
|
||||
currentLog.value = ''
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLog()
|
||||
})
|
||||
|
||||
watch([listDate, configID], () => {
|
||||
getLog()
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -179,7 +179,7 @@ async function onSubmitCreateFolder(evt: any) {
|
||||
return
|
||||
}
|
||||
|
||||
await $fetch(`api/file/${configStore.configGui[configStore.configID].id}/create-folder/`, {
|
||||
await $fetch(`/api/file/${configStore.configGui[configStore.configID].id}/create-folder/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ source: path }),
|
||||
@ -188,7 +188,7 @@ async function onSubmitCreateFolder(evt: any) {
|
||||
indexStore.alertVariant = 'alert-success'
|
||||
indexStore.alertMsg = 'Folder create done...'
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch((e: string) => {
|
||||
indexStore.alertVariant = 'alert-danger'
|
||||
indexStore.alertMsg = `Folder create error: ${e}`
|
||||
})
|
||||
@ -236,7 +236,7 @@ async function onSubmitUpload(evt: any) {
|
||||
|
||||
xhr.value.open(
|
||||
'PUT',
|
||||
`api/file/${configStore.configGui[configStore.configID].id}/upload/?path=${encodeURIComponent(
|
||||
`/api/file/${configStore.configGui[configStore.configID].id}/upload/?path=${encodeURIComponent(
|
||||
mediaStore.crumbs[mediaStore.crumbs.length - 1].path
|
||||
)}`
|
||||
)
|
||||
|
@ -301,7 +301,7 @@ onBeforeUnmount(() => {
|
||||
})
|
||||
|
||||
async function getPreset(index: number) {
|
||||
fetch(`api/presets/${configStore.configGui[configStore.configID].id}`, {
|
||||
fetch(`/api/presets/${configStore.configGui[configStore.configID].id}`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -385,7 +385,7 @@ async function savePreset() {
|
||||
channel_id: configStore.configGui[configStore.configID].id,
|
||||
}
|
||||
|
||||
const response = await fetch(`api/presets/${form.value.id}`, {
|
||||
const response = await fetch(`/api/presets/${form.value.id}`, {
|
||||
method: 'PUT',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(preset),
|
||||
@ -425,7 +425,7 @@ async function createNewPreset() {
|
||||
channel_id: configStore.configGui[configStore.configID].id,
|
||||
}
|
||||
|
||||
const response = await fetch('api/presets/', {
|
||||
const response = await fetch('/api/presets/', {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(preset),
|
||||
@ -445,7 +445,7 @@ async function createNewPreset() {
|
||||
|
||||
async function deletePreset() {
|
||||
if (selected.value && selected.value !== '') {
|
||||
await fetch(`api/presets/${form.value.id}`, {
|
||||
await fetch(`/api/presets/${form.value.id}`, {
|
||||
method: 'DELETE',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -468,7 +468,7 @@ async function submitMessage() {
|
||||
boxborderw: form.value.border.toString(),
|
||||
}
|
||||
|
||||
const response = await fetch(`api/control/${configStore.configGui[configStore.configID].id}/text/`, {
|
||||
const response = await fetch(`/api/control/${configStore.configGui[configStore.configID].id}/text/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(obj),
|
||||
|
@ -678,7 +678,7 @@ async function onSubmitImport(evt: any) {
|
||||
|
||||
playlistIsLoading.value = true
|
||||
await $fetch(
|
||||
`api/file/${configStore.configGui[configStore.configID].id}/import/?file=${textFile.value[0].name}&date=${
|
||||
`/api/file/${configStore.configGui[configStore.configID].id}/import/?file=${textFile.value[0].name}&date=${
|
||||
listDate.value
|
||||
}`,
|
||||
{
|
||||
@ -698,7 +698,7 @@ async function onSubmitImport(evt: any) {
|
||||
indexStore.showAlert = false
|
||||
}, 2000)
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch((e: string) => {
|
||||
indexStore.alertVariant = 'alert-danger'
|
||||
indexStore.alertMsg = e
|
||||
indexStore.showAlert = true
|
||||
@ -716,7 +716,7 @@ async function onSubmitImport(evt: any) {
|
||||
async function generatePlaylist() {
|
||||
playlistIsLoading.value = true
|
||||
|
||||
await $fetch(`api/playlist/${configStore.configGui[configStore.configID].id}/generate/${listDate.value}`, {
|
||||
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/generate/${listDate.value}`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -735,7 +735,7 @@ async function generatePlaylist() {
|
||||
indexStore.showAlert = false
|
||||
}, 2000)
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch((e: string) => {
|
||||
indexStore.alertVariant = 'alert-danger'
|
||||
indexStore.alertMsg = e
|
||||
indexStore.showAlert = true
|
||||
@ -757,7 +757,7 @@ async function savePlaylist(saveDate: string) {
|
||||
)
|
||||
const saveList = playlistStore.playlist.map(({ begin, ...item }) => item)
|
||||
|
||||
await $fetch(`api/playlist/${configStore.configGui[configStore.configID].id}/`, {
|
||||
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({
|
||||
@ -775,7 +775,7 @@ async function savePlaylist(saveDate: string) {
|
||||
indexStore.showAlert = false
|
||||
}, 2000)
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch((e: any) => {
|
||||
if (e.status === 409) {
|
||||
indexStore.alertVariant = 'alert-warning'
|
||||
indexStore.alertMsg = e.data
|
||||
@ -797,7 +797,7 @@ async function savePlaylist(saveDate: string) {
|
||||
}
|
||||
|
||||
async function deletePlaylist(playlistDate: string) {
|
||||
await $fetch(`api/playlist/${configStore.configGui[configStore.configID].id}/${playlistDate}`, {
|
||||
await $fetch(`/api/playlist/${configStore.configGui[configStore.configID].id}/${playlistDate}`, {
|
||||
method: 'DELETE',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
}).then(() => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as dayjs from 'dayjs'
|
||||
import dayjs from 'dayjs'
|
||||
import utc from 'dayjs/plugin/utc.js'
|
||||
import timezone from 'dayjs/plugin/timezone.js'
|
||||
|
||||
|
@ -40,7 +40,7 @@ export const useAuth = defineStore('auth', {
|
||||
password,
|
||||
}
|
||||
|
||||
await fetch('auth/login/', {
|
||||
await fetch('/auth/login/', {
|
||||
method: 'POST',
|
||||
headers: new Headers([['content-type', 'application/json;charset=UTF-8']]),
|
||||
body: JSON.stringify(payload),
|
||||
|
@ -92,7 +92,7 @@ export const useConfig = defineStore('config', {
|
||||
|
||||
async getGuiConfig() {
|
||||
let statusCode = 0
|
||||
await fetch('api/channels', {
|
||||
await fetch('/api/channels', {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -129,8 +129,9 @@ export const useConfig = defineStore('config', {
|
||||
},
|
||||
])
|
||||
|
||||
indexStore.errorAlertMessage = e
|
||||
indexStore.showErrorAlert = true
|
||||
indexStore.alertMsg = e
|
||||
indexStore.alertVariant = 'alert-danger'
|
||||
indexStore.showAlert = true
|
||||
})
|
||||
},
|
||||
|
||||
@ -140,13 +141,13 @@ export const useConfig = defineStore('config', {
|
||||
let response
|
||||
|
||||
if (this.configGuiRaw.some((e) => e.id === stringObj.id)) {
|
||||
response = await fetch(`api/channel/${obj.id}`, {
|
||||
response = await fetch(`/api/channel/${obj.id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(stringObj),
|
||||
})
|
||||
} else {
|
||||
response = await fetch('api/channel/', {
|
||||
response = await fetch('/api/channel/', {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(stringObj),
|
||||
@ -176,7 +177,7 @@ export const useConfig = defineStore('config', {
|
||||
async getPlayoutConfig() {
|
||||
const channel = this.configGui[this.configID].id
|
||||
|
||||
await fetch(`api/playout/config/${channel}`, {
|
||||
await fetch(`/api/playout/config/${channel}`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -195,8 +196,9 @@ export const useConfig = defineStore('config', {
|
||||
this.updatePlayoutConfig(data)
|
||||
})
|
||||
.catch(() => {
|
||||
indexStore.showErrorAlert = true
|
||||
indexStore.errorAlertMessage = 'No playout config found!'
|
||||
indexStore.alertMsg = 'No playout config found!'
|
||||
indexStore.alertVariant = 'alert-danger'
|
||||
indexStore.showAlert = true
|
||||
})
|
||||
},
|
||||
|
||||
@ -204,7 +206,7 @@ export const useConfig = defineStore('config', {
|
||||
const channel = this.configGui[this.configID].id
|
||||
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
|
||||
|
||||
const update = await fetch(`api/playout/config/${channel}`, {
|
||||
const update = await fetch(`/api/playout/config/${channel}`, {
|
||||
method: 'PUT',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(obj),
|
||||
@ -214,7 +216,7 @@ export const useConfig = defineStore('config', {
|
||||
},
|
||||
|
||||
async getUserConfig() {
|
||||
await fetch('api/user', {
|
||||
await fetch('/api/user', {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -228,7 +230,7 @@ export const useConfig = defineStore('config', {
|
||||
async setUserConfig(obj: any) {
|
||||
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
|
||||
|
||||
const update = await fetch(`api/user/${obj.id}`, {
|
||||
const update = await fetch(`/api/user/${obj.id}`, {
|
||||
method: 'PUT',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify(obj),
|
||||
|
@ -3,7 +3,7 @@ import { defineStore } from 'pinia'
|
||||
export const useIndex = defineStore('index', {
|
||||
state: () => ({
|
||||
showAlert: false,
|
||||
alertVariant: 'success',
|
||||
alertVariant: 'alert-success',
|
||||
alertMsg: '',
|
||||
}),
|
||||
|
||||
@ -11,7 +11,7 @@ export const useIndex = defineStore('index', {
|
||||
actions: {
|
||||
resetAlert() {
|
||||
this.showAlert = false
|
||||
this.alertVariant = 'success'
|
||||
this.alertVariant = 'alert-success'
|
||||
this.alertMsg = ''
|
||||
},
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ export const useMedia = defineStore('media', {
|
||||
const crumbs: Crumb[] = []
|
||||
let root = '/'
|
||||
|
||||
await fetch(`api/file/${channel}/browse/`, {
|
||||
await fetch(`/api/file/${channel}/browse/`, {
|
||||
method: 'POST',
|
||||
headers: { ...contentType, ...authStore.authHeader },
|
||||
body: JSON.stringify({ source: path }),
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as dayjs from 'dayjs'
|
||||
import dayjs from 'dayjs'
|
||||
import utc from 'dayjs/plugin/utc.js'
|
||||
import timezone from 'dayjs/plugin/timezone.js'
|
||||
|
||||
@ -45,7 +45,7 @@ export const usePlaylist = defineStore('playlist', {
|
||||
dateToday = dayjs(dateToday).utcOffset(configStore.utcOffset).subtract(1, 'day').format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
await fetch(`api/playlist/${channel}?date=${date}`, {
|
||||
await fetch(`/api/playlist/${channel}?date=${date}`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
@ -65,7 +65,7 @@ export const usePlaylist = defineStore('playlist', {
|
||||
async playoutStat() {
|
||||
const channel = configStore.configGui[configStore.configID].id
|
||||
|
||||
await fetch(`api/control/${channel}/media/current`, {
|
||||
await fetch(`/api/control/${channel}/media/current`, {
|
||||
method: 'GET',
|
||||
headers: authStore.authHeader,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user