diff --git a/protocol-dashboard/src/components/IndividualNodeUptimeChart/IndividualNodeUptimeChart.tsx b/protocol-dashboard/src/components/IndividualNodeUptimeChart/IndividualNodeUptimeChart.tsx index 949a0a7c631..c61386fb7c4 100644 --- a/protocol-dashboard/src/components/IndividualNodeUptimeChart/IndividualNodeUptimeChart.tsx +++ b/protocol-dashboard/src/components/IndividualNodeUptimeChart/IndividualNodeUptimeChart.tsx @@ -1,4 +1,4 @@ -import TrackerChart from 'components/TrackerChart' +import { TrackerChart } from 'components/TrackerChart' import React from 'react' import { useIndividualNodeUptime } from 'store/cache/analytics/hooks' import { Bucket, MetricError } from 'store/cache/analytics/slice' diff --git a/protocol-dashboard/src/components/ServiceTable/ServiceTable.module.css b/protocol-dashboard/src/components/ServiceTable/ServiceTable.module.css index 6ac916a9425..d06ccef2505 100644 --- a/protocol-dashboard/src/components/ServiceTable/ServiceTable.module.css +++ b/protocol-dashboard/src/components/ServiceTable/ServiceTable.module.css @@ -5,15 +5,34 @@ width: 100%; } -.colEndpoint { +.colVersion { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + text-align: right; + margin-right: 8px; +} + +.colEndpoint { + flex: 2; + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; margin-right: 8px; } +.colUptime { + flex: 1; + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + text-align: right; +} + .rowCol { font-family: var(--font-family); @@ -24,6 +43,8 @@ } .error { + display: inline-flex; + justify-content: flex-end; height: 20px; width: 20px; } diff --git a/protocol-dashboard/src/components/ServiceTable/ServiceTable.tsx b/protocol-dashboard/src/components/ServiceTable/ServiceTable.tsx index 5f9202959c9..ce9c4ff3591 100644 --- a/protocol-dashboard/src/components/ServiceTable/ServiceTable.tsx +++ b/protocol-dashboard/src/components/ServiceTable/ServiceTable.tsx @@ -5,6 +5,10 @@ import { NodeService, ContentNode, DiscoveryProvider } from 'types' import styles from './ServiceTable.module.css' import Table from 'components/Table' import Error from 'components/Error' +import { isMobile } from 'utils/mobile' +import { useIndividualNodeUptime } from 'store/cache/analytics/hooks' +import { Bucket, MetricError } from 'store/cache/analytics/slice' +import { DataObject, TrackerMini } from 'components/TrackerChart' type ServiceRow = { endpoint: string @@ -40,10 +44,30 @@ const ServiceTable: React.FC = ({ }: ServiceTableProps) => { const columns = [ { title: 'Service Endpoint', className: styles.colEndpoint }, - { title: 'Version', className: styles.colVersion } + { title: 'Version', className: styles.colVersion }, + { title: 'Uptime', className: styles.colUptime } ] const renderRow = (data: NodeService) => { + let error: boolean, uptimeData: DataObject[] + const { uptime } = useIndividualNodeUptime(data.endpoint, Bucket.DAY) + if (uptime === MetricError.ERROR) { + error = true + uptimeData = [] + } else if (uptime?.uptime_raw_data) { + uptimeData = [] + const hoursToDisplay = isMobile() ? -7 : -9 + for (const up of Object.values(uptime.uptime_raw_data).slice( + hoursToDisplay + )) { + uptimeData.push({ + // TODO add harmony and use harmony css vars + color: up === 1 ? '#13c65a' : '#f9344c' + // color: up === 1 ? 'var(--harmony-light-green)' : 'var(--harmony-red)', + }) + } + } + return (
@@ -56,6 +80,13 @@ const ServiceTable: React.FC = ({
{data.version ? data.version : }
+
+ {error ? ( + + ) : ( + + )} +
) } diff --git a/protocol-dashboard/src/components/TrackerChart/TrackerChart.module.css b/protocol-dashboard/src/components/TrackerChart/TrackerChart.module.css index 2568550f2b2..d69d7c234e6 100644 --- a/protocol-dashboard/src/components/TrackerChart/TrackerChart.module.css +++ b/protocol-dashboard/src/components/TrackerChart/TrackerChart.module.css @@ -51,6 +51,29 @@ height: 128px; } +.chartMini { + flex-grow: 1; + display: flex; + justify-content: flex-end; + align-items: center; +} + +.trackerContainerMini { + display: flex; + flex-direction: column; + width: 64px; +} + +.trackerCellsMini { + position: relative; + display: flex; + flex-wrap: wrap; + gap: 5px; + width: 100%; + justify-content: space-evenly; + height: 30px; +} + .trackerCell { flex: 1 1 0; border-radius: 100px; diff --git a/protocol-dashboard/src/components/TrackerChart/TrackerChart.tsx b/protocol-dashboard/src/components/TrackerChart/TrackerChart.tsx index 24014ca93d4..2218f9a9552 100644 --- a/protocol-dashboard/src/components/TrackerChart/TrackerChart.tsx +++ b/protocol-dashboard/src/components/TrackerChart/TrackerChart.tsx @@ -10,25 +10,25 @@ import mobileStyles from './TrackerChartMobile.module.css' const styles = createStyles({ desktopStyles, mobileStyles }) type OwnProps = { - title: string + title?: string subtitle?: string data: DataObject[] | null error?: boolean } -type TrackerChartProps = OwnProps +type TrackerProps = OwnProps export type DataObject = { color: string - tooltip: string + tooltip?: string } -const TrackerChart: React.FC = ({ +export const TrackerChart: React.FC = ({ title, subtitle, data, error -}) => { +}: TrackerProps) => { const [tooltipText, setTooltipText] = React.useState('') const [showTooltip, setShowTooltip] = React.useState(false) @@ -77,4 +77,24 @@ const TrackerChart: React.FC = ({ ) } -export default TrackerChart +export const TrackerMini: React.FC = ({ data }: TrackerProps) => { + return ( +
+ {data && data.length >= 2 ? ( +
+
+ {data.map((item, index) => ( +
+ ))} +
+
+ ) : ( + + )} +
+ ) +} diff --git a/protocol-dashboard/src/components/TrackerChart/TrackerChartMobile.module.css b/protocol-dashboard/src/components/TrackerChart/TrackerChartMobile.module.css index 6f739bf86df..677e3bb436e 100644 --- a/protocol-dashboard/src/components/TrackerChart/TrackerChartMobile.module.css +++ b/protocol-dashboard/src/components/TrackerChart/TrackerChartMobile.module.css @@ -1,3 +1,9 @@ .header { margin-bottom: 32px; } + +.trackerContainerMini { + display: flex; + flex-direction: column; + width: 48px; +} diff --git a/protocol-dashboard/src/components/TrackerChart/index.tsx b/protocol-dashboard/src/components/TrackerChart/index.tsx index c6434e28ddb..aba6b1bc3c1 100644 --- a/protocol-dashboard/src/components/TrackerChart/index.tsx +++ b/protocol-dashboard/src/components/TrackerChart/index.tsx @@ -1 +1 @@ -export { default } from './TrackerChart' +export { TrackerChart, TrackerMini } from './TrackerChart'