diff --git a/@types/index.d.ts b/@types/index.ts similarity index 54% rename from @types/index.d.ts rename to @types/index.ts index 8b10625..c423969 100644 --- a/@types/index.d.ts +++ b/@types/index.ts @@ -21,14 +21,14 @@ export interface Status { lastUpdatedOn: number } export interface ProviderStatus { - status?: State + status: State response?: number version?: string latestRelease?: string } export interface AquariusStatus { - status?: State + status: State response?: number validChainList?: boolean version?: string @@ -38,7 +38,7 @@ export interface AquariusStatus { validQuery?: boolean } export interface SubgraphStatus { - status?: State + status: State response?: number version?: string latestRelease?: string @@ -46,7 +46,7 @@ export interface SubgraphStatus { } export interface OperatorStatus { - status?: State + status: State response?: number version?: string latestRelease?: string @@ -54,7 +54,7 @@ export interface OperatorStatus { limitReached?: boolean } export interface FaucetStatus { - status?: State + status: State response?: number ethBalance?: BigNumber ethBalanceSufficient?: boolean @@ -71,41 +71,7 @@ export interface Network { oceanAddress?: string } -export interface dbRow { - network: string - currentBlock: number - aquariusStatus: State - aquariusResponse: number - aquariusChain: number - aquariusVersion: string - aquariusMonitorVersion: string - aquariusLatestRelease: string - aquariusBlock: number - aquariusValidQuery: number - providerStatus: State - providerResponse: number - providerVersion: string - providerLatestRelease: string - subgraphStatus: State - subgraphResponse: number - subgraphVersion: string - subgraphLatestRelease: string - subgraphBlock: number - operatorStatus: State - operatorResponse: number - operatorVersion: string - operatorLatestRelease: string - operatorEnvironments: number - operatorLimitReached: number - market: State - port: State - faucetStatus: State - faucetResponse: number - faucetEthBalance: BigNumber - faucetEthBalanceSufficient: number | string - faucetOceanBalance: BigNumber - faucetOceanBalanceSufficient: number | string - dataFarming: State - daoGrants: State - lastUpdatedOn: number +export interface Data { + component: string + status: State } diff --git a/pages/index.tsx b/pages/index.tsx index b284407..a1710fd 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,22 +1,39 @@ import Head from 'next/head' import React, { ReactElement, useEffect, useState } from 'react' -import { Status } from '../@types' +import { Status, State, Summary } from '../@types' import styles from '../styles/Home.module.css' -import { getData } from '../utils/getData' +import { getData, getSummary } from '../utils/getData' export default function HomePage(): ReactElement { - const [statuses, setStatuses] = useState() - const [network, setNetwork] = useState(1) + const [network, setNetwork] = useState(0) + const [data, setData] = useState([ + { + component: 'Loading', + status: State.Up + } + ]) + + function style(state: State) { + console.log('state', state) + if (state === State.Down) { + return styles.down + } else if (state === State.Warning) { + return styles.warning + } else { + return styles.up + } + } useEffect(() => { async function getStatuses() { - const data = await getData() - data && setStatuses(data) - // console.log('statuses', statuses) - // console.log('statuses?[1].aquarius.status', statuses[1].aquarius.status) + const summary = await getSummary(network) + console.log('summary', summary) + if (summary) setData(summary) } getStatuses() - }, []) + }, [network]) + + console.log('data', data) return (
@@ -31,48 +48,14 @@ export default function HomePage(): ReactElement { Current Status of Ocean Components{' '}

- {statuses && ( + {data && ( <> -
-

Aquarius

-

{statuses[network].aquarius.status}

-
-
-

Provider

-

{statuses[network].provider.status}

-
- -
-

Subgraph

-

{statuses[network].subgraph.status}

-
- -
-

Market

-

{statuses[network].market}

-
-
-

Port

-

{statuses[network].port}

-
-
-

Data Farming

-

{statuses[network].dataFarming}

-
-
-

Operator Service

-

{statuses[network].operator.status}

-
- {statuses[network].faucet.status && ( -
-

Faucet

-

{statuses[network].faucet.status}

+ {data.map((value: Summary) => ( +
+

{value?.component}

+

{value?.status}

- )} -
-

DAO Grants

-

{statuses[network].daoGrants}

-
+ ))} )}
@@ -82,3 +65,47 @@ export default function HomePage(): ReactElement {
) } + +// <> +//
+//

{data[0].component}

+//

{data[0].status}

+//
+//
+//

Provider

+//

{statuses[network].provider.status}

+//
+ +//
+//

Subgraph

+//

{statuses[network].subgraph.status}

+//
+ +//
+//

Market

+//

{statuses[network].market}

+//
+//
+//

Port

+//

{statuses[network].port}

+//
+//
+//

Data Farming

+//

{statuses[network].dataFarming}

+//
+//
+//

Operator Service

+//

{statuses[network].operator.status}

+//
+// {statuses[network].faucet.status && ( +//
+//

Faucet

+//

{statuses[network].faucet.status}

+//
+// )} +//
+//

DAO Grants

+//

{statuses[network].daoGrants}

+//
+// +// } diff --git a/styles/Home.module.css b/styles/Home.module.css index bd50f42..1eca517 100644 --- a/styles/Home.module.css +++ b/styles/Home.module.css @@ -79,12 +79,16 @@ text-align: left; color: inherit; text-decoration: none; - border: 1px solid #eaeaea; + border-radius: 10px; transition: color 0.15s ease, border-color 0.15s ease; max-width: 300px; } +.warning { + border: 1px solid #eac146; +} + .card:hover, .card:focus, .card:active { diff --git a/utils/getData.ts b/utils/getData.ts index 5a3490a..db0de78 100644 --- a/utils/getData.ts +++ b/utils/getData.ts @@ -1,18 +1,56 @@ import axios, { AxiosResponse } from 'axios' -import { Status } from '../@types' +import { Status, Summary } from '../@types' import { statusServiceUri } from '../app.config' -export async function getData(): Promise { +export async function getData(): Promise { try { const response: AxiosResponse = await axios.get( `${statusServiceUri}` ) - if (!response || response.status !== 200 || !response.data) return + if (!response || response.status !== 200 || !response.data) + console.log('ERROR: no data recieved') const data = { ...response.data } console.log('data', data) + return data } catch (error) { console.log(error) } } + +export async function getSummary(network: number): Promise { + try { + const data = await getData() + console.log('data', data) + + const summary: Summary[] = [ + { component: 'Aquarius', status: data[network].aquarius.status }, + { component: 'Provider', status: data[network].provider.status }, + { component: 'Subgraph', status: data[network].subgraph.status }, + { component: 'Market', status: data[network].market }, + { component: 'Port', status: data[network].port }, + { + component: 'Data Farming', + status: data[network].dataFarming + }, + { + component: 'Operator Service', + status: data[network].operator.status + }, + { + component: 'DAO Grants', + status: data[network].daoGrants + } + ] + + return summary + } catch (error) { + console.log(error) + } +} + +// data[network].faucet.status && { +// component: 'Faucet', +// status: data[network].faucet.status +// }