From 6657a59cb987566fffcdef888997db081987eb70 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Tue, 21 Feb 2023 15:08:41 +0100 Subject: [PATCH] change(ui): mock back response --- .../Header/HealthStatus/HealthModal/mock.ts | 187 ++++++++++++++++++ .../Header/HealthStatus/HealthStatus.tsx | 34 ++++ 2 files changed, 221 insertions(+) create mode 100644 frontend/app/components/Header/HealthStatus/HealthModal/mock.ts diff --git a/frontend/app/components/Header/HealthStatus/HealthModal/mock.ts b/frontend/app/components/Header/HealthStatus/HealthModal/mock.ts new file mode 100644 index 000000000..8211126f6 --- /dev/null +++ b/frontend/app/components/Header/HealthStatus/HealthModal/mock.ts @@ -0,0 +1,187 @@ +export const response = { + databases: { + postgres: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + clickhouse: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + }, + ingestionPipeline: { + redis: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + kafka: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + }, + backendServices: { + alerts: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + assets: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + assist: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + chalice: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + db: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + ender: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + frontend: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + heuristics: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + http: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + 'ingress-nginx': { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + integrations: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + peers: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + quickwit: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + sink: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + sourcemapreader: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + storage: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + utilities: { + health: true, + details: { + version: 'v1.13', + schema: 'v1.10', + lastUpdatedOn: '12jan2023', + }, + }, + }, + overall: { + health: true, + details: { + numberOfEventCaptured: 123000, + numberOfSessionsCaptured: 25678, + }, + labels: { + parent: 'information', + }, + }, + ssl: true, +}; diff --git a/frontend/app/components/Header/HealthStatus/HealthStatus.tsx b/frontend/app/components/Header/HealthStatus/HealthStatus.tsx index 5296594c2..361e49be3 100644 --- a/frontend/app/components/Header/HealthStatus/HealthStatus.tsx +++ b/frontend/app/components/Header/HealthStatus/HealthStatus.tsx @@ -2,6 +2,40 @@ import React from 'react'; import { Icon } from 'UI'; import cn from 'classnames'; import HealthModal from 'Components/Header/HealthStatus/HealthModal/HealthModal'; +import { response } from './HealthModal/mock' + +function mapResponse(resp) { + const dbKeys = Object.keys(resp.databases) + const ingestKeys = Object.keys(resp.ingestionPipeline) + const backendKeys = Object.keys(resp.backendServices) + + if (!resp.overall.health) { + const dbHealth: Record = { + overall: true, + } + const ingestHealth: Record = { + overall: true, + } + const backHealth: Record = { + overall: true, + } + dbKeys.forEach(key => { + const dbStatus = resp.databases[key].health + if (!dbStatus) dbHealth.overall = false + dbHealth[key] = resp.databases.key + }) + ingestKeys.forEach(key => { + const ingestStatus = resp.ingestionPipeline[key].health + if (!ingestStatus) ingestHealth.overall = false + ingestHealth[key] = resp.ingestionPipeline.key + }) + backendKeys.forEach(key => { + const backendStatus = resp.backendServices[key].health + if (!backendStatus) backHealth.overall = false + backHealth[key] = resp.backendServices.key + }) + } +} function HealthStatus() { const [healthOk, setHealth] = React.useState(false);