fix(striker-ui-api): allow filter alert override list with recipient

main
Tsu-ba-me 11 months ago
parent 4a7feae98a
commit dc0c919436
  1. 7
      striker-ui-api/src/lib/request_handlers/alert-override/deleteAlertOverride.ts
  2. 23
      striker-ui-api/src/lib/request_handlers/alert-override/getAlertOverride.ts
  3. 2
      striker-ui-api/src/lib/request_handlers/alert-override/getAlertOverrideDetail.ts
  4. 2
      striker-ui-api/src/lib/request_handlers/alert-override/updateAlertOverride.ts
  5. 6
      striker-ui-api/src/types/ApiAlertOverride.d.ts

@ -3,9 +3,10 @@ import { RequestHandler } from 'express';
import { execManageAlerts } from '../../execManageAlerts'; import { execManageAlerts } from '../../execManageAlerts';
import { stderr } from '../../shell'; import { stderr } from '../../shell';
export const deleteAlertOverride: RequestHandler< export const deleteAlertOverride: RequestHandler<AlertOverrideReqParams> = (
AlertOverrideParamsDictionary request,
> = (request, response) => { response,
) => {
const { const {
params: { uuid }, params: { uuid },
} = request; } = request;

@ -2,12 +2,27 @@ import { RequestHandler } from 'express';
import { DELETED } from '../../consts'; import { DELETED } from '../../consts';
import { buildUnknownIDCondition } from '../../buildCondition';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; import { buildQueryResultReducer } from '../../buildQueryResultModifier';
import { getShortHostName } from '../../disassembleHostName'; import { getShortHostName } from '../../disassembleHostName';
export const getAlertOverride: RequestHandler = buildGetRequestHandler( export const getAlertOverride: RequestHandler<
(request, options) => { AlertOverrideReqParams,
undefined,
undefined,
AlertOverrideReqQuery
> = buildGetRequestHandler((request, options) => {
const {
query: { 'mail-recipient': mailRecipient },
} = request;
const { after: mailRecipientCond } = buildUnknownIDCondition(
mailRecipient,
'b.recipient_uuid',
{ onFallback: () => 'TRUE' },
);
const query = ` const query = `
SELECT SELECT
a.alert_override_uuid, a.alert_override_uuid,
@ -24,6 +39,7 @@ export const getAlertOverride: RequestHandler = buildGetRequestHandler(
ON a.alert_override_host_uuid = c.host_uuid ON a.alert_override_host_uuid = c.host_uuid
WHERE a.alert_override_alert_level != -1 WHERE a.alert_override_alert_level != -1
AND b.recipient_name != '${DELETED}' AND b.recipient_name != '${DELETED}'
AND ${mailRecipientCond}
ORDER BY b.recipient_name ASC;`; ORDER BY b.recipient_name ASC;`;
const afterQueryReturn: QueryResultModifierFunction = const afterQueryReturn: QueryResultModifierFunction =
@ -65,5 +81,4 @@ export const getAlertOverride: RequestHandler = buildGetRequestHandler(
} }
return query; return query;
}, });
);

@ -7,7 +7,7 @@ import { buildQueryResultModifier } from '../../buildQueryResultModifier';
import { getShortHostName } from '../../disassembleHostName'; import { getShortHostName } from '../../disassembleHostName';
import { sanitize } from '../../sanitize'; import { sanitize } from '../../sanitize';
export const getAlertOverrideDetail: RequestHandler<AlertOverrideParamsDictionary> = export const getAlertOverrideDetail: RequestHandler<AlertOverrideReqParams> =
buildGetRequestHandler((request, options) => { buildGetRequestHandler((request, options) => {
const { const {
params: { uuid: rUuid }, params: { uuid: rUuid },

@ -5,7 +5,7 @@ import { getAlertOverrideRequestBody } from './getAlertOverrideRequestBody';
import { stderr, stdout } from '../../shell'; import { stderr, stdout } from '../../shell';
export const updateAlertOverride: RequestHandler< export const updateAlertOverride: RequestHandler<
AlertOverrideParamsDictionary, AlertOverrideReqParams,
undefined, undefined,
AlertOverrideRequestBody AlertOverrideRequestBody
> = (request, response) => { > = (request, response) => {

@ -11,7 +11,11 @@ type AlertOverrideOverviewList = {
[uuid: string]: AlertOverrideOverview; [uuid: string]: AlertOverrideOverview;
}; };
type AlertOverrideParamsDictionary = { type AlertOverrideReqQuery = {
'mail-recipient': string | string[];
};
type AlertOverrideReqParams = {
uuid: string; uuid: string;
}; };

Loading…
Cancel
Save