fix: edit form shows incorrect eval window when 24hours is saved (#1393)

* fix: edit form shows incorrect eval window when 24hours is saved

* fix: edit form shows incorrect eval window when 24hours is saved

* feat: added 4 hour window to alert ui

Co-authored-by: Palash <palashgdev@gmail.com>
This commit is contained in:
Amol Umbark 2022-07-14 18:23:02 +05:30 committed by GitHub
parent 46f258747a
commit a2e1c41343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 4 deletions

View File

@ -33,6 +33,7 @@
"option_10min": "10 mins", "option_10min": "10 mins",
"option_15min": "15 mins", "option_15min": "15 mins",
"option_60min": "60 mins", "option_60min": "60 mins",
"option_4hours": "4 hours",
"option_24hours": "24 hours", "option_24hours": "24 hours",
"field_threshold": "Alert Threshold", "field_threshold": "Alert Threshold",
"option_allthetimes": "all the times", "option_allthetimes": "all the times",

View File

@ -33,6 +33,7 @@
"option_10min": "10 mins", "option_10min": "10 mins",
"option_15min": "15 mins", "option_15min": "15 mins",
"option_60min": "60 mins", "option_60min": "60 mins",
"option_4hours": "4 hours",
"option_24hours": "24 hours", "option_24hours": "24 hours",
"field_threshold": "Alert Threshold", "field_threshold": "Alert Threshold",
"option_allthetimes": "all the times", "option_allthetimes": "all the times",

View File

@ -112,7 +112,8 @@ function RuleOptions({
<Option value="10m0s">{t('option_10min')}</Option> <Option value="10m0s">{t('option_10min')}</Option>
<Option value="15m0s">{t('option_15min')}</Option> <Option value="15m0s">{t('option_15min')}</Option>
<Option value="60m0s">{t('option_60min')}</Option> <Option value="60m0s">{t('option_60min')}</Option>
<Option value="1440m0s">{t('option_24hours')}</Option> <Option value="4h0m0s">{t('option_4hours')}</Option>
<Option value="24h0m0s">{t('option_24hours')}</Option>
</InlineSelect> </InlineSelect>
); );
}; };

View File

@ -126,7 +126,9 @@ export const toChartInterval = (evalWindow: string | undefined): Time => {
return '30min'; return '30min';
case '60m0s': case '60m0s':
return '30min'; return '30min';
case '1440m0s': case '4h0m0s':
return '4hr';
case '24h0m0s':
return '1day'; return '1day';
default: default:
return '5min'; return '5min';

View File

@ -7,6 +7,7 @@ type ThirtyMin = '30min';
type OneMin = '1min'; type OneMin = '1min';
type SixHour = '6hr'; type SixHour = '6hr';
type OneHour = '1hr'; type OneHour = '1hr';
type FourHour = '4hr';
type OneDay = '1day'; type OneDay = '1day';
type OneWeek = '1week'; type OneWeek = '1week';
type Custom = 'custom'; type Custom = 'custom';
@ -17,6 +18,7 @@ export type Time =
| FifteenMin | FifteenMin
| ThirtyMin | ThirtyMin
| OneMin | OneMin
| FourHour
| SixHour | SixHour
| OneHour | OneHour
| Custom | Custom

View File

@ -36,8 +36,9 @@ const GetMinMax = (
// one week = one day * 7 // one week = one day * 7
const minTimeAgo = getMinAgo({ minutes: 26 * 60 * 7 }).getTime(); const minTimeAgo = getMinAgo({ minutes: 26 * 60 * 7 }).getTime();
minTime = minTimeAgo; minTime = minTimeAgo;
} else if (interval === '6hr') { } else if (['4hr', '6hr'].includes(interval)) {
const minTimeAgo = getMinAgo({ minutes: 6 * 60 }).getTime(); const h = parseInt(interval.replace('hr', ''), 10);
const minTimeAgo = getMinAgo({ minutes: h * 60 }).getTime();
minTime = minTimeAgo; minTime = minTimeAgo;
} else if (interval === 'custom') { } else if (interval === 'custom') {
maxTime = (dateTimeRange || [])[1] || 0; maxTime = (dateTimeRange || [])[1] || 0;