Pick up latest disk usage refresh task on page reload
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { Button } from 'pankow';
|
||||
import { prettyDecimalSize, prettyDate } from 'pankow/utils';
|
||||
import { TASK_TYPES } from '../constants.js';
|
||||
import Section from './Section.vue';
|
||||
import SystemModel from '../models/SystemModel.js';
|
||||
import AppsModel from '../models/AppsModel.js';
|
||||
@@ -17,6 +18,7 @@ const tasksModel = TasksModel.create();
|
||||
const busy = ref(false);
|
||||
const lastUpdated = ref(0);
|
||||
const disks = ref([]);
|
||||
const ready = ref(false);
|
||||
|
||||
async function updateTaskStatus(id) {
|
||||
const [error, result] = await tasksModel.get(id);
|
||||
@@ -155,7 +157,15 @@ async function refresh() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const [error, result] = await tasksModel.getLatestByType(TASK_TYPES.TASK_UPDATE_DISK_USAGE);
|
||||
if (!error && result.active) {
|
||||
busy.value = true;
|
||||
updateTaskStatus(result.id);
|
||||
}
|
||||
|
||||
await refresh();
|
||||
|
||||
ready.value = true;
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -164,7 +174,7 @@ onMounted(async () => {
|
||||
<Section :title="$t('system.diskUsage.title')">
|
||||
<template #header-buttons>
|
||||
<span class="small" style="margin: auto; margin-right: 10px" v-show="!busy && lastUpdated">Last updated: {{ prettyDate(lastUpdated) }}</span>
|
||||
<Button tool @click="onRescan()" :disabled="busy" :loading="busy" icon="fa-solid fa-sync-alt" />
|
||||
<Button tool @click="onRescan()" v-if="ready" :disabled="busy" :loading="busy" icon="fa-solid fa-sync-alt" />
|
||||
</template>
|
||||
|
||||
<div v-for="(disk, index) in disks" :key="disk.filesystem">
|
||||
|
||||
Reference in New Issue
Block a user