From 91ba78c19b9ea21bfae71b394ab644aa8f29aa7a Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Tue, 14 Apr 2026 09:49:02 +0200 Subject: [PATCH] refactor web project structure --- .../app/admin/AdminConfigContext.tsx | 35 ++----------------- .../components/AdminConfigSettingsSection.tsx | 15 +------- .../components/VulnerabilityDataSection.tsx | 18 +--------- .../types/adminConfig.ts | 30 ++++++++++++++++ src/Web/autopilot-monitor-web/types/index.ts | 1 + 5 files changed, 36 insertions(+), 63 deletions(-) create mode 100644 src/Web/autopilot-monitor-web/types/adminConfig.ts diff --git a/src/Web/autopilot-monitor-web/app/admin/AdminConfigContext.tsx b/src/Web/autopilot-monitor-web/app/admin/AdminConfigContext.tsx index 2188d16c..d7ff7500 100644 --- a/src/Web/autopilot-monitor-web/app/admin/AdminConfigContext.tsx +++ b/src/Web/autopilot-monitor-web/app/admin/AdminConfigContext.tsx @@ -4,33 +4,10 @@ import { createContext, useCallback, useContext, useEffect, useState } from "rea import { useAuth } from "../../contexts/AuthContext"; import { api } from "@/lib/api"; import { authenticatedFetch, TokenExpiredError } from "@/lib/authenticatedFetch"; +import type { AdminConfiguration, OpsAlertRule } from "@/types/adminConfig"; -// Re-export for section components -export interface AdminConfiguration { - partitionKey: string; - rowKey: string; - lastUpdated: string; - updatedBy: string; - globalRateLimitRequestsPerMinute: number; - platformStatsBlobSasUrl?: string; - collectorIdleTimeoutMinutes?: number; - maxSessionWindowHours?: number; - maintenanceBlockDurationHours?: number; - opsEventRetentionDays?: number; - diagnosticsGlobalLogPathsJson?: string; - customSettings?: string; - nvdApiKey?: string; - vulnerabilityCorrelationEnabled?: boolean; - vulnerabilityDataLastSyncUtc?: string; - // Ops Alert settings - opsAlertRulesJson?: string; - opsAlertTelegramEnabled?: boolean; - opsAlertTelegramChatId?: string; - opsAlertTeamsEnabled?: boolean; - opsAlertTeamsWebhookUrl?: string; - opsAlertSlackEnabled?: boolean; - opsAlertSlackWebhookUrl?: string; -} +// Re-export so existing `import { AdminConfiguration } from "../AdminConfigContext"` consumers keep working +export type { AdminConfiguration, OpsAlertRule }; interface AdminConfigContextValue { // Admin config @@ -103,12 +80,6 @@ interface AdminConfigContextValue { import { type DiagnosticsLogPath } from "./components/DiagnosticsLogPathsSection"; import { type TenantConfiguration } from "./components/TenantManagementSection"; -export interface OpsAlertRule { - eventType: string; - minSeverity: string; - enabled: boolean; -} - const AdminConfigContext = createContext(null); export function useAdminConfig() { diff --git a/src/Web/autopilot-monitor-web/app/admin/components/AdminConfigSettingsSection.tsx b/src/Web/autopilot-monitor-web/app/admin/components/AdminConfigSettingsSection.tsx index b2693b1d..6a169819 100644 --- a/src/Web/autopilot-monitor-web/app/admin/components/AdminConfigSettingsSection.tsx +++ b/src/Web/autopilot-monitor-web/app/admin/components/AdminConfigSettingsSection.tsx @@ -1,19 +1,6 @@ "use client"; -interface AdminConfiguration { - partitionKey: string; - rowKey: string; - lastUpdated: string; - updatedBy: string; - globalRateLimitRequestsPerMinute: number; - platformStatsBlobSasUrl?: string; - collectorIdleTimeoutMinutes?: number; - maxSessionWindowHours?: number; - maintenanceBlockDurationHours?: number; - opsEventRetentionDays?: number; - diagnosticsGlobalLogPathsJson?: string; - customSettings?: string; -} +import type { AdminConfiguration } from "@/types/adminConfig"; interface AdminConfigSettingsSectionProps { loadingConfig: boolean; diff --git a/src/Web/autopilot-monitor-web/app/admin/components/VulnerabilityDataSection.tsx b/src/Web/autopilot-monitor-web/app/admin/components/VulnerabilityDataSection.tsx index 8629976a..15c51684 100644 --- a/src/Web/autopilot-monitor-web/app/admin/components/VulnerabilityDataSection.tsx +++ b/src/Web/autopilot-monitor-web/app/admin/components/VulnerabilityDataSection.tsx @@ -4,23 +4,7 @@ import { useCallback, useState } from "react"; import { api } from "@/lib/api"; import { authenticatedFetch, TokenExpiredError } from "@/lib/authenticatedFetch"; import SaveResetBar from "../../settings/components/SaveResetBar"; - -interface AdminConfiguration { - partitionKey: string; - rowKey: string; - lastUpdated: string; - updatedBy: string; - globalRateLimitRequestsPerMinute: number; - platformStatsBlobSasUrl?: string; - collectorIdleTimeoutMinutes?: number; - maxSessionWindowHours?: number; - maintenanceBlockDurationHours?: number; - diagnosticsGlobalLogPathsJson?: string; - customSettings?: string; - nvdApiKey?: string; - vulnerabilityCorrelationEnabled?: boolean; - vulnerabilityDataLastSyncUtc?: string; -} +import type { AdminConfiguration } from "@/types/adminConfig"; interface VulnerabilityDataSectionProps { adminConfig: AdminConfiguration | null; diff --git a/src/Web/autopilot-monitor-web/types/adminConfig.ts b/src/Web/autopilot-monitor-web/types/adminConfig.ts new file mode 100644 index 00000000..d8fcc624 --- /dev/null +++ b/src/Web/autopilot-monitor-web/types/adminConfig.ts @@ -0,0 +1,30 @@ +export interface AdminConfiguration { + partitionKey: string; + rowKey: string; + lastUpdated: string; + updatedBy: string; + globalRateLimitRequestsPerMinute: number; + platformStatsBlobSasUrl?: string; + collectorIdleTimeoutMinutes?: number; + maxSessionWindowHours?: number; + maintenanceBlockDurationHours?: number; + opsEventRetentionDays?: number; + diagnosticsGlobalLogPathsJson?: string; + customSettings?: string; + nvdApiKey?: string; + vulnerabilityCorrelationEnabled?: boolean; + vulnerabilityDataLastSyncUtc?: string; + opsAlertRulesJson?: string; + opsAlertTelegramEnabled?: boolean; + opsAlertTelegramChatId?: string; + opsAlertTeamsEnabled?: boolean; + opsAlertTeamsWebhookUrl?: string; + opsAlertSlackEnabled?: boolean; + opsAlertSlackWebhookUrl?: string; +} + +export interface OpsAlertRule { + eventType: string; + minSeverity: string; + enabled: boolean; +} diff --git a/src/Web/autopilot-monitor-web/types/index.ts b/src/Web/autopilot-monitor-web/types/index.ts index a18a37a6..3abb7dfe 100644 --- a/src/Web/autopilot-monitor-web/types/index.ts +++ b/src/Web/autopilot-monitor-web/types/index.ts @@ -1,2 +1,3 @@ export type { Session } from "./session"; export type { EnrollmentEvent, RuleResult } from "./enrollment"; +export type { AdminConfiguration, OpsAlertRule } from "./adminConfig";