diff --git a/plugins/lime-plugin-mesh-wide-config/src/meshConfigApi.ts b/plugins/lime-plugin-mesh-wide-config/src/meshConfigApi.ts index fc92ad20..2e0f1d0f 100644 --- a/plugins/lime-plugin-mesh-wide-config/src/meshConfigApi.ts +++ b/plugins/lime-plugin-mesh-wide-config/src/meshConfigApi.ts @@ -1,7 +1,33 @@ -import { IMeshWideConfig } from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; +import { + IMeshWideConfig, + MeshWideConfigState, +} from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; + +export const getMeshWideConfigState = async () => meshWideConfigState; export const getMeshWideConfig = async () => meshWideConfig; +const meshWideConfigState: MeshWideConfigState = { + node1: { + state: "DEFAULT", + timestamp: "2021-09-01T00:00:00Z", + main_node: "NO", + error: "", + node_ip: "", + bleachTTL: 0, + author: "node1", + }, + node2: { + state: "DEFAULT", + timestamp: "2021-09-01T00:00:00Z", + main_node: "NO", + error: "", + node_ip: "", + bleachTTL: 0, + author: "node2", + }, +}; + const options = { primary_interface: "eth0", main_ipv4_address: "10.170.128.0/16/17", diff --git a/plugins/lime-plugin-mesh-wide-config/src/meshConfigQueries.tsx b/plugins/lime-plugin-mesh-wide-config/src/meshConfigQueries.tsx index 396d49af..a9785e51 100644 --- a/plugins/lime-plugin-mesh-wide-config/src/meshConfigQueries.tsx +++ b/plugins/lime-plugin-mesh-wide-config/src/meshConfigQueries.tsx @@ -1,14 +1,30 @@ import { useQuery } from "@tanstack/react-query"; -import { getMeshWideConfig } from "plugins/lime-plugin-mesh-wide-config/src/meshConfigApi"; -import { IMeshWideConfig } from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; +import { + getMeshWideConfig, + getMeshWideConfigState, +} from "plugins/lime-plugin-mesh-wide-config/src/meshConfigApi"; +import { + IMeshWideConfig, + MeshWideConfigState, +} from "plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes"; export function useMeshWideConfig(params) { return useQuery( - ["lime-meshwide", "get_mesh_config"], + ["lime-mesh-config", "get_mesh_config"], getMeshWideConfig, { ...params, } ); } + +export function useMeshWideConfigState(params) { + return useQuery( + ["lime-mesh-config", "get_mesh_config_state"], + getMeshWideConfigState, + { + ...params, + } + ); +} diff --git a/plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes.tsx b/plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes.tsx index d6e35770..a3585232 100644 --- a/plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes.tsx +++ b/plugins/lime-plugin-mesh-wide-config/src/meshConfigTypes.tsx @@ -1,6 +1,34 @@ +import { MainNodeStatusType } from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeTypes"; + export interface IMeshWideSection { name: string; options: { [key: string]: string }; } export type IMeshWideConfig = IMeshWideSection[]; + +export type ConfigUpdateState = + | "DEFAULT" // No transaction + | "READY_FOR_UPGRADE" + | "UPGRADE_SCHEDULED" + | "CONFIRMATION_PENDING" + | "CONFIRMED" + | "ABORTED" + | "ERROR"; + +export interface NodeMeshConfigInfo { + timestamp: string; + main_node: MainNodeStatusType; + error: string; + node_ip: string; + state: ConfigUpdateState; +} + +export type MeshWideNodeConfigInfo = { + bleachTTL: number; + author: string; +} & NodeMeshConfigInfo; + +export interface MeshWideConfigState { + [key: string]: MeshWideNodeConfigInfo; +}