get log from given date, fix #6

This commit is contained in:
Jonathan Baecker 2020-05-12 13:07:42 +02:00
parent 9888f48c86
commit 9ac74220d4
5 changed files with 39 additions and 16 deletions

View File

@ -1,5 +1,6 @@
import json import json
import os import os
from datetime import date
from platform import uname from platform import uname
from subprocess import PIPE, STDOUT, run from subprocess import PIPE, STDOUT, run
from time import sleep from time import sleep
@ -50,10 +51,14 @@ def write_json(data):
json.dump(data, outfile, indent=4) json.dump(data, outfile, indent=4)
def read_log(type): def read_log(type, _date):
config = read_yaml() config = read_yaml()
log_path = config['logging']['log_path'] log_path = config['logging']['log_path']
log_file = os.path.join(log_path, '{}.log'.format(type))
if _date == date.today():
log_file = os.path.join(log_path, '{}.log'.format(type))
else:
log_file = os.path.join(log_path, '{}.log.{}'.format(type, _date))
if os.path.isfile(log_file): if os.path.isfile(log_file):
with open(log_file, 'r') as log: with open(log_file, 'r') as log:

View File

@ -129,9 +129,11 @@ class SystemCtl(APIView):
class LogReader(APIView): class LogReader(APIView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if 'type' in request.GET.dict(): if 'type' in request.GET.dict() and 'date' in request.GET.dict():
type = request.GET.dict()['type'] type = request.GET.dict()['type']
log = read_log(type) _date = request.GET.dict()['date']
log = read_log(type, _date)
if log: if log:
return Response({'log': log}) return Response({'log': log})

View File

@ -9,6 +9,18 @@
font-style: normal; font-style: normal;
} }
.date-row {
height: 40px;
width: 100%;
padding-top: 5px;
margin: 0;
}
.date-div {
width: 250px;
float: right;
}
.breadcrumb { .breadcrumb {
margin-bottom: .2em; margin-bottom: .2em;
} }

View File

@ -1,6 +1,11 @@
<template> <template>
<div> <div>
<Menu /> <Menu />
<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> <b-card no-body>
<b-tabs pills card vertical> <b-tabs pills card vertical>
<b-tab title="Playout" active @click="getLog('ffplayout')"> <b-tab title="Playout" active @click="getLog('ffplayout')">
@ -61,13 +66,21 @@ export default {
data () { data () {
return { return {
currentLog: null logName: 'ffplayout',
currentLog: null,
listDate: this.$dayjs().format('YYYY-MM-DD')
} }
}, },
computed: { computed: {
}, },
watch: {
listDate (date) {
this.getLog(this.logName)
}
},
async created () { async created () {
await this.getLog('ffplayout') await this.getLog('ffplayout')
}, },
@ -75,7 +88,8 @@ export default {
methods: { methods: {
async getLog (type) { async getLog (type) {
await this.$store.dispatch('auth/inspectToken') await this.$store.dispatch('auth/inspectToken')
const response = await this.$axios.get(`api/player/log/?type=${type}`) this.logName = type
const response = await this.$axios.get(`api/player/log/?type=${type}&date=${this.listDate}`)
if (response.data.log) { if (response.data.log) {
this.currentLog = response.data.log this.currentLog = response.data.log

View File

@ -631,11 +631,6 @@ export default {
} }
} }
.date-row {
height: 44px;
padding-top: 5px;
}
.list-row { .list-row {
height: calc(100% - 40px - 254px - 46px - 70px); height: calc(100% - 40px - 254px - 46px - 70px);
min-height: 300px; min-height: 300px;
@ -645,11 +640,6 @@ export default {
margin: 0; margin: 0;
} }
.date-div {
width: 250px;
float: right;
}
.playlist-container { .playlist-container {
width: 100%; width: 100%;
height: 100%; height: 100%;