diff --git a/src/app/main/header/header.component.html b/src/app/main/header/header.component.html index c91e3659f2..d78e08e897 100644 --- a/src/app/main/header/header.component.html +++ b/src/app/main/header/header.component.html @@ -19,24 +19,11 @@

DSP

[expert]="true" (search)="doSearch($event)"> - - + - - - @@ -54,14 +41,3 @@

DSP

- -
- -
- - - - diff --git a/src/app/main/header/header.component.spec.ts b/src/app/main/header/header.component.spec.ts index 118ef12c0d..9558b5aa21 100644 --- a/src/app/main/header/header.component.spec.ts +++ b/src/app/main/header/header.component.spec.ts @@ -1,10 +1,11 @@ import { HttpClientModule } from '@angular/common/http'; -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { MatIconModule } from '@angular/material/icon'; import { MatListModule } from '@angular/material/list'; import { MatMenuModule } from '@angular/material/menu'; import { MatToolbarModule } from '@angular/material/toolbar'; import { By } from '@angular/platform-browser'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { KnoraApiConnection } from '@dasch-swiss/dsp-js'; import { @@ -13,16 +14,14 @@ import { DspApiConfigToken, DspApiConnectionToken, DspCoreModule, - DspSearchModule, - MessageComponent + DspSearchModule } from '@dasch-swiss/dsp-ui'; import { TranslateModule } from '@ngx-translate/core'; +import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service'; import { UserMenuComponent } from 'src/app/user/user-menu/user-menu.component'; import { TestConfig } from 'test.config'; import { SelectLanguageComponent } from '../select-language/select-language.component'; import { HeaderComponent } from './header.component'; -import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('HeaderComponent', () => { let component: HeaderComponent; @@ -102,14 +101,13 @@ describe('HeaderComponent', () => { expect(searchPanel).toBeDefined(); }); - it('should display the login success message when the loginSuccess event is emitted', () => { + it('should subscribe to component communication when the loginSuccess event is emitted', () => { componentCommsService.emit(new EmitEvent(Events.loginSuccess)); fixture.detectChanges(); - const message = fixture.debugElement.query(By.directive(MessageComponent)); - expect(message).toBeTruthy(); + expect(component.componentCommsSubscription.closed).toBe(false); }); - it('should unsubscribe from from changes on destruction', () => { + it('should unsubscribe from changes on destruction', () => { expect(component.componentCommsSubscription.closed).toBe(false); diff --git a/src/app/main/header/header.component.ts b/src/app/main/header/header.component.ts index 00a720d6cc..0f816d77d0 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 { DspMessageData, SearchParams, SessionService } from '@dasch-swiss/dsp-ui'; +import { NotificationService, SearchParams, SessionService } from '@dasch-swiss/dsp-ui'; import { Subscription } from 'rxjs'; import { DialogComponent } from 'src/app/main/dialog/dialog.component'; import { ComponentCommunicationEventService, Events } from 'src/app/main/services/component-communication-event.service'; @@ -23,22 +23,17 @@ export class HeaderComponent implements OnInit, OnDestroy { appVersion: string = 'v' + appVersion; - successMessage: DspMessageData = { - status: 200, - statusText: 'Login successful' - }; - - showMessage = false; - componentCommsSubscription: Subscription; constructor( - private _session: SessionService, + private _componentCommsService: ComponentCommunicationEventService, + private _dialog: MatDialog, private _domSanitizer: DomSanitizer, private _matIconRegistry: MatIconRegistry, - private _dialog: MatDialog, + private _notification: NotificationService, private _router: Router, - private _componentCommsService: ComponentCommunicationEventService) { + private _session: SessionService + ) { // create tool icons to use them in mat-icons this._matIconRegistry.addSvgIcon( @@ -60,7 +55,9 @@ export class HeaderComponent implements OnInit, OnDestroy { ngOnInit() { this.componentCommsSubscription = this._componentCommsService.on( - Events.loginSuccess, () => this.showMessage = true); + Events.loginSuccess, () => { + this._notification.openSnackBar('Login successful'); + }); } ngOnDestroy() {