diff --git a/goofy-client/libs/command-shared/src/lib/command.model.ts b/goofy-client/libs/command-shared/src/lib/command.model.ts index 9c0d79a98ee9792c6d137109d987ebcd90624e96..e12884e8ceca6e188c1354ef0e0d799a1a071ae8 100644 --- a/goofy-client/libs/command-shared/src/lib/command.model.ts +++ b/goofy-client/libs/command-shared/src/lib/command.model.ts @@ -21,5 +21,6 @@ export interface CommandListResource extends ListResource { } export enum CommandStatus { FINISHED = 'FINISHED', PENDING = 'PENDING', - REVOKED = 'REVOKED' -} \ No newline at end of file + REVOKED = 'REVOKED', + ERROR = 'ERROR' +} diff --git a/goofy-client/libs/postfach-shared/src/lib/postfach.model.ts b/goofy-client/libs/postfach-shared/src/lib/postfach.model.ts index d341ce0ff9cc3c47c4c25d68d7c6229f526c6760..36cd7c90bb7be6a6597dced8df79334a2a8ec747 100644 --- a/goofy-client/libs/postfach-shared/src/lib/postfach.model.ts +++ b/goofy-client/libs/postfach-shared/src/lib/postfach.model.ts @@ -9,7 +9,7 @@ export interface PostfachMail { mailBody: string; replyOption: ReplyOption; sentAt: Date; - sentSuccessful: Boolean; + sentSuccessful: boolean; } export enum Direction { @@ -33,4 +33,4 @@ export interface CreateSendPostfachMailCommand extends CreateCommand { export interface PostfachMailResource extends Resource, PostfachMail { } -export interface PostfachMailListResource extends ListResource { } \ No newline at end of file +export interface PostfachMailListResource extends ListResource { } diff --git a/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.spec.ts b/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.spec.ts index 3cfb6363e10a3fd421a19709819184853402fb25..92d594c654f3e009a2cbf9beb9246f32431ade65 100644 --- a/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.spec.ts +++ b/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.spec.ts @@ -1,5 +1,5 @@ import { MatSnackBar } from '@angular/material/snack-bar'; -import { CommandResource } from '@goofy-client/command-shared'; +import { CommandResource, CommandStatus } from '@goofy-client/command-shared'; import { Mock, mock, useFromMock } from '@goofy-client/test-utils'; import * as faker from 'faker'; import { createCommandResource } from 'libs/command-shared/test/command'; @@ -50,6 +50,15 @@ describe('SnackBarService', () => { expect(service.listenOnAfterDismissed).toHaveBeenCalled(); }) + + it('should open error snackbar when status is ERROR', () => { + const commandWithError = { ...commandResource, status: CommandStatus.ERROR} + service.show(commandWithError, message, null); + + expect(snackBar.openFromComponent).toHaveBeenCalledWith(SnackbarErrorComponent, { + data: { message }, duration: 10000 + }); + }); }) describe('show error', () => { diff --git a/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.ts b/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.ts index 18877bb2dcb64bd8f66d1f7c41c475e46fdff6d1..f77658c1042100035e9a91c00652d0b15ea91fef 100644 --- a/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.ts +++ b/goofy-client/libs/ui/src/lib/snackbar/snackbar.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { MatSnackBar, MatSnackBarRef } from '@angular/material/snack-bar'; -import { CommandResource } from '@goofy-client/command-shared'; +import { CommandResource, CommandStatus } from '@goofy-client/command-shared'; import { isNil } from 'lodash-es'; import { Subscription } from 'rxjs'; import { SnackbarErrorComponent } from './snackbar-error/snackbar-error.component'; @@ -16,7 +16,11 @@ export class SnackBarService { constructor(private snackBar: MatSnackBar) { } public show(commandResource: CommandResource, message: string, revokeAction?: () => void): void { - this.snackBarRef = this.snackBar.openFromComponent(SnackbarComponent, { data: { message, commandResource }, duration: this.durationTime }); + if (commandResource.status === CommandStatus.ERROR) { + this.showError(message); + } else { + this.snackBarRef = this.snackBar.openFromComponent(SnackbarComponent, { data: { message, commandResource }, duration: this.durationTime }); + } this.listenToActions(revokeAction); }