summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts
diff options
context:
space:
mode:
authorliuwh7 <liuwh7@asiainfo.com>2021-09-15 09:57:09 +0800
committerliu wenhao <liuwh7@asiainfo.com>2021-09-16 07:15:07 +0000
commitc437d5360c75c1af5417c3681235a0f8015a9a85 (patch)
tree69059fede467020a0b964f08ae56a999f85ffeb2 /usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts
parent9c8070280f88e0094acb83ee78251bb4f9690e2e (diff)
feat: add intent based service
Signed-off-by: liuwh7 <liuwh7@asiainfo.com> Change-Id: If63eb5e61f01751771ad090728f33214077edd6f Issue-ID: USECASEUI-605
Diffstat (limited to 'usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts')
-rw-r--r--usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts121
1 files changed, 85 insertions, 36 deletions
diff --git a/usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts b/usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts
index b9d74c19..ccdebc3b 100644
--- a/usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts
+++ b/usecaseui-portal/src/app/views/onboard-vnf-vm/onboard-vnf-vm.component.ts
@@ -14,11 +14,11 @@
limitations under the License.
*/
import { HttpClient, HttpRequest, HttpResponse } from '@angular/common/http';
-import { Component, OnInit, HostBinding, ViewChild } from '@angular/core';
+import { Component, HostBinding, OnInit, ViewChild } from '@angular/core';
+import { NzMessageService, NzModalService, UploadFile } from 'ng-zorro-antd';
+import { filter } from 'rxjs/operators';
import { onboardService } from '../../core/services/onboard.service';
import { slideToRight } from '../../shared/utils/animates';
-import { NzMessageService, UploadFile, NzModalService } from 'ng-zorro-antd';
-import { filter } from 'rxjs/operators';
@Component({
selector: 'app-onboard-vnf-vm',
@@ -38,6 +38,10 @@ export class OnboardVnfVmComponent implements OnInit {
infoId: string;
display: string = 'block';
+ // nlp dialog
+ nlpDialogFlag: boolean = false;
+ nlpType: string = '';
+
// table
isSpinning: boolean = false;
nsTableData: any[];
@@ -60,6 +64,20 @@ export class OnboardVnfVmComponent implements OnInit {
model: '/api/usecaseui-server/v1/intent/uploadModel'
};
+ tabMap = {
+ NS: 'ns',
+ VNF: 'vnf',
+ PNF: 'pnf',
+ 'NLP Model Reource': 'model',
+ }
+
+ currentTabApi = {
+ NS: 'createNetworkServiceData',
+ VNF: 'createVnfData',
+ PNF: 'createPnfData',
+ 'NLP Model Reource': '',
+ }
+
file: {
name: string,
uid: string,
@@ -113,31 +131,51 @@ export class OnboardVnfVmComponent implements OnInit {
beforeUpload = (file: UploadFile): boolean => {
this.fileList.splice(0, 1, file);
- let API: string;
- if (this.currentTab === 'NS') {
- API = 'createNetworkServiceData';
- } else if (this.currentTab === 'VNF') {
- API = 'createVnfData';
- } else if (this.currentTab === 'PNF') {
- API = 'createPnfData';
- } else {
+ let API: string = this.currentTabApi[this.currentTab];
+
+ if (!API) {
return false;
}
- this.myhttp.getCreatensData(API, this.requestBody)//on-line
+
+ this.myhttp.getCreatensData(API, this.requestBody)
.subscribe((data) => {
this.infoId = data["id"];
}, (err) => {
console.log(err);
- })
+ });
+
return false;
}
+ onClick() {
+ if (this.currentTab === 'NLP Model Reource') {
+ this.nlpDialogFlag = true;
+ return;
+ }
+ this.startUploadFile();
+ }
+
+ receiveNlpType(data) {
+ this.nlpDialogFlag = false;
+ if (data.cancel) {
+ return;
+ }
+ this.nlpType = data.nlpType;
+ this.startUploadFile();
+ }
+
// Drag and drop and click the upload button
- onClick(): void {
+ startUploadFile(): void {
this.display = 'none';
- let tab = this.currentTab === 'NS' ? 'ns' : (this.currentTab === 'VNF' ? 'vnf' : (this.currentTab === 'PNF' ? 'pnf' : 'model'));
- let url = tab === "model" ? this.url[tab] : this.url[tab].replace("*_*", this.infoId);
- tab === "model" ? this.handleUploadModel(url) : this.handleUpload(url);
+ let tab = this.tabMap[this.currentTab];
+ let url;
+ if (tab === "model") {
+ url = this.url[tab];
+ this.handleUploadModel(url);
+ return;
+ }
+ url = this.url[tab].replace("*_*", this.infoId);
+ this.handleUpload(url);
}
handleUploadModel(url: string): void {
@@ -243,24 +281,36 @@ export class OnboardVnfVmComponent implements OnInit {
this.isSpinning = true;
//ns vfc lists
this.myhttp.getOnboardTableData()
- .subscribe((data) => {
- this.nsTableData = data;
- //ns sdc list
- this.myhttp.getSDC_NSTableData()
- .subscribe((data) => {
- this.isSpinning = false; //loading hide
- let nsData = data;
- // this.NSTableData.map((nsvfc) => { nsvfc.sameid = nsData.find((nssdc) => { return nsvfc.id == nssdc.uuid }) && nsvfc.id; return nsvfc; });
- let sameData = nsData.filter((nssdc) => { return !this.nsTableData.find((nsvfc) => { return nsvfc.id == nssdc.uuid }) });
- this.nsTableData = this.nsTableData.concat(sameData);
- }, (err) => {
- this.msg.error(err);
- this.isSpinning = false;
- })
- }, (err) => {
- this.msg.error(err);
- this.isSpinning = false;
- })
+ .subscribe(
+ (data) => {
+ this.nsTableData = data;
+ //ns sdc list
+ this.myhttp.getSDC_NSTableData()
+ .subscribe(
+ (data) => {
+ this.isSpinning = false; //loading hide
+ if (!data) {
+ return;
+ }
+ let nsData = data;
+ let sameData = nsData.filter((nssdc) => {
+ return !this.nsTableData.find((nsvfc) => {
+ return nsvfc.id == nssdc.uuid
+ })
+ });
+ this.nsTableData = this.nsTableData.concat(sameData);
+ },
+ (err) => {
+ this.msg.error(err);
+ this.isSpinning = false;
+ }
+ )
+ },
+ (err) => {
+ this.msg.error(err);
+ this.isSpinning = false;
+ }
+ )
}
// Get the vnf list
@@ -443,7 +493,6 @@ export class OnboardVnfVmComponent implements OnInit {
// Actived Model Resource
activedModelFile(data) {
- console.log('actived model');
let url = `/api/usecaseui-server/v1/intent/activeModel?modelId=${data.id}`;
this.myhttp.getOnboardTableActiveModelData(url)
.subscribe((data) => {