From 8bc1e72e2874e5734965fd4647dc7fb682d4dd98 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Fri, 11 Oct 2019 09:57:03 +0800 Subject: feat: extract the public notification component Change-Id: I0e42ddf844e92b986d9bc1748dfc06b202d37f2b Issue-ID: USECASEUI-307 Signed-off-by: cyuamber --- .../notification/notification.component.html | 20 +++++++++++++ .../notification/notification.component.less | 0 .../notification/notification.component.spec.ts | 25 ++++++++++++++++ .../notification/notification.component.ts | 33 ++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 usecaseui-portal/src/app/shared/components/notification/notification.component.html create mode 100644 usecaseui-portal/src/app/shared/components/notification/notification.component.less create mode 100644 usecaseui-portal/src/app/shared/components/notification/notification.component.spec.ts create mode 100644 usecaseui-portal/src/app/shared/components/notification/notification.component.ts (limited to 'usecaseui-portal/src/app/shared') diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.html b/usecaseui-portal/src/app/shared/components/notification/notification.component.html new file mode 100644 index 00000000..97f66ba5 --- /dev/null +++ b/usecaseui-portal/src/app/shared/components/notification/notification.component.html @@ -0,0 +1,20 @@ + +
+
+ + {{notificationAttributes.status}} + +
+ {{"i18nTextDefine_"+notificationAttributes.title | translate}}  + {{"i18nTextDefine_"+notificationAttributes.action | translate}}  {{"i18nTextDefine_"+notificationAttributes.status | translate}} +
+
+
+

{{"i18nTextDefine_"+notificationAttributes.title | translate}}:

+ {{ notificationAttributes.name }} +
+
+
{{"i18nTextDefine_Close" | translate}}
+
+
+
diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.less b/usecaseui-portal/src/app/shared/components/notification/notification.component.less new file mode 100644 index 00000000..e69de29b diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.spec.ts b/usecaseui-portal/src/app/shared/components/notification/notification.component.spec.ts new file mode 100644 index 00000000..69192c5e --- /dev/null +++ b/usecaseui-portal/src/app/shared/components/notification/notification.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NotificationComponent } from './notification.component'; + +describe('NotificationComponent', () => { + let component: NotificationComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ NotificationComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NotificationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.ts b/usecaseui-portal/src/app/shared/components/notification/notification.component.ts new file mode 100644 index 00000000..031b161d --- /dev/null +++ b/usecaseui-portal/src/app/shared/components/notification/notification.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core'; +import { NzNotificationService } from 'ng-zorro-antd'; + +@Component({ + selector: 'app-notification', + templateUrl: './notification.component.html', + styleUrls: ['./notification.component.less'] +}) +export class NotificationComponent implements OnInit { + @ViewChild('notificationModel')notificationModel: any; + + notificationAttributes: object = null; + + constructor(private notification: NzNotificationService) { } + + ngOnInit() { + } + + setNotification({ title, imgPath, action, status, name }):void{ + this.notificationAttributes = { title, imgPath, action, status, name } + } + notificationSuccess(title: string, action: string, name: string): void { + this.notification.remove() + this.setNotification({ title, imgPath: "assets/images/execute-success.png", action, status: 'Success', name }) + this.notification.template(this.notificationModel); + } + notificationFailed(title: string, action: string, name: string): void { + this.notification.remove() + this.setNotification({ title, imgPath: "assets/images/execute-faild.png", action, status: 'Failed', name }) + this.notification.template(this.notificationModel) + } + +} -- cgit 1.2.3-korg