summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app
diff options
context:
space:
mode:
authorcyuamber <xuranyjy@chinamobile.com>2019-09-20 17:18:55 +0800
committercyuamber <xuranyjy@chinamobile.com>2019-09-20 17:19:13 +0800
commita6fc431622c2f9f5188dfcd00d1f73ec43bf5afb (patch)
tree324176acf0063ac52a6e0d18adf7d6a3761d1f6c /usecaseui-portal/src/app
parent2df65a7f82faf11f0f0a6e16c9864902a9388c89 (diff)
feat:optimize loop call progress function for service-list page
Change-Id: Ibc5e91b8882ba89b6b40506734700e5462e544a6 Issue-ID: USECASEUI-307 Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app')
-rw-r--r--usecaseui-portal/src/app/views/services/services-list/services-list.component.ts38
1 files changed, 20 insertions, 18 deletions
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 5fc7e5a7..aed66631 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
@@ -41,7 +41,10 @@ export class ServicesListComponent implements OnInit {
this.width = document.documentElement.clientWidth
});
}
-
+ ngOnDestroy() {
+ clearInterval(this.progressOutTimer);
+ clearInterval(this.progressingTimer);
+ }
// customer servicetype
isSol005Interface = false;
orchestratorList = [];
@@ -84,6 +87,14 @@ export class ServicesListComponent implements OnInit {
}
];
+ requery;
+ progressOutTimer = setTimeout(() => {
+ this.requery();
+ }, 10000);
+ progressingTimer = setTimeout(() => {
+ this.requery();
+ }, 5000);
+
//The icon behind each row of data in the table expands
iconMoreShow(data, tableData) {
tableData.map((its) => {
@@ -1291,7 +1302,7 @@ export class ServicesListComponent implements OnInit {
let mypromise = new Promise((res, rej) => {
let operationTypeObj = {operationType:obj.operationType};
let errorNums = 180;
- let requery = () => {
+ this.requery = () => {
this.myhttp.getProgress(obj,operationTypeObj)
.subscribe((data) => {
if (data.status == "FAILED") {
@@ -1304,9 +1315,7 @@ export class ServicesListComponent implements OnInit {
callback({ progress: 255, status: "time over" });
return false;
}
- setTimeout(() => {
- requery();
- }, 10000)
+ this.progressOutTimer;
return false;
}
if (data.operationStatus.progress > 100) {
@@ -1315,15 +1324,13 @@ export class ServicesListComponent implements OnInit {
}
if (data.operationStatus.progress < 100) {
callback(data.operationStatus);
- setTimeout(() => {
- requery();
- }, 5000)
+ this.progressingTimer;
} else {
res(data.operationStatus);
}
})
}
- requery();
+ this.requery();
})
return mypromise;
}
@@ -1336,7 +1343,7 @@ export class ServicesListComponent implements OnInit {
"serviceInstanceId":id,
"operationType":operationType
}
- let requery = () => {
+ this.requery = () => {
this.myhttp.getNsProgress(jobid,paramsObj)
.subscribe((data) => {
if (data.status == "FAILED") {
@@ -1349,9 +1356,7 @@ export class ServicesListComponent implements OnInit {
callback({ progress: 255, status: "time over" });
return false;
}
- setTimeout(() => {
- requery();
- }, 10000)
+ this.progressOutTimer;
return false;
}
if (data.responseDescriptor.progress > 100 && data.responseDescriptor.status == "error") {
@@ -1360,17 +1365,14 @@ export class ServicesListComponent implements OnInit {
}
if (data.responseDescriptor.progress < 100) {
callback(data.responseDescriptor);
- setTimeout(() => {
- requery();
- }, 5000)
+ this.progressingTimer;
} else {
res(data);
}
})
};
- requery();
+ this.requery();
});
return mypromise;
}
-
}