[ngModelOptions]="{standalone: true}"></ng-select>
</div>
</div>
+ <div class="form-group row" *ngIf="primitiveType === 'VNF_Primitive' || primitiveType === 'VDU_Primitive'">
+ <label class="col-sm-4 col-form-label">VNF {{'MEMBERINDEX' | translate}}*</label>
+ <div class="col-sm-3">
+ <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
+ [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index"
+ formControlName="vnf_member_index" id="vnf_member_index"
+ [ngClass]="{ 'is-invalid': submitted && f.vnf_member_index.errors }"></ng-select>
+ </div>
+ </div>
+ <div class="form-group row" *ngIf="primitiveType === 'VDU_Primitive'">
+ <label class="col-sm-4 col-form-label">{{'SELECT' | translate}} VDU *</label>
+ <div class="col-sm-8">
+ <ng-select (change)="getVDUPrimitive($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
+ [items]="vduList" bindLabel="name" bindValue="id" formControlName="vdu_id" id="vdu_id"
+ [ngClass]="{ 'is-invalid': submitted && f.vdu_id.errors }"></ng-select>
+ </div>
+ </div>
<div class="form-group row">
- <ng-container *ngIf="primitiveType == 'VNF_Primitive'">
- <label class="col-sm-4 col-form-label">VNF {{'MEMBERINDEX' | translate}}*</label>
- <div class="col-sm-3">
- <ng-select (change)="indexChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
- [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index"
- formControlName="vnf_member_index" id="vnf_member_index"
- [ngClass]="{ 'is-invalid': submitted && f.vnf_member_index.errors }"></ng-select>
- </div>
- </ng-container>
- <label [ngClass]="{ 'col-sm-4': primitiveType != 'VNF_Primitive', 'col-sm-2': primitiveType == 'VNF_Primitive' }" class="col-form-label">
+ <label class="col-sm-4 col-form-label">
{{'PAGE.NSPRIMITIVE.PRIMITIVE' | translate}}*</label>
- <div [ngClass]="{ 'col-sm-8': primitiveType != 'VNF_Primitive', 'col-sm-3': primitiveType == 'VNF_Primitive' }" class="col-sm-3">
+ <div class="col-sm-8">
<ng-select (change)="primitiveChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
[items]="primitiveList" bindLabel="name" bindValue="name" formControlName="primitive" id="primitive"
[ngClass]="{ 'is-invalid': submitted && f.primitive.errors }"></ng-select>
import { APIURLHEADER, ERRORDATA, URLPARAMS } from 'CommonModel';
import { DataService } from 'DataService';
import { environment } from 'environment';
-import { NSData } from 'NSDModel';
+import { NSData, VDUPRIMITIVELEVEL } from 'NSDModel';
import { NSPrimitiveParams } from 'NSInstanceModel';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
/** Model value used to hold selected primitive type @public */
public primitiveType: string;
+ /** Contains list of VDU primitive lists @public */
+ public vduList: {}[];
+
/** FormBuilder instance added to the formBuilder @private */
private formBuilder: FormBuilder;
this.sharedService = this.injector.get(SharedService);
this.activeModal = this.injector.get(NgbActiveModal);
this.formBuilder = this.injector.get(FormBuilder);
- this.primitiveTypeList = [{ title: this.translateService.instant('VNFPRIMITIVE'), value: 'VNF_Primitive' }];
+ this.primitiveTypeList = [
+ {
+ title: this.translateService.instant('VNFPRIMITIVE'),
+ value: 'VNF_Primitive'
+ },
+ {
+ title: this.translateService.instant('VDUPRIMITIVE'),
+ value: 'VDU_Primitive'
+ }
+ ];
this.primitiveType = 'VNF_Primitive';
}
this.primitiveForm = this.formBuilder.group({
primitive: [null, [Validators.required]],
vnf_member_index: [null, [Validators.required]],
+ vdu_id: [null, [Validators.required]],
primitive_params: this.formBuilder.array([this.primitiveParamsBuilder()])
});
}
// tslint:disable-next-line: no-string-literal
primitiveParamsPayLoads['vnf_member_index'] = this.primitiveForm.value.vnf_member_index;
}
+ if (this.primitiveType === 'VDU_Primitive') {
+ // tslint:disable-next-line: no-string-literal
+ primitiveParamsPayLoads['vnf_member_index'] = this.primitiveForm.value.vnf_member_index;
+ // tslint:disable-next-line: no-string-literal
+ primitiveParamsPayLoads['vdu_id'] = this.primitiveForm.value.vdu_id;
+ }
const apiURLHeader: APIURLHEADER = {
url: environment.NSDINSTANCES_URL + '/' + this.nsdId + '/action'
};
this.primitiveList = !isNullOrUndefined(this.params.nsConfig['config-primitive']) ?
this.params.nsConfig['config-primitive'] : [];
this.getFormControl('vnf_member_index').setValidators([]);
+ this.getFormControl('vdu_id').setValidators([]);
}
}
/** Member index change event */
- public indexChange(data: {}): void {
+ public indexChange(data: {}, getType?: string): void {
+ this.getFormControl('vdu_id').setValue(null);
if (data) {
- this.getVnfdInfo(data['vnfd-id-ref']);
+ this.getVnfdInfo(data['vnfd-id-ref'], getType);
} else {
this.primitiveList = [];
this.getFormControl('primitive').setValue(null);
this.primitiveParameter = [];
}
}
+ /** Get VDU Primitive from selected VDU id/name change event */
+ public getVDUPrimitive(data: {}): void {
+ this.primitiveList = data['vdu-configuration']['config-primitive'];
+ }
/** Primivtive change event */
public primitiveChange(data: { parameter: {}[] }): void {
this.primitiveParameter = [];
this.updatePrimitive(data);
}
}
+ /** Generate vdu section @public */
+ public generateVDUData(vduData: VDUPRIMITIVELEVEL): VDUPRIMITIVELEVEL {
+ return {
+ id: vduData.id,
+ name: vduData.name,
+ 'vdu-configuration': vduData['vdu-configuration']
+ };
+ }
/** Update primitive value based on parameter */
private updatePrimitive(primitive: { parameter: {}[] }): void {
if (primitive.parameter) {
}
}
/** Get primivitive actions from vnfd data */
- private getVnfdInfo(vnfdRef: string): void {
+ private getVnfdInfo(vnfdRef: string, getType?: string): void {
this.primitiveList = [];
this.primitiveParameter = [];
this.getFormControl('primitive').setValue(null);
this.restService.getResource(apiUrl)
.subscribe((vnfdInfo: {}) => {
if (vnfdInfo[0]['vnf-configuration']) {
+ this.getFormControl('vdu_id').setValidators([]);
this.primitiveList = vnfdInfo[0]['vnf-configuration']['config-primitive'];
}
+ if (getType === 'VDU_Primitive') {
+ this.vduList = [];
+ vnfdInfo[0].vdu.forEach((vduData: VDUPRIMITIVELEVEL) => {
+ if (vduData['vdu-configuration']) {
+ const vduDataObj: VDUPRIMITIVELEVEL = this.generateVDUData(vduData);
+ this.vduList.push(vduDataObj);
+ }
+ });
+ }
this.isLoadingResults = false;
}, (error: ERRORDATA) => {
this.isLoadingResults = false;