diff --git a/apps/desktop/src/components/admin/PostgresDashboard.vue b/apps/desktop/src/components/admin/PostgresDashboard.vue index f1c8a5620..41a00e019 100644 --- a/apps/desktop/src/components/admin/PostgresDashboard.vue +++ b/apps/desktop/src/components/admin/PostgresDashboard.vue @@ -9,23 +9,7 @@ import { useConnectionStore } from "@/stores/connectionStore"; import MetricCard from "@/components/common/MetricCard.vue"; import MetricLineChart from "@/components/chart/MetricLineChart.vue"; import * as api from "@/lib/backend/api"; -import { - computePgTps, - computeRate, - formatBytesPerSec, - formatNumber, - formatRate, - formatUptime, - isPgStatusCompatibilityError, - MAX_SAMPLES, - parsePgStatusRow, - pgCacheHitRatio, - PG_STATUS_LEGACY_SQL, - PG_STATUS_SQL, - PG_VARIABLES_SQL, - statusNumber, - type StatusSample, -} from "@/lib/database/postgresServerStatus"; +import { computePgTps, computeRate, formatBytesPerSec, formatNumber, formatRate, formatUptime, MAX_SAMPLES, parsePgStatusRow, pgCacheHitRatio, resolveServerDashboardDriverForConnection, statusNumber, type StatusSample } from "@/lib/database/postgresServerStatus"; import { useVerticalOverlayScrollbar } from "@/composables/useVerticalOverlayScrollbar"; const props = defineProps<{ @@ -58,7 +42,9 @@ const { const fallbackStatusSql = ref(null); let refreshTimer: ReturnType | null = null; -const connectionName = computed(() => connectionStore.getConfig(props.connectionId)?.name ?? ""); +const connection = computed(() => connectionStore.getConfig(props.connectionId)); +const statusDriver = computed(() => resolveServerDashboardDriverForConnection(connection.value)); +const connectionName = computed(() => connection.value?.name ?? ""); const latest = computed(() => samples.value[samples.value.length - 1]); const previous = computed(() => (samples.value.length >= 2 ? samples.value[samples.value.length - 2] : undefined)); @@ -138,8 +124,10 @@ function formatClock(at: number): string { } async function fetchVariables() { + const activeDriver = statusDriver.value; + if (!activeDriver) return; try { - const result = await api.executeQuery(props.connectionId, "", PG_VARIABLES_SQL, undefined, undefined, { maxRows: 2000 }); + const result = await api.executeQuery(props.connectionId, "", activeDriver.variablesSql, undefined, undefined, { maxRows: 2000 }); variables.value = parsePgStatusRow(result); } catch { // Non-fatal: cards that depend on variables (max_connections/version) degrade. @@ -147,20 +135,22 @@ async function fetchVariables() { } async function fetchStatus(options: { silent?: boolean } = {}) { + const activeDriver = statusDriver.value; + if (!activeDriver) return; if (fetching.value) return; fetching.value = true; if (!options.silent) loading.value = true; error.value = ""; try { await connectionStore.ensureConnected(props.connectionId); - const sql = fallbackStatusSql.value ?? PG_STATUS_SQL; + const sql = fallbackStatusSql.value ?? activeDriver.statusSql; let result; try { result = await api.executeQuery(props.connectionId, "", sql, undefined, undefined, { maxRows: 2000 }); } catch (queryError) { - if (fallbackStatusSql.value || !isPgStatusCompatibilityError(queryError)) throw queryError; - result = await api.executeQuery(props.connectionId, "", PG_STATUS_LEGACY_SQL, undefined, undefined, { maxRows: 2000 }); - fallbackStatusSql.value = PG_STATUS_LEGACY_SQL; + if (fallbackStatusSql.value || !activeDriver.fallbackStatusSql || !activeDriver.shouldUseFallbackStatusSql?.(queryError)) throw queryError; + result = await api.executeQuery(props.connectionId, "", activeDriver.fallbackStatusSql, undefined, undefined, { maxRows: 2000 }); + fallbackStatusSql.value = activeDriver.fallbackStatusSql; } const sample: StatusSample = { at: Date.now(), status: parsePgStatusRow(result) }; const next = [...samples.value, sample]; @@ -212,8 +202,8 @@ onUnmounted(stopAutoRefresh);
{{ t("serverDashboard.title") }}
- {{ connectionName }} - {{ serverVersion }} + {{ connectionName }} + {{ serverVersion }}
{{ t("serverDashboard.autoRefresh") }}