Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 616 - rename notification classes / directories #803

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/src/app/modules/core/known-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const OTHER_PARTS_BASE_ROUTE = 'otherParts';
export const DASHBOARD_BASE_ROUTE = 'dashboard';
export const ADMIN_BASE_ROUTE = 'admin';
export const ABOUT_BASE_ROUTE = 'about';
export const ALERT_BASE_ROUTE = 'alerts';
export const NOTIFICATION_BASE_ROUTE = 'alerts';
export const NO_PERMISSION_BASE_ROUTE = 'no-permissions';

export const NavigableUrls = [
Expand All @@ -36,13 +36,13 @@ export const NavigableUrls = [
DASHBOARD_BASE_ROUTE,
ADMIN_BASE_ROUTE,
ABOUT_BASE_ROUTE,
ALERT_BASE_ROUTE,
NOTIFICATION_BASE_ROUTE,
] as const;

export type KnownUrl = (typeof NavigableUrls)[number];

export const getRoute = (urlType: KnownUrl, ...args): PageRoute => {
if (urlType === ALERT_BASE_ROUTE) {
if (urlType === NOTIFICATION_BASE_ROUTE) {
return getNotificationInboxRoute(urlType, ...args);
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/modules/core/layout/layout.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { RouterModule, Routes } from '@angular/router';
import {
ABOUT_BASE_ROUTE,
ADMIN_BASE_ROUTE,
ALERT_BASE_ROUTE,
NOTIFICATION_BASE_ROUTE,
DASHBOARD_BASE_ROUTE,
NO_PERMISSION_BASE_ROUTE,
OTHER_PARTS_BASE_ROUTE,
Expand Down Expand Up @@ -81,8 +81,8 @@ const routes: Routes = [
canActivate: [ RoleGuard ],
},
{
path: ALERT_BASE_ROUTE,
loadChildren: () => import('../../page/alerts/alerts.module').then(m => m.AlertsModule),
path: NOTIFICATION_BASE_ROUTE,
loadChildren: () => import('@page/notifications/notifications.module').then(m => m.NotificationsModule),
data: {
breadcrumb: 'alerts',
roles: [ 'user', 'admin' ],
Expand Down
102 changes: 0 additions & 102 deletions frontend/src/app/modules/page/alerts/core/alerts.facade.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ALERT_BASE_ROUTE, getRoute } from '@core/known-route';
import { NOTIFICATION_BASE_ROUTE, getRoute } from '@core/known-route';
import { DashboardStats } from '@page/dashboard/model/dashboard.model';
import { MetricData } from '@page/dashboard/presentation/dashboard.model';
import { TableType } from '@shared/components/multi-select-autocomplete/table-type.model';
Expand Down Expand Up @@ -70,7 +70,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
const {
link: alertLink,
queryParams: alertQueryParams,
} = getRoute(ALERT_BASE_ROUTE, NotificationStatusGroup.QUEUED_AND_REQUESTED);
} = getRoute(NOTIFICATION_BASE_ROUTE, NotificationStatusGroup.QUEUED_AND_REQUESTED);

this.alertLink = alertLink;
this.alertParams = alertQueryParams;
Expand Down Expand Up @@ -130,7 +130,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
}

public onAlertSelected(notification: Notification): void {
const { link } = getRoute(ALERT_BASE_ROUTE);
const { link } = getRoute(NOTIFICATION_BASE_ROUTE);
this.router.navigate([ `/${ link }/${ notification.id }` ]).then();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import { TitleCasePipe } from '@angular/common';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { AlertDetailFacade } from '@page/alerts/core/alert-detail.facade';
import { AlertDetailState } from '@page/alerts/core/alert-detail.state';
import { NotificationDetailFacade } from '@page/notifications/core/notification-detail.facade';
import { NotificationDetailState } from '@page/notifications/core/notification-detail.state';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { Part } from '@page/parts/model/parts.model';
import { PartsAssembler } from '@shared/assembler/parts.assembler';
Expand All @@ -30,9 +30,9 @@ import { PartsService } from '@shared/service/parts.service';
import { KeycloakService } from 'keycloak-angular';
import { MOCK_part_1 } from '../../../../mocks/services/parts-mock/partsAsPlanned/partsAsPlanned.test.model';

describe('AlertDetailFacade', () => {
let alertDetailFacade: AlertDetailFacade;
let alertDetailState: AlertDetailState;
describe('NotificationDetailFacade', () => {
let notificationDetailFacade: NotificationDetailFacade;
let notificationDetailState: NotificationDetailState;
let partService: PartsService;

beforeEach(() => {
Expand All @@ -45,23 +45,23 @@ describe('AlertDetailFacade', () => {
KeycloakService,
PartsService,
TitleCasePipe,
AlertDetailFacade,
AlertDetailState,
NotificationDetailFacade,
NotificationDetailState,
FormatPartlistSemanticDataModelToCamelCasePipe,
],
});

alertDetailFacade = TestBed.inject(AlertDetailFacade);
notificationDetailFacade = TestBed.inject(NotificationDetailFacade);

alertDetailState = TestBed.inject(AlertDetailState);
notificationDetailState = TestBed.inject(NotificationDetailState);

partService = TestBed.inject(PartsService);
});

[
{
method: 'sortNotificationParts',
prop: 'alertPartsInformation' as any,
prop: 'notificationPartsInformation' as any,
},
{
method: 'sortSupplierParts',
Expand All @@ -84,11 +84,11 @@ describe('AlertDetailFacade', () => {

it('should pass sortParts', function() {

spyOnProperty(alertDetailState, object.prop, 'get').and.returnValue({
spyOnProperty(notificationDetailState, object.prop, 'get').and.returnValue({
data: fallacy,
});

alertDetailFacade[object.method]('', '');
notificationDetailFacade[object.method]('', '');

index == 0
? (() => {
Expand All @@ -103,13 +103,13 @@ describe('AlertDetailFacade', () => {

it('should set part infos after sort', function() {

spyOnProperty(alertDetailState, object.prop, 'get').and.returnValue({
spyOnProperty(notificationDetailState, object.prop, 'get').and.returnValue({
data: fallacy,
});

this.spyPropSet = spyOnProperty(alertDetailState, object.prop, 'set');
this.spyPropSet = spyOnProperty(notificationDetailState, object.prop, 'set');

alertDetailFacade[object.method]('', '');
notificationDetailFacade[object.method]('', '');

index == 0
? (() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
********************************************************************************/

import { Injectable } from '@angular/core';
import { AlertDetailState } from '@page/alerts/core/alert-detail.state';
import { NotificationDetailState } from '@page/notifications/core/notification-detail.state';
import { Part } from '@page/parts/model/parts.model';
import { Notification } from '@shared/model/notification.model';
import { View } from '@shared/model/view.model';
Expand All @@ -29,43 +29,43 @@ import { filter, map, switchMap } from 'rxjs/operators';
import { SortDirection } from '../../../../mocks/services/pagination.helper';

@Injectable()
export class AlertDetailFacade {
export class NotificationDetailFacade {
private notificationPartsInformationDescription: Subscription;
private supplierPartsSubscription: Subscription;

constructor(
private readonly partsService: PartsService,
private readonly alertDetailState: AlertDetailState,
private readonly notificationDetailState: NotificationDetailState,
private readonly formatPartlistSemanticDataModelToCamelCasePipe: FormatPartlistSemanticDataModelToCamelCasePipe,
) {
}

public get notificationPartsInformation$(): Observable<View<Part[]>> {
return this.alertDetailState.alertPartsInformation$;
return this.notificationDetailState.notificationPartsInformation$;
}

public get supplierPartsInformation$(): Observable<View<Part[]>> {
return this.alertDetailState.supplierPartsInformation$;
return this.notificationDetailState.supplierPartsInformation$;
}

public get selected$(): Observable<View<Notification>> {
return this.alertDetailState.selected$;
return this.notificationDetailState.selected$;
}

public set selected(selectedAlert: View<Notification>) {
this.alertDetailState.selected = selectedAlert;
public set selected(selectedNotification: View<Notification>) {
this.notificationDetailState.selected = selectedNotification;
}

public get selected(): View<Notification> {
return this.alertDetailState.selected;
return this.notificationDetailState.selected;
}

public setAlertPartsInformation(notification: Notification): void {
public setNotificationPartsInformation(notification: Notification): void {
this.notificationPartsInformationDescription?.unsubscribe();
this.alertDetailState.alertPartsInformation = { loader: true };
this.notificationDetailState.notificationPartsInformation = { loader: true };

if (!notification.assetIds.length) {
this.alertDetailState.alertPartsInformation = { data: [] };
this.notificationDetailState.notificationPartsInformation = { data: [] };
return;
}

Expand All @@ -74,18 +74,18 @@ export class AlertDetailFacade {
.subscribe({
next: data => {
this.formatPartlistSemanticDataModelToCamelCasePipe.transform(data);
this.alertDetailState.alertPartsInformation = { data };
this.notificationDetailState.notificationPartsInformation = { data };
},
error: error => (this.alertDetailState.alertPartsInformation = { error }),
error: error => (this.notificationDetailState.notificationPartsInformation = { error }),
});

}

public setAndSupplierPartsInformation(): void {
this.supplierPartsSubscription?.unsubscribe();
this.alertDetailState.supplierPartsInformation = { loader: true };
this.notificationDetailState.supplierPartsInformation = { loader: true };

this.supplierPartsSubscription = this.alertDetailState.alertPartsInformation$
this.supplierPartsSubscription = this.notificationDetailState.notificationPartsInformation$
.pipe(
filter(view => !!view.data),
map(({ data }) => this.getIdsFromPartList(data)),
Expand All @@ -94,26 +94,26 @@ export class AlertDetailFacade {
.subscribe({
next: data => {
this.formatPartlistSemanticDataModelToCamelCasePipe.transform(data);
this.alertDetailState.supplierPartsInformation = { data };
this.notificationDetailState.supplierPartsInformation = { data };
},
error: error => (this.alertDetailState.supplierPartsInformation = { error }),
error: error => (this.notificationDetailState.supplierPartsInformation = { error }),
});
}

public sortNotificationParts(key: string, direction: SortDirection): void {
const { data } = this.alertDetailState.alertPartsInformation;
const { data } = this.notificationDetailState.notificationPartsInformation;
if (!data) return;

const sortedData = this.partsService.sortParts(data, key, direction);
this.alertDetailState.alertPartsInformation = { data: [ ...sortedData ] };
this.notificationDetailState.notificationPartsInformation = { data: [ ...sortedData ] };
}

public sortSupplierParts(key: string, direction: SortDirection): void {
const { data } = this.alertDetailState.supplierPartsInformation;
const { data } = this.notificationDetailState.supplierPartsInformation;
if (!data) return;

const sortedData = this.partsService.sortParts(data, key, direction);
this.alertDetailState.supplierPartsInformation = { data: [ ...sortedData ] };
this.notificationDetailState.supplierPartsInformation = { data: [ ...sortedData ] };
}

public unsubscribeSubscriptions(): void {
Expand Down
Loading
Loading