Skip to content

Commit

Permalink
Merge pull request #789 from catenax-ng/main
Browse files Browse the repository at this point in the history
Merge Quality Investigations / Alerts Frontend
  • Loading branch information
ds-mmaul authored Mar 26, 2024
2 parents 78621c6 + c00a952 commit 432e841
Show file tree
Hide file tree
Showing 64 changed files with 483 additions and 2,266 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #606 refactored response model to only be used by common model package tx-models
- #709 Fixed CVE-2024-22257 overriding spring-security-core from 6.1.7 to 6.2.3
- #596 Policy management has been moved to different module
- #616 Merged quality investigations / alerts into a single view
- #762 updated documentation for release 24.5
- #706 StartNotificationRequest now requires additional parameter type ("ALERT", "INVESTIGATION") which
- #706 Search criteria allows to filter by new type parameter
Expand Down
4 changes: 0 additions & 4 deletions frontend/cypress/support/step_definitions/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ When("user navigate to {string}", function(desiredMenu) {
cy.get('[href="/dashboard"]').click();
break;
}
case 'Quality investigations': {
cy.get('[href="/investigations"]').click();
break;
}
case 'Quality alerts': {
cy.get('[href="/alerts"]').click();
break;
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/app/mocks/services/alerts-mock/alerts.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ import {
} from './alerts.test.model';

const commonHandler = [
rest.post(`*${ environment.apiUrl }/alerts/:alertId/close`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/:alertId/close`, (req, res, ctx) => {
return res(ctx.status(204));
}),

rest.post(`*${ environment.apiUrl }/alerts/:alertId/approve`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/:alertId/approve`, (req, res, ctx) => {
return res(ctx.status(400), ctx.json({message: "Failed to send alert to EDC"}));
}),

rest.post(`*${ environment.apiUrl }/alerts/:alertId/cancel`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/:alertId/cancel`, (req, res, ctx) => {
return res(ctx.status(204));
}),

rest.post(`${ environment.apiUrl }/alerts/:alertId/update`, (req, res, ctx) => {
rest.post(`${ environment.apiUrl }/notifications/:alertId/update`, (req, res, ctx) => {
return res(ctx.status(204));
}),
];

export const alertsHandlers = [
rest.post(`*${ environment.apiUrl }/alerts/filter`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/filter`, (req, res, ctx) => {
const pagination = extractPaginationOfNotifications(req);

const currentStatus = [
Expand All @@ -65,7 +65,7 @@ export const alertsHandlers = [
return res(ctx.status(200), ctx.json(applyPagination(buildMockAlerts(currentStatus, 'SENDER'), pagination)));
}),

rest.post(`*${ environment.apiUrl }/alerts/filter`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/filter`, (req, res, ctx) => {
const pagination = extractPaginationOfNotifications(req);

const currentStatus = [
Expand All @@ -79,7 +79,7 @@ export const alertsHandlers = [
return res(ctx.status(200), ctx.json(applyPagination(buildMockAlerts(currentStatus, 'RECEIVER'), pagination)));
}),

rest.get(`*${ environment.apiUrl }/alerts/:alertId`, (req, res, ctx) => {
rest.get(`*${ environment.apiUrl }/notifications/:alertId`, (req, res, ctx) => {
const { alertId } = req.params;

const indexFromId = parseInt((alertId as string).replace('id-', ''), 10);
Expand All @@ -105,12 +105,12 @@ export const alertsHandlers = [

return res(ctx.status(200), ctx.json({ ...randomNotification, id: alertId }));
}),
rest.post(`*${ environment.apiUrl }/alerts`, (_, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications`, (_, res, ctx) => {
return res(ctx.status(400), ctx.json({message: "Error while sending Alert to EDC"} ));
//return res(ctx.status(200), ctx.json({ id: AlertIdPrefix + 1 }));
}),

rest.put(`*${ environment.apiUrl }/alerts/:alertId/status`, async (req, res, ctx) => {
rest.put(`*${ environment.apiUrl }/notifications/:alertId/status`, async (req, res, ctx) => {
const { alertId } = req.params;
const { status } = await req.json();

Expand All @@ -121,7 +121,7 @@ export const alertsHandlers = [
];

export const alertsTestHandlers = [
rest.post(`*${ environment.apiUrl }/alerts/filter`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/filter`, (req, res, ctx) => {
const pagination = extractPaginationOfNotifications(req);

const currentStatus = [
Expand All @@ -135,14 +135,14 @@ export const alertsTestHandlers = [
return res(ctx.status(200), ctx.json(applyPagination(testBuildMockAlerts(currentStatus, 'SENDER'), pagination)));
}),

rest.post(`*${ environment.apiUrl }/alerts/filter`, (req, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications/filter`, (req, res, ctx) => {
const pagination = extractPaginationOfNotifications(req);

const currentStatus = [ NotificationStatus.RECEIVED, NotificationStatus.ACKNOWLEDGED ];
return res(ctx.status(200), ctx.json(applyPagination(testBuildMockAlerts(currentStatus, 'RECEIVER'), pagination)));
}),

rest.get(`*${ environment.apiUrl }/alerts/:alertId`, (req, res, ctx) => {
rest.get(`*${ environment.apiUrl }/notifications/:alertId`, (req, res, ctx) => {
const { alertId } = req.params;

const indexFromId = parseInt((alertId as string).replace('id-', ''), 10);
Expand All @@ -163,11 +163,11 @@ export const alertsTestHandlers = [

return res(ctx.status(200), ctx.json({ ...randomNotification, id: alertId }));
}),
rest.post(`*${ environment.apiUrl }/alerts`, (_, res, ctx) => {
rest.post(`*${ environment.apiUrl }/notifications`, (_, res, ctx) => {
return res(ctx.status(200), ctx.json({ id: testAlertIdPrefix + 1 }));
}),

rest.put(`*${ environment.apiUrl }/alerts/:alertId/status`, async (req, res, ctx) => {
rest.put(`*${ environment.apiUrl }/notifications/:alertId/status`, async (req, res, ctx) => {
const { alertId } = req.params;
const { status } = await req.json();

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/app/mocks/services/alerts-mock/alerts.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
********************************************************************************/

import type { NotificationResponse } from '@shared/model/notification.model';
import { NotificationStatus } from '@shared/model/notification.model';
import { NotificationStatus, NotificationTypeResponse } from '@shared/model/notification.model';
import { Severity } from '@shared/model/severity.model';
import { getRandomAsset } from '../parts-mock/partsAsPlanned/partsAsPlanned.model';
import { MOCK_part_1 } from '../parts-mock/partsAsPlanned/partsAsPlanned.test.model';
Expand Down Expand Up @@ -61,6 +61,7 @@ export const buildMockAlerts = (
return {
id: `${ AlertIdPrefix }${ index + 1 }`,
description: `Alert No ${ index + 1 } ${ getRandomText(getRandomIntFromInterval(15, 500)) }`,
title: 'title',
status,
severity,
channel,
Expand All @@ -73,13 +74,15 @@ export const buildMockAlerts = (
targetDate: `2022-${ numberToString(month) }-${ numberToString(day + 1) }T12:34:12`,
assetIds: [ MOCK_part_1.id, getRandomAsset().id, getRandomAsset().id, getRandomAsset().id ],
errorMessage: errorAlert,
type: NotificationTypeResponse.ALERT,
};
});

const MockEmptyAlert: NotificationResponse = {
id: `${ AlertIdPrefix }000`,
description: `Alert No 000`,
status: NotificationStatus.CREATED,
title: 'Title',
severity: Severity.MINOR,
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
Expand All @@ -90,6 +93,7 @@ const MockEmptyAlert: NotificationResponse = {
targetDate: `2022-02-01T12:34:12`,
assetIds: [ getRandomAsset().id ],
channel: 'SENDER',
type: NotificationTypeResponse.ALERT,
};

export const getAlertById = (id: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
********************************************************************************/

import type { NotificationResponse } from '@shared/model/notification.model';
import { NotificationStatus } from '@shared/model/notification.model';
import { NotificationStatus, NotificationTypeResponse } from '@shared/model/notification.model';
import { Severity } from '@shared/model/severity.model';
import { getRandomAsset } from '../parts-mock/partsAsPlanned/partsAsPlanned.model';
import { MOCK_part_1 } from '../parts-mock/partsAsPlanned/partsAsPlanned.test.model';
Expand Down Expand Up @@ -50,11 +50,13 @@ export const buildMockAlerts = (
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
sendTo: 'BPN20000000OEM0B',
title: 'Title',
sendToName: 'OEM xxxxxxxxxxxxxxx B',
reason: { close: '', accept: '', decline: '' },
createdDate: `2022-${ numberToString(month) }-${ numberToString(day) }T12:34:12`,
assetIds: [ MOCK_part_1.id, getRandomAsset().id, getRandomAsset().id, getRandomAsset().id ],
errorMessage: errorAlert,
type: NotificationTypeResponse.ALERT,
};
});

Expand All @@ -71,6 +73,8 @@ export const MockEmptyAlert: NotificationResponse = {
createdDate: `2022-05-01T12:34:12`,
assetIds: [ getRandomAsset().id ],
channel: 'SENDER',
title: 'Title',
type: NotificationTypeResponse.ALERT,
};

export const getAlertById = (id: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
********************************************************************************/

import type { NotificationResponse } from '@shared/model/notification.model';
import { NotificationStatus, NotificationType } from '@shared/model/notification.model';
import { NotificationStatus, NotificationType, NotificationTypeResponse } from '@shared/model/notification.model';
import { Severity } from '@shared/model/severity.model';
import { getRandomAsset } from '../parts-mock/partsAsPlanned/partsAsPlanned.model';
import { MOCK_part_1 } from '../parts-mock/partsAsPlanned/partsAsPlanned.test.model';
Expand All @@ -29,74 +29,77 @@ import { getRandomIntFromInterval, getRandomText } from '../text-generator.helpe
export const InvestigationIdPrefix = 'id-';

// TODO: rethink this approach
const severities = [ Severity.MINOR, Severity.MAJOR, Severity.CRITICAL, Severity.LIFE_THREATENING ];
const severities = [Severity.MINOR, Severity.MAJOR, Severity.CRITICAL, Severity.LIFE_THREATENING];

export const buildMockInvestigations = (
statuses: NotificationStatus[],
channel: 'SENDER' | 'RECEIVER',
statuses: NotificationStatus[],
channel: 'SENDER' | 'RECEIVER',
): NotificationResponse[] =>
new Array(101).fill(null).map((_, index) => {
const status = statuses[index % statuses.length];
const severity = severities[index % severities.length];
// every 10th alert should have an error
const errorInvestigation = (index + 1) % 10 === 0 ? 'The Services returned an Error while processing this Investigation' : undefined;
new Array(101).fill(null).map((_, index) => {
const status = statuses[index % statuses.length];
const severity = severities[index % severities.length];
// every 10th alert should have an error
const errorInvestigation = (index + 1) % 10 === 0 ? 'The Services returned an Error while processing this Investigation' : undefined;

const close = status === NotificationStatus.CLOSED ? getRandomText(getRandomIntFromInterval(15, 500)) : '';
const isDeclined = Math.random() >= 0.5;
const close = status === NotificationStatus.CLOSED ? getRandomText(getRandomIntFromInterval(15, 500)) : '';
const isDeclined = Math.random() >= 0.5;

const decline =
status === NotificationStatus.DECLINED || (!!close && isDeclined)
? getRandomText(getRandomIntFromInterval(15, 500))
: '';
const decline =
status === NotificationStatus.DECLINED || (!!close && isDeclined)
? getRandomText(getRandomIntFromInterval(15, 500))
: '';

const accept =
status === NotificationStatus.ACCEPTED || (!!close && !isDeclined)
? getRandomText(getRandomIntFromInterval(15, 500))
: '';
const accept =
status === NotificationStatus.ACCEPTED || (!!close && !isDeclined)
? getRandomText(getRandomIntFromInterval(15, 500))
: '';

const numberToString = (i: number) => i.toString().padStart(2, '0');
const month = getRandomIntFromInterval(1, 12);
const day = getRandomIntFromInterval(1, 27);

return {
id: `${ InvestigationIdPrefix }${ index + 1 }`,
description: `Investigation No ${ index + 1 } ${ getRandomText(getRandomIntFromInterval(15, 500)) }`,
status,
severity,
channel,
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
sendTo: 'BPN20000000OEM0B',
sendToName: 'OEM xxxxxxxxxxxxxxx B',
reason: { close, decline, accept },
createdDate: `2022-${ numberToString(month) }-${ numberToString(day) }T12:34:12`,
targetDate: `2022-${ numberToString(month) }-${ numberToString(day + 1) }T11:34:12Z`,
assetIds: [ MOCK_part_1.id, getRandomAsset().id, getRandomAsset().id, getRandomAsset().id ],
errorMessage: errorInvestigation,
notificationType: NotificationType.INVESTIGATION,
};
});
const numberToString = (i: number) => i.toString().padStart(2, '0');
const month = getRandomIntFromInterval(1, 12);
const day = getRandomIntFromInterval(1, 27);
const title = 'Title';
return {
id: `${InvestigationIdPrefix}${index + 1}`,
description: `Investigation No ${index + 1} ${getRandomText(getRandomIntFromInterval(15, 500))}`,
status,
severity,
channel,
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
title,
sendTo: 'BPN20000000OEM0B',
sendToName: 'OEM xxxxxxxxxxxxxxx B',
reason: {close, decline, accept},
createdDate: `2022-${numberToString(month)}-${numberToString(day)}T12:34:12`,
targetDate: `2022-${numberToString(month)}-${numberToString(day + 1)}T11:34:12Z`,
assetIds: [MOCK_part_1.id, getRandomAsset().id, getRandomAsset().id, getRandomAsset().id],
errorMessage: errorInvestigation,
type: NotificationTypeResponse.INVESTIGATION,
};
});

const MockEmptyInvestigation: NotificationResponse = {
id: `${ InvestigationIdPrefix }000`,
description: `Investigation No 000`,
status: NotificationStatus.CREATED,
severity: Severity.MINOR,
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
sendTo: 'BPN20000000OEM0B',
sendToName: 'OEM xxxxxxxxxxxxxxx B',
reason: { close: '', decline: '', accept: '' },
createdDate: `2022-05-01T12:34:12`,
targetDate: `2022-02-01T12:34:12`,
assetIds: [ getRandomAsset().id ],
channel: 'SENDER',
id: `${InvestigationIdPrefix}000`,
description: `Investigation No 000`,
status: NotificationStatus.CREATED,
severity: Severity.MINOR,
createdBy: 'BPN10000000OEM0A',
createdByName: 'OEM xxxxxxxxxxxxxxx A',
sendTo: 'BPN20000000OEM0B',
sendToName: 'OEM xxxxxxxxxxxxxxx B',
title: 'Title',
reason: {close: '', decline: '', accept: ''},
createdDate: `2022-05-01T12:34:12`,
targetDate: `2022-02-01T12:34:12`,
assetIds: [getRandomAsset().id],
channel: 'SENDER',
type: NotificationTypeResponse.INVESTIGATION
};

export interface NotificationFilter {
notificationIds: string[];
notificationIds: string[];
}

export const getInvestigationById = (id: string) => {
return [].find(investigation => investigation.id === id) || { ...MockEmptyInvestigation, id };
return [].find(investigation => investigation.id === id) || {...MockEmptyInvestigation, id};
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
********************************************************************************/

import type { NotificationResponse } from '@shared/model/notification.model';
import { NotificationStatus } from '@shared/model/notification.model';
import { NotificationStatus, NotificationTypeResponse } from '@shared/model/notification.model';
import { Severity } from '@shared/model/severity.model';
import { getRandomAsset } from '../parts-mock/partsAsPlanned/partsAsPlanned.model';
import { MOCK_part_1 } from '../parts-mock/partsAsPlanned/partsAsPlanned.test.model';
Expand Down Expand Up @@ -56,11 +56,14 @@ export const buildMockInvestigations = (
createdDate: `2022-${ numberToString(month) }-${ numberToString(day) }T12:34:12`,
assetIds: [ MOCK_part_1.id, getRandomAsset().id, getRandomAsset().id, getRandomAsset().id ],
errorMessage: errorInvestigation,
title: 'Title',
type: NotificationTypeResponse.INVESTIGATION,
};
});

const MockEmptyInvestigation: NotificationResponse = {
id: `${ InvestigationIdPrefix }000`,
title: '',
description: `Investigation No 000`,
status: NotificationStatus.CREATED,
severity: Severity.MINOR,
Expand All @@ -72,6 +75,7 @@ const MockEmptyInvestigation: NotificationResponse = {
createdDate: `2022-05-01T12:34:12`,
assetIds: [ getRandomAsset().id ],
channel: 'SENDER',
type: NotificationTypeResponse.INVESTIGATION,
};

export const getInvestigationById = (id: string) => {
Expand Down
Loading

0 comments on commit 432e841

Please sign in to comment.