Align alert grouping defaults with backend
This commit is contained in:
parent
93d8c624b4
commit
9b50dec0e4
2 changed files with 8 additions and 3 deletions
|
|
@ -216,6 +216,11 @@ const COOLDOWN_DEFAULT_MINUTES = 30;
|
||||||
const MAX_ALERTS_MIN = 1;
|
const MAX_ALERTS_MIN = 1;
|
||||||
const MAX_ALERTS_MAX = 10;
|
const MAX_ALERTS_MAX = 10;
|
||||||
const MAX_ALERTS_DEFAULT = 3;
|
const MAX_ALERTS_DEFAULT = 3;
|
||||||
|
const GROUPING_WINDOW_DEFAULT_SECONDS = 30; // Keep in sync with backend default in internal/alerts/alerts.go
|
||||||
|
const GROUPING_WINDOW_DEFAULT_MINUTES = Math.max(
|
||||||
|
0,
|
||||||
|
Math.round(GROUPING_WINDOW_DEFAULT_SECONDS / 60),
|
||||||
|
);
|
||||||
|
|
||||||
export const clampCooldownMinutes = (value?: number): number => {
|
export const clampCooldownMinutes = (value?: number): number => {
|
||||||
const numericValue = typeof value === 'number' ? value : Number.NaN;
|
const numericValue = typeof value === 'number' ? value : Number.NaN;
|
||||||
|
|
@ -280,7 +285,7 @@ export const createDefaultCooldown = (): CooldownConfig => ({
|
||||||
|
|
||||||
export const createDefaultGrouping = (): GroupingConfig => ({
|
export const createDefaultGrouping = (): GroupingConfig => ({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
window: 1,
|
window: GROUPING_WINDOW_DEFAULT_MINUTES,
|
||||||
byNode: true,
|
byNode: true,
|
||||||
byGuest: false,
|
byGuest: false,
|
||||||
});
|
});
|
||||||
|
|
@ -1094,7 +1099,7 @@ const [appriseConfig, setAppriseConfig] = createSignal<UIAppriseConfig>(
|
||||||
? groupingConfig.window
|
? groupingConfig.window
|
||||||
: typeof config.schedule.groupingWindow === 'number'
|
: typeof config.schedule.groupingWindow === 'number'
|
||||||
? config.schedule.groupingWindow
|
? config.schedule.groupingWindow
|
||||||
: 30;
|
: GROUPING_WINDOW_DEFAULT_SECONDS;
|
||||||
const normalizedGroupingWindowSeconds = Math.max(0, rawGroupingWindowSeconds);
|
const normalizedGroupingWindowSeconds = Math.max(0, rawGroupingWindowSeconds);
|
||||||
const groupingWindowMinutes = Math.round(normalizedGroupingWindowSeconds / 60);
|
const groupingWindowMinutes = Math.round(normalizedGroupingWindowSeconds / 60);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ describe('default schedule helpers', () => {
|
||||||
it('creates grouping defaults', () => {
|
it('creates grouping defaults', () => {
|
||||||
expect(createDefaultGrouping()).toEqual({
|
expect(createDefaultGrouping()).toEqual({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
window: 5,
|
window: 1,
|
||||||
byNode: true,
|
byNode: true,
|
||||||
byGuest: false,
|
byGuest: false,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue