diff options
author | 2020-09-08 09:50:48 +0800 | |
---|---|---|
committer | 2020-09-08 10:03:42 +0800 | |
commit | 43cb242d5a78e86786d4274fc539d81680fc15c4 (patch) | |
tree | e4635ef8ee1c7bc7102f6333e3ed2488b27b8cab /usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts | |
parent | 926b57b4d540c73f1930e6d2d2070e5ac6939e5d (diff) |
feat: Optimize the public request method of axios
Change-Id: Iab9e86c66628c9a0c39e0a9ed56607417805c9d4
Issue-ID: USECASEUI-444
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts | 100 |
1 files changed, 38 insertions, 62 deletions
diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts index 5410a0f4..cf9b221c 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-resource-management/slicing-business-management/slicing-business-table/slicing-business-table.component.ts @@ -56,11 +56,13 @@ export class SlicingBusinessTableComponent implements OnInit { paramsObj["businessStatus"] = this.selectedValue.toLocaleLowerCase(); this.isSelect = true; } - this.myhttp.getSlicingBusinessList(paramsObj, this.isSelect).subscribe(res => { - const { result_header: { result_code }, result_body: { slicing_business_list, record_number } } = res; + let getSlicingBusinessListFailedCallback = () => { this.loading = false; - if (+result_code === 200) { - this.total = record_number; + } + this.myhttp.getSlicingBusinessList(paramsObj, this.isSelect, getSlicingBusinessListFailedCallback).then(res => { + const { result_body: { slicing_business_list, record_number } } = res; + this.loading = false; + this.total = record_number; if(slicing_business_list !==null && slicing_business_list.length >0){ this.listOfData = slicing_business_list.map((item, index) => { if (item.last_operation_progress && item.last_operation_type && Number(item.last_operation_progress) < 100) { @@ -80,7 +82,6 @@ export class SlicingBusinessTableComponent implements OnInit { return item }); } - } }) } getListOfProcessingStatus() { @@ -124,27 +125,18 @@ export class SlicingBusinessTableComponent implements OnInit { } changeActivate(paramsObj, isActivate, slicing, activateValue, finished, index) { this.loading = true; - this.myhttp.changeActivateSlicingService(paramsObj, isActivate).subscribe(res => { - const { result_header: { result_code, result_message }, result_body: { operation_id } } = res; - this.loading = false; - if (+result_code === 200) { - this.notification1.notificationSuccess('slicing business', finished, slicing.service_instance_id); - this.getBusinessList(); - } else { - let singleSlicing = Object.assign({}, this.listOfData[index]); - this.listOfData[index] = singleSlicing; - this.listOfData = [...this.listOfData]; - this.notification1.notificationFailed('slicing business', finished, slicing.service_instance_id); - this.getBusinessList(); - } - this.getBusinessList(); - }, () => { + let changeActivateFailedCallback = () => { this.loading = false; let singleSlicing = Object.assign({}, this.listOfData[index]); this.listOfData[index] = singleSlicing; this.listOfData = [...this.listOfData]; this.notification1.notificationFailed('slicing business', finished, slicing.service_instance_id); this.getBusinessList(); + } + this.myhttp.changeActivateSlicingService(paramsObj, isActivate, changeActivateFailedCallback).then(res => { + this.loading = false; + this.notification1.notificationSuccess('slicing business', finished, slicing.service_instance_id); + this.getBusinessList(); }) } terminate(slicing,index) { @@ -156,20 +148,15 @@ export class SlicingBusinessTableComponent implements OnInit { let paramsObj = { serviceId: slicing.service_instance_id }; this.terminateStart[index] = true; this.loading = true; - this.myhttp.terminateSlicingService(paramsObj).subscribe(res => { - const { result_header: { result_code, result_message }, result_body: { operation_id } } = res; - this.loading = false; - if (+result_code === 200) { - this.notification1.notificationSuccess('slicing business', 'terminate', slicing.service_instance_id); - this.getBusinessList(); - } else { - this.notification1.notificationFailed('slicing business', 'terminate', slicing.service_instance_id); - this.terminateStart[index] = false; - } - }, () => { + let terminateFailedCallback = () => { this.loading = false; this.notification1.notificationFailed('slicing business', 'terminate', slicing.service_instance_id); this.terminateStart[index] = false; + } + this.myhttp.terminateSlicingService(paramsObj, terminateFailedCallback).then(res => { + this.loading = false; + this.notification1.notificationSuccess('slicing business', 'terminate', slicing.service_instance_id); + this.getBusinessList(); }) }, nzCancelText: 'No', @@ -193,44 +180,33 @@ export class SlicingBusinessTableComponent implements OnInit { queryProgress(obj, action, index, callback) { return new Promise(res => { let requery = () => { - this.myhttp.getSlicingBusinessProgress(obj) - .subscribe((data) => { - const { result_header: { result_code, result_message }, result_body: { operation_id } } = data; - if (+result_code === 200) { - if (data.result_body.operation_progress && Number(data.result_body.operation_progress) < 100) { - callback(data.result_body); - let progressSetTimeOut = setTimeout(() => { - requery(); - }, 5000); - this.progressingTimer.push({ - id: obj.serviceId, - timer: progressSetTimeOut - }) - } else { - this.progressingTimer.forEach((item) => { - if (item.serviceId === obj.serviceId) { - clearInterval(item.timer); - } - }); - res(data.result_body); - } + let queryProgressFailedCallback = () => { + this.progressingTimer.forEach((item) => { + if (item.serviceId === obj.serviceId) { + clearInterval(item.timer); + } + }); + this.getBusinessList(); + } + this.myhttp.getSlicingBusinessProgress(obj, queryProgressFailedCallback) + .then((data) => { + if (data.result_body.operation_progress && Number(data.result_body.operation_progress) < 100) { + callback(data.result_body); + let progressSetTimeOut = setTimeout(() => { + requery(); + }, 5000); + this.progressingTimer.push({ + id: obj.serviceId, + timer: progressSetTimeOut + }) } else { this.progressingTimer.forEach((item) => { if (item.serviceId === obj.serviceId) { clearInterval(item.timer); } }); - this.getBusinessList(); - this.message.error(result_message); + res(data.result_body); } - }, (err) => { - this.progressingTimer.forEach((item) => { - if (item.serviceId === obj.serviceId) { - clearInterval(item.timer); - } - }); - this.getBusinessList(); - this.message.error(err); }) }; requery(); |