Skip to content
Snippets Groups Projects
Commit 1d59ceeb authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' of git.ozg-sh.de:mgm/goofy

parents 880afab9 e32aef82
No related branches found
No related tags found
No related merge requests found
...@@ -21,5 +21,6 @@ export interface CommandListResource extends ListResource { } ...@@ -21,5 +21,6 @@ export interface CommandListResource extends ListResource { }
export enum CommandStatus { export enum CommandStatus {
FINISHED = 'FINISHED', FINISHED = 'FINISHED',
PENDING = 'PENDING', PENDING = 'PENDING',
REVOKED = 'REVOKED' REVOKED = 'REVOKED',
ERROR = 'ERROR'
} }
...@@ -9,7 +9,7 @@ export interface PostfachMail { ...@@ -9,7 +9,7 @@ export interface PostfachMail {
mailBody: string; mailBody: string;
replyOption: ReplyOption; replyOption: ReplyOption;
sentAt: Date; sentAt: Date;
sentSuccessful: Boolean; sentSuccessful: boolean;
} }
export enum Direction { export enum Direction {
......
import { MatSnackBar } from '@angular/material/snack-bar'; 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 { Mock, mock, useFromMock } from '@goofy-client/test-utils';
import * as faker from 'faker'; import * as faker from 'faker';
import { createCommandResource } from 'libs/command-shared/test/command'; import { createCommandResource } from 'libs/command-shared/test/command';
...@@ -50,6 +50,15 @@ describe('SnackBarService', () => { ...@@ -50,6 +50,15 @@ describe('SnackBarService', () => {
expect(service.listenOnAfterDismissed).toHaveBeenCalled(); 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', () => { describe('show error', () => {
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { MatSnackBar, MatSnackBarRef } from '@angular/material/snack-bar'; 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 { isNil } from 'lodash-es';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { SnackbarErrorComponent } from './snackbar-error/snackbar-error.component'; import { SnackbarErrorComponent } from './snackbar-error/snackbar-error.component';
...@@ -16,7 +16,11 @@ export class SnackBarService { ...@@ -16,7 +16,11 @@ export class SnackBarService {
constructor(private snackBar: MatSnackBar) { } constructor(private snackBar: MatSnackBar) { }
public show(commandResource: CommandResource, message: string, revokeAction?: () => void): void { public show(commandResource: CommandResource, message: string, revokeAction?: () => void): void {
if (commandResource.status === CommandStatus.ERROR) {
this.showError(message);
} else {
this.snackBarRef = this.snackBar.openFromComponent(SnackbarComponent, { data: { message, commandResource }, duration: this.durationTime }); this.snackBarRef = this.snackBar.openFromComponent(SnackbarComponent, { data: { message, commandResource }, duration: this.durationTime });
}
this.listenToActions(revokeAction); this.listenToActions(revokeAction);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment