2023-01-11 04:54:25 -05:00
|
|
|
<template>
|
2024-04-04 17:28:25 -04:00
|
|
|
<div class="w-full max-w-[800px]">
|
2024-04-16 08:07:50 -04:00
|
|
|
<h2 class="pt-3 text-3xl">{{ $t('config.channelConf') }}</h2>
|
2024-04-04 17:28:25 -04:00
|
|
|
<div class="w-full flex justify-end my-4">
|
2024-04-16 08:07:50 -04:00
|
|
|
<button class="btn btn-sm btn-primary" @click="addChannel()">{{ $t('config.addChannel') }}</button>
|
2024-04-04 17:28:25 -04:00
|
|
|
</div>
|
|
|
|
<form
|
|
|
|
v-if="configStore.configGui && configStore.configGui[configStore.configID]"
|
|
|
|
@submit.prevent="onSubmitGui"
|
|
|
|
class="w-full"
|
|
|
|
>
|
|
|
|
<label class="form-control w-full">
|
|
|
|
<div class="label">
|
2024-04-16 08:07:50 -04:00
|
|
|
<span class="label-text">{{ $t('config.name') }}</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-04 17:28:25 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
placeholder="Type here"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
v-model="configStore.configGui[configStore.configID].name"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-5">
|
|
|
|
<div class="label">
|
2024-04-16 08:07:50 -04:00
|
|
|
<span class="label-text">{{ $t('config.previewUrl') }}</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-04 17:28:25 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
v-model="configStore.configGui[configStore.configID].preview_url"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-5">
|
|
|
|
<div class="label">
|
2024-04-16 08:07:50 -04:00
|
|
|
<span class="label-text">{{ $t('config.configPath') }}</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-04 17:28:25 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
v-model="configStore.configGui[configStore.configID].config_path"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-5">
|
|
|
|
<div class="label">
|
2024-04-16 08:07:50 -04:00
|
|
|
<span class="label-text">{{ $t('config.extensions') }}</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-04 17:28:25 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
v-model="configStore.configGui[configStore.configID].extra_extensions"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="form-control w-full mt-5">
|
|
|
|
<div class="label">
|
2024-04-16 08:07:50 -04:00
|
|
|
<span class="label-text">{{ $t('config.service') }}</span>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-04-04 17:28:25 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
2024-04-05 12:53:07 -04:00
|
|
|
class="input input-bordered w-full !bg-base-100"
|
2024-04-04 17:28:25 -04:00
|
|
|
v-model="configStore.configGui[configStore.configID].service"
|
|
|
|
disabled
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
|
2024-04-07 09:45:26 -04:00
|
|
|
<div class="join my-4">
|
2024-04-16 08:07:50 -04:00
|
|
|
<button class="join-item btn btn-primary" type="submit">{{ $t('config.save') }}</button>
|
2024-04-04 17:28:25 -04:00
|
|
|
<button
|
|
|
|
class="join-item btn btn-primary"
|
|
|
|
v-if="configStore.configGui.length > 1 && configStore.configGui[configStore.configID].id > 1"
|
|
|
|
@click="deleteChannel()"
|
|
|
|
>
|
2024-04-16 08:07:50 -04:00
|
|
|
{{ $t('config.delete') }}
|
2024-04-04 17:28:25 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
const { $_ } = useNuxtApp()
|
2024-04-16 08:07:50 -04:00
|
|
|
const { t } = useI18n()
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
const authStore = useAuth()
|
|
|
|
const configStore = useConfig()
|
|
|
|
const indexStore = useIndex()
|
|
|
|
|
|
|
|
async function addChannel() {
|
|
|
|
const channels = $_.cloneDeep(configStore.configGui)
|
|
|
|
const newChannel = $_.cloneDeep(configStore.configGui[configStore.configGui.length - 1])
|
|
|
|
|
|
|
|
const playoutConfigPath = newChannel.config_path.match(/.*\//)
|
|
|
|
const confName = `channel${String(channels.length + 1).padStart(3, '0')}`
|
|
|
|
|
|
|
|
newChannel.id = channels.length + 1
|
|
|
|
newChannel.name = `Channel ${Math.random().toString(36).substring(7)}`
|
|
|
|
newChannel.config_path = `${playoutConfigPath}${confName}.yml`
|
|
|
|
newChannel.service = `ffplayout@${confName}.service`
|
|
|
|
|
|
|
|
channels.push(newChannel)
|
2023-11-02 08:38:45 -04:00
|
|
|
configStore.configGui = channels
|
2023-07-14 07:45:48 -04:00
|
|
|
configStore.configID = configStore.configGui.length - 1
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
async function onSubmitGui() {
|
|
|
|
/*
|
|
|
|
Save GUI settings.
|
|
|
|
*/
|
|
|
|
const update = await configStore.setGuiConfig(configStore.configGui[configStore.configID])
|
|
|
|
|
|
|
|
if (update.status) {
|
2024-04-16 08:07:50 -04:00
|
|
|
indexStore.msgAlert('success', t('config.updateChannelSuccess'), 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
} else {
|
2024-04-16 08:07:50 -04:00
|
|
|
indexStore.msgAlert('error', t('config.updateChannelFailed'), 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function deleteChannel() {
|
|
|
|
const config = $_.cloneDeep(configStore.configGui)
|
|
|
|
const id = config[configStore.configID].id
|
|
|
|
|
|
|
|
if (id === 1) {
|
2024-04-16 08:07:50 -04:00
|
|
|
indexStore.msgAlert('warning', t('config.errorChannelDelete'), 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-01-11 07:41:22 -05:00
|
|
|
const response = await fetch(`/api/channel/${id}`, {
|
2023-01-11 04:54:25 -05:00
|
|
|
method: 'DELETE',
|
|
|
|
headers: authStore.authHeader,
|
|
|
|
})
|
|
|
|
|
|
|
|
config.splice(configStore.configID, 1)
|
2023-07-14 07:45:48 -04:00
|
|
|
configStore.configGui = config
|
|
|
|
configStore.configID = configStore.configGui.length - 1
|
2023-01-11 04:54:25 -05:00
|
|
|
await configStore.getPlayoutConfig()
|
|
|
|
|
|
|
|
if (response.status === 200) {
|
2024-04-16 08:07:50 -04:00
|
|
|
indexStore.msgAlert('success', t('config.errorChannelDelete'), 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
} else {
|
2024-04-16 08:07:50 -04:00
|
|
|
indexStore.msgAlert('error', t('config.deleteChannelFailed'), 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|