List update tasks

This commit is contained in:
Johannes Zellner
2025-01-24 14:09:30 +01:00
parent 63ee99fde9
commit b3736617c4
2 changed files with 21 additions and 4 deletions
+20 -3
View File
@@ -4,10 +4,14 @@ const API_ORIGIN = import.meta.env.VITE_API_ORIGIN ? import.meta.env.VITE_API_OR
import { ref, onMounted, useTemplateRef } from 'vue';
import { Button, Dialog, ProgressBar, Radiobutton, MultiSelect } from 'pankow';
import { prettyLongDate } from 'pankow/utils';
import { TASK_TYPES } from '../constants.js';
import Section from '../components/Section.vue';
import UpdaterModel from '../models/UpdaterModel.js';
import TasksModel from '../models/TasksModel.js';
import DashboardModel from '../models/DashboardModel.js';
const tasksModel = TasksModel.create(API_ORIGIN, localStorage.token);
const updaterModel = UpdaterModel.create(API_ORIGIN, localStorage.token);
const dashboardModel = DashboardModel.create(API_ORIGIN, localStorage.token);
@@ -139,6 +143,19 @@ async function onCheck() {
checkingBusy.value = false;
}
async function refreshTasks() {
const [error, result] = await tasksModel.getByType(TASK_TYPES.TASK_UPDATE);
if (error) return console.error(error);
taskLogsMenu.value = result.map(t => {
return {
icon: 'fa-solid ' + ((!t.active && t.success) ? 'status-active fa-check-circle' : (t.active ? 'fa-circle-notch fa-spin' : 'status-error fa-times-circle')),
label: prettyLongDate(t.ts),
action: () => { window.open(`/logs.html?taskId=${t.id}`); }
};
});
}
onMounted(async () => {
const [error, result] = await dashboardModel.getConfig();
if (error) return console.error(error);
@@ -148,6 +165,7 @@ onMounted(async () => {
await refreshInfo();
await refreshAutoupdatePattern();
await refreshTasks();
});
</script>
@@ -173,7 +191,7 @@ onMounted(async () => {
<div>{{ $t('settings.updateScheduleDialog.days') }}: <MultiSelect v-model="configureDays" :options="cronDays" option-label="name" /></div>
<div>{{ $t('settings.updateScheduleDialog.hours') }}: <MultiSelect v-model="configureHours" :options="cronHours" option-label="name" /></div>
</div>
<!-- <span class="label label-danger" ng-show="updateSchedule.type === 'pattern' && !updateSchedule.isScheduleValid()">{{ 'settings.updateScheduleDialog.selectOne' | tr }}</span> -->
<!-- TODO <span class="label label-danger" ng-show="updateSchedule.type === 'pattern' && !updateSchedule.isScheduleValid()">{{ 'settings.updateScheduleDialog.selectOne' | tr }}</span> -->
</Dialog>
<Section :title="$t('settings.updates.title')">
@@ -194,7 +212,7 @@ onMounted(async () => {
<div class="info-value actionable" @click="onShowConfigure()">
<span v-show="currentPattern !== 'never'">{{ prettyAutoUpdateSchedule(currentPattern) }}</span>
<span v-show="currentPattern === 'never'">{{ $t('settings.updates.disabled') }}</span>
<i class="fa-solid fa-edit text-small"></i>
<i class="fa-solid fa-edit text-small" style="margin-left: 10px;"></i>
</div>
</div>
@@ -204,7 +222,6 @@ onMounted(async () => {
<Button danger v-show="updateBusy" @click="onStop()">{{ $t('settings.updates.stopUpdateAction') }}</Button>
<Button v-show="!pendingUpdate" :disabled="checkingBusy" :loading="checkingBusy" @click="onCheck()">{{ $t('settings.updates.checkForUpdatesAction') }}</Button>
<Button :danger="(pendingUpdate && pendingUpdate.unstable) ? true : undefined" :success="(pendingUpdate && !pendingUpdate.unstable) ? true : undefined" v-show="pendingUpdate && pendingUpdate.version !== version && !updateBusy" @click="onShowUpdate()">{{ $t('settings.updates.updateAvailableAction') }}</Button>
</Section>
</div>
</template>