|
|
@ -2,13 +2,28 @@ 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, |
|
|
|
const query = ` |
|
|
|
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 |
|
|
|
SELECT |
|
|
|
a.alert_override_uuid, |
|
|
|
a.alert_override_uuid, |
|
|
|
a.alert_override_alert_level, |
|
|
|
a.alert_override_alert_level, |
|
|
@ -24,46 +39,46 @@ 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 = |
|
|
|
buildQueryResultReducer<AlertOverrideOverviewList>( |
|
|
|
buildQueryResultReducer<AlertOverrideOverviewList>( |
|
|
|
( |
|
|
|
( |
|
|
|
previous, |
|
|
|
previous, |
|
|
|
[ |
|
|
|
[ |
|
|
|
uuid, |
|
|
|
uuid, |
|
|
|
level, |
|
|
|
level, |
|
|
|
mailRecipientUuid, |
|
|
|
mailRecipientUuid, |
|
|
|
mailRecipientName, |
|
|
|
mailRecipientName, |
|
|
|
hostUuid, |
|
|
|
hostUuid, |
|
|
|
|
|
|
|
hostName, |
|
|
|
|
|
|
|
hostType, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
) => { |
|
|
|
|
|
|
|
previous[uuid] = { |
|
|
|
|
|
|
|
host: { |
|
|
|
hostName, |
|
|
|
hostName, |
|
|
|
hostType, |
|
|
|
hostType, |
|
|
|
], |
|
|
|
hostUUID: hostUuid, |
|
|
|
) => { |
|
|
|
shortHostName: getShortHostName(hostName), |
|
|
|
previous[uuid] = { |
|
|
|
}, |
|
|
|
host: { |
|
|
|
level: Number(level), |
|
|
|
hostName, |
|
|
|
mailRecipient: { |
|
|
|
hostType, |
|
|
|
name: mailRecipientName, |
|
|
|
hostUUID: hostUuid, |
|
|
|
uuid: mailRecipientUuid, |
|
|
|
shortHostName: getShortHostName(hostName), |
|
|
|
}, |
|
|
|
}, |
|
|
|
uuid, |
|
|
|
level: Number(level), |
|
|
|
}; |
|
|
|
mailRecipient: { |
|
|
|
|
|
|
|
name: mailRecipientName, |
|
|
|
|
|
|
|
uuid: mailRecipientUuid, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
uuid, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
return previous; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{}, |
|
|
|
{}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (options) { |
|
|
|
if (options) { |
|
|
|
options.afterQueryReturn = afterQueryReturn; |
|
|
|
options.afterQueryReturn = afterQueryReturn; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return query; |
|
|
|
return query; |
|
|
|
}, |
|
|
|
}); |
|
|
|
); |
|
|
|
|
|
|
|