From 092b3a3cc9366e819b61f08dba28b26c463b054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20Mi=C3=9Ffeldt?= <56537019+finnmissfeldt@users.noreply.github.com> Date: Thu, 27 Feb 2020 14:59:33 +0100 Subject: [PATCH] temp commit before rebase --- .../access-items-management.component.ts | 5 + .../classification-details.component.ts | 9 + .../list/classification-list.component.ts | 2 + .../import-export/import-export.component.ts | 8 + .../access-items/access-items.component.ts | 6 +- .../distribution-targets.component.ts | 4 + .../workbasket-information.component.ts | 10 + .../details/workbasket-details.component.ts | 2 + .../workbasket-list-toolbar.component.ts | 5 +- web/src/app/guards/domain.guard.ts | 2 + web/src/app/guards/history.guard.ts | 2 + web/src/app/models/error-model.ts | 7 +- web/src/app/services/general-modal/errors.ts | 176 ++++++++---------- .../general-modal/general-modal.service.ts | 3 +- .../shared/services/errors/errors.service.ts | 7 +- .../services/forms/forms-validator.service.ts | 4 + .../http-client-interceptor.service.ts | 7 +- .../app/shared/spinner/spinner.component.ts | 4 + .../taskdetails/taskdetails.component.ts | 7 + 19 files changed, 160 insertions(+), 110 deletions(-) diff --git a/web/src/app/administration/access-items-management/access-items-management.component.ts b/web/src/app/administration/access-items-management/access-items-management.component.ts index f25e99e5d..2c6f1a4ae 100644 --- a/web/src/app/administration/access-items-management/access-items-management.component.ts +++ b/web/src/app/administration/access-items-management/access-items-management.component.ts @@ -16,6 +16,7 @@ import { AlertService } from 'app/services/alert/alert.service'; import { RequestInProgressService } from '../../services/requestInProgress/request-in-progress.service'; import { AccessIdsService } from '../../shared/services/access-ids/access-ids.service'; import { AccessIdDefinition } from '../../models/access-id'; +import { ERROR_TYPES } from '../../services/general-modal/errors'; @Component({ selector: 'taskana-access-items-management', @@ -98,6 +99,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy { this.belongingGroups = accessIdsWithGroups.filter(item => item.accessId.includes(this.groupsKey)); this.searchForAccessItemsWorkbaskets(); }, + // new Key: ERROR_TYPES.FETCH_ERR error => { this.requestInProgressService.setRequestInProgress(false); this.generalModalService.triggerMessage( @@ -133,6 +135,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy { this.setAccessItemsGroups(accessItemsResource ? accessItemsResource.accessItems : []); this.requestInProgressService.setRequestInProgress(false); }, + // new Key: ERROR_TYPES.FETCH_ERR_2 error => { this.requestInProgressService.setRequestInProgress(false); this.generalModalService.triggerMessage( @@ -157,6 +160,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy { this.requestInProgressService.setRequestInProgress(true); this.accessIdsService.removeAccessItemsPermissions(this.accessIdSelected) .subscribe( + // new Key: ALERT_TYPES.SUCCESS_ALERT response => { this.requestInProgressService.setRequestInProgress(false); this.alertService.triggerAlert( @@ -168,6 +172,7 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy { ); this.searchForAccessItemsWorkbaskets(); }, + // new Key: ERROR_TYPES.DELETE_ERR error => { this.requestInProgressService.setRequestInProgress(false); this.generalModalService.triggerMessage( diff --git a/web/src/app/administration/classification/details/classification-details.component.ts b/web/src/app/administration/classification/details/classification-details.component.ts index 3e6328e06..22bde3d77 100644 --- a/web/src/app/administration/classification/details/classification-details.component.ts +++ b/web/src/app/administration/classification/details/classification-details.component.ts @@ -25,6 +25,7 @@ import { NgForm } from '@angular/forms'; import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service'; import { ImportExportService } from 'app/administration/services/import-export/import-export.service'; import { CustomFieldsService } from '../../../services/custom-fields/custom-fields.service'; +import { ERROR_TYPES } from '../../../services/general-modal/errors'; @Component({ selector: 'taskana-classification-details', @@ -175,9 +176,11 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { .subscribe((classification: ClassificationDefinition) => { this.classification = classification; this.classificationsService.selectClassification(classification); + // new Key ALERT_TYPES.SUCCESS_ALERT_2 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${classification.key} was saved successfully`)); this.afterRequest(); }, + // new Key: ERROR_TYPES.CREATE_ERR error => { this.generalModalService.triggerMessage(new MessageModal('There was an error creating a classification', error)); this.afterRequest(); @@ -188,11 +191,13 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { this.classification._links.self.href, this.classification )); this.afterRequest(); + // new Key: ALERT_TYPES.SUCCESS_ALERT_3 this.alertService.triggerAlert( new AlertModel(AlertType.SUCCESS, `Classification ${this.classification.key} was saved successfully`) ); this.cloneClassification(this.classification); } catch (error) { + // new Key: ERROR_TYPES.SAVE_ERR this.generalModalService.triggerMessage(new MessageModal('There was error while saving your classification', error)); this.afterRequest(); } @@ -201,6 +206,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { onClear() { this.formsValidatorService.formSubmitAttempt = false; + // new Key: ALERT_TYPES.INFO_ALERT this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields')); this.classification = { ...this.classificationClone }; } @@ -275,6 +281,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { private removeClassificationConfirmation() { if (!this.classification || !this.classification.classificationId) { this.generalModalService.triggerMessage( + // new Key ERROR_TYPES.SELECT_ERR new MessageModal('There is no classification selected', 'Please check if you are creating a classification') ); return; @@ -290,8 +297,10 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { this.afterRequest(); this.classificationsService.selectClassification(); this.router.navigate(['taskana/administration/classifications']); + // new Key: ALERT_TYPES.SUCCESS_ALERT_4 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${key} was removed successfully`)); }, error => { + // new Key: ERROR_TYPES.REMOVE_ERR this.generalModalService.triggerMessage(new MessageModal('There was error while removing your classification', error)); this.afterRequest(); }); diff --git a/web/src/app/administration/classification/master/list/classification-list.component.ts b/web/src/app/administration/classification/master/list/classification-list.component.ts index 839492874..2ce795b13 100644 --- a/web/src/app/administration/classification/master/list/classification-list.component.ts +++ b/web/src/app/administration/classification/master/list/classification-list.component.ts @@ -13,6 +13,7 @@ import { ImportExportService } from 'app/administration/services/import-export/i import { ClassificationDefinition } from '../../../../models/classification-definition'; import { AlertModel, AlertType } from '../../../../models/alert'; import { AlertService } from '../../../../services/alert/alert.service'; +import { ERROR_TYPES } from '../../../../services/general-modal/errors'; @Component({ selector: 'taskana-classification-list', @@ -130,6 +131,7 @@ export class ClassificationListComponent implements OnInit, OnDestroy { this.requestInProgress = false; }); + // new Error-Key: ALERT_TYPES.SUCCESS_ALERT_5 if (key) { this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${key} was saved successfully`)); } diff --git a/web/src/app/administration/components/import-export/import-export.component.ts b/web/src/app/administration/components/import-export/import-export.component.ts index b6c40b742..13d0a9351 100644 --- a/web/src/app/administration/components/import-export/import-export.component.ts +++ b/web/src/app/administration/components/import-export/import-export.component.ts @@ -10,6 +10,7 @@ import { AlertService } from 'app/services/alert/alert.service'; import { AlertModel, AlertType } from 'app/models/alert'; import { UploadService } from 'app/shared/services/upload/upload.service'; import { ImportExportService } from 'app/administration/services/import-export/import-export.service'; +import { ERROR_TYPES } from '../../../services/general-modal/errors'; @Component({ selector: 'taskana-import-export-component', @@ -88,6 +89,7 @@ export class ImportExportComponent implements OnInit { break; default: file.value = ''; + // new Key: ERROR_TYPES.FILE_ERR this.generalModalService.triggerMessage(new MessageModal('Wrong format', 'This file format is not allowed! Please use a .json file.')); } @@ -104,16 +106,21 @@ export class ImportExportComponent implements OnInit { if (event.readyState === 4 && event.status >= 400) { let title; if (event.status === 401) { + // new Key ERROR_TYPES.IMPORT_ERR_1 title = 'Import was not successful, you have no access to apply this operation.'; } else if (event.status === 404) { + // new Key ERROR_TYPES.IMPORT_ERR_2 title = 'Import was not successful, operation was not found.'; } else if (event.status === 409) { + // new Key ERROR_TYPES.IMPORT_ERR_3 title = 'Import was not successful, operation has some conflicts.'; } else if (event.status === 413) { + // new Key ERROR_TYPES.IMPORT_ERR_4 title = 'Import was not successful, maximum file size exceeded.'; } this.errorHandler(title, JSON.parse(event.responseText).message); } else if (event.readyState === 4 && event.status === 200) { + // new Key: ALERT_TYPES.SUCCESS_ALERT_6 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'Import was successful')); this.importExportService.setImportingFinished(true); this.resetProgress(); @@ -121,6 +128,7 @@ export class ImportExportComponent implements OnInit { } private onFailedResponse(event) { + // new Key ERROR_TYPES.UPLOAD_ERR this.errorHandler('Upload failed', 'The upload didn\'t proceed sucessfully. \n' + 'Probably the uploaded file exceeded the maximum file size of 10 MB'); } diff --git a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts index bed08f0a9..382f826fe 100644 --- a/web/src/app/administration/workbasket/details/access-items/access-items.component.ts +++ b/web/src/app/administration/workbasket/details/access-items/access-items.component.ts @@ -18,6 +18,7 @@ import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.se import { highlight } from 'app/shared/animations/validation.animation'; import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service'; import { AccessIdDefinition } from 'app/models/access-id'; +import { ERROR_TYPES } from '../../../../services/general-modal/errors'; @Component({ selector: 'taskana-workbasket-access-items', @@ -140,7 +141,8 @@ export class AccessItemsComponent implements OnChanges, OnDestroy { this.AccessItemsForm.reset(); this.setAccessItemsGroups(this.accessItemsResetClone); this.accessItemsClone = this.cloneAccessItems(this.accessItemsResetClone); - this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields')); + // new Key ALERT_TYPES.INFO_ALERT + this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields')); } remove(index: number) { @@ -184,11 +186,13 @@ export class AccessItemsComponent implements OnChanges, OnDestroy { .subscribe(response => { this.accessItemsClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups); this.accessItemsResetClone = this.cloneAccessItems(this.AccessItemsForm.value.accessItemsGroups); + // new Key ALERT_TYPES.SUCCESS_ALERT_7 this.alertService.triggerAlert(new AlertModel( AlertType.SUCCESS, `Workbasket ${this.workbasket.name} Access items were saved successfully` )); this.requestInProgressService.setRequestInProgress(false); }, error => { + // new Key ERROR_TYPES.SAVE_ERR_2 this.generalModalService.triggerMessage(new MessageModal('There was error while saving your workbasket\'s access items', error)); this.requestInProgressService.setRequestInProgress(false); }); diff --git a/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts b/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts index a1f33bed3..835621f58 100644 --- a/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts +++ b/web/src/app/administration/workbasket/details/distribution-targets/distribution-targets.component.ts @@ -18,6 +18,7 @@ import { TaskanaQueryParameters } from 'app/shared/util/query-parameters'; import { Page } from 'app/models/page'; import { OrientationService } from 'app/services/orientation/orientation.service'; import { Orientation } from 'app/models/orientation'; +import { ALERT_TYPES, ERROR_TYPES } from '../../../../services/general-modal/errors'; export enum Side { LEFT, @@ -121,11 +122,13 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy { this.distributionTargetsSelected = response.distributionTargets; this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected); this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft); + // new Key ALERT_TYPES.SUCCESS_ALERT_8 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Workbasket ${this.workbasket.name} : Distribution targets were saved successfully`)); return true; }, error => { + // new Key ERROR_TYPES.SAVE_ERR_3 this.generalModalService.triggerMessage( new MessageModal('There was error while saving your workbasket\'s distribution targets', error) ); @@ -136,6 +139,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy { } onClear() { + // new key ALERT_TYPES.INFO_ALERT this.alertService.triggerAlert(new AlertModel(AlertType.INFO, 'Reset edited fields')); this.distributionTargetsLeft = Object.assign([], this.distributionTargetsClone); this.distributionTargetsRight = Object.assign([], this.distributionTargetsSelectedClone); diff --git a/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts b/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts index bfaa72aaf..3f4952a4d 100644 --- a/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts +++ b/web/src/app/administration/workbasket/details/information/workbasket-information.component.ts @@ -18,6 +18,7 @@ import { RequestInProgressService } from 'app/services/requestInProgress/request import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.service'; import { RemoveConfirmationService } from 'app/services/remove-confirmation/remove-confirmation.service'; import { FormsValidatorService } from 'app/shared/services/forms/forms-validator.service'; +import {ALERT_TYPES, ERROR_TYPES} from '../../../../services/general-modal/errors'; @Component({ selector: 'taskana-workbasket-information', @@ -123,6 +124,7 @@ implements OnInit, OnChanges, OnDestroy { onClear() { this.formsValidatorService.formSubmitAttempt = false; this.alertService.triggerAlert( + // new Key ALERT_TYPES.INFO_ALERT new AlertModel(AlertType.INFO, 'Reset edited fields') ); this.workbasket = { ...this.workbasketClone }; @@ -152,6 +154,7 @@ implements OnInit, OnChanges, OnDestroy { .subscribe( reponse => { this.requestInProgressService.setRequestInProgress(false); + // new Key ALERT_TYPES.SUCCESS_ALERT_9 this.alertService.triggerAlert( new AlertModel( AlertType.SUCCESS, @@ -162,6 +165,7 @@ implements OnInit, OnChanges, OnDestroy { ); }, error => { + // new Key ERROR_TYPES.REMOVE_ERR_2 this.generalModalService.triggerMessage( new MessageModal( `There was an error removing distribution target for ${ @@ -189,6 +193,7 @@ implements OnInit, OnChanges, OnDestroy { this.afterRequest(); this.workbasket = workbasketUpdated; this.workbasketClone = { ...this.workbasket }; + // new Key ALERT_TYPES.SUCCESS_ALERT_10 this.alertService.triggerAlert( new AlertModel( AlertType.SUCCESS, @@ -198,6 +203,7 @@ implements OnInit, OnChanges, OnDestroy { }, error => { this.afterRequest(); + // new Key ERROR_TYPES.SAVE_ERR_4 this.generalModalService.triggerMessage( new MessageModal( 'There was error while saving your workbasket', @@ -221,6 +227,7 @@ implements OnInit, OnChanges, OnDestroy { this.addDateToWorkbasket(); this.workbasketService.createWorkbasket(this.workbasket).subscribe( (workbasketUpdated: Workbasket) => { + // new Key ALERT_TYPES.SUCCESS_ALERT_11 this.alertService.triggerAlert( new AlertModel( AlertType.SUCCESS, @@ -250,6 +257,7 @@ implements OnInit, OnChanges, OnDestroy { } }, error => { + // new Key ERROR_TYPES.CREATE_ERR_2 this.generalModalService.triggerMessage( new MessageModal('There was an error creating a workbasket', error) ); @@ -273,11 +281,13 @@ implements OnInit, OnChanges, OnDestroy { this.requestInProgressService.setRequestInProgress(false); this.workbasketService.triggerWorkBasketSaved(); if (response) { + // new Key ERROR_TYPES.MARK_ERR this.generalModalService.triggerMessage( new MessageModal('There was an error marking workbasket for deletion', 'It not possible to mark the workbasket for deletion, It has been deleted.') ); } else { + // new Key ALERT_TYPES.SUCCESS_ALERT_12 this.alertService.triggerAlert( new AlertModel(AlertType.SUCCESS, `The Workbasket ${this.workbasket.workbasketId} has been marked for deletion`) ); diff --git a/web/src/app/administration/workbasket/details/workbasket-details.component.ts b/web/src/app/administration/workbasket/details/workbasket-details.component.ts index 17cdbc6ce..d673f148a 100644 --- a/web/src/app/administration/workbasket/details/workbasket-details.component.ts +++ b/web/src/app/administration/workbasket/details/workbasket-details.component.ts @@ -11,6 +11,7 @@ import { DomainService } from 'app/services/domain/domain.service'; import { ImportExportService } from 'app/administration/services/import-export/import-export.service'; import { GeneralModalService } from '../../../services/general-modal/general-modal.service'; import { MessageModal } from '../../../models/message-modal'; +import { ERROR_TYPES } from '../../../services/general-modal/errors'; @Component({ selector: 'taskana-workbasket-details', @@ -114,6 +115,7 @@ export class WorkbasketDetailsComponent implements OnInit, OnDestroy { this.requestInProgress = false; this.checkDomainAndRedirect(); }, err => { + // new Key ERROR_TYPES.FETCH_ERR_4 this.generalModalService.triggerMessage( new MessageModal('An error occurred while fetching the workbasket', err) ); diff --git a/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.ts b/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.ts index be857286a..1ea0ecfdb 100644 --- a/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.ts +++ b/web/src/app/administration/workbasket/master/workbasket-list-toolbar/workbasket-list-toolbar.component.ts @@ -9,6 +9,8 @@ import { WorkbasketSummary } from 'app/models/workbasket-summary'; import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service'; import { TaskanaType } from 'app/models/taskana-type'; import { expandDown } from 'app/shared/animations/expand.animation'; +import { ErrorsService } from '../../../../shared/services/errors/errors.service'; +import { ERROR_TYPES } from '../../../../services/general-modal/errors'; @Component({ selector: 'taskana-workbasket-list-toolbar', @@ -33,7 +35,8 @@ export class WorkbasketListToolbarComponent implements OnInit { constructor( private workbasketService: WorkbasketService, private route: ActivatedRoute, - private router: Router + private router: Router, + private errors: ErrorsService ) { } diff --git a/web/src/app/guards/domain.guard.ts b/web/src/app/guards/domain.guard.ts index 8dbbc9af3..16ab68592 100644 --- a/web/src/app/guards/domain.guard.ts +++ b/web/src/app/guards/domain.guard.ts @@ -5,6 +5,7 @@ import { DomainService } from 'app/services/domain/domain.service'; import { GeneralModalService } from 'app/services/general-modal/general-modal.service'; import { MessageModal } from 'app/models/message-modal'; import { map, catchError } from 'rxjs/operators'; +import { ERROR_TYPES } from '../services/general-modal/errors'; @Injectable() export class DomainGuard implements CanActivate { @@ -14,6 +15,7 @@ export class DomainGuard implements CanActivate { return this.domainService.getDomains().pipe( map(domain => true), catchError(() => { + // new Key ERROR_TYPES.FETCH_ERR_5 this.generalModalService.triggerMessage(new MessageModal( 'There was an error, please contact with your administrator', 'There was an error getting Domains' )); diff --git a/web/src/app/guards/history.guard.ts b/web/src/app/guards/history.guard.ts index 1bb05c7a1..609fbb2a4 100644 --- a/web/src/app/guards/history.guard.ts +++ b/web/src/app/guards/history.guard.ts @@ -5,6 +5,7 @@ import { TaskanaEngineService } from 'app/services/taskana-engine/taskana-engine import { map, catchError } from 'rxjs/operators'; import { GeneralModalService } from 'app/services/general-modal/general-modal.service'; import { MessageModal } from 'app/models/message-modal'; +import {ERROR_TYPES} from '../services/general-modal/errors'; @Injectable({ providedIn: 'root' @@ -28,6 +29,7 @@ export class HistoryGuard implements CanActivate { return this.navigateToWorkplace(); }), catchError(() => { + // new Key ERROR_TYPES.FETCH_ERR_6 this.generalModalService.triggerMessage(new MessageModal( 'There was an error, please contact with your administrator', 'There was an error getting history provider' )); diff --git a/web/src/app/models/error-model.ts b/web/src/app/models/error-model.ts index f8fd11b7e..3e9f5316b 100644 --- a/web/src/app/models/error-model.ts +++ b/web/src/app/models/error-model.ts @@ -6,9 +6,12 @@ export class ErrorModel { body: string; errObj?: ErrorHandler; - constructor(key: ERROR_TYPES, passedError?: ErrorHandler) { + constructor(key: ERROR_TYPES, passedError?: ErrorHandler, addition?: string) { this.head = errors.get(key).name; - this.body = errors.get(key).text; + this.body = errors.get(key).text + if (addition) { + this.body.replace('{rep}', addition); + } this.errObj = passedError; } } diff --git a/web/src/app/services/general-modal/errors.ts b/web/src/app/services/general-modal/errors.ts index 9b2a4417e..19eadef70 100644 --- a/web/src/app/services/general-modal/errors.ts +++ b/web/src/app/services/general-modal/errors.ts @@ -1,23 +1,27 @@ import { ErrorModel } from '../../models/error-model'; -import {Pair} from '../../models/pair'; +import { Pair } from '../../models/pair'; export enum ERROR_TYPES { - DELETE_ERR_2, - FETCH_ERR_7, - NONE, - // Mock Errors - NO_AUTH, - EXP_AUTH, - NO_ACCESS, - // Real Errors + // ERRORS FETCH_ERR, FETCH_ERR_2, + FETCH_ERR_3, + FETCH_ERR_4, + FETCH_ERR_5, + FETCH_ERR_6, + FETCH_ERR_7, DELETE_ERR, + DELETE_ERR_2, CREATE_ERR, + CREATE_ERR_2, REMOVE_ERR, + REMOVE_ERR_2, SAVE_ERR, + SAVE_ERR_2, + SAVE_ERR_3, + SAVE_ERR_4, SELECT_ERR, FILE_ERR, IMPORT_ERR_1, @@ -25,62 +29,36 @@ export enum ERROR_TYPES { IMPORT_ERR_3, IMPORT_ERR_4, UPLOAD_ERR, - FETCH_ERR_3, - CREATE_ERR_2, - SAVE_ERR_4, - REMOVE_ERR_2, - SAVE_ERR_3, - SAVE_ERR_2, - FETCH_ERR_4, TIMEOUT_ERR, GENERAL_ERR, - HANDLE_ERR, - FETCH_ERR_6, - FETCH_ERR_5, + ACCESS_ERR, MARK_ERR, + NONE, -} - -export enum ALERT_TYPES { - INFO_ALERT_2, - DANGER_ALERT_2, - SUCCESS_ALERT_14, - SUCCESS_ALERT_13, - WARNING_ALERT_2, - SUCCESS_ALERT_12, - SUCCESS_ALERT_11, - SUCCESS_ALERT_10, - SUCCESS_ALERT_9, - - // TODO: check all alert models - SUCCESS_ALERT, + // ALERTS INFO_ALERT, - WARNING_ALERT, + INFO_ALERT_2, DANGER_ALERT, - SUCCESS_ALERT_8, - SUCCESS_ALERT_7, - SUCCESS_ALERT_6, - SUCCESS_ALERT_5, - SUCCESS_ALERT_4, - SUCCESS_ALERT_3, + DANGER_ALERT_2, + SUCCESS_ALERT, SUCCESS_ALERT_2, - + SUCCESS_ALERT_3, + SUCCESS_ALERT_4, + SUCCESS_ALERT_5, + SUCCESS_ALERT_6, + SUCCESS_ALERT_7, + SUCCESS_ALERT_8, + SUCCESS_ALERT_9, + SUCCESS_ALERT_10, + SUCCESS_ALERT_11, + SUCCESS_ALERT_12, + SUCCESS_ALERT_13, + SUCCESS_ALERT_14, + WARNING_ALERT, + WARNING_ALERT_2, } -// TODO: funktioniert unser Pair hierfür? -> Konstruktor checken! -export const errors = new Map ([ - [ERROR_TYPES.NO_AUTH, new Pair( - 'Authentication required', - 'You need to be logged in to perform this action.' - )], - [ERROR_TYPES.EXP_AUTH, new Pair( - 'Authentication expired', - 'Your session has expired, log in to perform this action.' - )], - [ERROR_TYPES.NO_ACCESS, new Pair( - 'Access denied', - 'You have no permission to perform this action.' - )], +export const errors = new Map ([ // access-items-management.component.ts [ERROR_TYPES.FETCH_ERR, new Pair( '', @@ -123,22 +101,22 @@ export const errors = new Map ([ )], // import-export.component [ERROR_TYPES.IMPORT_ERR_1, new Pair( - '', + 'Import was not successful', 'Import was not successful, you have no access to apply this operation.' )], // import-export.component [ERROR_TYPES.IMPORT_ERR_2, new Pair( - '', + 'Import was not successful', 'Import was not successful, operation was not found.' )], // import-export.component [ERROR_TYPES.IMPORT_ERR_3, new Pair( - '', + 'Import was not successful', 'Import was not successful, operation has some conflicts.' )], // import-export.component [ERROR_TYPES.IMPORT_ERR_4, new Pair( - '', + 'Import was not successful', 'Import was not successful, maximum file size exceeded.' )], // import-export.component @@ -197,139 +175,139 @@ export const errors = new Map ([ 'There was an error, please contact with your administrator', 'There was an error getting history provider' )], - // http-client-interceptor.component - [ERROR_TYPES.HANDLE_ERR, new Pair( + // http-client-interceptor.service + [ERROR_TYPES.ACCESS_ERR, new Pair( 'You have no access to this resource ', '' )], - // http-client-interceptor.component + // http-client-interceptor.service [ERROR_TYPES.GENERAL_ERR, new Pair( 'There was error, please contact with your administrator', '' )], - // http-client-interceptor.component + // http-client-interceptor.service [ERROR_TYPES.NONE, new Pair( - 'Error wird ignoriert, keine Message geworfen', - '' + '', + 'Error wird ignoriert, keine Message geworfen' )], // spinner.component [ERROR_TYPES.TIMEOUT_ERR, new Pair( - 'There was an error with your request, please make sure you have internet connection', - 'Request time execeed' + 'Request time exceeded', + 'There was an error with your request, please make sure you have internet connection' )], // taskdetails.component [ERROR_TYPES.FETCH_ERR_7, new Pair( - 'An error occurred while fetching the task', - '' + '', + 'An error occurred while fetching the task' )], // taskdetails.component [ERROR_TYPES.DELETE_ERR_2, new Pair( - 'An error occurred while deleting the task', - '' + '', + 'An error occurred while deleting the task' )], // ALERTS // access-items-management.component - [ALERT_TYPES.SUCCESS_ALERT, new Pair( - '${this.accessIdSelected} was removed successfully', - '' + [ERROR_TYPES.SUCCESS_ALERT, new Pair( + '', + '${this.accessIdSelected} was removed successfully' )], // classification-details.component - [ALERT_TYPES.SUCCESS_ALERT_2, new Pair( - 'Classification ${classification.key} was saved successfully', - '' + [ERROR_TYPES.SUCCESS_ALERT_2, new Pair( + '', + 'Classification ${classification.key} was saved successfully' )], // classification-details.component - [ALERT_TYPES.SUCCESS_ALERT_3, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_3, new Pair( 'Classification ${this.classification.key} was saved successfully', '' )], // classification-details.component // access-items.component - // distribution-targets.component + // workbasket.distribution-targets.component // workbasket-information.component - [ALERT_TYPES.INFO_ALERT, new Pair( + [ERROR_TYPES.INFO_ALERT, new Pair( 'Reset edited fields', '' )], // classification-details.component - [ALERT_TYPES.SUCCESS_ALERT_4, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_4, new Pair( 'Classification ${key} was removed successfully', '' )], // classification-list.component - [ALERT_TYPES.SUCCESS_ALERT_5, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_5, new Pair( 'Classification ${key} was saved successfully', '' )], // import-export.component - [ALERT_TYPES.SUCCESS_ALERT_6, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_6, new Pair( 'Import was successful', '' )], // access-items.component - [ALERT_TYPES.SUCCESS_ALERT_7, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_7, new Pair( 'Workbasket ${component.workbasket.key} Access items were saved successfully', '' )], - // distribution-targets.component - [ALERT_TYPES.SUCCESS_ALERT_8, new Pair( + // workbasket.distribution-targets.component + [ERROR_TYPES.SUCCESS_ALERT_8, new Pair( 'Workbasket ${this.workbasket.name} : Distribution targets were saved successfully', '' )], // workbasket-information.component - [ALERT_TYPES.SUCCESS_ALERT_9, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_9, new Pair( 'DistributionTarget for workbasketID: ${this.workbasket.workbasketId} was removed successfully', '' )], // workbasket-information.component - [ALERT_TYPES.SUCCESS_ALERT_10, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_10, new Pair( 'Workbasket ${workbasketUpdated.key} was saved successfully', '' )], // workbasket-information.component - [ALERT_TYPES.SUCCESS_ALERT_11, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_11, new Pair( 'Workbasket ${workbasketUpdated.key} was created successfully', '' )], // workbasket-information.component - [ALERT_TYPES.SUCCESS_ALERT_12, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_12, new Pair( 'The Workbasket ${this.workbasket.workbasketId} has been marked for deletion', '' )], // forms-validator.service - [ALERT_TYPES.WARNING_ALERT, new Pair( + [ERROR_TYPES.WARNING_ALERT, new Pair( 'There are some empty fields which are required.', '' )], // forms-validator.service x2 - [ALERT_TYPES.WARNING_ALERT_2, new Pair( + [ERROR_TYPES.WARNING_ALERT_2, new Pair( 'The ${responseOwner.field} introduced is not valid.', '' )], - // taskdetails.component TODO: is dis error - [ALERT_TYPES.DANGER_ALERT, new Pair( + // taskdetails.component + [ERROR_TYPES.DANGER_ALERT, new Pair( 'There was an error while updating.', '' )], // taskdetails.component - [ALERT_TYPES.SUCCESS_ALERT_13, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_13, new Pair( 'Task ${this.currentId} was created successfully.', '' )], // taskdetails.component - [ALERT_TYPES.SUCCESS_ALERT_14, new Pair( + [ERROR_TYPES.SUCCESS_ALERT_14, new Pair( 'Updating was successful.', '' )], // taskdetails.component - [ALERT_TYPES.DANGER_ALERT_2, new Pair( + [ERROR_TYPES.DANGER_ALERT_2, new Pair( 'There was an error while creating a new task.', '' )], // task-master.component - [ALERT_TYPES.INFO_ALERT_2, new Pair( + [ERROR_TYPES.INFO_ALERT_2, new Pair( 'The selected Workbasket is empty!', '' )], diff --git a/web/src/app/services/general-modal/general-modal.service.ts b/web/src/app/services/general-modal/general-modal.service.ts index 8824ff49e..0ea9fd1be 100644 --- a/web/src/app/services/general-modal/general-modal.service.ts +++ b/web/src/app/services/general-modal/general-modal.service.ts @@ -2,13 +2,14 @@ import { Injectable } from '@angular/core'; import { Subject, Observable } from 'rxjs'; import { MessageModal } from 'app/models/message-modal'; -import { errors as ERRORS } from './errors'; +import { ERROR_TYPES, errors as ERRORS } from './errors'; @Injectable() export class GeneralModalService { private messageTriggered = new Subject(); triggerMessage(message: MessageModal) { + console.log(ERRORS.get(ERROR_TYPES.DELETE_ERR)); this.messageTriggered.next(message); } diff --git a/web/src/app/shared/services/errors/errors.service.ts b/web/src/app/shared/services/errors/errors.service.ts index 19f7c297d..dfede80ec 100644 --- a/web/src/app/shared/services/errors/errors.service.ts +++ b/web/src/app/shared/services/errors/errors.service.ts @@ -7,7 +7,6 @@ import { ERROR_TYPES } from '../../../services/general-modal/errors'; providedIn: 'root' }) export class ErrorsService { - // Wie initialisieren? Default ERROR_TYPE für leeres initialisieren einfügen? errorSubject$: Subject; constructor() {} @@ -15,8 +14,8 @@ export class ErrorsService { this.errorSubject$.next(errorToShow); } - public updateError(key: ERROR_TYPES, passedError: ErrorHandler): void { - // wahrscheinlich wollen wir nicht jedes mal ein neues ErrorModel erzeugen... oder wollen wir? - this.updateErrorSubject(new ErrorModel(key, passedError)); + public updateError(key: ERROR_TYPES, passedError?: ErrorHandler): void { + const errorModel = new ErrorModel(key, passedError); + this.updateErrorSubject(errorModel); } } diff --git a/web/src/app/shared/services/forms/forms-validator.service.ts b/web/src/app/shared/services/forms/forms-validator.service.ts index da214a460..bd1caa7bd 100644 --- a/web/src/app/shared/services/forms/forms-validator.service.ts +++ b/web/src/app/shared/services/forms/forms-validator.service.ts @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'; import { AlertService } from 'app/services/alert/alert.service'; import { AlertModel, AlertType } from 'app/models/alert'; import { AccessIdsService } from 'app/shared/services/access-ids/access-ids.service'; +import { ALERT_TYPES } from '../../../services/general-modal/errors'; @Injectable() export class FormsValidatorService { @@ -51,8 +52,10 @@ export class FormsValidatorService { const responseOwner = new ResponseOwner(values[1]); if (!(values[0] && responseOwner.valid)) { if (!responseOwner.valid) { + // new Key ALERT_TYPES.WARNING_ALERT_2 this.alertService.triggerAlert(new AlertModel(AlertType.WARNING, `The ${responseOwner.field} introduced is not valid.`)); } else { + // new Key ALERT_TYPES.WARNING_ALERT this.alertService.triggerAlert(new AlertModel(AlertType.WARNING, 'There are some empty fields which are required.')); } } @@ -80,6 +83,7 @@ export class FormsValidatorService { result = result && responseOwner.valid; }); if (!result) { + // new key ALERT_TYPES.WARNING_ALERT_2 this.alertService.triggerAlert(new AlertModel(AlertType.WARNING, `The ${responseOwner.field} introduced is not valid.`)); } return result; diff --git a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts index 93bf1cc27..ee2c04f19 100644 --- a/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts +++ b/web/src/app/shared/services/httpClientInterceptor/http-client-interceptor.service.ts @@ -8,6 +8,7 @@ import { GeneralModalService } from 'app/services/general-modal/general-modal.se import { RequestInProgressService } from 'app/services/requestInProgress/request-in-progress.service'; import { environment } from 'environments/environment'; import { tap } from 'rxjs/operators'; +import { ERROR_TYPES } from '../../../services/general-modal/errors'; @Injectable() export class HttpClientInterceptor implements HttpInterceptor { @@ -26,12 +27,14 @@ export class HttpClientInterceptor implements HttpInterceptor { return next.handle(req).pipe(tap(() => { }, error => { this.requestInProgressService.setRequestInProgress(false); if (error instanceof HttpErrorResponse && (error.status === 401 || error.status === 403)) { - this.generalModalService.triggerMessage( + // new Key ERROR_TYPES.ACCESS_ERR + this.generalModalService.triggerMessage( new MessageModal('You have no access to this resource ', error) ); } else if (error instanceof HttpErrorResponse && (error.status === 404) && error.url.indexOf('environment-information.json')) { - // ignore this error message + // ignore this error message Key ERROR_TYPES.NONE } else { + // new Key ERROR_TYPES.GENERAL_ERR this.generalModalService.triggerMessage( new MessageModal('There was error, please contact with your administrator ', error) ); diff --git a/web/src/app/shared/spinner/spinner.component.ts b/web/src/app/shared/spinner/spinner.component.ts index 17c997e25..43b3b9164 100644 --- a/web/src/app/shared/spinner/spinner.component.ts +++ b/web/src/app/shared/spinner/spinner.component.ts @@ -4,9 +4,12 @@ import { Component, Input, Output, EventEmitter, OnDestroy, ViewChild } from '@a import { MessageModal } from 'app/models/message-modal'; import { GeneralModalService } from 'app/services/general-modal/general-modal.service'; +import {ERROR_TYPES} from '../../services/general-modal/errors'; declare let $: any; + + @Component({ selector: 'taskana-spinner', templateUrl: './spinner.component.html', @@ -64,6 +67,7 @@ export class SpinnerComponent implements OnDestroy { this.isDelayedRunning = value; this.cancelTimeout(); this.requestTimeout = setTimeout(() => { + // new Key ERROR_TYPES.TIMEOUT_ERR this.generalModalService.triggerMessage( new MessageModal('There was an error with your request, please make sure you have internet connection', 'Request time execeed') diff --git a/web/src/app/workplace/taskdetails/taskdetails.component.ts b/web/src/app/workplace/taskdetails/taskdetails.component.ts index 3a4d1ef12..46e0b9688 100644 --- a/web/src/app/workplace/taskdetails/taskdetails.component.ts +++ b/web/src/app/workplace/taskdetails/taskdetails.component.ts @@ -16,6 +16,7 @@ import { ObjectReference } from 'app/workplace/models/object-reference'; import { Workbasket } from 'app/models/workbasket'; import { WorkplaceService } from 'app/workplace/services/workplace.service'; import { MasterAndDetailService } from 'app/services/masterAndDetail/master-and-detail.service'; +import { ERROR_TYPES } from '../../services/general-modal/errors'; @Component({ selector: 'taskana-task-details', @@ -85,6 +86,7 @@ export class TaskdetailsComponent implements OnInit, OnDestroy { this.cloneTask(); this.taskService.selectTask(task); }, err => { + // new Key ERROR_TYPES.FETCH_ERR_7 this.generalModalService.triggerMessage( new MessageModal('An error occurred while fetching the task', err) ); @@ -115,6 +117,7 @@ export class TaskdetailsComponent implements OnInit, OnDestroy { this.task = null; this.router.navigate(['taskana/workplace/tasks']); }, err => { + // new Key ERROR_TYPES.DELETE_ERR_2 this.generalModalService.triggerMessage( new MessageModal('An error occurred while deleting the task ', err) ); @@ -142,9 +145,11 @@ export class TaskdetailsComponent implements OnInit, OnDestroy { this.task = task; this.cloneTask(); this.taskService.publishUpdatedTask(task); + // new Key ALERT_TYPES.SUCCESS_ALERT_14 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, 'Updating was successful.')); }, err => { this.requestInProgressService.setRequestInProgress(false); + // new Key ALERT_TYPES.DANGER_ALERT this.alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'There was an error while updating.')); }); } @@ -154,6 +159,7 @@ export class TaskdetailsComponent implements OnInit, OnDestroy { this.addDateToTask(); this.taskService.createTask(this.task).subscribe(task => { this.requestInProgressService.setRequestInProgress(false); + // new Key ALERT_TYPES.SUCCESS_ALERT_13 this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Task ${this.currentId} was created successfully.`)); this.task = task; this.taskService.selectTask(this.task); @@ -161,6 +167,7 @@ export class TaskdetailsComponent implements OnInit, OnDestroy { this.router.navigate([`../${task.taskId}`], { relativeTo: this.route }); }, err => { this.requestInProgressService.setRequestInProgress(false); + // new Key ALERT_TYPES.DANGER_ALERT_2 this.alertService.triggerAlert(new AlertModel(AlertType.DANGER, 'There was an error while creating a new task.')); }); }