From e9ed865ef5d4095cd81e405e8248218247f2d494 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Sat, 12 Oct 2019 16:06:37 +0800 Subject: feat: extract the deletion notification of the service-list page Change-Id: I7520a0a2e7406db712ad7c09dd1f23e213e725dc Issue-ID: USECASEUI-307 Signed-off-by: cyuamber --- .../notification/notification.component.html | 47 ++++++-- .../notification/notification.component.ts | 15 ++- .../management/customer/customer.component.html | 2 +- .../onboard-vnf-vm/onboard-vnf-vm.component.html | 2 +- .../services-list/services-list.component.html | 52 ++------- .../services-list/services-list.component.ts | 125 +++++++++------------ 6 files changed, 111 insertions(+), 132 deletions(-) diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.html b/usecaseui-portal/src/app/shared/components/notification/notification.component.html index acf6f62a..f20fd48c 100644 --- a/usecaseui-portal/src/app/shared/components/notification/notification.component.html +++ b/usecaseui-portal/src/app/shared/components/notification/notification.component.html @@ -4,18 +4,47 @@ {{notificationAttributes.status}} -
- {{(notificationAttributes.action === 'OnboardingState'? notificationAttributes.title : "i18nTextDefine_"+notificationAttributes.title) | translate}}  - {{"i18nTextDefine_"+notificationAttributes.action | translate}}  {{"i18nTextDefine_"+notificationAttributes.status | translate}} + +
+
+ {{(notificationAttributes.action === 'OnboardingState'? notificationAttributes.title : "i18nTextDefine_"+notificationAttributes.title) | translate}}  + {{"i18nTextDefine_"+notificationAttributes.action | translate}}  {{"i18nTextDefine_"+notificationAttributes.status | translate}} +
+
+
+

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

+

{{notificationAttributes.title}} id: 

+ {{ notificationAttributes.name }} +
+
+
{{"i18nTextDefine_Close" | translate}}
-
-
-

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

-

{{notificationAttributes.title}} id: 

- {{ notificationAttributes.name }} + +
+
+ {{ notificationAttributes.title }}   {{notificationAttributes.status === 'Success'? "i18nTextDefine_InstanceTeminatedSuccessfully" : (notificationAttributes.status === 'Failed'?"i18nTextDefine_InstanceTeminationFailed":"i18nTextDefine_InstanceTeminationStarting") | translate}} +
+
+ {{notificationAttributes.title === 'E2E Service'?'E2E': 'NS'}}  {{notificationAttributes.status === 'Success'? "i18nTextDefine_InstanceTeminatedSuccessfully" :(notificationAttributes.status === 'Failed'?"i18nTextDefine_InstanceTeminationFailed":"i18nTextDefine_InstanceTeminationStarting")| translate}} +
+
+
+

{{"i18nTextDefine_InstanceName" | translate}} :

+ {{ notificationAttributes.name }} +
+
+

{{"i18nTextDefine_Customer" | translate}} :

+ {{ customerSelected.name }} +
+
+

{{"i18nTextDefine_UseCase" | translate}} :

+ {{ notificationAttributes.title }} +
+
{{"i18nTextDefine_Close" | translate}}
-
{{"i18nTextDefine_Close" | translate}}
diff --git a/usecaseui-portal/src/app/shared/components/notification/notification.component.ts b/usecaseui-portal/src/app/shared/components/notification/notification.component.ts index 00ccf90b..de0df083 100644 --- a/usecaseui-portal/src/app/shared/components/notification/notification.component.ts +++ b/usecaseui-portal/src/app/shared/components/notification/notification.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core'; +import { Component, OnInit, ViewChild, Input } from '@angular/core'; import { NzNotificationService } from 'ng-zorro-antd'; @Component({ @@ -8,6 +8,8 @@ import { NzNotificationService } from 'ng-zorro-antd'; }) export class NotificationComponent implements OnInit { @ViewChild('notificationModel')notificationModel: any; + @Input()isServicesList: boolean; + @Input()customerSelected: object; notificationAttributes: { title: string, @@ -23,17 +25,22 @@ export class NotificationComponent implements OnInit { } setNotification({ title, imgPath, action, status, name }):void{ - this.notificationAttributes = { title, imgPath, action, status, name } + this.notificationAttributes = { title, imgPath, action, status, name }; } notificationSuccess(title: string, action: string, name: string): void { - this.notification.remove() + 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.notification.remove(); this.setNotification({ title, imgPath: "assets/images/execute-faild.png", action, status: 'Failed', name }) this.notification.template(this.notificationModel) } + notificationStart(title: string, action: string, name: string): void { + this.notification.remove(); + this.setNotification({ title, imgPath: "assets/images/execute-inproess.png", action , status: 'instance temination is starting', name }) + this.notification.template(this.notificationModel) + } } diff --git a/usecaseui-portal/src/app/views/management/customer/customer.component.html b/usecaseui-portal/src/app/views/management/customer/customer.component.html index 0f033e47..63b0a5b8 100644 --- a/usecaseui-portal/src/app/views/management/customer/customer.component.html +++ b/usecaseui-portal/src/app/views/management/customer/customer.component.html @@ -114,5 +114,5 @@
{{thisdeleteServiceType["type"]}}
- + \ No newline at end of file diff --git a/usecaseui-portal/src/app/views/services/onboard-vnf-vm/onboard-vnf-vm.component.html b/usecaseui-portal/src/app/views/services/onboard-vnf-vm/onboard-vnf-vm.component.html index 374afe0d..c48d68f9 100644 --- a/usecaseui-portal/src/app/views/services/onboard-vnf-vm/onboard-vnf-vm.component.html +++ b/usecaseui-portal/src/app/views/services/onboard-vnf-vm/onboard-vnf-vm.component.html @@ -120,4 +120,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/usecaseui-portal/src/app/views/services/services-list/services-list.component.html b/usecaseui-portal/src/app/views/services/services-list/services-list.component.html index a82c8a2b..a97c3766 100644 --- a/usecaseui-portal/src/app/views/services/services-list/services-list.component.html +++ b/usecaseui-portal/src/app/views/services/services-list/services-list.component.html @@ -66,7 +66,7 @@ [serviceDetailName]="item.detailName"> -
+
@@ -256,46 +256,6 @@ [(ngModel)]="gracefulTerminationTimeout">
- - -
-
- - instance temination is starting - -
- {{ thisService['serviceDomain'] }}   {{"i18nTextDefine_InstanceTeminationStarting" | - translate}} -
-
E2E   - {{"i18nTextDefine_InstanceTeminationStarting" | translate}} -
-
NS   - {{"i18nTextDefine_InstanceTeminationStarting" | translate}} -
-
-
-

{{"i18nTextDefine_InstanceName" | translate}} :

- {{ thisService["service-instance-name"] || - thisService["nsInstanceName"] }} - -
-
-

{{"i18nTextDefine_Customer" | translate}} :

- {{ customerSelected.name }} -
-
-

{{"i18nTextDefine_UseCase" | translate}} :

- {{ thisService["serviceDomain"] }} -
-
-
{{"i18nTextDefine_Close" | translate}}
-
-
-
+
@@ -409,7 +370,7 @@ instance temination is starting
+ *ngIf="thisCreateService['serviceDomain'] === 'CCVPN' || thisService['serviceDomain'] === 'SOTN'"> {{ thisService['serviceDomain'] }}   {{"i18nTextDefine_InstanceCreationStarting" | translate}}
@@ -517,6 +478,7 @@ *ngIf="(thisService['serviceDomain'] == 'Network Service') && thisService.status == 'Successful'"> NS   {{"i18nTextDefine_InstanceTeminatedSuccessfully" | translate}}
+
{{ thisService['serviceDomain'] }}   {{"i18nTextDefine_InstanceTeminationFailed" | @@ -678,7 +640,7 @@
- \ No newline at end of file + \ No newline at end of file diff --git a/usecaseui-portal/src/app/views/services/services-list/services-list.component.ts b/usecaseui-portal/src/app/views/services/services-list/services-list.component.ts index 5a1a1ab0..9de72233 100644 --- a/usecaseui-portal/src/app/views/services/services-list/services-list.component.ts +++ b/usecaseui-portal/src/app/views/services/services-list/services-list.component.ts @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Component, OnInit, HostBinding, TemplateRef } from '@angular/core'; +import { Component, OnInit, HostBinding, TemplateRef, ViewChild } from '@angular/core'; import { ServiceListService } from '../../../core/services/serviceList.service'; import { slideToRight } from '../../../shared/utils/animates'; import { NzModalService } from 'ng-zorro-antd'; @@ -28,6 +28,7 @@ import { Observable } from 'rxjs/Rx'; }) export class ServicesListComponent implements OnInit { @HostBinding('@routerAnimate') routerAnimateState; + @ViewChild('notification') notification1: any; public width:number = document.documentElement.clientWidth; @@ -516,7 +517,7 @@ export class ServicesListComponent implements OnInit { }) if (service["serviceDomain"] === 'CCVPN' || service["serviceDomain"] === 'SOTN') { this.detailshow = true; - if (typeNum == 1) { + if (typeNum === 1) { this.upDateShow = false; } else { this.upDateShow = true; @@ -538,25 +539,21 @@ export class ServicesListComponent implements OnInit { this.deleteModalVisible = true; } - deleteOk(templatedeletestarting, templateDeleteSuccessFaild) { + deleteOk(templateDeleteSuccessFaild) { this.deleteModalVisible = false; this.loadingAnimateShow = true; - if (this.thisService["serviceDomain"] == "Network Service") { - this.deleteNsService(this.thisService, templateDeleteSuccessFaild); + if (this.thisService["serviceDomain"] === "Network Service") { + this.deleteNsService(this.thisService); } else { this.deleteService(this.thisService, templateDeleteSuccessFaild); } - this.deleteNotification(templatedeletestarting); + this.notification1.notificationStart(this.thisService['serviceDomain'],'deleteStarting',this.thisService["service-instance-name"] ||this.thisService["nsInstanceName"]) } deleteCancel() { this.deleteModalVisible = false; } - deleteNotification(template: TemplateRef<{}>): void { - this.notification.template(template); - } - deleteSuccessNotification(template: TemplateRef<{}>): void { this.notification.template(template); } @@ -1072,7 +1069,7 @@ export class ServicesListComponent implements OnInit { }) } - deleteNsService(service, templateDeleteSuccessFaild) { + deleteNsService(service) { service.rate = 0; service.status = "In Progress"; service.tips = ""; @@ -1084,9 +1081,9 @@ export class ServicesListComponent implements OnInit { gracefulTerminationTimeout: this.gracefulTerminationTimeout } this.stopNsService(id, requestBody).then((jobid) => { - if (jobid == "Failed") { + if (jobid === "Failed") { service.status = "Failed"; - this.deleteSuccessNotification(templateDeleteSuccessFaild); + this.notification1.notificationFailed(service.serviceDomain,'deleteStarting',service["service-instance-name"] ||service["nsInstanceName"]) service.tips = this.listSortMasters["operationTypes"].find((its) => { return its["sortCode"] == service.statusClass && its["language"] == this.language })["sortValue"] + this.listSortMasters["operationResults"].find((its) => { @@ -1095,55 +1092,47 @@ export class ServicesListComponent implements OnInit { return false; } let updata = (prodata) => { - service.rate = prodata.progress; + service.rate = prodata.progress || 0; + if(service['rate'] > 100)service["status"] = prodata.status; service.tips = this.listSortMasters["operationTypes"].find((its) => { return its["sortCode"] == service.statusClass && its["language"] == this.language - })["sortValue"] + '\xa0\xa0\xa0' + service.rate + "%"; - if (service["rate"] > 100) { - service["status"] = prodata.status; - service.tips = this.listSortMasters["operationTypes"].find((its) => { - return its["sortCode"] == service.statusClass && its["language"] == this.language - })["sortValue"] + service["status"]; - } + })["sortValue"] + (service["rate"] > 100? service["status"] : ('\xa0\xa0\xa0' + service.rate + "%")); } - return this.queryNsProgress(jobid, null, updata, operationType); - }).then(() => { - let paramsObj = { - "ns_instance_id":id - }; - this.myhttp.nsDeleteInstance(paramsObj) - .subscribe((data) => { - console.log(data); - service.rate = 100; - service.status = "Successful"; - service.tips = this.listSortMasters["operationTypes"].find((its) => { - return its["sortCode"] == service.statusClass && its["language"] == this.language - })["sortValue"] + this.listSortMasters["operationResults"].find((its) => { - return its["sortCode"] == 2001 && its["language"] == this.language - })["sortValue"]; - this.deleteSuccessNotification(templateDeleteSuccessFaild); - if (data.status == "FAILED") { - console.log("delete ns service Failed :" + JSON.stringify(data)); - service.status = "Failed"; - service.tips = this.listSortMasters["operationTypes"].find((its) => { - return its["sortCode"] == service.statusClass && its["language"] == this.language - })["sortValue"] + this.listSortMasters["operationResults"].find((its) => { - return its["sortCode"] == 2002 && its["language"] == this.language - })["sortValue"]; - this.deleteSuccessNotification(templateDeleteSuccessFaild); - return false; - } - console.log(service, "deleteservice"); - console.log(this.thisService, "thisService"); - let hasUndone = this.tableData.some((item) => { - return item.rate < 100; + this.queryNsProgress(jobid, null, updata, operationType).then(() => { + let paramsObj = { + "ns_instance_id":id + }; + this.myhttp.nsDeleteInstance(paramsObj) + .subscribe((data) => { + if(data.status == "SUCCESS"){ + service.rate = 100; + service.status = "Successful"; + service.tips = this.listSortMasters["operationTypes"].find((its) => { + return its["sortCode"] == service.statusClass && its["language"] == this.language + })["sortValue"] + this.listSortMasters["operationResults"].find((its) => { + return its["sortCode"] == 2001 && its["language"] == this.language + })["sortValue"]; + this.notification1.notificationSuccess(service.serviceDomain,'deleteStarting',service["service-instance-name"] ||service["nsInstanceName"]) + }else { + service.status = "Failed"; + service.tips = this.listSortMasters["operationTypes"].find((its) => { + return its["sortCode"] == service.statusClass && its["language"] == this.language + })["sortValue"] + this.listSortMasters["operationResults"].find((its) => { + return its["sortCode"] == 2002 && its["language"] == this.language + })["sortValue"]; + this.notification1.notificationFailed(service.serviceDomain,'deleteStarting',service["service-instance-name"] ||service["nsInstanceName"]) + return false; + } + let hasUndone = this.tableData.some((item) => { + return item.rate < 100; + }) + if (!hasUndone) { + setTimeout(() => { + this.getTableData(); + }, 1000) + } }) - if (!hasUndone) { - setTimeout(() => { - this.getTableData(); - }, 1000) - } - }) + }) }) } @@ -1151,7 +1140,7 @@ export class ServicesListComponent implements OnInit { let paramsObj = { "ns_instance_id":id } - let mypromise = new Promise((res, rej) => { + return new Promise((res, rej) => { this.myhttp.stopNsService(paramsObj, obj) .subscribe((data) => { this.loadingAnimateShow = false; @@ -1163,7 +1152,6 @@ export class ServicesListComponent implements OnInit { res(data.jobId); }) }) - return mypromise; } queryProgress(obj, callback) { @@ -1201,7 +1189,7 @@ export class ServicesListComponent implements OnInit { } queryNsProgress(jobid, id, callback, operationType) { - let mypromise = new Promise((res, rej) => { + return new Promise((res, rej) => { let errorNums = 180; let paramsObj = { "responseId":0, @@ -1213,24 +1201,18 @@ export class ServicesListComponent implements OnInit { .subscribe((data) => { if (data.status == "FAILED") { callback({ progress: 255, status: "Failed" }); - return false; - } - if (data.responseDescriptor == null || data.responseDescriptor.progress == undefined) { + }else if (data.responseDescriptor === null || data.responseDescriptor.progress === undefined) { errorNums--; - if (errorNums == 0) { + if (errorNums === 0) { callback({ progress: 255, status: "time over" }); return false; } this.progressNsOutTimer = setTimeout(()=>{ requeryNs(); },10000); - return false; - } - if (data.responseDescriptor.progress > 100 && data.responseDescriptor.status == "error") { + }else if (data.responseDescriptor.progress > 100 && data.responseDescriptor.status === "error") { callback({ progress: 255, status: data.responseDescriptor.statusDescription }); - return false; - } - if (data.responseDescriptor.progress < 100) { + }else if (data.responseDescriptor.progress < 100) { callback(data.responseDescriptor); this.progressingNsTimer = setTimeout(()=>{ requeryNs(); @@ -1242,6 +1224,5 @@ export class ServicesListComponent implements OnInit { }; requeryNs(); }); - return mypromise; } } -- cgit 1.2.3-korg