Sharkey/src/client/pages/instance/logs.vue
syuilo 11349561d6
Use FontAwesome as web font instead of vue component (#7469)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update yarn.lock

* wip

* wip
2021-04-20 23:22:59 +09:00

91 lines
2.1 KiB
Vue

<template>
<div class="_section">
<div class="_inputs">
<MkInput v-model:value="logDomain" :debounce="true">
<span>{{ $ts.domain }}</span>
</MkInput>
<MkSelect v-model:value="logLevel">
<template #label>{{ $ts.level }}</template>
<option value="all">{{ $ts.levels.all }}</option>
<option value="info">{{ $ts.levels.info }}</option>
<option value="success">{{ $ts.levels.success }}</option>
<option value="warning">{{ $ts.levels.warning }}</option>
<option value="error">{{ $ts.levels.error }}</option>
<option value="debug">{{ $ts.levels.debug }}</option>
</MkSelect>
</div>
<div class="logs">
<code v-for="log in logs" :key="log.id" :class="log.level">
<details>
<summary><MkTime :time="log.createdAt"/> [{{ log.domain.join('.') }}] {{ log.message }}</summary>
<!--<vue-json-pretty v-if="log.data" :data="log.data"></vue-json-pretty>-->
</details>
</code>
</div>
<MkButton @click="deleteAllLogs()" primary><i class="fas fa-trash-alt"></i> {{ $ts.deleteAll }}</MkButton>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import MkButton from '@client/components/ui/button.vue';
import MkInput from '@client/components/ui/input.vue';
import MkSelect from '@client/components/ui/select.vue';
import MkTextarea from '@client/components/ui/textarea.vue';
import * as os from '@client/os';
import * as symbols from '@client/symbols';
export default defineComponent({
components: {
MkButton,
MkInput,
MkSelect,
MkTextarea,
},
data() {
return {
[symbols.PAGE_INFO]: {
title: this.$ts.serverLogs,
icon: 'fas fa-stream'
},
logs: [],
logLevel: 'all',
logDomain: '',
}
},
watch: {
logLevel() {
this.logs = [];
this.fetchLogs();
},
logDomain() {
this.logs = [];
this.fetchLogs();
}
},
created() {
this.fetchLogs();
},
methods: {
fetchLogs() {
os.api('admin/logs', {
level: this.logLevel === 'all' ? null : this.logLevel,
domain: this.logDomain === '' ? null : this.logDomain,
limit: 30
}).then(logs => {
this.logs = logs.reverse();
});
},
deleteAllLogs() {
os.apiWithDialog('admin/delete-logs');
},
}
});
</script>