From eabfa64dae4a7d7280ff176561ee86ac0adf914b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Mon, 21 Mar 2022 14:58:17 +0100 Subject: [PATCH] refactor(error): use error handler everywhere (DEV-475) (#688) * refactor(error): use error handler everywhere (DEV-475) * test: fix tests * refactor(results): remove commented code * refactor(resource): remove unnecessary asterisks * test(error): clean up test * test(error): clean up test --- .../main/error/error-handler.service.spec.ts | 5 ----- src/app/main/header/header.component.ts | 4 +--- .../properties/properties.component.spec.ts | 6 +++--- .../select-ontology.component.html | 2 +- .../select-project.component.html | 2 +- .../select-resource-class.component.html | 2 +- .../workspace/resource/resource.component.ts | 2 +- .../list-value/list-value.component.spec.ts | 8 +++++--- .../values/list-value/list-value.component.ts | 5 +++-- .../list-view/list-view.component.spec.ts | 6 +++++- .../results/list-view/list-view.component.ts | 17 ++++++++--------- .../advanced-search.component.spec.ts | 2 ++ .../advanced-search.component.ts | 16 ++++++++-------- .../search-list-value.component.spec.ts | 8 +++++--- .../search-list-value.component.ts | 8 ++++---- .../expert-search.component.spec.ts | 10 ++++++---- .../fulltext-search.component.spec.ts | 18 ++++++++++-------- .../fulltext-search.component.ts | 11 ++++++----- 18 files changed, 70 insertions(+), 62 deletions(-) diff --git a/src/app/main/error/error-handler.service.spec.ts b/src/app/main/error/error-handler.service.spec.ts index 757d9de13d..1af2f0a786 100644 --- a/src/app/main/error/error-handler.service.spec.ts +++ b/src/app/main/error/error-handler.service.spec.ts @@ -68,11 +68,6 @@ describe('ErrorHandlerService', () => { httpTestingController.verify(); }); - afterEach(async () => { - // angular won't call this for us so we need to do it ourselves to avoid leaks. - overlayContainer.ngOnDestroy(); - }); - it('should be created', () => { expect(service).toBeTruthy(); }); diff --git a/src/app/main/header/header.component.ts b/src/app/main/header/header.component.ts index 65e0c8e12c..79969c4982 100644 --- a/src/app/main/header/header.component.ts +++ b/src/app/main/header/header.component.ts @@ -3,7 +3,7 @@ import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { MatIconRegistry } from '@angular/material/icon'; import { DomSanitizer } from '@angular/platform-browser'; import { NavigationStart, Router } from '@angular/router'; -import { ApiResponseData, ApiResponseError, HealthResponse, KnoraApiConnection } from '@dasch-swiss/dsp-js'; +import { KnoraApiConnection } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; import { AppInitService } from 'src/app/app-init.service'; import { DialogComponent } from 'src/app/main/dialog/dialog.component'; @@ -11,7 +11,6 @@ import { ComponentCommunicationEventService, Events } from 'src/app/main/service import { SearchParams } from 'src/app/workspace/results/list-view/list-view.component'; import { DspApiConnectionToken } from '../declarations/dsp-api-tokens'; import { DspConfig } from '../declarations/dsp-config'; -import { ErrorHandlerService } from '../error/error-handler.service'; import { NotificationService } from '../services/notification.service'; import { SessionService } from '../services/session.service'; @@ -36,7 +35,6 @@ export class HeaderComponent implements OnInit, OnDestroy { private _componentCommsService: ComponentCommunicationEventService, private _dialog: MatDialog, private _domSanitizer: DomSanitizer, - private _errorHandler: ErrorHandlerService, private _matIconRegistry: MatIconRegistry, private _notification: NotificationService, private _router: Router, diff --git a/src/app/workspace/resource/properties/properties.component.spec.ts b/src/app/workspace/resource/properties/properties.component.spec.ts index 8fe0dde684..d7de823e45 100644 --- a/src/app/workspace/resource/properties/properties.component.spec.ts +++ b/src/app/workspace/resource/properties/properties.component.spec.ts @@ -7,6 +7,7 @@ import { MatMenuModule } from '@angular/material/menu'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTooltipModule } from '@angular/material/tooltip'; import { By } from '@angular/platform-browser'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { ApiResponseError, @@ -25,9 +26,7 @@ import { } from '@dasch-swiss/dsp-js'; import { of, Subscription } from 'rxjs'; import { AppInitService } from 'src/app/app-init.service'; -import { DspApiConnectionToken, DspAppConfigToken } from 'src/app/main/declarations/dsp-api-tokens'; -import { DspAppConfig } from 'src/app/main/declarations/dsp-app-config'; -import { TestConfig } from 'test.config'; +import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { DspResource } from '../dsp-resource'; import { IncomingService } from '../services/incoming.service'; import { UserService } from '../services/user.service'; @@ -157,6 +156,7 @@ describe('PropertiesComponent', () => { TestBed.configureTestingModule({ imports: [ + BrowserAnimationsModule, ClipboardModule, MatDialogModule, MatIconModule, diff --git a/src/app/workspace/resource/resource-instance-form/select-ontology/select-ontology.component.html b/src/app/workspace/resource/resource-instance-form/select-ontology/select-ontology.component.html index 01d97fe185..b50c5cf108 100644 --- a/src/app/workspace/resource/resource-instance-form/select-ontology/select-ontology.component.html +++ b/src/app/workspace/resource/resource-instance-form/select-ontology/select-ontology.component.html @@ -4,7 +4,7 @@ - Select a data model * + Select a data model {{ onto.label }} diff --git a/src/app/workspace/resource/resource-instance-form/select-project/select-project.component.html b/src/app/workspace/resource/resource-instance-form/select-project/select-project.component.html index 4a7bb32ab9..cf31e45e85 100644 --- a/src/app/workspace/resource/resource-instance-form/select-project/select-project.component.html +++ b/src/app/workspace/resource/resource-instance-form/select-project/select-project.component.html @@ -4,7 +4,7 @@ - Select a project * + Select a project {{ project.shortcode }} | {{ project.shortname }} diff --git a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html index 7d416b0d29..f89b63f123 100644 --- a/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html +++ b/src/app/workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component.html @@ -4,7 +4,7 @@ - Select a resource * + Select a resource {{ res.label }} diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index dc90ddce28..b405ba0076 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -134,7 +134,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { // hide loading indicator // present error to user - this._notification.openSnackBar(event.error); + this._errorHandler.showMessage(event.error); } diff --git a/src/app/workspace/resource/values/list-value/list-value.component.spec.ts b/src/app/workspace/resource/values/list-value/list-value.component.spec.ts index 413a21975a..9eb2d319fc 100644 --- a/src/app/workspace/resource/values/list-value/list-value.component.spec.ts +++ b/src/app/workspace/resource/values/list-value/list-value.component.spec.ts @@ -1,6 +1,7 @@ import { Component, DebugElement, OnInit, ViewChild } from '@angular/core'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatInputModule } from '@angular/material/input'; import { MatMenuModule } from '@angular/material/menu'; import { MatSnackBarModule } from '@angular/material/snack-bar'; @@ -86,11 +87,12 @@ describe('ListValueComponent', () => { TestHostCreateValueComponent ], imports: [ - ReactiveFormsModule, + BrowserAnimationsModule, + MatDialogModule, MatInputModule, MatMenuModule, MatSnackBarModule, - BrowserAnimationsModule + ReactiveFormsModule, ], providers: [ { diff --git a/src/app/workspace/resource/values/list-value/list-value.component.ts b/src/app/workspace/resource/values/list-value/list-value.component.ts index 8fdd5c9888..d5e84486e0 100644 --- a/src/app/workspace/resource/values/list-value/list-value.component.ts +++ b/src/app/workspace/resource/values/list-value/list-value.component.ts @@ -13,6 +13,7 @@ import { import { Subscription } from 'rxjs'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; import { BaseValueDirective } from 'src/app/main/directive/base-value.directive'; +import { ErrorHandlerService } from 'src/app/main/error/error-handler.service'; import { NotificationService } from 'src/app/main/services/notification.service'; // https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror @@ -44,7 +45,7 @@ export class ListValueComponent extends BaseValueDirective implements OnInit, On constructor( @Inject(FormBuilder) private _fb: FormBuilder, @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, - private _notification: NotificationService + private _errorHandler: ErrorHandlerService ) { super(); } @@ -76,7 +77,7 @@ export class ListValueComponent extends BaseValueDirective implements OnInit, On (response2: ListNodeV2) => { this.listRootNode.children.push(response2); }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); }); } } else { diff --git a/src/app/workspace/results/list-view/list-view.component.spec.ts b/src/app/workspace/results/list-view/list-view.component.spec.ts index 56ea186324..b80690bd67 100644 --- a/src/app/workspace/results/list-view/list-view.component.spec.ts +++ b/src/app/workspace/results/list-view/list-view.component.spec.ts @@ -1,9 +1,11 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { MatButtonModule } from '@angular/material/button'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CountQueryResponse, IFulltextSearchParams, MockResource, ReadResourceSequence, SearchEndpointV2 } from '@dasch-swiss/dsp-js'; import { of } from 'rxjs'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; @@ -112,7 +114,9 @@ describe('ListViewComponent', () => { TestResourceListComponent ], imports: [ + BrowserAnimationsModule, MatButtonModule, + MatDialogModule, MatIconModule, MatPaginatorModule, MatSnackBarModule diff --git a/src/app/workspace/results/list-view/list-view.component.ts b/src/app/workspace/results/list-view/list-view.component.ts index 0968677655..8418ece96f 100644 --- a/src/app/workspace/results/list-view/list-view.component.ts +++ b/src/app/workspace/results/list-view/list-view.component.ts @@ -2,6 +2,7 @@ import { Component, EventEmitter, Inject, Input, OnChanges, Output } from '@angu import { PageEvent } from '@angular/material/paginator'; import { ApiResponseError, CountQueryResponse, IFulltextSearchParams, KnoraApiConnection, ReadResourceSequence } from '@dasch-swiss/dsp-js'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; +import { ErrorHandlerService } from 'src/app/main/error/error-handler.service'; import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service'; import { NotificationService } from 'src/app/main/services/notification.service'; @@ -116,8 +117,9 @@ export class ListViewComponent implements OnChanges { constructor( @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, - private _notification: NotificationService, private _componentCommsService: ComponentCommunicationEventService, + private _errorHandler: ErrorHandlerService, + private _notification: NotificationService ) { } ngOnChanges(): void { @@ -148,10 +150,8 @@ export class ListViewComponent implements OnChanges { } else if (res.count > 0) { this.selectedResourceIdx = res.resListIndex; this.selectedResources.emit(res); - this.resourceSelected.emit(res.resInfo[0].id); } - } goToPage(page: PageEvent) { @@ -159,7 +159,6 @@ export class ListViewComponent implements OnChanges { this._doSearch(); } - /** * do the search and send the resources to the child components * like resource-list, resource-grid or resource-table @@ -183,7 +182,7 @@ export class ListViewComponent implements OnChanges { } }, (countError: ApiResponseError) => { - this._notification.openSnackBar(countError); + this._errorHandler.showMessage(countError); } ); } @@ -200,7 +199,7 @@ export class ListViewComponent implements OnChanges { this.loading = false; }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); this.resources = undefined; this.loading = false; } @@ -224,7 +223,7 @@ export class ListViewComponent implements OnChanges { } }, (countError: ApiResponseError) => { - this._notification.openSnackBar(countError); + this._errorHandler.showMessage(countError); } ); } @@ -246,13 +245,13 @@ export class ListViewComponent implements OnChanges { this.loading = false; }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); this.resources = undefined; this.loading = false; } ); } else { - console.error('The gravsearch query is not set correctly'); + this._notification.openSnackBar('The gravsearch query is not set correctly'); this.resources = undefined; this.loading = false; } diff --git a/src/app/workspace/search/advanced-search/advanced-search.component.spec.ts b/src/app/workspace/search/advanced-search/advanced-search.component.spec.ts index 8d3c9f3328..26c304641f 100644 --- a/src/app/workspace/search/advanced-search/advanced-search.component.spec.ts +++ b/src/app/workspace/search/advanced-search/advanced-search.component.spec.ts @@ -3,6 +3,7 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FormGroup, ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { By } from '@angular/platform-browser'; @@ -92,6 +93,7 @@ describe('AdvancedSearchComponent', () => { imports: [ ReactiveFormsModule, BrowserAnimationsModule, + MatDialogModule, MatIconModule, MatSnackBarModule ], diff --git a/src/app/workspace/search/advanced-search/advanced-search.component.ts b/src/app/workspace/search/advanced-search/advanced-search.component.ts index f8a0c303e6..9fc1a5365e 100644 --- a/src/app/workspace/search/advanced-search/advanced-search.component.ts +++ b/src/app/workspace/search/advanced-search/advanced-search.component.ts @@ -13,11 +13,11 @@ import { FormBuilder, FormGroup } from '@angular/forms'; import { ApiResponseError, Constants, KnoraApiConnection, OntologiesMetadata, OntologyMetadata } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; -import { NotificationService } from 'src/app/main/services/notification.service'; +import { ErrorHandlerService } from 'src/app/main/error/error-handler.service'; import { SearchParams } from '../../results/list-view/list-view.component'; import { GravsearchGenerationService } from '../services/gravsearch-generation.service'; -import { PropertyWithValue } from './resource-and-property-selection/search-select-property/specify-property-value/operator'; import { ResourceAndPropertySelectionComponent } from './resource-and-property-selection/resource-and-property-selection.component'; +import { PropertyWithValue } from './resource-and-property-selection/search-select-property/specify-property-value/operator'; @Component({ selector: 'app-advanced-search', @@ -58,11 +58,11 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy, AfterViewChec errorMessage: ApiResponseError; constructor( - @Inject(FormBuilder) private _fb: FormBuilder, @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, - private _notification: NotificationService, - private _gravsearchGenerationService: GravsearchGenerationService) { - } + @Inject(FormBuilder) private _fb: FormBuilder, + private _errorHandler: ErrorHandlerService, + private _gravsearchGenerationService: GravsearchGenerationService + ) { } ngOnInit() { @@ -105,7 +105,7 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy, AfterViewChec }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); this.errorMessage = error; }); } else { @@ -120,7 +120,7 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy, AfterViewChec }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); this.errorMessage = error; }); } diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.spec.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.spec.ts index 5f237bfb8c..6382ddc92d 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.spec.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.spec.ts @@ -1,9 +1,10 @@ import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { Component, EventEmitter, Inject, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { MatButtonHarness } from '@angular/material/button/testing'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatInputModule } from '@angular/material/input'; import { MatMenu, MatMenuModule } from '@angular/material/menu'; import { MatSnackBarModule } from '@angular/material/snack-bar'; @@ -80,10 +81,11 @@ describe('SearchListValueComponent', () => { TestBed.configureTestingModule({ imports: [ BrowserAnimationsModule, - ReactiveFormsModule, + MatDialogModule, MatInputModule, MatMenuModule, - MatSnackBarModule + MatSnackBarModule, + ReactiveFormsModule ], declarations: [ SearchListValueComponent, diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.ts index c0605fac22..7660e20524 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-property/specify-property-value/search-list-value/search-list-value.component.ts @@ -9,7 +9,7 @@ import { ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; -import { NotificationService } from 'src/app/main/services/notification.service'; +import { ErrorHandlerService } from 'src/app/main/error/error-handler.service'; import { IRI, PropertyValue, Value } from '../operator'; // https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror @@ -39,8 +39,8 @@ export class SearchListValueComponent implements OnInit, OnDestroy, PropertyValu constructor( @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, - private _notification: NotificationService, - @Inject(FormBuilder) private _fb: FormBuilder + @Inject(FormBuilder) private _fb: FormBuilder, + private _errorHandler: ErrorHandlerService ) { } @@ -62,7 +62,7 @@ export class SearchListValueComponent implements OnInit, OnDestroy, PropertyValu this.listRootNode = response; }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); } ); diff --git a/src/app/workspace/search/expert-search/expert-search.component.spec.ts b/src/app/workspace/search/expert-search/expert-search.component.spec.ts index 3a6a03af47..b55fd7e97f 100644 --- a/src/app/workspace/search/expert-search/expert-search.component.spec.ts +++ b/src/app/workspace/search/expert-search/expert-search.component.spec.ts @@ -1,6 +1,7 @@ import { Component, DebugElement, OnInit, ViewChild } from '@angular/core'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { By } from '@angular/platform-browser'; @@ -53,11 +54,12 @@ describe('ExpertSearchComponent', () => { TestHostComponent ], imports: [ - FormsModule, - ReactiveFormsModule, BrowserAnimationsModule, + FormsModule, + MatDialogModule, MatFormFieldModule, - MatInputModule + MatInputModule, + ReactiveFormsModule ], providers: [ { diff --git a/src/app/workspace/search/fulltext-search/fulltext-search.component.spec.ts b/src/app/workspace/search/fulltext-search/fulltext-search.component.spec.ts index 521315589b..9401eb1b9f 100644 --- a/src/app/workspace/search/fulltext-search/fulltext-search.component.spec.ts +++ b/src/app/workspace/search/fulltext-search/fulltext-search.component.spec.ts @@ -1,7 +1,8 @@ import { OverlayModule } from '@angular/cdk/overlay'; import { Component, OnInit, ViewChild } from '@angular/core'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -72,16 +73,17 @@ describe('FulltextSearchComponent', () => { TestHostFulltextSearchComponent ], imports: [ - OverlayModule, - FormsModule, BrowserAnimationsModule, - MatMenuModule, - MatInputModule, - MatTooltipModule, - MatIconModule, + FormsModule, + MatDialogModule, MatDividerModule, + MatIconModule, + MatInputModule, MatListModule, - MatSnackBarModule + MatMenuModule, + MatSnackBarModule, + MatTooltipModule, + OverlayModule, ], providers: [ { diff --git a/src/app/workspace/search/fulltext-search/fulltext-search.component.ts b/src/app/workspace/search/fulltext-search/fulltext-search.component.ts index dc64047215..4ceae3ae62 100644 --- a/src/app/workspace/search/fulltext-search/fulltext-search.component.ts +++ b/src/app/workspace/search/fulltext-search/fulltext-search.component.ts @@ -26,6 +26,7 @@ import { } from '@dasch-swiss/dsp-js'; import { Subscription } from 'rxjs'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; +import { ErrorHandlerService } from 'src/app/main/error/error-handler.service'; import { ComponentCommunicationEventService, Events } from 'src/app/main/services/component-communication-event.service'; import { NotificationService } from 'src/app/main/services/notification.service'; import { SortingService } from 'src/app/main/services/sorting.service'; @@ -130,11 +131,11 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy { constructor( @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, - private _notification: NotificationService, - private _sortingService: SortingService, + private _componentCommsService: ComponentCommunicationEventService, + private _errorHandler: ErrorHandlerService, private _overlay: Overlay, + private _sortingService: SortingService, private _viewContainerRef: ViewContainerRef, - private _componentCommsService: ComponentCommunicationEventService, ) { } ngOnInit(): void { @@ -219,8 +220,8 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy { this.projects = this._sortingService.keySortByAlphabetical(response.body.projects, 'shortname'); }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); this.error = error; + this._errorHandler.showMessage(error); } ); } @@ -235,7 +236,7 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy { this.setProject(project.body.project); }, (error: ApiResponseError) => { - this._notification.openSnackBar(error); + this._errorHandler.showMessage(error); } ); }