fix(ui): show the last update's outcome on Settings > Status and present install as staged
This commit is contained in:
1 parent
2615a26760
commit
4b98919ca3
2 files changed
+98
-59
No files matched your search
@@ -12,7 +12,9 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { ApiError, api } from "@/lib/api";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
|
||||
/**
|
||||
* Per-component versions and the update that applies them: /api/version reports
|
||||
@@ -42,6 +44,8 @@ const installing = ref(false);
|
||||
const installProgress = ref<string[]>([]);
|
||||
const installResult = ref<string | null>(null);
|
||||
const installError = ref<string | null>(null);
|
||||
const outcome = ref<{ at: string; summary: string; failed: boolean } | null>(null);
|
||||
const outcomeError = ref<string | null>(null);
|
||||
|
||||
const updateable = computed(() =>
|
||||
components.value.filter((c) => c.status === "update_available"),
|
||||
@@ -93,6 +97,32 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// The last update's outcome is the update_report event the watchdog records
|
||||
// after it restarts and health-checks the daemon.
|
||||
async function loadOutcome(): Promise<void> {
|
||||
try {
|
||||
const page = await api.audit<{
|
||||
records: {
|
||||
at: string;
|
||||
summary: string;
|
||||
detail: { data: { health_check?: string; rolled_back?: boolean } | null };
|
||||
}[];
|
||||
}>({ actions: "update_report", limit: 1 });
|
||||
const last = page.records[0];
|
||||
const data = last?.detail.data;
|
||||
outcome.value = last
|
||||
? {
|
||||
at: last.at,
|
||||
summary: last.summary,
|
||||
failed: !!data?.rolled_back || data?.health_check !== "passed",
|
||||
}
|
||||
: null;
|
||||
outcomeError.value = null;
|
||||
} catch (err) {
|
||||
outcomeError.value = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
}
|
||||
|
||||
// The snapshot the install endpoint demands is the one the operator saw: the
|
||||
// endpoint re-checks freshness and answers 409 when releases moved.
|
||||
function installableSnapshot(): unknown {
|
||||
@@ -118,6 +148,7 @@ async function install(): Promise<void> {
|
||||
.map(([id, version]) => `${id} → ${version}`)
|
||||
.join(", ")
|
||||
: "update finished";
|
||||
installResult.value = `Staged: ${installResult.value}. The outcome appears below after the restart.`;
|
||||
await load();
|
||||
} catch (err) {
|
||||
installError.value = err instanceof Error ? err.message : String(err);
|
||||
@@ -126,7 +157,11 @@ async function install(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
onMounted(() => {
|
||||
void load();
|
||||
void loadOutcome();
|
||||
});
|
||||
useLiveResource("updates", () => void loadOutcome());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -171,6 +206,10 @@ onMounted(load);
|
||||
<p v-if="installResult" class="mt-2 text-sm text-ok">
|
||||
{{ installResult }}
|
||||
</p>
|
||||
<p v-if="outcome" class="mt-2 text-sm" :class="outcome.failed ? 'text-danger' : 'text-ok'">
|
||||
<Timestamp :at="outcome.at" /> {{ outcome.summary }}
|
||||
</p>
|
||||
<p v-if="outcomeError" class="mt-2 text-sm text-danger">{{ outcomeError }}</p>
|
||||
<p v-if="installError" class="mt-2 text-sm text-danger">
|
||||
{{ installError }}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user