ffplayout/pages/logging.vue

197 lines
4.8 KiB
Vue
Raw Normal View History

2020-04-17 09:02:21 -04:00
<template>
2020-04-27 10:07:28 -04:00
<div>
2020-04-17 09:02:21 -04:00
<Menu />
2020-05-12 07:07:42 -04:00
<b-row class="date-row">
<b-col>
<b-datepicker v-model="listDate" size="sm" class="date-div" offset="-35px" />
</b-col>
</b-row>
<b-card no-body class="card-container">
2020-04-27 10:07:28 -04:00
<b-tabs pills card vertical>
<b-tab title="Playout" active @click="getLog('ffplayout')">
<b-container class="log-container">
<!-- eslint-disable-next-line -->
2021-01-28 12:19:36 -05:00
<perfect-scrollbar
v-if="currentLog"
:options="scrollOP"
class="log-content"
:inner-html.prop="currentLog | formatStr"
/>
2020-04-27 10:07:28 -04:00
</b-container>
</b-tab>
<b-tab title="Decoder" @click="getLog('decoder')">
<b-container class="log-container">
<!-- eslint-disable-next-line -->
2021-01-28 12:19:36 -05:00
<perfect-scrollbar
v-if="currentLog"
:options="scrollOP"
class="log-content"
:inner-html.prop="currentLog | formatStr"
/>
2020-04-27 10:07:28 -04:00
</b-container>
</b-tab>
<b-tab title="Encoder" @click="getLog('encoder')">
<b-container class="log-container">
<!-- eslint-disable-next-line -->
2021-01-28 12:19:36 -05:00
<perfect-scrollbar
v-if="currentLog"
:options="scrollOP"
class="log-content"
:inner-html.prop="currentLog | formatStr"
/>
2020-04-27 10:07:28 -04:00
</b-container>
</b-tab>
</b-tabs>
</b-card>
2020-04-17 09:02:21 -04:00
</div>
</template>
<script>
2021-03-21 10:37:16 -04:00
import { mapState } from 'vuex'
2020-04-17 09:02:21 -04:00
import Menu from '@/components/Menu.vue'
export default {
name: 'Logging',
2020-04-17 09:02:21 -04:00
components: {
Menu
2020-04-27 10:07:28 -04:00
},
filters: {
formatStr (text) {
return text
2021-02-04 11:32:09 -05:00
.replace(/(".*")/g, '<span class="log-cmd">$1</span>')
2021-02-04 11:56:25 -05:00
.replace(/(?<!".*)(\/.*)/g, '<span class="log-path">$1</span>')
2020-04-27 10:07:28 -04:00
.replace(/(\/[\w\d.\-/]+\n)/g, '<span class="log-path">$1</span>')
.replace(/((tcp|https?):\/\/[\w\d.:]+)/g, '<span class="log-url">$1</span>')
.replace(/(\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[0-9,.]+\])/g, '<span class="log-time">$1</span>')
.replace(/\[INFO\]/g, '<span class="log-info">[INFO]</span>')
.replace(/\[WARNING\]/g, '<span class="log-warning">[WARNING]</span>')
.replace(/\[ERROR\]/g, '<span class="log-error">[ERROR]</span>')
.replace(/\[DEBUG\]/g, '<span class="log-debug">[DEBUG]</span>')
}
},
2020-12-03 11:14:02 -05:00
middleware: 'auth',
2020-04-17 09:02:21 -04:00
data () {
return {
2020-05-12 07:07:42 -04:00
logName: 'ffplayout',
currentLog: null,
2021-03-23 08:57:30 -04:00
listDate: this.$dayjs().tz(this.timezone).format('YYYY-MM-DD'),
scrollOP: {
wheelSpeed: 5
}
2020-04-17 09:02:21 -04:00
}
},
computed: {
2021-03-23 08:57:30 -04:00
...mapState('config', ['configID', 'timezone'])
2020-04-17 09:02:21 -04:00
},
2020-05-12 07:07:42 -04:00
watch: {
2021-03-23 16:46:05 -04:00
listDate () {
2020-05-12 07:07:42 -04:00
this.getLog(this.logName)
2021-03-21 10:34:16 -04:00
},
2021-03-23 16:46:05 -04:00
configID () {
2021-03-21 10:34:16 -04:00
this.getLog(this.logName)
2020-05-12 07:07:42 -04:00
}
},
2020-04-17 09:02:21 -04:00
async created () {
2020-04-27 10:07:28 -04:00
await this.getLog('ffplayout')
2020-04-17 09:02:21 -04:00
},
methods: {
2020-04-27 10:07:28 -04:00
async getLog (type) {
2020-05-12 07:07:42 -04:00
this.logName = type
2021-01-03 15:44:05 -05:00
const response = await this.$axios.get(
`api/player/log/?type=${type}&date=${this.listDate}&config_path=${this.$store.state.config.configGui[this.$store.state.config.configID].playout_config}`)
2020-04-27 10:07:28 -04:00
if (response.data.log) {
this.currentLog = response.data.log
} else {
this.currentLog = ''
2020-04-27 10:07:28 -04:00
}
}
2020-04-17 09:02:21 -04:00
}
}
</script>
<style>
.ps__thumb-x {
display: inherit !important;
}
2020-04-27 10:07:28 -04:00
.col-auto {
width: 122px;
height: 100%;
}
.card-container {
height: calc(100% - 90px);
width: 100%;
}
.card-container > div, .tab-content > .active {
height: 100%;
width: 100%;
2020-04-27 10:07:28 -04:00
}
.tab-content {
width: calc(100% - 122px);
height: 100%;
2020-04-27 10:07:28 -04:00
}
.log-container {
background: #1d2024;
max-width: 100%;
width: 100%;
height: 100%;
2020-04-27 10:07:28 -04:00
padding: 1em;
overflow: hidden
2020-04-27 10:07:28 -04:00
}
.log-content {
color: #ececec;
width: 100%;
height: 100%;
font-family: monospace;
font-size: 13px;
white-space: pre;
2020-04-27 10:07:28 -04:00
}
.log-time {
color: #a7a7a7;
}
.log-info {
color: #51d1de;
}
.log-warning {
color: #e4a428;
}
.log-error {
color: #e42e28;
}
.log-debug {
color: #23e493;
}
.log-path {
color: #e366cf;
}
.log-url {
color: #e3d666;
}
.log-cmd {
color: #f1aa77;
}
2020-04-17 09:02:21 -04:00
</style>