From e88cfcd4daedd5e76a8e3e8b4e85c6a5911649a8 Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Wed, 29 Jun 2022 16:24:49 +0530 Subject: [PATCH 1/3] fix: legend for empty metrics names list --- .../store/actions/dashboard/getQueryResults.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/store/actions/dashboard/getQueryResults.ts b/frontend/src/store/actions/dashboard/getQueryResults.ts index f1143a1431..17137b13c1 100644 --- a/frontend/src/store/actions/dashboard/getQueryResults.ts +++ b/frontend/src/store/actions/dashboard/getQueryResults.ts @@ -143,17 +143,23 @@ export async function GetMetricQueryRange({ `API responded with ${response.statusCode} - ${response.error}`, ); } - if (response.payload?.data?.result) { response.payload.data.result = response.payload.data.result.map( (queryData) => { const newQueryData = queryData; - newQueryData.legend = legendMap[queryData.queryName]; + newQueryData.legend = legendMap[queryData.queryName]; // Adds the legend if it is already defined by the user. + // If metric names is an empty object if (isEmpty(queryData.metric)) { - newQueryData.metric[queryData.queryName] = queryData.queryName; - newQueryData.legend = queryData.queryName; + // If metrics list is empty && the user haven't defined a legend then add the legend equal to the name of the query. + if (!newQueryData.legend) { + newQueryData.legend = queryData.queryName; + } + // If name of the query and the legend if inserted is same then add the same to the metrics object. + if (queryData.queryName === newQueryData.legend) { + newQueryData.metric[queryData.queryName] = queryData.queryName; + } } - return queryData; + return newQueryData; }, ); } From dd9cbcee331855c1b064fb348321519033519250 Mon Sep 17 00:00:00 2001 From: Palash Date: Thu, 30 Jun 2022 19:02:31 +0530 Subject: [PATCH 2/3] fix: decimal-precision is made undefined (#1344) Co-authored-by: Prashant Shahi --- frontend/src/components/Graph/yAxisConfig.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Graph/yAxisConfig.ts b/frontend/src/components/Graph/yAxisConfig.ts index 44377b6fc5..5d1eeb5da7 100644 --- a/frontend/src/components/Graph/yAxisConfig.ts +++ b/frontend/src/components/Graph/yAxisConfig.ts @@ -7,17 +7,13 @@ export const getYAxisFormattedValue = ( let decimalPrecision: number | undefined; const parsedValue = getValueFormat(format)( parseFloat(value), - 12, - 12, + undefined, + undefined, undefined, ); - try { const decimalSplitted = parsedValue.text.split('.'); - if ( - decimalSplitted.length === 1 || - parseFloat(parsedValue.text) === parseInt(parsedValue.text, 10) - ) { + if (decimalSplitted.length === 1) { decimalPrecision = 0; } else { const decimalDigits = decimalSplitted[1].split(''); From 669dc05eecc51d71a8c2bc4cd3bb75ff735b77b6 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Fri, 1 Jul 2022 00:56:15 +0530 Subject: [PATCH 3/3] fix: add request/response interceptors for ApiV2Instance --- frontend/src/api/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 82f4bdc010..b59a224cdc 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -102,6 +102,11 @@ export const AxiosAlertManagerInstance = axios.create({ export const ApiV2Instance = axios.create({ baseURL: `${ENVIRONMENT.baseURL}${apiV2}`, }); +ApiV2Instance.interceptors.response.use( + interceptorsResponse, + interceptorRejected, +); +ApiV2Instance.interceptors.request.use(interceptorsRequestResponse); AxiosAlertManagerInstance.interceptors.response.use( interceptorsResponse,