From edf19113159f8d31946cc40e2a86cff9b7a013c1 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Thu, 26 Dec 2019 17:56:23 +0800 Subject: feat: Modified progress logic Change-Id: I06f2e78c8ffccfd4a0bd1eab723ea892b100af3c Issue-ID: USECASEUI-368 Signed-off-by: cyuamber --- .../check-process-model.component.html | 4 ++-- .../check-process-model.component.ts | 26 ++++++++++++---------- .../slicing-task-model.component.ts | 22 +++++++++--------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.html b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.html index ecba2cdf..00a63057 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.html +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.html @@ -30,10 +30,10 @@ - +

No data

diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.ts index 8a0ef970..95106050 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/check-process-model/check-process-model.component.ts @@ -92,23 +92,25 @@ export class CheckProcessModelComponent implements OnInit { const { result_body, result_header: { result_code } } = res; if (+result_code === 200) { this.data = []; - Object.keys(result_body).forEach(item => { - let currentProgress = 1 - let status = 'process'; - if (+result_body[item] === 100) { - currentProgress = 3; - status = 'finish' - } - const title = item === 'an_progress' ? 'An' : (item === 'tn_progress' ? 'Tn' : 'Cn') - let obj = { [item]: result_body[item], currentProgress, title, status }; - if (result_body[item]) { + const nssiList: string[] = ['an', 'tn', 'cn']; + nssiList.forEach( item => { + const progress: number = +result_body[item +'_progress']; + const title: string = item.charAt(0).toUpperCase() + item.slice(1); + let status: string = result_body[item +'_status']; + if ((progress || progress === 0) && status) { + let currentProgress = 1 + if (progress === 100 && status === 'finished') { + currentProgress = 3; + status = 'finish' + } + const obj = { progress, currentProgress, title, status }; this.data.push(obj) } }) this.data = [this.data]; let flag: boolean = false; - Object.values(result_body).forEach(item => { - if (+item !== 100 && typeof item !== 'object') { + nssiList.forEach(item => { + if (result_body[item +'_status'] === 'processing' && result_body[item +'_progress'] !== 0) { flag = true; } }) diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts index f3024586..101b48b8 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts @@ -87,8 +87,8 @@ export class SlicingTaskModelComponent implements OnInit { } getautidInfo(): void { - this.http.getAuditInfo(this.taskId).subscribe(res => { - const { result_header: { result_code } } = res; + this.http.getAuditInfo(this.taskId).subscribe( res => { + const { result_header: { result_code, result_message } } = res; this.isSpinning = false; if (+result_code === 200) { const { @@ -179,7 +179,7 @@ export class SlicingTaskModelComponent implements OnInit { cn_area_traffic_cap_ul }; } else { - this.message.error('Failed to get data') + this.message.error(result_message || 'Failed to get data') } }, ({ status, statusText }) => { this.message.error(status + ' (' + statusText + ')'); @@ -208,14 +208,14 @@ export class SlicingTaskModelComponent implements OnInit { getSlicingInstances(pageNo: string, pageSize: string): void { this.slicingInstances.isLoading = true; this.http.getSlicingInstance(pageNo, pageSize).subscribe(res => { - const { result_header: { result_code }, result_body } = res; + const { result_header: { result_code, result_message }, result_body } = res; setTimeout(() => { if (+result_code === 200) { const { nsi_service_instances, record_number } = result_body; this.slicingInstances.total = record_number; this.slicingInstances.list.push(...nsi_service_instances); } else { - this.message.error('Failed to get slicing instance ID') + this.message.error(result_message || 'Failed to get slicing instance ID') } this.slicingInstances.isLoading = false; this.slicingInstances.flag = false; @@ -233,12 +233,12 @@ export class SlicingTaskModelComponent implements OnInit { this.selectedServiceName = ''; // 获取切片子网实例数据 this.http.getSlicingSubnetInstance(this.selectedServiceId).subscribe(res => { - const { result_header: { result_code }, result_body, record_number } = res; + const { result_header: { result_code, result_message }, result_body, record_number} = res; if (+result_code === 200) { - this.subnetDataFormatting(result_body, record_number); + this.subnetDataFormatting(result_body, record_number) } else { this.subnetDataFormatting({}, 1); - this.message.error('Failed to get slicing subnet instance ID'); + this.message.error(result_message || 'Failed to get slicing subnet instance ID') } }, ({ status, statusText }) => { this.message.error(status + ' (' + statusText + ')'); @@ -250,7 +250,7 @@ export class SlicingTaskModelComponent implements OnInit { }) } - subnetDataFormatting(subnetData: any, total: number): void { + subnetDataFormatting ( subnetData?: any, total?: number): void{ const { an_suggest_nssi_id, an_suggest_nssi_name, tn_suggest_nssi_id, tn_suggest_nssi_name, cn_suggest_nssi_id, cn_suggest_nssi_name } = subnetData; this.slicingSubnet[0].slicingId = an_suggest_nssi_id; this.slicingSubnet[0].slicingName = an_suggest_nssi_name; @@ -312,7 +312,7 @@ export class SlicingTaskModelComponent implements OnInit { instance.isLoading = true; const { context, currentPage, pageSize } = instance; this.http.getSubnetInContext(context, currentPage, pageSize).subscribe(res => { - const { result_header: { result_code }, result_body } = res; + const { result_header: { result_code, result_message }, result_body } = res; if (+result_code === 200) { const { nssi_service_instances, record_number } = result_body; this.slicingSubnet.map(item => { @@ -322,7 +322,7 @@ export class SlicingTaskModelComponent implements OnInit { } }) } else { - this.message.error('Failed to get slicing subnet instance ID'); + this.message.error(result_message || 'Failed to get slicing subnet instance ID'); } instance.isLoading = false; instance.flag = false; -- cgit 1.2.3-korg