diff options
author | liuwh7 <liuwh7@asiainfo.com> | 2021-10-22 15:21:16 +0800 |
---|---|---|
committer | liuwh7 <liuwh7@asiainfo.com> | 2021-10-22 15:22:55 +0800 |
commit | f1168a9fad8244d9a4ae5f21efb48bb9c14a2a4c (patch) | |
tree | c5fe713ec2f126645b78fece08c6585dff4a3cbb /usecaseui-portal/src/app/views/services/intent-based-services | |
parent | 4190f0efa75b358c3e1edda1381c7a7712b72e3e (diff) |
feat: modify intent based service
Signed-off-by: liuwh7 <liuwh7@asiainfo.com>
Change-Id: I8efc89b26a1d51eddfdfdab53c3ad6e2136e1440
Issue-ID: USECASEUI-605
Diffstat (limited to 'usecaseui-portal/src/app/views/services/intent-based-services')
3 files changed, 73 insertions, 34 deletions
diff --git a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.html b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.html index 64924b9f..2fe58cfc 100644 --- a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.html +++ b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.html @@ -29,9 +29,7 @@ [name]="item.key" *ngIf="item.type === 'input'" [(ngModel)]="cloud_leased_line_info[item.key]" - [ngClass]="{'error-input-border' : validateRulesShow[i] === true}" [placeholder]="item.placeholder ? item.placeholder : ''" - (blur)="item.required ? this.Util.validator(item.title,item.key,cloud_leased_line_info[item.key],i,rulesText,validateRulesShow) : this.Util.validator()" /> </nz-tooltip> <nz-select @@ -55,9 +53,7 @@ [id]="item.key" [name]="item.key" [(ngModel)]="cloud_leased_line_info[item.key].bandwidth" - [ngClass]="{'error-input-border' : validateRulesShow[i] === true}" [placeholder]="item.placeholder ? item.placeholder : ''" - (blur)="item.required ? this.Util.validator(item.title,item.key,cloud_leased_line_info[item.key],i,rulesText,validateRulesShow) : this.Util.validator()" /> </div> <div> diff --git a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.ts b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.ts index 90bcf9b0..a8c617ae 100644 --- a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.ts +++ b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line-modal/cloud-leased-line-modal.component.ts @@ -21,7 +21,6 @@ export class CloudLeasedLineModalComponent implements OnInit { @Input() cloudLeasedLineShowFlag: boolean; @Output() cancelEmitter = new EventEmitter<boolean>(); comunicationFormItems = COMMUNICATION_FORM_ITEMS; - validateRulesShow: any[] = []; isLoadingOne = false; nodeLists: any[] = []; cloudPointOptions: any[] = []; @@ -81,11 +80,31 @@ export class CloudLeasedLineModalComponent implements OnInit { } submit(): void { + const paramOnj = { ...this.cloud_leased_line_info }; + for (const iterator in paramOnj) { + if (this.isString(paramOnj[iterator]) && !paramOnj[iterator]) { + this.nzMessage.error(`Please enter ${iterator}`); + return; + } + if (!this.isString(paramOnj[iterator])) { + const { name, bandwidth} = paramOnj[iterator]; + if (!name) { + this.nzMessage.error(`Please enter accessPointOne Name`); + return; + } + + if (bandwidth !== 0 && !/^\+?[1-9][0-9]*$/.test(bandwidth)) { + this.nzMessage.error(`Please enter a positive integer accessPointOne bandwidth`); + return; + } + } + } + this.myHttp.createIntentInstance({ ...this.cloud_leased_line_info }).subscribe( (data) => { - console.log(data); + this.nzMessage.success('Create IntentInstance Success!'); this.cancel(); }, (err) => { @@ -107,4 +126,8 @@ export class CloudLeasedLineModalComponent implements OnInit { }; this.cancelEmitter.emit(); } + + isString(val) { + return Object.prototype.toString.call(val) === '[object String]'; + } }
\ No newline at end of file diff --git a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line/cloud-leased-line.component.ts b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line/cloud-leased-line.component.ts index 28e312af..dd7949b4 100644 --- a/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line/cloud-leased-line.component.ts +++ b/usecaseui-portal/src/app/views/services/intent-based-services/cloud-leased-line/cloud-leased-line.component.ts @@ -64,17 +64,16 @@ export class CloudLeasedLineComponent implements OnInit { } this.listOfData = data.list.map((item, index) => { - if (item.status === 'Incomplete') { + if (this.statusObj[item.status] === 'Incomplete') { const updateStatus = (prodata) => { item.status = prodata.status || item.status; }; - const obj = { serviceId: item.id }; + const obj = { instanceId: item.instanceId }; this.queryStatus(obj, index, updateStatus).then(() => { - item.status = "Completed"; - this.getCloudLeasedLineList(); + item.status = '1'; }); - } + } return item; }); }, (err) => { @@ -85,27 +84,33 @@ export class CloudLeasedLineComponent implements OnInit { queryStatus(obj: any, index: number, callback: any) { return new Promise((res) => { const requery = () => { - const param = [obj.id]; + const param = { + ids: [obj.instanceId] + }; this.myHttp.getInstanceStatus(param).subscribe((response) => { - if ( - response.data.status && response.data.status === 'Incomplete') { - callback(response.data); - let progressSetTimeOut = setTimeout(() => { - requery(); - }, this.intervalTime); - this.progressingTimer.push({ - id: obj.id, - timer: progressSetTimeOut, - }); - } else { - this.progressingTimer.forEach((item) => { - if (item.serviceId === obj.serviceId) { - clearInterval(item.timer); - } - }); - res(response.data); - } - }); + const { code, data:{ IntentInstances } } = response; + if (code !== 200 || !IntentInstances || IntentInstances.length === 0) { + return; + } + const intentInstance = IntentInstances[0]; + if (this.statusObj[intentInstance.status] === 'Incomplete') { + callback(intentInstance); + let progressSetTimeOut = setTimeout(() => { + requery(); + }, this.intervalTime); + this.progressingTimer.push({ + instanceId: obj.instanceId, + timer: progressSetTimeOut, + }); + } else { + this.progressingTimer.forEach((item) => { + if (item.instanceId === obj.instanceId) { + clearInterval(item.timer); + } + }); + res(intentInstance); + } + }); }; requery(); }); @@ -159,7 +164,12 @@ export class CloudLeasedLineComponent implements OnInit { this.myHttp.activeIntentInstance({ instanceId: row.instanceId }).subscribe((data) => { - console.log(data); + const { code, message } = data; + if (code !== 200) { + this.nzMessage.error(message); + return; + } + this.getCloudLeasedLineList(); }, (err) => { console.log(err); }); @@ -169,7 +179,12 @@ export class CloudLeasedLineComponent implements OnInit { this.myHttp.invalidIntentInstance({ instanceId: row.instanceId }).subscribe((data) => { - console.log(data); + const { code, message } = data; + if (code !== 200) { + this.nzMessage.error(message); + return; + } + this.getCloudLeasedLineList(); }, (err) => { console.log(err); }); @@ -177,7 +192,12 @@ export class CloudLeasedLineComponent implements OnInit { deleteCloudLeasedLine(row): void { this.myHttp.deleteIntentInstance(row.instanceId).subscribe((data) => { - console.log(data); + const { code, message } = data; + if (code !== 200) { + this.nzMessage.error(message); + return; + } + this.getCloudLeasedLineList(); }, (err) => { console.log(err); }); |