From e21757b8e8b33bf8097d797bfd2427fc3f5b99f8 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Wed, 12 May 2021 10:34:10 +0200 Subject: [PATCH] Added error handling and now possible to post employees --- apps/dafa-web/src/app/app.component.html | 1 + apps/dafa-web/src/app/app.module.ts | 12 +- .../toast-list/toast-list.component.html | 15 + .../toast-list/toast-list.component.scss | 55 + .../toast-list/toast-list.component.spec.ts | 25 + .../toast-list/toast-list.component.ts | 30 + .../toast-list/toast-list.module.ts | 11 + .../toast-list/toast/toast.component.html | 14 + .../toast-list/toast/toast.component.scss | 63 + .../toast-list/toast/toast.component.spec.ts | 25 + .../toast-list/toast/toast.component.ts | 32 + .../toast-list/toast/toast.module.ts | 21 + .../src/app/data/enums/error-severity.enum.ts | 5 + .../src/app/data/enums/error-type.enum.ts | 6 + .../src/app/data/enums/toast-position.enum.ts | 11 + .../models/api/employee-response.model.ts | 26 - .../data/models/api/user-response.model.ts | 23 - .../src/app/data/models/employee.model.ts | 66 +- .../src/app/data/models/error/custom-error.ts | 58 + .../src/app/data/models/user.model.ts | 27 +- .../custom-error-handler.module.ts | 13 + .../create-account.component.html | 8 + .../create-account.component.ts | 13 +- .../app/services/api/employee.service copy.ts | 69 - .../src/app/services/api/employee.service.ts | 33 +- .../src/app/services/api/user.service.ts | 7 +- .../src/app/services/error.service.ts | 34 + .../src/styles/variables/_shadows.scss | 1 + package-lock.json | 26604 +++++++++++++++- package.json | 1 + tsconfig.base.json | 1 + 31 files changed, 27107 insertions(+), 203 deletions(-) create mode 100644 apps/dafa-web/src/app/components/toast-list/toast-list.component.html create mode 100644 apps/dafa-web/src/app/components/toast-list/toast-list.component.scss create mode 100644 apps/dafa-web/src/app/components/toast-list/toast-list.component.spec.ts create mode 100644 apps/dafa-web/src/app/components/toast-list/toast-list.component.ts create mode 100644 apps/dafa-web/src/app/components/toast-list/toast-list.module.ts create mode 100644 apps/dafa-web/src/app/components/toast-list/toast/toast.component.html create mode 100644 apps/dafa-web/src/app/components/toast-list/toast/toast.component.scss create mode 100644 apps/dafa-web/src/app/components/toast-list/toast/toast.component.spec.ts create mode 100644 apps/dafa-web/src/app/components/toast-list/toast/toast.component.ts create mode 100644 apps/dafa-web/src/app/components/toast-list/toast/toast.module.ts create mode 100644 apps/dafa-web/src/app/data/enums/error-severity.enum.ts create mode 100644 apps/dafa-web/src/app/data/enums/error-type.enum.ts create mode 100644 apps/dafa-web/src/app/data/enums/toast-position.enum.ts delete mode 100644 apps/dafa-web/src/app/data/models/api/employee-response.model.ts delete mode 100644 apps/dafa-web/src/app/data/models/api/user-response.model.ts create mode 100644 apps/dafa-web/src/app/data/models/error/custom-error.ts create mode 100644 apps/dafa-web/src/app/interceptors/custom-error-handler.module.ts delete mode 100644 apps/dafa-web/src/app/services/api/employee.service copy.ts create mode 100644 apps/dafa-web/src/app/services/error.service.ts create mode 100644 apps/dafa-web/src/styles/variables/_shadows.scss diff --git a/apps/dafa-web/src/app/app.component.html b/apps/dafa-web/src/app/app.component.html index 2cc0df8..9ee2bcb 100644 --- a/apps/dafa-web/src/app/app.component.html +++ b/apps/dafa-web/src/app/app.component.html @@ -14,3 +14,4 @@ + diff --git a/apps/dafa-web/src/app/app.module.ts b/apps/dafa-web/src/app/app.module.ts index e5dec12..f1791dd 100644 --- a/apps/dafa-web/src/app/app.module.ts +++ b/apps/dafa-web/src/app/app.module.ts @@ -1,13 +1,15 @@ import { DigiNgNavigationBreadcrumbsModule } from '@af/digi-ng/_navigation/navigation-breadcrumbs'; import { HttpClientModule } from '@angular/common/http'; -import { NgModule } from '@angular/core'; +import { ErrorHandler, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { RouterModule } from '@angular/router'; +import { CustomErrorHandler } from '@dafa-interceptors/custom-error-handler.module'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { NavigationModule } from './components/navigation/navigation.module'; import { SidebarModule } from './components/sidebar/sidebar.module'; import { SkipToContentModule } from './components/skip-to-content/skip-to-content.module'; +import { ToastListModule } from './components/toast-list/toast-list.module'; @NgModule({ declarations: [AppComponent], @@ -19,9 +21,15 @@ import { SkipToContentModule } from './components/skip-to-content/skip-to-conten SkipToContentModule, NavigationModule, SidebarModule, + ToastListModule, DigiNgNavigationBreadcrumbsModule, ], - providers: [], + providers: [ + { + provide: ErrorHandler, + useClass: CustomErrorHandler, + }, + ], bootstrap: [AppComponent], }) export class AppModule {} diff --git a/apps/dafa-web/src/app/components/toast-list/toast-list.component.html b/apps/dafa-web/src/app/components/toast-list/toast-list.component.html new file mode 100644 index 0000000..9c20563 --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast-list.component.html @@ -0,0 +1,15 @@ +
+ +
+ +

{{ errors.length }} fel har uppstått!

+
    +
  • {{ error.name }}: {{ error.message }}
  • +
+
+
+
diff --git a/apps/dafa-web/src/app/components/toast-list/toast-list.component.scss b/apps/dafa-web/src/app/components/toast-list/toast-list.component.scss new file mode 100644 index 0000000..0a23a39 --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast-list.component.scss @@ -0,0 +1,55 @@ +@import 'mixins/list'; + +.toast-list { + position: fixed; + pointer-events: none; + z-index: 9999; + margin: var(--digi--layout--gutter); + top: 0; + right: 0; + bottom: 0; + left: 0; + display: flex; + + &--top-right { + justify-content: flex-end; + } + &--top-left { + justify-content: flex-start; + } + &--top-center { + justify-content: center; + } + &--center-right { + justify-content: flex-end; + align-items: center; + } + &--center-left { + justify-content: flex-start; + align-items: center; + } + &--center-center { + justify-content: center; + align-items: center; + } + &--bottom-right { + justify-content: flex-end; + align-items: flex-end; + } + &--bottom-left { + justify-content: flex-start; + align-items: flex-end; + } + &--bottom-center { + justify-content: center; + align-items: flex-end; + } + + &__list { + @include dafa__reset-list; + } + + &__item:not(:first-child) { + margin-top: var(--digi--layout--gutter); + } +} diff --git a/apps/dafa-web/src/app/components/toast-list/toast-list.component.spec.ts b/apps/dafa-web/src/app/components/toast-list/toast-list.component.spec.ts new file mode 100644 index 0000000..7925e4c --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast-list.component.spec.ts @@ -0,0 +1,25 @@ +/* tslint:disable:no-unused-variable */ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { ToastListComponent } from './toast-list.component'; + + +describe('ToastListComponent', () => { + let component: ToastListComponent; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ToastListComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ToastListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/dafa-web/src/app/components/toast-list/toast-list.component.ts b/apps/dafa-web/src/app/components/toast-list/toast-list.component.ts new file mode 100644 index 0000000..cd074b9 --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast-list.component.ts @@ -0,0 +1,30 @@ +import { AriaLivePoliteness } from '@angular/cdk/a11y'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ToastPosition } from '@dafa-enums/toast-position.enum'; +import { CustomError } from '@dafa-models/error/custom-error'; +import { ErrorService } from '@dafa-services/error.service'; +import { Observable } from 'rxjs'; + +@Component({ + selector: 'dafa-toast-list', + templateUrl: './toast-list.component.html', + styleUrls: ['./toast-list.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ToastListComponent { + @Input() ariaLivePoliteness: AriaLivePoliteness = 'assertive'; + @Input() ariaAtomic = true; + @Input() position: ToastPosition = ToastPosition.TOP_RIGHT; + + errors$: Observable = this.errorService.errors$; + + constructor(private errorService: ErrorService) {} + + get className(): string { + return `toast-list toast-list--${this.position}`; + } + + removeError(error: CustomError): void { + this.errorService.remove(error); + } +} diff --git a/apps/dafa-web/src/app/components/toast-list/toast-list.module.ts b/apps/dafa-web/src/app/components/toast-list/toast-list.module.ts new file mode 100644 index 0000000..0d702f6 --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast-list.module.ts @@ -0,0 +1,11 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { ToastListComponent } from './toast-list.component'; +import { ToastModule } from './toast/toast.module'; + +@NgModule({ + declarations: [ToastListComponent], + imports: [CommonModule, ToastModule], + exports: [ToastListComponent], +}) +export class ToastListModule {} diff --git a/apps/dafa-web/src/app/components/toast-list/toast/toast.component.html b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.html new file mode 100644 index 0000000..c7dcf17 --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.html @@ -0,0 +1,14 @@ +
+
+ + + +
+
+ +

{{ error.name }}

+

{{ error.message }}

+
+
diff --git a/apps/dafa-web/src/app/components/toast-list/toast/toast.component.scss b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.scss new file mode 100644 index 0000000..30593aa --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.scss @@ -0,0 +1,63 @@ +@import 'variables/shadows'; + +.toast { + position: relative; + display: flex; + align-items: stretch; + background-color: var(--digi--ui--color--informative); + border: 2px solid var(--digi--ui--color--informative); + box-shadow: $dafa__shadow; + pointer-events: auto; + color: var(--digi--typography--color--text); + font-size: 1rem; + + &--high { + background-color: var(--digi--ui--color--danger); + border-color: var(--digi--ui--color--danger); + } + + &--medium { + background-color: var(--digi--ui--color--warning); + border-color: var(--digi--ui--color--warning); + } + + &__icon-wrapper { + display: flex; + align-items: center; + padding: var(--digi--layout--gutter); + color: var(--digi--typography--color--text--light); + font-size: 2rem; + + .toast--medium & { + color: var(--digi--typography--color--text); + } + } + + &__content { + display: flex; + background-color: var(--digi--ui--color--background); + flex-direction: column; + justify-content: center; + padding: var(--digi--layout--gutter--s); + } + + &__heading { + margin: 0; + } + + &__message { + max-width: 400px !important; + margin: 0; + overflow-wrap: break-word; + } + + &__close-button { + background-color: transparent; + border-width: 0; + position: absolute; + top: 0; + right: 0; + padding: var(--digi--layout--gutter--s); + color: var(--digi--typography--color--text); + } +} diff --git a/apps/dafa-web/src/app/components/toast-list/toast/toast.component.spec.ts b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.spec.ts new file mode 100644 index 0000000..b3fc46d --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.spec.ts @@ -0,0 +1,25 @@ +/* tslint:disable:no-unused-variable */ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { ToastComponent } from './toast.component'; + + +describe('ToastComponent', () => { + let component: ToastComponent; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ToastComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ToastComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/dafa-web/src/app/components/toast-list/toast/toast.component.ts b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.ts new file mode 100644 index 0000000..ab5a78d --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast/toast.component.ts @@ -0,0 +1,32 @@ +import { AfterViewInit, ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ErrorSeverity } from '@dafa-enums/error-severity.enum'; +import { CustomError } from '@dafa-models/error/custom-error'; + +@Component({ + selector: 'dafa-toast', + templateUrl: './toast.component.html', + styleUrls: ['./toast.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ToastComponent implements AfterViewInit { + @Input() error: CustomError; + @Output() closeToast: EventEmitter = new EventEmitter(); + + errorSeverity = ErrorSeverity; + + ngAfterViewInit(): void { + if (this.error.removeAfter) { + setTimeout(() => { + this.closeToast.emit(this.error); + }, this.error.removeAfter); + } + } + + get className(): string { + return `toast toast--${this.error.severity.toLowerCase()}`; + } + + emitCloseEvent(): void { + this.closeToast.emit(this.error); + } +} diff --git a/apps/dafa-web/src/app/components/toast-list/toast/toast.module.ts b/apps/dafa-web/src/app/components/toast-list/toast/toast.module.ts new file mode 100644 index 0000000..b29f33f --- /dev/null +++ b/apps/dafa-web/src/app/components/toast-list/toast/toast.module.ts @@ -0,0 +1,21 @@ +import { DigiNgIconExclamationCircleModule } from '@af/digi-ng/_icon/icon-exclamation-circle'; +import { DigiNgIconExclamationTriangleModule } from '@af/digi-ng/_icon/icon-exclamation-triangle'; +import { DigiNgIconInfoCircleRegModule } from '@af/digi-ng/_icon/icon-info-circle-reg'; +import { DigiNgIconXModule } from '@af/digi-ng/_icon/icon-x'; +import { CommonModule } from '@angular/common'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { ToastComponent } from './toast.component'; + +@NgModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ToastComponent], + imports: [ + CommonModule, + DigiNgIconXModule, + DigiNgIconExclamationCircleModule, + DigiNgIconExclamationTriangleModule, + DigiNgIconInfoCircleRegModule, + ], + exports: [ToastComponent], +}) +export class ToastModule {} diff --git a/apps/dafa-web/src/app/data/enums/error-severity.enum.ts b/apps/dafa-web/src/app/data/enums/error-severity.enum.ts new file mode 100644 index 0000000..b079d0a --- /dev/null +++ b/apps/dafa-web/src/app/data/enums/error-severity.enum.ts @@ -0,0 +1,5 @@ +export enum ErrorSeverity { + HIGH = 'High', + MEDIUM = 'Medium', + LOW = 'Low' +} diff --git a/apps/dafa-web/src/app/data/enums/error-type.enum.ts b/apps/dafa-web/src/app/data/enums/error-type.enum.ts new file mode 100644 index 0000000..3a1227d --- /dev/null +++ b/apps/dafa-web/src/app/data/enums/error-type.enum.ts @@ -0,0 +1,6 @@ +export enum ErrorType { + API = 'API Error', + NETWORK = 'Network Error', + APP = 'Application Error', + UNKNOWN = 'Unknown Error' +} diff --git a/apps/dafa-web/src/app/data/enums/toast-position.enum.ts b/apps/dafa-web/src/app/data/enums/toast-position.enum.ts new file mode 100644 index 0000000..4a0be97 --- /dev/null +++ b/apps/dafa-web/src/app/data/enums/toast-position.enum.ts @@ -0,0 +1,11 @@ +export enum ToastPosition { + TOP_RIGHT = 'top-right', + TOP_CENTER = 'top-center', + TOP_LEFT = 'top-left', + BOTTOM_RIGHT = 'bottom-right', + BOTTOM_CENTER = 'bottom-center', + BOTTOM_LEFT = 'bottom-left', + CENTER_RIGHT = 'center-right', + CENTER_CENTER = 'center-center', + CENTER_LEFT = 'center-left', +} diff --git a/apps/dafa-web/src/app/data/models/api/employee-response.model.ts b/apps/dafa-web/src/app/data/models/api/employee-response.model.ts deleted file mode 100644 index 4767728..0000000 --- a/apps/dafa-web/src/app/data/models/api/employee-response.model.ts +++ /dev/null @@ -1,26 +0,0 @@ -export interface EmployeesApiResponse { - pxMore: string; - pxObjClass: string; - pxPageCount: string; - pxQueryTimeStamp: string; - pxResultCount: string; - pxTotalResultCount: string; - pyMaxRecords: string; - pyObjClass: string; - pxResults: EmployeeResponse[]; - pzPerformanceSettings: string[]; -} - -export interface EmployeeResponse { - pxInsHandle: string; - pxObjClass: string; - pyAccessGroup: string; - pyFirstName: string; - pyLastName: string; - pyOrganization: string; - pyOrgDivision: string; - pyOrgUnit: string; - pyTelephone: string; - pyUserIdentifier: string; - pyUserName: string; -} diff --git a/apps/dafa-web/src/app/data/models/api/user-response.model.ts b/apps/dafa-web/src/app/data/models/api/user-response.model.ts deleted file mode 100644 index 78610dc..0000000 --- a/apps/dafa-web/src/app/data/models/api/user-response.model.ts +++ /dev/null @@ -1,23 +0,0 @@ -export interface UserResponse { - pxInsName: string; - pxLimitedAccess: string; - pxObjClass: string; - pyAccessGroup: string; - pyFirstName: string; - pyLastName: string; - pyLastSignon: string; - pyOrganization: string; - pyOrgDivision: string; - pyOrgUnit: string; - pyTelephone: string; - pyUserIdentifier: string; - pyUserName: string; - pyAccessGroupsAdditional: string[]; - pyAddresses: { - Email: { - pxObjClass: string; - pxSubscript: string; - pyEmailAddress: string; - }; - }; -} diff --git a/apps/dafa-web/src/app/data/models/employee.model.ts b/apps/dafa-web/src/app/data/models/employee.model.ts index 63ed837..55449e2 100644 --- a/apps/dafa-web/src/app/data/models/employee.model.ts +++ b/apps/dafa-web/src/app/data/models/employee.model.ts @@ -1,27 +1,72 @@ import { mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum'; import { Agency } from '@dafa-models/agency.model'; -import { EmployeeResponse } from './api/employee-response.model'; import { Participant } from './participant.model'; import { User } from './user.model'; // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Employee extends User {} - -export interface EmployeeDetail extends Employee { +export interface Employee extends User { languages: string[]; outOfOffice: { start: Date; end: Date; }[]; - authorisations: string[]; - phone: string; - email: string; ssn: string; agencies: Agency[]; participants: Participant[]; } -export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee { +export interface EmployeesApiResponse { + pxMore: string; + pxObjClass: string; + pxPageCount: string; + pxQueryTimeStamp: string; + pxResultCount: string; + pxTotalResultCount: string; + pyMaxRecords: string; + pyObjClass: string; + pxResults: EmployeeApiResponse[]; + pzPerformanceSettings: string[]; +} + +export interface EmployeeApiResponse { + pxInsHandle: string; + pxObjClass: string; + pyAccessGroup: string; + pyFirstName: string; + pyLastName: string; + pyOrganization: string; + pyOrgDivision: string; + pyOrgUnit: string; + pyTelephone: string; + pyUserIdentifier: string; + pyUserName: string; +} + +export interface EmployeeApiRequestData { + pyFirstName: string; + pyLastName: string; + pyTelephone: string; +} + +export interface EmployeeApiPostResponse { + pxObjClass: string; + pyErrorMessage: string; + pyFirstName: string; + pyHasError: 'true' | 'false'; + pyLastName: string; + pyTelephone: string; + pyUserIdentifier: string; +} + +export function mapEmployeeToEmployeeApiRequestData(data: Employee): EmployeeApiRequestData { + return { + pyFirstName: data.firstName, + pyLastName: data.lastName, + pyTelephone: data.phone, + }; +} + +export function mapEmployeeReponseToEmployee(data: EmployeeApiResponse): Employee { return { id: data.pyUserIdentifier, lastName: data.pyLastName, @@ -35,5 +80,10 @@ export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee { accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup), utforandeverksamhet: '', service: '', + languages: [], + outOfOffice: null, + ssn: '', + agencies: [], + participants: [], }; } diff --git a/apps/dafa-web/src/app/data/models/error/custom-error.ts b/apps/dafa-web/src/app/data/models/error/custom-error.ts new file mode 100644 index 0000000..e33d875 --- /dev/null +++ b/apps/dafa-web/src/app/data/models/error/custom-error.ts @@ -0,0 +1,58 @@ +import { ErrorSeverity } from '@dafa-enums/error-severity.enum'; +import { ErrorType } from '@dafa-enums/error-type.enum'; + +export class CustomError implements Error { + id: string; + name: string; + message: string; + stack: string; + type: ErrorType; + severity: ErrorSeverity; + timestamp: Date; + error: Error; + removeAfter: number; + + constructor(args: { error: Error; type: ErrorType; message?: string; severity?: ErrorSeverity; stack?: string }) { + this.timestamp = new Date(); + this.id = this.timestamp.getTime().toString(); + this.type = this.name = args.type; + this.message = args.message ? args.message : args.error.message; + this.severity = args.severity ? args.severity : ErrorSeverity.HIGH; + this.stack = args.stack ? args.stack : CustomError.getStack(args.error); + this.error = args.error; + this.removeAfter = + this.severity === ErrorSeverity.LOW ? 5000 : this.severity === ErrorSeverity.MEDIUM ? 10000 : 20000; + } + + static getStack(error: Error): string { + if (!error) { + return ''; + } + if (error.stack) { + return error.stack; + } else if ((error as any).error) { + return this.getStack((error as any).error); + } else { + return error as any; + } + } +} + +export function errorToCustomError(error: Error): CustomError { + console.log(error); + const type = (error as any).type || ErrorType.UNKNOWN; + const message = error.message || (error as any); + const severity = ErrorSeverity.HIGH; + + // this is done to avoid circular references while running in debug mode + if ((error as any).ngDebugContext) { + (error as any).ngDebugContext = {}; + } + + return new CustomError({ + error, + type, + severity, + message, + }); +} diff --git a/apps/dafa-web/src/app/data/models/user.model.ts b/apps/dafa-web/src/app/data/models/user.model.ts index df744c0..57903c7 100644 --- a/apps/dafa-web/src/app/data/models/user.model.ts +++ b/apps/dafa-web/src/app/data/models/user.model.ts @@ -1,5 +1,4 @@ import { AccessGroup, mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum'; -import { UserResponse } from './api/user-response.model'; export interface User { id: string; @@ -16,7 +15,31 @@ export interface User { service: string; } -export function mapUserReponseToUser(data: UserResponse): User { +export interface UserApiResponse { + pxInsName: string; + pxLimitedAccess: string; + pxObjClass: string; + pyAccessGroup: string; + pyFirstName: string; + pyLastName: string; + pyLastSignon: string; + pyOrganization: string; + pyOrgDivision: string; + pyOrgUnit: string; + pyTelephone: string; + pyUserIdentifier: string; + pyUserName: string; + pyAccessGroupsAdditional: string[]; + pyAddresses: { + Email: { + pxObjClass: string; + pxSubscript: string; + pyEmailAddress: string; + }; + }; +} + +export function mapUserApiReponseToUser(data: UserApiResponse): User { return { id: data.pyUserIdentifier, lastName: data.pyLastName, diff --git a/apps/dafa-web/src/app/interceptors/custom-error-handler.module.ts b/apps/dafa-web/src/app/interceptors/custom-error-handler.module.ts new file mode 100644 index 0000000..37848a4 --- /dev/null +++ b/apps/dafa-web/src/app/interceptors/custom-error-handler.module.ts @@ -0,0 +1,13 @@ +import { ErrorHandler, Injectable } from '@angular/core'; +import { CustomError, errorToCustomError } from '@dafa-models/error/custom-error'; +import { ErrorService } from '@dafa-services/error.service'; + +@Injectable() +export class CustomErrorHandler implements ErrorHandler { + constructor(private errorService: ErrorService) {} + + handleError(error: any): void { + const customError: CustomError = errorToCustomError(error); + this.errorService.add(customError); + } +} diff --git a/apps/dafa-web/src/app/pages/administration/pages/create-account/create-account.component.html b/apps/dafa-web/src/app/pages/administration/pages/create-account/create-account.component.html index 86c83c3..88b2c46 100644 --- a/apps/dafa-web/src/app/pages/administration/pages/create-account/create-account.component.html +++ b/apps/dafa-web/src/app/pages/administration/pages/create-account/create-account.component.html @@ -34,6 +34,14 @@ [afDisableValidStyle]="true" [afInvalid]="ssnControl.invalid && ssnControl.dirty" > +