--- /dev/null
+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)
+ }
+
+}
<input nz-input placeholder=" {{'i18nTextDefine_Input_customerName' | translate}} " class="customer_name"
nzSize="default" [(ngModel)]="addNewCustomer">
<button nz-button nzType="primary" class="customer_addbut"
- (click)="createNewCustomer(notificationModel)">{{"i18nTextDefine_Add" | translate}}</button>
+ (click)="createNewCustomer()">{{"i18nTextDefine_Add" | translate}}</button>
</div>
<div class="customer_list">
<ul>
<input nz-input placeholder=" {{'i18nTextDefine_Input_ServicesType' | translate}} " class="services_name"
nzSize="default" [(ngModel)]="addNewServiceType">
<button nz-button nzType="primary" class="services_addbut"
- (click)="createNewServiceType(notificationModel)">{{"i18nTextDefine_Add" | translate}}</button>
+ (click)="createNewServiceType()">{{"i18nTextDefine_Add" | translate}}</button>
</div>
<div class="services_list_content">
<div class="border_size"></div>
</div>
<nz-modal nzWidth="428" [(nzVisible)]="deleteCustomerModelVisible" nzTitle=" {{'i18nTextDefine_delete' | translate}} "
- (nzOnCancel)="deleteCustomerCancel()" (nzOnOk)="deleteCustomerOk(notificationModel)" nzClassName="deleteModel"
+ (nzOnCancel)="deleteCustomerCancel()" (nzOnOk)="deleteCustomerOk()" nzClassName="deleteModel"
nzCancelText=" {{'i18nTextDefine_Cancel' | translate}} " nzOkText=" {{'i18nTextDefine_modelOk' | translate}} ">
<h3><span style="color: red">* </span> {{"i18nTextDefine_Input_Sure_deleteCustomer" | translate}} </h3>
<div class="question">
</nz-modal>
<nz-modal nzWidth="428" [(nzVisible)]="deleteServiceTypeModelVisible"
nzTitle=" {{'i18nTextDefine_delete' | translate}} " (nzOnCancel)="deleteServiceTypeCancel()"
- (nzOnOk)="deleteServiceTypeOk(notificationModel)" nzClassName="deleteModel deleteServiceTypeModel"
+ (nzOnOk)="deleteServiceTypeOk()" nzClassName="deleteModel deleteServiceTypeModel"
nzCancelText=" {{'i18nTextDefine_Cancel' | translate}} " nzOkText=" {{'i18nTextDefine_modelOk' | translate}} ">
<h3><span style="color: red">* </span> {{"i18nTextDefine_Input_Sure_deleteServiceType" | translate}} </h3>
<div class="question">
<div class="deleteModelContent">{{thisdeleteServiceType["type"]}}</div>
</div>
</nz-modal>
- <!--2019.08.14 add notification-->
- <ng-template #notificationModel>
- <div class="ant-notification-notice-content">
- <div class="ant-notification-notice-with-icon">
- <span class="ant-notification-notice-icon">
- <img src="{{this.notificationAttributes.imgPath}}" alt="{{notificationAttributes.status}}">
- </span>
- <div class="ant-notification-notice-message" *ngIf="notificationAttributes.title == 'Customer'">
- {{"i18nTextDefine_"+notificationAttributes.title | translate}}
- {{"i18nTextDefine_"+notificationAttributes.action | translate}} {{"i18nTextDefine_"+notificationAttributes.status | translate}}
- </div>
- <div class="ant-notification-notice-description">
- <div class="notificationlist">
- <p>{{"i18nTextDefine_"+notificationAttributes.title | translate}}:</p>
- <span>{{ notificationAttributes.name }}</span>
- </div>
- </div>
- <div class="close-icons">{{"i18nTextDefine_Close" | translate}}</div>
- </div>
- </div>
- </ng-template>
+ <app-notification #notification></app-notification>
</div>
\ No newline at end of file
*/
import { Component, OnInit, ViewChild } from '@angular/core';
import { ManagemencsService } from '../../../core/services/managemencs.service';
-import { NzNotificationService } from 'ng-zorro-antd';
import { Observable } from 'rxjs';
@Component({
export class CustomerComponent implements OnInit {
@ViewChild('chart') chart;
@ViewChild('pie') pie;
+ @ViewChild('notification')notification:any;
public chose = '';
resizeMark;
constructor(
private managemencs: ManagemencsService,
- private notification: NzNotificationService
) {
}
addNewServiceType = null;
deleteCustomerModelVisible = false;
deleteServiceTypeModelVisible = false;
- //2019.08.14 add
- notificationAttributes = null;
- setNotification({ title, imgPath, action, status, name }):void{
- this.notificationAttributes = { title, imgPath, action, status, name }
- }
- notificationSuccess(notificationModel,title,action,name) {
- this.notification.remove()
- this.setNotification({ title, imgPath: "assets/images/execute-success.png", action, status: 'Success', name })
- this.notification.template(notificationModel);
- }
- notificationFailed(notificationModel,title,action,name) {
- this.notification.remove()
- this.setNotification({ title, imgPath: "assets/images/execute-faild.png", action, status: 'Failed', name })
- this.notification.template(notificationModel)
- }
getAllCustomers() {
this.managemencs.getAllCustomers().subscribe((data) => {
this.AllCustomersdata = data.map((item) => {
})
}
- createNewCustomer(notificationModel) {
+ createNewCustomer(): void {
let createParams = {
customerId: this.addNewCustomer,
'global-customer-id': this.addNewCustomer,
};
this.managemencs.createCustomer(this.addNewCustomer, createParams).subscribe((data) => {
if (data["status"] == 'SUCCESS') {
- this.notificationSuccess(notificationModel,'Customer','Create',this.addNewCustomer);
+ this.notification.notificationSuccess('Customer','Create',this.addNewCustomer);
this.getAllCustomers();
} else {
- this.notificationFailed(notificationModel,'Customer','Create',this.addNewCustomer);
+ this.notification.notificationFailed('Customer','Create',this.addNewCustomer);
}
})
}
deleteCustomerCancel() {
this.deleteCustomerModelVisible = false;
}
- deleteCustomerOk(notificationModel) {
+ deleteCustomerOk() {
this.deleteCustomerModelVisible = false;
- this.getCustomerVersion(this.thisdeleteCustomer, notificationModel);
+ this.getCustomerVersion(this.thisdeleteCustomer,);
}
- getCustomerVersion(thisdeleteCustomer, notificationModel) {
+ getCustomerVersion(thisdeleteCustomer) {
this.managemencs.getdeleteCustomerVersion(thisdeleteCustomer).subscribe((data) => {
if (data["status"] == 'SUCCESS') {
let params = {
customerId: thisdeleteCustomer.id,
resourceVersion: data["result"]["resource-version"]
};
- this.deleteCustomer(params, notificationModel)
+ this.deleteCustomer(params)
} else {
console.error(data, "Interface returned error")
}
})
}
- deleteCustomer(paramsObj, notificationModel) {
+ deleteCustomer(paramsObj) {
this.managemencs.deleteSelectCustomer(paramsObj).subscribe((data) => {
if (data["status"] == 'SUCCESS') {
- this.notificationSuccess(notificationModel,'Customer','delete',this.thisdeleteCustomer.name);
+ this.notification.notificationSuccess('Customer','delete',this.thisdeleteCustomer.name);
this.getAllCustomers();
} else {
- this.notificationFailed(notificationModel,'Customer','delete',this.thisdeleteCustomer.name);
+ this.notification.notificationFailed('Customer','delete',this.thisdeleteCustomer.name);
}
})
}
- createNewServiceType(notificationModel) {
+ createNewServiceType() {
let createParams = {
customer: this.selectCustomer,
ServiceType: this.addNewServiceType,
};
this.managemencs.createServiceType(createParams).subscribe((data) => {
if (data["status"] == 'SUCCESS') {
- this.notificationSuccess(notificationModel,'ServiceType','Create',this.addNewServiceType);
+ this.notification.notificationSuccess('ServiceType','Create',this.addNewServiceType);
this.getAllCustomers();
} else {
- this.notificationFailed(notificationModel,'ServiceType','Create',this.addNewServiceType);
+ this.notification.notificationFailed('ServiceType','Create',this.addNewServiceType);
}
})
}
deleteServiceTypeCancel() {
this.deleteServiceTypeModelVisible = false;
}
- deleteServiceTypeOk(notificationModel) {
+ deleteServiceTypeOk() {
this.deleteServiceTypeModelVisible = false;
- this.getServiceTypeVersion(notificationModel);
+ this.getServiceTypeVersion();
}
- getServiceTypeVersion(notificationModel) {
+ getServiceTypeVersion() {
let paramss = {
customerId: this.selectCustomer,
ServiceType: this.thisdeleteServiceType["type"]
ServiceType: this.thisdeleteServiceType["type"],
version: data["result"]["resource-version"]
};
- this.deleteServiceType(params, notificationModel);
+ this.deleteServiceType(params);
} else {
console.error(data, "Interface returned error")
}
})
}
- deleteServiceType(params, notificationModel) {
+ deleteServiceType(params) {
this.managemencs.deleteSelectServiceType(params).subscribe((data) => {
if (data["status"] == 'SUCCESS') {
- this.notificationSuccess(notificationModel,'ServiceType','delete',this.thisdeleteServiceType["type"]);
+ this.notification.notificationSuccess('ServiceType','delete',this.thisdeleteServiceType["type"]);
this.getAllCustomers();
} else {
- this.notificationFailed(notificationModel,'ServiceType','delete',this.thisdeleteServiceType["type"]);
+ this.notification.notificationFailed('ServiceType','delete',this.thisdeleteServiceType["type"]);
}
})
}