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 { stderr } from '../../shell';
export const deleteAlertOverride: RequestHandler<
AlertOverrideParamsDictionary
> = (request, response) => {
export const deleteAlertOverride: RequestHandler<AlertOverrideReqParams> = (
request,
response,
) => {
const {
params: { uuid },
} = request;

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

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

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

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

Loading…
Cancel
Save