argos/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.comp...

28 lines
862 B
TypeScript
Raw Normal View History

2017-12-14 11:41:26 +01:00
import { Component, Inject } from '@angular/core';
import { MAT_SNACK_BAR_DATA } from '@angular/material';
2018-11-27 18:33:17 +01:00
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../core/common/base/base.component';
2017-12-14 11:41:26 +01:00
@Component({
2018-10-05 17:00:54 +02:00
selector: 'app-snack-bar-notification',
templateUrl: 'snack-bar-notification.component.html'
2017-12-14 11:41:26 +01:00
})
2018-11-27 18:33:17 +01:00
export class SnackBarNotificationComponent extends BaseComponent {
2018-10-05 17:00:54 +02:00
message: string;
constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any) {
2018-11-27 18:33:17 +01:00
super();
2018-10-05 17:00:54 +02:00
this.parseMessage(data.message, data.language);
}
2017-12-14 11:41:26 +01:00
2018-10-05 17:00:54 +02:00
parseMessage(message: any, language: TranslateService): void {
if (language) {
2018-11-27 18:33:17 +01:00
language.get(message)
.pipe(takeUntil(this._destroyed))
.subscribe((value: string) => {
this.message = value;
});
2018-10-05 17:00:54 +02:00
} else { this.message = message; }
}
2017-12-14 11:41:26 +01:00
}