2020-04-09 12:30:28 -04:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-04-15 12:10:43 -04:00
|
|
|
<Menu />
|
|
|
|
<b-card no-body>
|
|
|
|
<b-tabs pills card vertical>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-tab title="GUI" active @click="resetAlert()">
|
2020-04-15 12:10:43 -04:00
|
|
|
<b-container class="config-container">
|
|
|
|
<b-form v-if="configGui" @submit="onSubmitGui">
|
|
|
|
<b-form-group
|
|
|
|
label-cols-lg="2"
|
|
|
|
label="GUI Configuration"
|
|
|
|
label-size="lg"
|
|
|
|
label-class="font-weight-bold pt-0"
|
|
|
|
class="config-group"
|
|
|
|
>
|
2020-12-29 16:01:15 -05:00
|
|
|
<div style="width: 100%; height: 43px;">
|
|
|
|
<div class="float-right">
|
|
|
|
<b-button size="sm" variant="primary" class="m-md-2" @click="addChannel()">
|
|
|
|
Add new Channel
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-for="(prop, name, idx) in configGui[configID]" :key="idx">
|
2020-05-08 09:31:39 -04:00
|
|
|
<b-form-group
|
2021-03-31 07:13:33 -04:00
|
|
|
v-if="idx >= 1 && name !== 'engine_service'"
|
2020-05-08 09:31:39 -04:00
|
|
|
label-cols-sm="2"
|
|
|
|
:label="name"
|
|
|
|
label-align-sm="right"
|
|
|
|
:label-for="name"
|
|
|
|
>
|
|
|
|
<b-form-tags
|
|
|
|
v-if="name === 'extra_extensions'"
|
2020-12-29 16:01:15 -05:00
|
|
|
v-model="configGui[configID][name]"
|
2020-05-08 09:31:39 -04:00
|
|
|
:input-id="name"
|
|
|
|
separator=" ,;"
|
|
|
|
:placeholder="`add ${name}...`"
|
|
|
|
class="mb-2 tags-list"
|
|
|
|
/>
|
|
|
|
<b-form-text v-if="name === 'extra_extensions'">
|
|
|
|
Visible extensions only for the GUI and not the playout
|
|
|
|
</b-form-text>
|
2020-12-29 16:01:15 -05:00
|
|
|
<b-form-select v-else-if="name === 'net_interface'" :id="name" v-model="configGui[configID][name]" :options="netChoices" :value="prop" />
|
2021-01-17 12:09:21 -05:00
|
|
|
<b-form-input
|
|
|
|
v-else
|
|
|
|
:id="name"
|
|
|
|
v-model="configGui[configID][name]"
|
|
|
|
:value="prop"
|
2021-03-31 07:13:33 -04:00
|
|
|
:disabled="(name === 'playout_config') ? true : false"
|
2021-01-17 12:09:21 -05:00
|
|
|
/>
|
2020-05-08 09:31:39 -04:00
|
|
|
</b-form-group>
|
|
|
|
</div>
|
2020-04-15 12:10:43 -04:00
|
|
|
</b-form-group>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-row>
|
2020-12-30 16:08:54 -05:00
|
|
|
<b-col cols="1" style="min-width:158px">
|
|
|
|
<b-button-group>
|
|
|
|
<b-button type="submit" variant="primary">
|
|
|
|
Save
|
|
|
|
</b-button>
|
|
|
|
<b-button variant="danger" @click="deleteChannel()">
|
|
|
|
Delete
|
|
|
|
</b-button>
|
|
|
|
</b-button-group>
|
2020-04-16 12:30:04 -04:00
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-alert v-model="showAlert" :variant="alertVariant" dismissible>
|
|
|
|
{{ alertMsg }}
|
|
|
|
</b-alert>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2020-04-15 12:10:43 -04:00
|
|
|
</b-form>
|
|
|
|
</b-container>
|
|
|
|
</b-tab>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-tab title="Playout" @click="resetAlert()">
|
2020-04-15 12:10:43 -04:00
|
|
|
<b-container class="config-container">
|
|
|
|
<b-form v-if="configPlayout" @submit="onSubmitPlayout">
|
|
|
|
<b-form-group
|
|
|
|
v-for="(item, key, index) in configPlayout"
|
|
|
|
:key="index"
|
|
|
|
label-cols-lg="2"
|
|
|
|
:label="key"
|
|
|
|
label-size="lg"
|
|
|
|
label-class="font-weight-bold pt-0"
|
|
|
|
class="config-group"
|
|
|
|
>
|
|
|
|
<b-form-group
|
|
|
|
v-for="(prop, name, idx) in item"
|
|
|
|
:key="idx"
|
|
|
|
label-cols-sm="2"
|
|
|
|
:label="(typeof prop === 'boolean' || name === 'helptext') ? '' : name"
|
|
|
|
label-align-sm="right"
|
|
|
|
:label-for="name"
|
|
|
|
>
|
|
|
|
<b-form-textarea
|
|
|
|
v-if="name === 'helptext'"
|
|
|
|
id="textarea-plaintext"
|
|
|
|
plaintext
|
|
|
|
:value="prop"
|
|
|
|
rows="2"
|
|
|
|
max-rows="8"
|
|
|
|
class="text-area"
|
|
|
|
/>
|
|
|
|
<b-form-checkbox
|
|
|
|
v-else-if="typeof prop === 'boolean'"
|
|
|
|
:id="name"
|
|
|
|
v-model="configPlayout[key][name]"
|
|
|
|
:name="name"
|
|
|
|
>
|
|
|
|
{{ name }}
|
|
|
|
</b-form-checkbox>
|
|
|
|
<b-form-input
|
2020-04-15 15:55:14 -04:00
|
|
|
v-else-if="prop && prop.toString().match(/^-?\d+[.,]\d+$/)"
|
2020-04-15 12:10:43 -04:00
|
|
|
:id="name"
|
2020-05-08 07:16:41 -04:00
|
|
|
v-model.number="configPlayout[key][name]"
|
2020-04-15 12:10:43 -04:00
|
|
|
type="number"
|
2020-04-15 15:55:14 -04:00
|
|
|
step="0.001"
|
2020-04-15 12:10:43 -04:00
|
|
|
class="input-field"
|
|
|
|
/>
|
|
|
|
<b-form-input
|
2020-04-15 15:55:14 -04:00
|
|
|
v-else-if="prop && !isNaN(prop)"
|
2020-04-15 12:10:43 -04:00
|
|
|
:id="name"
|
2020-05-08 07:16:41 -04:00
|
|
|
v-model.number="configPlayout[key][name]"
|
2020-04-15 12:10:43 -04:00
|
|
|
type="number"
|
2020-04-15 15:55:14 -04:00
|
|
|
step="1"
|
2020-04-15 12:10:43 -04:00
|
|
|
class="input-field"
|
|
|
|
/>
|
|
|
|
<b-form-tags
|
|
|
|
v-else-if="Array.isArray(prop)"
|
|
|
|
v-model="configPlayout[key][name]"
|
2020-04-16 12:30:04 -04:00
|
|
|
:input-id="name"
|
2020-04-15 12:10:43 -04:00
|
|
|
separator=" ,;"
|
|
|
|
:placeholder="`add ${name}...`"
|
2020-04-16 12:30:04 -04:00
|
|
|
class="mb-2 tags-list"
|
|
|
|
/>
|
|
|
|
<b-form-input
|
|
|
|
v-else-if="name.includes('pass')"
|
|
|
|
:id="name"
|
|
|
|
v-model="configPlayout[key][name]"
|
|
|
|
type="password"
|
|
|
|
:value="prop"
|
2020-04-15 12:10:43 -04:00
|
|
|
/>
|
|
|
|
<b-form-input v-else :id="name" v-model="configPlayout[key][name]" :value="prop" />
|
|
|
|
</b-form-group>
|
|
|
|
</b-form-group>
|
2020-04-09 12:30:28 -04:00
|
|
|
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-row>
|
|
|
|
<b-col cols="1" style="min-width: 85px">
|
|
|
|
<b-button type="submit" variant="primary">
|
|
|
|
Save
|
|
|
|
</b-button>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-alert v-model="showAlert" :variant="alertVariant" dismissible>
|
|
|
|
{{ alertMsg }}
|
|
|
|
</b-alert>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2020-04-15 12:10:43 -04:00
|
|
|
</b-form>
|
|
|
|
</b-container>
|
|
|
|
</b-tab>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-tab title="User" @click="resetAlert()">
|
2020-04-15 12:10:43 -04:00
|
|
|
<b-card-text>
|
|
|
|
<b-container class="config-container">
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-form v-if="configUser" @submit="onSubmitUser">
|
2020-04-15 12:10:43 -04:00
|
|
|
<b-form-group
|
|
|
|
label-cols-lg="2"
|
|
|
|
label="User Configuration"
|
|
|
|
label-size="lg"
|
|
|
|
label-class="font-weight-bold pt-0"
|
|
|
|
class="config-group"
|
|
|
|
>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="2"
|
2020-04-16 12:30:04 -04:00
|
|
|
:label="'username'"
|
|
|
|
label-align-sm="right"
|
|
|
|
:label-for="'username'"
|
|
|
|
>
|
|
|
|
<b-form-input id="username" v-model="configUser['username']" :value="configUser['username']" disabled />
|
|
|
|
</b-form-group>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="2"
|
|
|
|
:label="'email'"
|
2020-04-15 12:10:43 -04:00
|
|
|
label-align-sm="right"
|
2020-04-16 12:30:04 -04:00
|
|
|
:label-for="'email'"
|
2020-04-15 12:10:43 -04:00
|
|
|
>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-form-input id="email" v-model="configUser['email']" :value="configUser['email']" />
|
2020-04-15 12:10:43 -04:00
|
|
|
</b-form-group>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="2"
|
|
|
|
label="old password"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="oldPass"
|
|
|
|
>
|
|
|
|
<b-form-input id="oldPass" v-model="oldPass" type="password" />
|
|
|
|
</b-form-group>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="2"
|
|
|
|
label="new password"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="newPass"
|
|
|
|
>
|
|
|
|
<b-form-input id="newPass" v-model="newPass" type="password" />
|
|
|
|
</b-form-group>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="2"
|
|
|
|
label="confirm password"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="confirmPass"
|
|
|
|
>
|
|
|
|
<b-form-input id="confirmPass" v-model="confirmPass" type="password" />
|
|
|
|
</b-form-group>
|
|
|
|
</b-form-group>
|
2020-04-16 12:30:04 -04:00
|
|
|
<b-row>
|
|
|
|
<b-col cols="1" style="min-width: 85px">
|
|
|
|
<b-button type="submit" variant="primary">
|
|
|
|
Save
|
|
|
|
</b-button>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-alert v-model="showAlert" :variant="alertVariant" dismissible>
|
|
|
|
{{ alertMsg }}
|
|
|
|
</b-alert>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2020-04-15 12:10:43 -04:00
|
|
|
</b-form>
|
|
|
|
</b-container>
|
|
|
|
</b-card-text>
|
|
|
|
</b-tab>
|
|
|
|
</b-tabs>
|
|
|
|
</b-card>
|
2020-04-09 12:30:28 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-05-24 07:34:34 -04:00
|
|
|
import { mapState } from 'vuex'
|
2020-04-15 12:10:43 -04:00
|
|
|
import Menu from '@/components/Menu.vue'
|
2020-04-12 15:14:57 -04:00
|
|
|
|
2020-04-09 12:30:28 -04:00
|
|
|
export default {
|
|
|
|
name: 'Configure',
|
|
|
|
|
2020-04-12 15:14:57 -04:00
|
|
|
components: {
|
2020-04-28 15:00:23 -04:00
|
|
|
Menu
|
2020-04-12 15:14:57 -04:00
|
|
|
},
|
2020-04-09 12:30:28 -04:00
|
|
|
|
2020-12-03 11:14:02 -05:00
|
|
|
middleware: 'auth',
|
|
|
|
|
2020-05-24 07:34:34 -04:00
|
|
|
data () {
|
2020-04-09 12:30:28 -04:00
|
|
|
return {
|
2020-04-15 12:10:43 -04:00
|
|
|
oldPass: null,
|
|
|
|
newPass: null,
|
|
|
|
confirmPass: null,
|
2020-04-16 12:30:04 -04:00
|
|
|
showAlert: false,
|
|
|
|
alertVariant: 'success',
|
|
|
|
alertMsg: ''
|
2020-04-09 12:30:28 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-24 07:34:34 -04:00
|
|
|
computed: {
|
2020-12-29 16:01:15 -05:00
|
|
|
...mapState('config', ['configID', 'netChoices']),
|
2020-05-24 07:34:34 -04:00
|
|
|
configGui: {
|
|
|
|
get () {
|
|
|
|
return this.$store.state.config.configGui
|
|
|
|
},
|
|
|
|
set (config) {
|
|
|
|
this.$store.commit('config/UPDATE_GUI_CONFIG', config)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
configPlayout: {
|
|
|
|
get () {
|
|
|
|
return this.$store.state.config.configPlayout
|
|
|
|
},
|
|
|
|
set (config) {
|
|
|
|
this.$store.commit('config/UPDATE_PLAYLOUT_CONFIG', config)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
configUser: {
|
|
|
|
get () {
|
|
|
|
return this.$store.state.config.configUser
|
|
|
|
},
|
|
|
|
set (config) {
|
|
|
|
this.$store.commit('config/UPDATE_USER_CONFIG', config)
|
|
|
|
}
|
2020-04-09 12:30:28 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-12-29 16:01:15 -05:00
|
|
|
addChannel () {
|
2021-03-23 08:56:14 -04:00
|
|
|
const config = this.$_.cloneDeep(this.configGui)
|
|
|
|
const newConf = this.$_.cloneDeep(this.configGui[this.configGui.length - 1])
|
2020-12-30 16:08:54 -05:00
|
|
|
|
|
|
|
const playoutConfigPath = newConf.playout_config.match(/.*\//)
|
|
|
|
const playoutConfigFile = newConf.playout_config.replace(/(.*\/|\.yml)/g, '').split('-')
|
|
|
|
|
|
|
|
const engineServicePath = newConf.engine_service.match(/.*\//)
|
|
|
|
const engineServiceFile = newConf.engine_service.replace(/(.*\/|\.conf)/g, '').split('-')
|
|
|
|
|
2020-12-29 16:01:15 -05:00
|
|
|
newConf.id = config.length + 1
|
2021-01-03 15:43:53 -05:00
|
|
|
newConf.channel = `Channel ${Math.random().toString(36).substring(7)}`
|
2020-12-30 16:08:54 -05:00
|
|
|
newConf.playout_config = `${playoutConfigPath}${playoutConfigFile[0]}-${String(parseInt(playoutConfigFile[1]) + 1).padStart(3, '0')}.yml`
|
|
|
|
newConf.engine_service = `${engineServicePath}${engineServiceFile[0]}-${String(parseInt(engineServiceFile[1]) + 1).padStart(3, '0')}.conf`
|
2020-12-29 16:01:15 -05:00
|
|
|
|
|
|
|
config.push(newConf)
|
|
|
|
|
|
|
|
this.$store.commit('config/UPDATE_GUI_CONFIG', config)
|
|
|
|
this.$store.commit('config/UPDATE_CONFIG_ID', this.configGui.length - 1)
|
|
|
|
},
|
2020-04-15 12:10:43 -04:00
|
|
|
async onSubmitGui (evt) {
|
2020-04-09 12:30:28 -04:00
|
|
|
evt.preventDefault()
|
2020-04-10 08:52:00 -04:00
|
|
|
await this.$store.dispatch('auth/inspectToken')
|
2020-12-30 16:08:54 -05:00
|
|
|
const update = await this.$store.dispatch('config/setGuiConfig', this.configGui[this.configID])
|
2020-04-16 12:30:04 -04:00
|
|
|
|
2020-12-29 16:01:15 -05:00
|
|
|
if (update.status === 200 || update.status === 201) {
|
2020-04-16 12:30:04 -04:00
|
|
|
this.alertVariant = 'success'
|
|
|
|
this.alertMsg = 'Update GUI config success!'
|
|
|
|
} else {
|
|
|
|
this.alertVariant = 'danger'
|
|
|
|
this.alertMsg = 'Update GUI config failed!'
|
|
|
|
}
|
|
|
|
|
|
|
|
this.showAlert = true
|
2020-04-15 12:10:43 -04:00
|
|
|
},
|
2020-12-30 16:08:54 -05:00
|
|
|
async deleteChannel () {
|
2021-03-23 08:56:14 -04:00
|
|
|
const config = this.$_.cloneDeep(this.configGui)
|
2020-12-30 16:08:54 -05:00
|
|
|
const id = config[this.configID].id
|
2021-03-19 07:28:41 -04:00
|
|
|
|
|
|
|
if (id === 1) {
|
|
|
|
this.alertVariant = 'warning'
|
|
|
|
this.alertMsg = 'First channel can not be deleted!'
|
|
|
|
this.showAlert = true
|
|
|
|
return
|
|
|
|
}
|
2020-12-30 16:08:54 -05:00
|
|
|
const response = await this.$axios.delete(`api/player/guisettings/${id}/`)
|
|
|
|
|
|
|
|
config.splice(this.configID, 1)
|
|
|
|
|
|
|
|
this.$store.commit('config/UPDATE_GUI_CONFIG', config)
|
|
|
|
this.$store.commit('config/UPDATE_CONFIG_ID', this.configGui.length - 1)
|
2021-03-19 07:28:41 -04:00
|
|
|
await this.$store.dispatch('config/getPlayoutConfig')
|
2020-12-30 16:08:54 -05:00
|
|
|
|
|
|
|
if (response.status === 204) {
|
|
|
|
this.alertVariant = 'success'
|
|
|
|
this.alertMsg = 'Delete GUI config success!'
|
|
|
|
} else {
|
|
|
|
this.alertVariant = 'danger'
|
|
|
|
this.alertMsg = 'Delete GUI config failed!'
|
|
|
|
}
|
|
|
|
|
|
|
|
this.showAlert = true
|
|
|
|
},
|
2020-04-15 12:10:43 -04:00
|
|
|
async onSubmitPlayout (evt) {
|
|
|
|
evt.preventDefault()
|
|
|
|
await this.$store.dispatch('auth/inspectToken')
|
2020-04-16 12:30:04 -04:00
|
|
|
const update = await this.$store.dispatch('config/setPlayoutConfig', this.configPlayout)
|
|
|
|
|
|
|
|
if (update.status === 200) {
|
|
|
|
this.alertVariant = 'success'
|
|
|
|
this.alertMsg = 'Update playout config success!'
|
|
|
|
} else {
|
|
|
|
this.alertVariant = 'danger'
|
|
|
|
this.alertMsg = 'Update playout config failed!'
|
|
|
|
}
|
|
|
|
|
|
|
|
this.showAlert = true
|
|
|
|
},
|
|
|
|
async onSubmitUser (evt) {
|
|
|
|
evt.preventDefault()
|
|
|
|
if (this.oldPass && this.newPass && this.newPass === this.confirmPass) {
|
|
|
|
this.configUser.old_password = this.oldPass
|
|
|
|
this.configUser.new_password = this.newPass
|
|
|
|
}
|
|
|
|
await this.$store.dispatch('auth/inspectToken')
|
|
|
|
const update = await this.$store.dispatch('config/setUserConfig', this.configUser)
|
|
|
|
|
|
|
|
if (update.status === 200) {
|
|
|
|
this.alertVariant = 'success'
|
|
|
|
this.alertMsg = 'Update user profil success!'
|
|
|
|
} else {
|
|
|
|
this.alertVariant = 'danger'
|
|
|
|
this.alertMsg = 'Update user profil failed!'
|
|
|
|
}
|
|
|
|
|
|
|
|
this.showAlert = true
|
|
|
|
|
|
|
|
this.oldPass = null
|
|
|
|
this.newPass = null
|
|
|
|
this.confirmPass = null
|
|
|
|
},
|
|
|
|
|
|
|
|
resetAlert () {
|
|
|
|
this.showAlert = false
|
|
|
|
this.alertVariant = 'success'
|
|
|
|
this.alertMsg = ''
|
2020-04-09 12:30:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.config-container {
|
2020-04-12 15:14:57 -04:00
|
|
|
margin: 2em auto 2em auto;
|
2020-04-09 12:30:28 -04:00
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.config-group {
|
|
|
|
margin-bottom: 2em;
|
|
|
|
}
|
2020-04-12 15:14:57 -04:00
|
|
|
|
|
|
|
.input-field {
|
|
|
|
max-width: 200px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text-area {
|
|
|
|
overflow-y: hidden !important;
|
|
|
|
}
|
2020-04-09 12:30:28 -04:00
|
|
|
</style>
|