|
13 | 13 | step="1" |
14 | 14 | thumb-label="always" |
15 | 15 | /> |
| 16 | + <v-data-table :items="systemLogsData" :headers="headers" class="max-w-[80%] max-h-[60%]"> |
| 17 | + <template #item.actions="{ item }"> |
| 18 | + <div class="text-center cursor-pointer icon-btn mdi mdi-download" @click="downloadLog(item.name)" /> |
| 19 | + </template> |
| 20 | + </v-data-table> |
16 | 21 | </template> |
17 | 22 | </BaseConfigurationView> |
18 | 23 | </template> |
19 | 24 |
|
20 | 25 | <script setup lang="ts"> |
| 26 | +import { saveAs } from 'file-saver' |
| 27 | +import { onBeforeMount } from 'vue' |
| 28 | +import { ref } from 'vue' |
| 29 | +
|
| 30 | +import { type SystemLog, cockpitSytemLogsDB } from '@/libs/system-logging' |
21 | 31 | import { useDevelopmentStore } from '@/stores/development' |
22 | 32 |
|
23 | 33 | import BaseConfigurationView from './BaseConfigurationView.vue' |
24 | | -
|
25 | 34 | const devStore = useDevelopmentStore() |
| 35 | +
|
| 36 | +const systemLogsData = ref<Record<string, string | number>[]>([]) |
| 37 | +
|
| 38 | +const headers = [ |
| 39 | + { title: 'Name', value: 'name' }, |
| 40 | + { title: 'Time (initial)', value: 'initialTime' }, |
| 41 | + { title: 'Date (initial)', value: 'initialDate' }, |
| 42 | + { title: 'N. events', value: 'nEvents' }, |
| 43 | + { title: 'Actions', value: 'actions' }, |
| 44 | +] |
| 45 | +
|
| 46 | +onBeforeMount(async () => { |
| 47 | + await cockpitSytemLogsDB.iterate((log: SystemLog, logName) => { |
| 48 | + systemLogsData.value.push({ |
| 49 | + name: logName, |
| 50 | + initialTime: log.initialTime, |
| 51 | + initialDate: log.initialDate, |
| 52 | + nEvents: log.events.length, |
| 53 | + }) |
| 54 | + }) |
| 55 | + console.log(systemLogsData.value) |
| 56 | +}) |
| 57 | +
|
| 58 | +const downloadLog = async (logName: string): Promise<void> => { |
| 59 | + const log = await cockpitSytemLogsDB.getItem(logName) |
| 60 | + const logParts = JSON.stringify(log, null, 2) |
| 61 | + const logBlob = new Blob([logParts], { type: 'application/json' }) |
| 62 | + saveAs(logBlob, logName) |
| 63 | +} |
26 | 64 | </script> |
0 commit comments