From 1e70dc6c8d989c71ca962b7749d55389cd93e95e Mon Sep 17 00:00:00 2001 From: Siddhant Deshmukh Date: Tue, 12 Nov 2024 12:59:42 -0800 Subject: [PATCH] Make sure API configuration changes are reflected on the UI (#28) Signed-off-by: Siddhant Deshmukh --- public/pages/TopNQueries/TopNQueries.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/pages/TopNQueries/TopNQueries.tsx b/public/pages/TopNQueries/TopNQueries.tsx index 066e748..426350e 100644 --- a/public/pages/TopNQueries/TopNQueries.tsx +++ b/public/pages/TopNQueries/TopNQueries.tsx @@ -184,7 +184,9 @@ const TopNQueries = ({ const { latency, cpu, memory } = resp?.response?.persistent?.search?.insights?.top_queries || {}; if (latency !== undefined && latency.enabled === 'true') { - const [time, timeUnits] = latency.window_size.match(/\D+|\d+/g); + const [time, timeUnits] = latency.window_size + ? latency.window_size.match(/\D+|\d+/g) + : ['1', 'm']; setMetricSettings('latency', { isEnabled: true, currTopN: latency.top_n_size, @@ -193,7 +195,9 @@ const TopNQueries = ({ }); } if (cpu !== undefined && cpu.enabled === 'true') { - const [time, timeUnits] = cpu.window_size.match(/\D+|\d+/g); + const [time, timeUnits] = cpu.window_size + ? cpu.window_size.match(/\D+|\d+/g) + : ['1', 'm']; setMetricSettings('cpu', { isEnabled: true, currTopN: cpu.top_n_size, @@ -202,7 +206,9 @@ const TopNQueries = ({ }); } if (memory !== undefined && memory.enabled === 'true') { - const [time, timeUnits] = memory.window_size.match(/\D+|\d+/g); + const [time, timeUnits] = memory.window_size + ? memory.window_size.match(/\D+|\d+/g) + : ['1', 'm']; setMetricSettings('memory', { isEnabled: true, currTopN: memory.top_n_size,