From 6952ed2e8d0554fb15d937eb5d41721a2088adb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Jani=C5=A1?= Date: Tue, 19 Jan 2021 00:32:31 +0100 Subject: [PATCH] feat: show city also in header --- src/components/monitorDayAverage.js | 7 +------ src/components/monitorStatusHeader.js | 4 +++- src/functions/helpers.js | 7 +++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/monitorDayAverage.js b/src/components/monitorDayAverage.js index 88904406e..c1bdb9af6 100644 --- a/src/components/monitorDayAverage.js +++ b/src/components/monitorDayAverage.js @@ -1,9 +1,4 @@ -const locations = { - WAW: 'Warsaw', - SCL: 'Santiago de Chile', - MEL: 'Melbourne', - SIN: 'Singapore', -} +import { locations } from '../functions/helpers' export default function MonitorDayAverage({ location, avg }) { return ( diff --git a/src/components/monitorStatusHeader.js b/src/components/monitorStatusHeader.js index 63cd940ce..38bddac59 100644 --- a/src/components/monitorStatusHeader.js +++ b/src/components/monitorStatusHeader.js @@ -1,4 +1,5 @@ import config from '../../config.yaml' +import { locations } from '../functions/helpers' const classes = { green: @@ -24,7 +25,8 @@ export default function MonitorStatusHeader({ kvMonitorsLastUpdate }) {
checked{' '} {Math.round((Date.now() - kvMonitorsLastUpdate.time) / 1000)} sec - ago (from {kvMonitorsLastUpdate.loc}) + ago (from{' '} + {locations[kvMonitorsLastUpdate.loc] || kvMonitorsLastUpdate.loc})
)} diff --git a/src/functions/helpers.js b/src/functions/helpers.js index d4e80c4d8..2fa5a490c 100644 --- a/src/functions/helpers.js +++ b/src/functions/helpers.js @@ -3,6 +3,13 @@ import { useEffect, useState } from 'react' const kvDataKey = 'monitors_data_v1_1' +export const locations = { + WAW: 'Warsaw', + SCL: 'Santiago de Chile', + MEL: 'Melbourne', + SIN: 'Singapore', +} + export async function getKVMonitors() { // trying both to see performance difference return KV_STATUS_PAGE.get(kvDataKey, 'json')