uxowe i funkcjonalne

This commit is contained in:
Mateusz Gruszczyński
2026-03-25 13:16:47 +01:00
parent 84fe898a74
commit 077ea315f5
7 changed files with 352 additions and 53 deletions

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@ import type {
AuthUsersPayload,
DashboardConfig,
DiagnosticsPayload,
KioskChartGroup,
KioskSettingsPayload,
DistributionPayload,
HistoryPayload,
@@ -68,9 +69,13 @@ async function demoResponse<T>(factory: () => T): Promise<T> {
return clone(factory());
}
function demoKioskChartGroups(): KioskChartGroup[] {
return [{ id: "overview", title: null, metric_ids: ["ac_power", "dc_power_total", "inverter_temp"] }];
}
export const api = {
getConfig: () => (DEMO_MODE ? demoResponse(() => demoConfig) : request<DashboardConfig>("/dashboard/config")),
getKioskSettings: (mode: "public" | "private") => (DEMO_MODE ? demoResponse(() => ({ mode, widgets: ["hero", "history", "strings", "status", "production", "comparison", "importStatus"], realtime_range: "today", analytics_range: "30d", analytics_bucket: "day", compare_mode: "none" })) : request<KioskSettingsPayload>(`/dashboard/kiosk-settings?mode=${mode}`)),
getKioskSettings: (mode: "public" | "private") => (DEMO_MODE ? demoResponse(() => ({ mode, widgets: ["hero", "history", "strings", "status", "production", "comparison", "importStatus"], hero_metric_ids: ["ac_power", "dc_power_total", "energy_today", "energy_total"], realtime_range: "today", analytics_range: "30d", analytics_bucket: "day", compare_mode: "none", chart_groups: demoKioskChartGroups() })) : request<KioskSettingsPayload>(`/dashboard/kiosk-settings?mode=${mode}`)),
saveKioskSettings: (payload: KioskSettingsPayload) => (DEMO_MODE ? demoResponse(() => payload) : request<KioskSettingsPayload>("/dashboard/kiosk-settings", { method: "PUT", body: JSON.stringify(payload) })),
getAuthStatus: () => (DEMO_MODE ? demoResponse(() => demoAuthStatus) : request<AuthStatus>("/auth/status")),
login: (username: string, password: string) =>

View File

@@ -68,7 +68,7 @@ export const demoConfig: DashboardConfig = {
{ metric_id: "string_1_voltage", label: "Napiecie stringu DC1", entity_id: "sofarsolar_dc1_voltage", measurement: "V", unit: "V", kind: "gauge" },
{ metric_id: "string_2_power", label: "Moc stringu DC2", entity_id: "sofarsolar_dc2_power", measurement: "W", unit: "W", kind: "gauge" },
{ metric_id: "string_2_voltage", label: "Napiecie stringu DC2", entity_id: "sofarsolar_dc2_voltage", measurement: "V", unit: "V", kind: "gauge" },
{ metric_id: "inverter_temperature", label: "Temperatura falownika", entity_id: "sofarsolar_temprature_inverter", measurement: "°C", unit: "°C", kind: "gauge" },
{ metric_id: "inverter_temp", label: "Temperatura falownika", entity_id: "sofarsolar_temprature_inverter", measurement: "°C", unit: "°C", kind: "gauge" },
],
};
@@ -77,9 +77,9 @@ export const demoSnapshot = (): SnapshotPayload => ({
hero_cards: [
{ metric_id: "ac_power", label: "Produkcja AC", value: 6840, unit: "W", accent: "emerald", subtitle: "Aktualna moc oddawana przez falownik" },
{ metric_id: "energy_today", label: "Dzisiaj", value: 31.8, unit: "kWh", accent: "amber", subtitle: "Liczone z energy_total / fallback z AC power" },
{ metric_id: "dc1_power", label: "String DC1", value: 3450, unit: "W", accent: "emerald", subtitle: "Wschod" },
{ metric_id: "dc2_power", label: "String DC2", value: 3310, unit: "W", accent: "emerald", subtitle: "Zachod" },
{ metric_id: "inverter_temperature", label: "Temp. falownika", value: 47.3, unit: "°C", accent: "rose", subtitle: "Live status termiczny" },
{ metric_id: "string_1_power", label: "String DC1", value: 3450, unit: "W", accent: "emerald", subtitle: "Wschód" },
{ metric_id: "string_2_power", label: "String DC2", value: 3310, unit: "W", accent: "emerald", subtitle: "Zachód" },
{ metric_id: "inverter_temp", label: "Temp. falownika", value: 47.3, unit: "°C", accent: "rose", subtitle: "Live status termiczny" },
],
kpis: {
energy_today: { metric_id: "energy_today", label: "Energia dzis", unit: "kWh", value: 31.8, precision: 2, kind: "counter", status: "ok" },
@@ -94,7 +94,7 @@ export const demoSnapshot = (): SnapshotPayload => ({
],
phases: [],
status: [
{ metric_id: "inverter_temperature", label: "Temperatura falownika", unit: "°C", value: 47.3, precision: 1, kind: "gauge", status: "ok" },
{ metric_id: "inverter_temp", label: "Temperatura falownika", unit: "°C", value: 47.3, precision: 1, kind: "gauge", status: "ok" },
{ metric_id: "data_freshness", label: "Swiezosc danych", unit: "", value: "3 s temu", precision: 0, kind: "text", status: "ok" },
],
faults: [],
@@ -110,9 +110,9 @@ export const demoHistory: HistoryPayload = {
end: isoAt(0),
series: [
{ metric_id: "ac_power", label: "Moc AC", unit: "W", points: historyPoints([0, 120, 860, 1840, 2760, 3920, 5180, 6020, 6840, 6500, 5710, 4980]) },
{ metric_id: "dc1_power", label: "DC1", unit: "W", points: historyPoints([0, 80, 620, 1320, 2140, 2860, 3250, 3490, 3450, 3300, 2920, 2480]) },
{ metric_id: "dc2_power", label: "DC2", unit: "W", points: historyPoints([0, 40, 240, 520, 880, 1260, 1930, 2530, 3310, 3200, 2790, 2410]) },
{ metric_id: "inverter_temperature", label: "Temp. falownika", unit: "°C", points: historyPoints([22, 24, 27, 31, 35, 39, 42, 45, 47.3, 46.8, 44.1, 41.2]) },
{ metric_id: "string_1_power", label: "DC1", unit: "W", points: historyPoints([0, 80, 620, 1320, 2140, 2860, 3250, 3490, 3450, 3300, 2920, 2480]) },
{ metric_id: "string_2_power", label: "DC2", unit: "W", points: historyPoints([0, 40, 240, 520, 880, 1260, 1930, 2530, 3310, 3200, 2790, 2410]) },
{ metric_id: "inverter_temp", label: "Temp. falownika", unit: "°C", points: historyPoints([22, 24, 27, 31, 35, 39, 42, 45, 47.3, 46.8, 44.1, 41.2]) },
],
};

View File

@@ -34,7 +34,7 @@ const messages = {
settingsSubtitle: "Import archiwum, wygląd, kiosk, bezpieczeństwo",
noData: "Brak danych",
noDataDescription: "Brak odpowiedzi z backendu lub InfluxDB.",
chartPowerHistory: "Historia mocy i temperatury",
kioskCharts: "Wykresy",
chartProduction: "Produkcja",
chartProductionSubtitle: "Agregacja w wybranym bucketcie",
chartComparison: "Porównanie okresów",
@@ -141,7 +141,7 @@ const messages = {
settingsSubtitle: "Archive import, appearance, kiosk, security",
noData: "No data",
noDataDescription: "No response from backend or InfluxDB.",
chartPowerHistory: "Power and temperature history",
kioskCharts: "Charts",
chartProduction: "Production",
chartProductionSubtitle: "Aggregated by selected bucket",
chartComparison: "Period comparison",

View File

@@ -263,13 +263,21 @@ export interface AuthUsersPayload {
}
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;
}