fix: SAC version from /health in sidebar and dashboard (0.9.4)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
||||||
|
|
||||||
APP_NAME = "Security Alert Center"
|
APP_NAME = "Security Alert Center"
|
||||||
APP_VERSION = "0.9.3"
|
APP_VERSION = "0.9.4"
|
||||||
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
||||||
|
|||||||
@@ -34,10 +34,9 @@ import { computed } from "vue";
|
|||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { clearToken, isAdmin } from "../api";
|
import { clearToken, isAdmin } from "../api";
|
||||||
import SidebarSystemStats from "./SidebarSystemStats.vue";
|
import SidebarSystemStats from "./SidebarSystemStats.vue";
|
||||||
import { APP_NAME, APP_VERSION } from "../version";
|
import { useSacVersion } from "../composables/useSacVersion";
|
||||||
|
|
||||||
const appName = APP_NAME;
|
const { appName, appVersion } = useSacVersion();
|
||||||
const appVersion = APP_VERSION;
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import { APP_NAME, APP_VERSION } from "../version";
|
||||||
|
|
||||||
|
export interface SacVersionInfo {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cached: SacVersionInfo | null = null;
|
||||||
|
let inflight: Promise<SacVersionInfo> | null = null;
|
||||||
|
|
||||||
|
async function fetchSacVersion(): Promise<SacVersionInfo> {
|
||||||
|
if (cached) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
if (inflight) {
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
inflight = (async () => {
|
||||||
|
const fallback: SacVersionInfo = { name: APP_NAME, version: APP_VERSION };
|
||||||
|
try {
|
||||||
|
const response = await fetch("/health");
|
||||||
|
if (!response.ok) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
const data = (await response.json()) as { name?: string; version?: string };
|
||||||
|
const info: SacVersionInfo = {
|
||||||
|
name: (data.name || APP_NAME).trim() || APP_NAME,
|
||||||
|
version: (data.version || APP_VERSION).trim() || APP_VERSION,
|
||||||
|
};
|
||||||
|
cached = info;
|
||||||
|
return info;
|
||||||
|
} catch {
|
||||||
|
return fallback;
|
||||||
|
} finally {
|
||||||
|
inflight = null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Версия SAC с бэкенда (/health); fallback — frontend/src/version.ts */
|
||||||
|
export function useSacVersion() {
|
||||||
|
const appName = ref(APP_NAME);
|
||||||
|
const appVersion = ref(APP_VERSION);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void fetchSacVersion().then((info) => {
|
||||||
|
appName.value = info.name;
|
||||||
|
appVersion.value = info.version;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return { appName, appVersion };
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/** Fallback до загрузки /health; при релизе держите в sync с backend/app/version.py */
|
||||||
export const APP_NAME = "Security Alert Center";
|
export const APP_NAME = "Security Alert Center";
|
||||||
export const APP_VERSION = "0.9.3";
|
export const APP_VERSION = "0.9.4";
|
||||||
export const APP_VERSION_LABEL = `${APP_NAME} v.${APP_VERSION}`;
|
export const APP_VERSION_LABEL = `${APP_NAME} v.${APP_VERSION}`;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="overview-page">
|
<div class="overview-page">
|
||||||
<h1>Обзор</h1>
|
<h1>Обзор</h1>
|
||||||
|
<p class="dashboard-sac-version">{{ appName }} v.{{ appVersion }}</p>
|
||||||
|
|
||||||
<p v-if="error" class="error">{{ error }}</p>
|
<p v-if="error" class="error">{{ error }}</p>
|
||||||
|
|
||||||
@@ -305,8 +306,11 @@
|
|||||||
import { onMounted, onUnmounted, ref } from "vue";
|
import { onMounted, onUnmounted, ref } from "vue";
|
||||||
|
|
||||||
import { apiFetch, getToken, type DashboardSummary, type EventSummary } from "../api";
|
import { apiFetch, getToken, type DashboardSummary, type EventSummary } from "../api";
|
||||||
|
import { useSacVersion } from "../composables/useSacVersion";
|
||||||
import { formatServerName } from "../utils/hostDisplay";
|
import { formatServerName } from "../utils/hostDisplay";
|
||||||
|
|
||||||
|
const { appName, appVersion } = useSacVersion();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const data = ref<DashboardSummary | null>(null);
|
const data = ref<DashboardSummary | null>(null);
|
||||||
@@ -569,6 +573,12 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-sac-version {
|
||||||
|
margin: -0.35rem 0 1rem;
|
||||||
|
color: #9aa4b2;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.dash-recent-hint {
|
.dash-recent-hint {
|
||||||
|
|
||||||
margin: -0.25rem 0 0.75rem;
|
margin: -0.25rem 0 0.75rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user