ffplayout/pages/logging.vue

124 lines
2.6 KiB
Vue
Raw Normal View History

2020-04-17 09:02:21 -04:00
<template>
2024-04-16 12:13:28 -04:00
<div>
<div class="flex justify-end p-3 h-14">
<div>
<VueDatePicker
v-model="listDate"
:clearable="false"
:hide-navigation="['time']"
:action-row="{ showCancel: false, showSelect: false, showPreview: false }"
:format="calendarFormat"
model-type="yyyy-MM-dd"
auto-apply
2024-04-13 18:01:45 -04:00
:locale="locale"
2024-04-09 11:21:13 -04:00
:dark="colorMode.value === 'dark'"
2024-04-17 06:32:07 -04:00
input-class-name="input input-sm !input-bordered !w-[300px] text-right !pe-3"
required
/>
2024-04-16 12:13:28 -04:00
</div>
</div>
<div class="px-3 inline-block h-[calc(100vh-140px)] text-[13px]">
<div class="bg-base-300 whitespace-pre h-full font-mono overflow-auto p-3" v-html="formatLog(currentLog)" />
2023-01-11 04:54:25 -05:00
</div>
2024-04-05 12:51:50 -04:00
</div>
2020-04-17 09:02:21 -04:00
</template>
2023-01-11 04:54:25 -05:00
<script setup lang="ts">
2023-03-22 11:01:58 -04:00
import { storeToRefs } from 'pinia'
2023-01-11 04:54:25 -05:00
const colorMode = useColorMode()
2024-04-16 08:07:50 -04:00
const { locale, t } = useI18n()
2023-01-11 04:54:25 -05:00
useHead({
2024-04-16 08:07:50 -04:00
title: `${t('button.logging')} | ffplayout`,
2023-01-11 04:54:25 -05:00
})
2023-03-22 11:01:58 -04:00
const { configID } = storeToRefs(useConfig())
2023-01-11 04:54:25 -05:00
const { $dayjs } = useNuxtApp()
const authStore = useAuth()
const configStore = useConfig()
const currentLog = ref('')
const listDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
const { formatLog } = stringFormatter()
2023-03-22 11:01:58 -04:00
onMounted(() => {
getLog()
})
watch([listDate, configID], () => {
getLog()
})
const calendarFormat = (date: Date) => {
2024-04-15 11:39:41 -04:00
return $dayjs(date).locale(locale.value).format('dddd - LL')
}
2023-01-11 04:54:25 -05:00
async function getLog() {
let date = listDate.value
if (date === $dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD')) {
date = ''
2020-04-17 09:02:21 -04:00
}
2023-01-11 04:54:25 -05:00
await fetch(`/api/log/${configStore.configGui[configStore.configID].id}?date=${date}`, {
2023-01-11 04:54:25 -05:00
method: 'GET',
headers: authStore.authHeader,
})
.then((response) => response.text())
.then((data) => {
currentLog.value = data
})
.catch(() => {
currentLog.value = ''
})
2020-04-17 09:02:21 -04:00
}
</script>
<style>
.log-time {
color: #666864;
}
.log-number {
2024-04-15 11:39:41 -04:00
color: var(--my-yellow);
}
.log-addr {
2024-04-15 11:39:41 -04:00
color: var(--my-purple);
font-weight: 500;
}
.log-cmd {
2024-04-15 11:39:41 -04:00
color: var(--my-blue);
}
2020-04-27 10:07:28 -04:00
.log-info {
2024-04-15 11:39:41 -04:00
color: var(--my-green);
2020-04-27 10:07:28 -04:00
}
.log-warning {
color: #ff8700;
2020-04-27 10:07:28 -04:00
}
.log-error {
color: #d32828;
2020-04-27 10:07:28 -04:00
}
.log-debug {
color: #6e99c7;
2020-04-27 10:07:28 -04:00
}
2022-01-25 04:32:29 -05:00
.log-decoder {
color: #56efff;
2022-01-25 04:32:29 -05:00
}
.log-encoder {
color: #45ccee;
2022-01-25 04:32:29 -05:00
}
.log-server {
color: #23cbdd;
2022-01-25 04:32:29 -05:00
}
2020-04-17 09:02:21 -04:00
</style>