From ef9130dd7124057cca4bca7e210430febd4a1847 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Wed, 25 Sep 2019 14:29:06 +0800 Subject: feat: fix ns file upload logic of onboard page Change-Id: I84e144f53d170ca11b949b458083de1c4f12077f Issue-ID: USECASEUI-307 Signed-off-by: cyuamber --- .../onboard-vnf-vm/onboard-vnf-vm.component.html | 52 ++++++------ .../onboard-vnf-vm/onboard-vnf-vm.component.ts | 96 ++++++++++------------ 2 files changed, 68 insertions(+), 80 deletions(-) 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 4f865ff3..787d76b6 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 @@ -17,7 +17,7 @@
-
+

@@ -26,43 +26,39 @@

{{"i18nTextDefine_Click_CSAR_File" | translate}}

-
-
{{"i18nTextDefine_Uploaded_files" | translate}}
-
{{"i18nTextDefine_Nofileuploading" | translate}}
-
-
-
- -
-
{{itemns.name}}
-
- -
-
- {{"i18nTextDefine_File_upload_completed" | translate}} - {{"i18nTextDefine_File_upload_failed" | translate}} -
-
- - -
+
{{"i18nTextDefine_Uploaded_files" | translate}}
+
{{"i18nTextDefine_Nofileuploading" | translate}}
+
+ +
{{nsfile.name}}
+
+ +
+
+ {{"i18nTextDefine_File_upload_completed" | translate}} + {{"i18nTextDefine_File_upload_failed" | translate}} +
+
+ +
- +
+ - + {{"i18nTextDefine_NO" | translate}} {{"i18nTextDefine_Name" | translate}} {{"i18nTextDefine_Version" | translate}} @@ -108,7 +104,7 @@
-
+

@@ -147,7 +143,7 @@

- +
-
+

@@ -229,7 +225,7 @@

- +
{ - this.fileListNS.push(file); + this.fileListNS.splice(0,1,file); this.myhttp.getCreatensData("createNetworkServiceData", this.requestBody)//on-line - // this.myhttp.getCreatensData("creatensDataNS") //local .subscribe((data) => { this.nsdInfoId = data["id"]; }, (err) => { @@ -210,27 +204,30 @@ export class OnboardVnfVmComponent implements OnInit { //Drag and drop and click the upload button onClick(tab) { + this.isNone = 'none'; switch (tab) { case 'NS': - // this.handleUpload('/api/nsd/v1/ns_descriptors/'+this.nsdInfoId+'/nsd_content',tab); this.handleUpload(this.url.ns.replace("*_*", this.nsdInfoId), tab); this.getTableData(); break case 'VNF': - // this.handleUpload('/api/vnfpkgm/v1/vnf_packages/'+this.vnfPkgId+'/package_content',tab); this.handleUpload(this.url.vnf.replace("*_*", this.vnfPkgId), tab); this.getTableVnfData() break case 'PNF': - // this.handleUpload('/api/nsd/v1/pnf_descriptors/'+this.pnfdInfoId+'/pnfd_content',tab); this.handleUpload(this.url.pnf.replace("*_*", this.pnfdInfoId), tab); this.getTablePnfData(); break } } - nsRightList = []; - nsNum = 0; + nsfile: { + name: string, + uid: string, + progress: number, + status: boolean, + success: number + }; vnfRightList = []; vnfNum = 0; pnfRightList = []; @@ -242,31 +239,25 @@ export class OnboardVnfVmComponent implements OnInit { switch (tab) { case "NS": this.fileListNS.forEach((file: any) => { - formData.append('file', file); + formData.set('file', file); }); this.nsuploading = true; - let lastNs = this.fileListNS[this.fileListNS.length - 1]; - let nsfile = { - name: lastNs.name, - uid: lastNs.uid, + this.nsfile = { + name: this.fileListNS[0].name, + uid: this.fileListNS[0].uid, progress: 0, status: true, success: 0 }; - this.nsNum += 1; - this.nsRightList.push(nsfile); - let requeryNs = (nsfile) => { + let requeryNS = (nsfile) => { + nsfile.progress += 3; setTimeout(() => { - nsfile.progress += 2; if (nsfile.progress < 100) { - requeryNs(nsfile) - } else { - nsfile.progress = 100; - nsfile.status = false; + requeryNS(nsfile) } }, 100) }; - requeryNs(nsfile); + requeryNS(this.nsfile); break case "VNF": this.fileListVNF.forEach((file: any) => { @@ -340,9 +331,9 @@ export class OnboardVnfVmComponent implements OnInit { .subscribe( (event: {}) => { if (tab == "NS") { - this.nsRightList[this.nsNum - 1].progress = 100; - this.nsRightList[this.nsNum - 1].status = false; - this.nsRightList[this.nsNum - 1].success = 0; + this.nsfile.progress = 100; + this.nsfile.status = false; + this.isNone = 'block'; } if (tab == "VNF") { this.vnfRightList[this.vnfNum - 1].progress = 100; @@ -359,9 +350,9 @@ export class OnboardVnfVmComponent implements OnInit { }, err => { if (tab == "NS") { - this.nsRightList[this.nsNum - 1].progress = 100; - this.nsRightList[this.nsNum - 1].status = false; - this.nsRightList[this.nsNum - 1].success = 1; + this.nsfile.progress = 100; + this.nsfile.status = false; + this.nsfile.success = 1; } if (tab == "VNF") { this.vnfRightList[this.vnfNum - 1].progress = 100; @@ -401,22 +392,21 @@ export class OnboardVnfVmComponent implements OnInit { //ns vfc lists this.myhttp.getOnboardTableData() .subscribe((data) => { - this.nsvfcData = data; - this.nstableData = this.nsvfcData; + this.nstableData = data; //ns sdc list this.myhttp.getSDC_NSTableData() .subscribe((data) => { this.isSpinning = false; //loading hide this.nssdcData = data; - this.nsvfcData.map((nsvfc) => { nsvfc.sameid = this.nssdcData.find((nssdc) => { return nsvfc.id == nssdc.uuid }) && nsvfc.id; return nsvfc; }); - let sameData = this.nssdcData.filter((nssdc) => { return !this.nsvfcData.find((nsvfc) => { return nsvfc.id == nssdc.uuid }) }); + this.nstableData.map((nsvfc) => { nsvfc.sameid = this.nssdcData.find((nssdc) => { return nsvfc.id == nssdc.uuid }) && nsvfc.id; return nsvfc; }); + let sameData = this.nssdcData.filter((nssdc) => { return !this.nstableData.find((nsvfc) => { return nsvfc.id == nssdc.uuid }) }); this.nstableData = this.nstableData.concat(sameData); }, (err) => { - console.log(err); + console.error(err); this.isSpinning = false; }) }, (err) => { - console.log(err); + console.error(err); this.isSpinning = false; }) @@ -428,22 +418,23 @@ export class OnboardVnfVmComponent implements OnInit { //vnf vfc lists this.myhttp.getOnboardTableVnfData() .subscribe((data) => { - this.vnfvfcData = data; - this.vnftableData = this.vnfvfcData; + this.vnftableData = data; //vnf sdc lists this.myhttp.getSDC_VNFTableData() .subscribe((data) => { this.isSpinning = false; //loading hide this.vnfsdcData = data; - this.vnfvfcData.map((vnfvfc) => { vnfvfc.sameid = this.vnfsdcData.find((nssdc) => { return vnfvfc.id == nssdc.uuid }) && vnfvfc.id; return vnfvfc; }); - let sameData = this.vnfsdcData.filter((vnfsdc) => { return !this.vnfvfcData.find((vnfvfc) => { return vnfvfc.id == vnfsdc.uuid }) }); + this.vnftableData.map((vnfvfc) => { vnfvfc.sameid = this.vnfsdcData.find((nssdc) => { return vnfvfc.id == nssdc.uuid }) && vnfvfc.id; return vnfvfc; }); + let sameData = this.vnfsdcData.filter((vnfsdc) => { return !this.vnftableData.find((vnfvfc) => { return vnfvfc.id == vnfsdc.uuid }) }); this.vnftableData = this.vnftableData.concat(sameData); }, (err) => { - console.log(err); + console.error(err); + this.isSpinning = false; }) }, (err) => { - console.log(err); + console.error(err); + this.isSpinning = false; }) } @@ -455,7 +446,8 @@ export class OnboardVnfVmComponent implements OnInit { this.pnftableData = data; this.isSpinning = false; //loading hide }, (err) => { - console.log(err); + console.error(err); + this.isSpinning = false; }) } -- cgit 1.2.3-korg