feat(admin-ui): introduce view layer and refactor admin UI to use view components, consolidate demos, and update interfaces

This commit is contained in:
2025-12-27 12:33:14 +00:00
parent 87ac6e506f
commit c5632dae77
18 changed files with 875 additions and 754 deletions

View File

@@ -1,19 +1,63 @@
// Re-export interfaces from the public catalog for consistency
// ============================================
// Re-export shared types from @uptime.link/interfaces
// ============================================
// Status types
export type TStatusType = 'operational' | 'degraded' | 'partial_outage' | 'major_outage' | 'maintenance' | 'initializing' | 'error' | 'paused';
export type TCheckType = 'assumption' | 'function' | 'pwa' | 'pagerank';
export type TStatusMode = 'auto' | 'manual';
import { data } from '@uptime.link/interfaces';
// Check configuration interface
// Re-export core types
export type TStatusType = data.TStatusType;
export type TCheckType = data.TCheckType;
export type TStatusMode = data.TStatusMode;
export type TIncidentSeverity = data.TIncidentSeverity;
export type TIncidentStatus = data.TIncidentStatus;
export type TCheckResultStatus = data.TCheckResultStatus;
export type TCheckLastResult = data.TCheckLastResult;
// Re-export check configuration interfaces
export type ICheckBase = data.ICheckBase;
export type IAssumptionCheckConfig = data.IAssumptionCheckConfig;
export type IFunctionCheckConfig = data.IFunctionCheckConfig;
export type IPwaCheckConfig = data.IPwaCheckConfig;
export type IPageRankCheckConfig = data.IPageRankCheckConfig;
export type TCheckConfig = data.TCheckConfig;
// Re-export check execution interfaces
export type IAssumptionCheck = data.IAssumptionCheck;
export type IFunctionCheck = data.IFunctionCheck;
export type IPwaCheck = data.IPwaCheck;
export type IPageRankCheck = data.IPageRankCheck;
export type ICheckCollection = data.ICheckCollection;
// Re-export incident interfaces
export type IIncident = data.IIncident;
export type IIncidentUpdateBase = data.IIncidentUpdate;
// Re-export status page config
export type IServiceGroup = data.IServiceGroup;
// ============================================
// Extended/UI-specific Interfaces
// ============================================
/**
* Flat check configuration for forms.
* Maps to TCheckConfig discriminated union when saving.
*/
export interface ICheckConfig {
domain: string;
// Assumption check fields
expectedTitle?: string;
expectedStatusCode?: string;
expectedDescription?: string;
assumedStatus?: TStatusType;
// Function check fields
functionDef?: string;
functionUrl?: string;
expectedStatusCodeNum?: number;
timeoutMs?: number;
// PWA check fields
targetUrl?: string;
lighthouseThreshold?: number;
// PageRank check fields
searchTerm?: string;
checkBing?: boolean;
@@ -22,6 +66,10 @@ export interface ICheckConfig {
googleMinRank?: number;
}
/**
* Service status for display and management.
* Extended with UI-specific fields.
*/
export interface IServiceStatus {
id: string;
name: string;
@@ -45,6 +93,9 @@ export interface IServiceStatus {
intervalMs?: number;
}
/**
* Status history point.
*/
export interface IStatusHistoryPoint {
timestamp: number;
status: TStatusType;
@@ -52,28 +103,9 @@ export interface IStatusHistoryPoint {
errorRate?: number;
}
export interface IIncidentUpdate {
id: string;
timestamp: number;
status: 'investigating' | 'identified' | 'monitoring' | 'resolved' | 'postmortem';
message: string;
author?: string;
}
export interface IIncidentDetails {
id: string;
title: string;
status: 'investigating' | 'identified' | 'monitoring' | 'resolved' | 'postmortem';
severity: 'critical' | 'major' | 'minor' | 'maintenance';
affectedServices: string[];
startTime: number;
endTime?: number;
updates: IIncidentUpdate[];
impact: string;
rootCause?: string;
resolution?: string;
}
/**
* Overall status with service counts for dashboard.
*/
export interface IOverallStatus {
status: TStatusType;
message: string;
@@ -82,6 +114,9 @@ export interface IOverallStatus {
totalServices: number;
}
/**
* Status page configuration.
*/
export interface IStatusPageConfig {
apiEndpoint?: string;
refreshInterval?: number;
@@ -100,7 +135,41 @@ export interface IStatusPageConfig {
legalUrl?: string;
}
// Admin-specific interfaces
/**
* Incident update entry (UI version with timestamp).
*/
export interface IIncidentUpdate {
id: string;
timestamp: number;
status: TIncidentStatus;
message: string;
author?: string;
}
/**
* Incident details for display.
*/
export interface IIncidentDetails {
id: string;
title: string;
status: TIncidentStatus;
severity: TIncidentSeverity;
affectedServices: string[];
startTime: number;
endTime?: number;
updates: IIncidentUpdate[];
impact: string;
rootCause?: string;
resolution?: string;
}
// ============================================
// Form Interfaces (UI-specific)
// ============================================
/**
* Monitor form data for creating/editing monitors.
*/
export interface IMonitorFormData {
id?: string;
name: string;
@@ -118,19 +187,25 @@ export interface IMonitorFormData {
intervalMs: number;
}
/**
* Incident form data for creating/editing incidents.
*/
export interface IIncidentFormData {
id?: string;
title: string;
severity: 'critical' | 'major' | 'minor' | 'maintenance';
status: 'investigating' | 'identified' | 'monitoring' | 'resolved' | 'postmortem';
severity: TIncidentSeverity;
status: TIncidentStatus;
affectedServices: string[];
impact: string;
rootCause?: string;
resolution?: string;
}
/**
* Incident update form data.
*/
export interface IIncidentUpdateFormData {
status: 'investigating' | 'identified' | 'monitoring' | 'resolved' | 'postmortem';
status: TIncidentStatus;
message: string;
author?: string;
}