323 lines
6.7 KiB
TypeScript
323 lines
6.7 KiB
TypeScript
export type StatusTone = "ok" | "warn" | "critical" | "neutral";
|
|
|
|
export interface HeroCard {
|
|
metric_id: string;
|
|
label: string;
|
|
value: number | string | null;
|
|
unit: string;
|
|
accent: string;
|
|
subtitle: string;
|
|
}
|
|
|
|
export interface MetricValue {
|
|
metric_id: string;
|
|
label: string;
|
|
unit: string;
|
|
value: number | string | null;
|
|
timestamp?: string | null;
|
|
precision: number;
|
|
kind: "gauge" | "counter" | "text";
|
|
status: StatusTone;
|
|
}
|
|
|
|
export interface SnapshotGroupRow {
|
|
id: string;
|
|
label: string;
|
|
values: Record<string, MetricValue>;
|
|
meta: Record<string, number | string>;
|
|
}
|
|
|
|
export interface SnapshotPayload {
|
|
updated_at?: string | null;
|
|
hero_cards: HeroCard[];
|
|
kpis: Record<string, MetricValue>;
|
|
strings: SnapshotGroupRow[];
|
|
phases: SnapshotGroupRow[];
|
|
status: MetricValue[];
|
|
faults: string[];
|
|
}
|
|
|
|
export interface SeriesPoint {
|
|
timestamp: string;
|
|
value: number | null;
|
|
}
|
|
|
|
export interface SeriesPayload {
|
|
metric_id: string;
|
|
label: string;
|
|
unit: string;
|
|
color?: string | null;
|
|
points: SeriesPoint[];
|
|
}
|
|
|
|
export interface HistoryPayload {
|
|
range_key: string;
|
|
start: string;
|
|
end: string;
|
|
series: SeriesPayload[];
|
|
}
|
|
|
|
export interface BucketPoint {
|
|
label: string;
|
|
start: string;
|
|
end: string;
|
|
value: number | null;
|
|
}
|
|
|
|
export interface AnalyticsSummary {
|
|
total: number;
|
|
unit: string;
|
|
average_bucket: number;
|
|
best_bucket_label: string;
|
|
best_bucket_value: number;
|
|
co2_saved_kg: number;
|
|
comparison_total?: number | null;
|
|
comparison_delta_pct?: number | null;
|
|
}
|
|
|
|
export interface AnalyticsPayload {
|
|
unit: string;
|
|
bucket: string;
|
|
compare_mode: string;
|
|
current: BucketPoint[];
|
|
comparison: BucketPoint[];
|
|
comparisons?: Array<{
|
|
key: string;
|
|
label: string;
|
|
start: string;
|
|
end: string;
|
|
total: number;
|
|
delta_pct?: number | null;
|
|
points: BucketPoint[];
|
|
}>;
|
|
summary: AnalyticsSummary;
|
|
meta: {
|
|
window: {
|
|
start: string;
|
|
end: string;
|
|
range_key: string;
|
|
};
|
|
source?: string;
|
|
};
|
|
}
|
|
|
|
export interface DistributionSlice {
|
|
label: string;
|
|
value: number;
|
|
share: number;
|
|
}
|
|
|
|
export interface DistributionPayload {
|
|
unit: string;
|
|
bucket: string;
|
|
total: number;
|
|
slices: DistributionSlice[];
|
|
}
|
|
|
|
export interface HistoricalCoverage {
|
|
imported_days: number;
|
|
first_day?: string | null;
|
|
last_day?: string | null;
|
|
total_energy_kwh: number;
|
|
available_days: number;
|
|
missing_days: number;
|
|
coverage_pct?: number | null;
|
|
}
|
|
|
|
export interface HistoricalChunkProgress {
|
|
chunk_index: number;
|
|
total_chunks: number;
|
|
start_date: string;
|
|
end_date: string;
|
|
processed_days: number;
|
|
imported_days: number;
|
|
skipped_days: number;
|
|
energy_kwh: number;
|
|
state: string;
|
|
started_at?: string | null;
|
|
finished_at?: string | null;
|
|
duration_seconds?: number | null;
|
|
note: string;
|
|
}
|
|
|
|
export interface HistoricalActivityEvent {
|
|
timestamp: string;
|
|
level: string;
|
|
title: string;
|
|
message: string;
|
|
day?: string | null;
|
|
chunk_index?: number | null;
|
|
}
|
|
|
|
export interface HistoricalStatus {
|
|
enabled: boolean;
|
|
running: boolean;
|
|
state: string;
|
|
job_id?: string | null;
|
|
started_at?: string | null;
|
|
finished_at?: string | null;
|
|
requested_start_date?: string | null;
|
|
requested_end_date?: string | null;
|
|
total_days: number;
|
|
processed_days: number;
|
|
imported_days: number;
|
|
skipped_days: number;
|
|
chunk_days: number;
|
|
total_chunks: number;
|
|
active_chunk_index: number;
|
|
current_date?: string | null;
|
|
current_chunk_start?: string | null;
|
|
current_chunk_end?: string | null;
|
|
elapsed_seconds?: number | null;
|
|
estimated_remaining_seconds?: number | null;
|
|
avg_days_per_minute?: number | null;
|
|
last_error?: string | null;
|
|
message: string;
|
|
coverage: HistoricalCoverage;
|
|
available_start_date?: string | null;
|
|
available_end_date?: string | null;
|
|
default_chunk_days: number;
|
|
recent_chunks: HistoricalChunkProgress[];
|
|
recent_events: HistoricalActivityEvent[];
|
|
}
|
|
|
|
export interface HistoricalStartPayload {
|
|
start_date?: string;
|
|
end_date?: string;
|
|
chunk_days?: number;
|
|
force?: boolean;
|
|
}
|
|
|
|
export interface AuthStatus {
|
|
enabled: boolean;
|
|
authenticated: boolean;
|
|
user?: string | null;
|
|
display_name?: string | null;
|
|
role?: string | null;
|
|
}
|
|
|
|
export interface DashboardConfig {
|
|
app: {
|
|
name: string;
|
|
version: string;
|
|
site_name: string;
|
|
timezone: string;
|
|
installed_power_kwp: number;
|
|
};
|
|
defaults: {
|
|
realtime_range: string;
|
|
analytics_range: string;
|
|
analytics_bucket: string;
|
|
tab: string;
|
|
theme: string;
|
|
language: string;
|
|
};
|
|
auth?: {
|
|
enabled: boolean;
|
|
};
|
|
i18n?: {
|
|
default_language: string;
|
|
supported_languages: string[];
|
|
};
|
|
capabilities: {
|
|
modules: Record<string, boolean>;
|
|
strings_enabled: boolean;
|
|
strings_count: number;
|
|
phases_enabled: boolean;
|
|
phases_count: number;
|
|
analytics_enabled: boolean;
|
|
realtime_enabled: boolean;
|
|
comparison_modes: string[];
|
|
ranges: Array<{ key: string; label: string }>;
|
|
buckets: Array<{ key: string; label: string }>;
|
|
historical_import_enabled: boolean;
|
|
history: {
|
|
enabled: boolean;
|
|
default_chunk_days: number;
|
|
auto_sync_enabled: boolean;
|
|
auto_sync_interval_minutes: number;
|
|
};
|
|
};
|
|
visible_entities: Array<{
|
|
metric_id: string;
|
|
label: string;
|
|
entity_id: string;
|
|
measurement: string;
|
|
unit: string;
|
|
kind: string;
|
|
}>;
|
|
}
|
|
|
|
|
|
export interface AuthUserItem {
|
|
username: string;
|
|
display_name: string;
|
|
role: string;
|
|
is_active: boolean;
|
|
created_at?: string | null;
|
|
updated_at?: string | null;
|
|
}
|
|
|
|
export interface AuthUsersPayload {
|
|
items: AuthUserItem[];
|
|
}
|
|
|
|
|
|
export interface KioskChartGroup {
|
|
id: string;
|
|
title?: string | null;
|
|
metric_ids: string[];
|
|
}
|
|
|
|
export interface KioskSettingsPayload {
|
|
mode: "public" | "private";
|
|
widgets: string[];
|
|
hero_metric_ids: string[];
|
|
realtime_range: string;
|
|
analytics_range: string;
|
|
analytics_bucket: string;
|
|
compare_mode: string;
|
|
chart_groups: KioskChartGroup[];
|
|
updated_at?: string | null;
|
|
updated_by?: string | null;
|
|
}
|
|
|
|
|
|
export interface DiagnosticsPayload {
|
|
app: {
|
|
name: string;
|
|
version: string;
|
|
debug: boolean;
|
|
timezone: string;
|
|
site_name: string;
|
|
installed_power_kwp: number;
|
|
auth_enabled: boolean;
|
|
started_at: string;
|
|
uptime_seconds: number;
|
|
python_version: string;
|
|
pid: number;
|
|
};
|
|
api: {
|
|
status: string;
|
|
prefix: string;
|
|
cors_origins_count: number;
|
|
};
|
|
influx: {
|
|
status: "connected" | "error";
|
|
reachable: boolean;
|
|
database_exists: boolean;
|
|
url: string;
|
|
database: string;
|
|
username_masked: string;
|
|
verify_ssl: boolean;
|
|
timeout_seconds: number;
|
|
error?: string | null;
|
|
};
|
|
storage: {
|
|
sqlite_path: string;
|
|
historical_import_enabled: boolean;
|
|
auto_sync_enabled: boolean;
|
|
default_chunk_days: number;
|
|
};
|
|
}
|