Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align frontend type contracts with normalized data

rcourtmanf919a241867f
diff --git a/frontend-modern/src/api/connections.ts b/frontend-modern/src/api/connections.ts
index 120342e801..88c3f8c624 100644
--- a/frontend-modern/src/api/connections.ts
+++ b/frontend-modern/src/api/connections.ts
@@ -93,6 +93,11 @@ export interface ConnectionSystem {
export interface ConnectionsListResponse {
connections: Connection[];
+ systems: ConnectionSystem[];
+}
+
+interface ConnectionsListWireResponse {
+ connections?: Connection[];
systems?: ConnectionSystem[];
}
@@ -116,7 +121,7 @@ export class ConnectionsAPI {
private static readonly baseUrl = '/api/connections';
static async list(): Promise<ConnectionsListResponse> {
- const response: ConnectionsListResponse = await apiFetchJSON(this.baseUrl);
+ const response: ConnectionsListWireResponse = await apiFetchJSON(this.baseUrl);
return {
connections: response.connections ?? [],
systems: response.systems ?? [],
diff --git a/frontend-modern/src/api/orgs.ts b/frontend-modern/src/api/orgs.ts
index e1eae11e7c..1a2c301bd7 100644
--- a/frontend-modern/src/api/orgs.ts
+++ b/frontend-modern/src/api/orgs.ts
@@ -17,11 +17,17 @@ export interface OrganizationInvitation {
invitedBy: string;
}
-export interface OrganizationAccessMutationResult {
- kind: 'member' | 'invitation';
- member?: OrganizationMember;
- invitation?: OrganizationInvitation;
-}
+export type OrganizationAccessMutationResult =
+ | {
+ kind: 'member';
+ member: OrganizationMember;
+ invitation?: never;
+ }
+ | {
+ kind: 'invitation';
+ invitation: OrganizationInvitation;
+ member?: never;
+ };
export interface UserOrganizationInvitation extends OrganizationInvitation {
orgId: string;
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsPanelRegistryContext.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsPanelRegistryContext.test.ts
index aabbb3a48e..6e68023ae0 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsPanelRegistryContext.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsPanelRegistryContext.test.ts
@@ -36,7 +36,8 @@ function buildParams(
savingHideLocalLogin: () => false,
handleHideLocalLoginChange: vi.fn(async () => undefined),
versionInfo: () => null,
- getInfrastructurePanelProps: () => ({}),
+ getInfrastructurePanelProps: () =>
+ ({} as ReturnType<UseSettingsPanelRegistryParams['getInfrastructurePanelProps']>),
systemPanels,
};
}
diff --git a/frontend-modern/src/components/Settings/__tests__/useDiagnosticsPanelState.test.ts b/frontend-modern/src/components/Settings/__tests__/useDiagnosticsPanelState.test.ts
index 9de992bc73..6534c8be95 100644
--- a/frontend-modern/src/components/Settings/__tests__/useDiagnosticsPanelState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useDiagnosticsPanelState.test.ts
@@ -3,6 +3,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { DiagnosticsData } from '@/components/Settings/diagnosticsModel';
type UseDiagnosticsPanelStateModule = typeof import('../useDiagnosticsPanelState');
+type URLStaticWithBlobMethods = {
+ createObjectURL?: typeof URL.createObjectURL;
+ revokeObjectURL?: typeof URL.revokeObjectURL;
+};
const createDiagnosticsData = (): DiagnosticsData => ({
version: '6.0.0',
@@ -135,7 +139,7 @@ describe('useDiagnosticsPanelState', () => {
value: originalCreateObjectURL,
});
} else {
- delete (URL as URL & { createObjectURL?: typeof URL.createObjectURL }).createObjectURL;
+ delete (URL as unknown as URLStaticWithBlobMethods).createObjectURL;
}
if (originalRevokeObjectURL) {
Object.defineProperty(URL, 'revokeObjectURL', {
@@ -143,7 +147,7 @@ describe('useDiagnosticsPanelState', () => {
value: originalRevokeObjectURL,
});
} else {
- delete (URL as URL & { revokeObjectURL?: typeof URL.revokeObjectURL }).revokeObjectURL;
+ delete (URL as unknown as URLStaticWithBlobMethods).revokeObjectURL;
}
vi.restoreAllMocks();
vi.resetModules();
diff --git a/frontend-modern/src/components/Settings/__tests__/useSettingsInfrastructurePanelProps.test.ts b/frontend-modern/src/components/Settings/__tests__/useSettingsInfrastructurePanelProps.test.ts
index db4ce7e52a..a0260b0d86 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSettingsInfrastructurePanelProps.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useSettingsInfrastructurePanelProps.test.ts
@@ -51,10 +51,14 @@ const mountHook = (
resources: () => resources,
discoverySettings: {
discoveryEnabled: () => false,
+ setDiscoveryEnabled: () => false,
+ discoverySubnet: () => 'auto',
discoveryMode: () => 'auto',
discoverySubnetDraft: () => '',
+ lastCustomSubnet: () => '',
discoverySubnetError: () => undefined,
savingDiscoverySettings: () => false,
+ setSavingDiscoverySettings: () => false,
setDiscoveryMode: () => 'auto',
setDiscoverySubnetDraft: () => '',
setDiscoverySubnetError: () => undefined,
@@ -63,7 +67,9 @@ const mountHook = (
normalizeSubnetList: (value: string) => value,
isValidCIDR: () => true,
currentDraftSubnetValue: () => '',
+ applySavedDiscoverySubnet: () => undefined,
assignDiscoverySubnetInputRef: () => undefined,
+ getDiscoverySubnetInputRef: () => undefined,
} as Parameters<typeof useSettingsInfrastructurePanelProps>[0]['discoverySettings'],
systemSettings: {
envOverrides: () => ({}),
diff --git a/frontend-modern/src/components/Settings/diagnosticsModel.ts b/frontend-modern/src/components/Settings/diagnosticsModel.ts
index 15a5dd722c..41c9c59b51 100644
--- a/frontend-modern/src/components/Settings/diagnosticsModel.ts
+++ b/frontend-modern/src/components/Settings/diagnosticsModel.ts
@@ -42,6 +42,20 @@ export interface DiscoveryDiagnostic {
lastResultTimestamp?: string;
lastResultServers?: number;
lastResultErrors?: number;
+ history?: DiscoveryHistoryDiagnostic[];
+}
+
+export interface DiscoveryHistoryDiagnostic {
+ startedAt?: string;
+ completedAt?: string;
+ duration?: string;
+ durationMs?: number;
+ subnet?: string;
+ serverCount?: number;
+ errorCount?: number;
+ blocklistLength?: number;
+ status?: string;
+ [key: string]: unknown;
}
export interface APITokenDiagnostic {
@@ -246,11 +260,8 @@ export function sanitizeDiagnosticsData(raw: DiagnosticsData): DiagnosticsData {
subnetBlocklist: data.discovery.subnetBlocklist?.map(() => '[REDACTED_SUBNET]'),
};
- const discovery = data.discovery as DiscoveryDiagnostic & {
- history?: Array<Record<string, unknown>>;
- };
- if (Array.isArray(discovery.history)) {
- discovery.history = discovery.history.map((historyEntry) => ({
+ if (Array.isArray(data.discovery.history)) {
+ data.discovery.history = data.discovery.history.map((historyEntry) => ({
...historyEntry,
subnet: '[REDACTED_SUBNET]',
}));
diff --git a/frontend-modern/src/components/Settings/useOrganizationAccessPanelState.ts b/frontend-modern/src/components/Settings/useOrganizationAccessPanelState.ts
index c391719156..747e617d3d 100644
--- a/frontend-modern/src/components/Settings/useOrganizationAccessPanelState.ts
+++ b/frontend-modern/src/components/Settings/useOrganizationAccessPanelState.ts
@@ -125,7 +125,9 @@ export function useOrganizationAccessPanelState(props: OrganizationAccessPanelPr
const result = await OrgsAPI.inviteMember(currentOrg.id, { userId, role });
if (result.kind === 'invitation') {
- notificationStore.success(getOrganizationAccessInvitationSentMessage(userId, role));
+ notificationStore.success(
+ getOrganizationAccessInvitationSentMessage(userId, result.invitation.role),
+ );
} else {
notificationStore.success(getOrganizationAccessMemberAddedMessage(userId, role));
}
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index f862a53249..431d24c3b4 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -207,6 +207,10 @@ describe('shared storage override migration', () => {
displayName: 'ceph-pool',
type: 'storage',
platformId: 'Main',
+ platformType: 'proxmox-pve',
+ sourceType: 'api',
+ status: 'online',
+ lastSeen: Date.now(),
proxmox: {
instance: 'Main',
node: 'cluster',