aboutsummaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/CDTProperties.json2
-rw-r--r--src/app/about-us/aboutus.component.html41
-rw-r--r--src/app/about-us/aboutus.component.spec.ts21
-rw-r--r--src/app/about-us/aboutus.component.ts5
-rw-r--r--src/app/cdt.application.properties.json8
-rw-r--r--src/app/home/home/home.component.html4
-rw-r--r--src/app/shared/services/httpUtil/http-util.service.ts11
-rw-r--r--src/app/test/test.component.html6
-rw-r--r--src/app/test/test.component.ts2
-rw-r--r--src/app/vnfs/build-artifacts/build-artifacts.component.html9
-rw-r--r--src/app/vnfs/build-artifacts/build-artifacts.component.spec.ts9
-rw-r--r--src/app/vnfs/build-artifacts/build-artifacts.component.ts14
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts17
-rw-r--r--src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html78
-rw-r--r--src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts513
-rw-r--r--src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts293
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts1
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts42
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html3
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts40
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts67
21 files changed, 680 insertions, 506 deletions
diff --git a/src/app/CDTProperties.json b/src/app/CDTProperties.json
deleted file mode 100644
index 2c63c08..0000000
--- a/src/app/CDTProperties.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-}
diff --git a/src/app/about-us/aboutus.component.html b/src/app/about-us/aboutus.component.html
index 1d8134b..3c2fb52 100644
--- a/src/app/about-us/aboutus.component.html
+++ b/src/app/about-us/aboutus.component.html
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
-->
@@ -28,8 +27,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<div class="card-header" style="font-size: 20px">CONTACT DETAILS</div>
<div class="mdl-card__title">
<div class="text-center">
- Contact us @: <a href="#">APPC
- DEVELOPMENT TEAM </a>
+ Contact us @:<a href="mailto:{{contactUsMail.CONTACT_US_EMAIL}}?Subject={{contactUsMail.CONTACT_US_SUBJECT}}">APPC DEVELOPMENT TEAM</a>
</div>
</div>
</div>&emsp;&emsp;&emsp;&emsp;
@@ -39,29 +37,28 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<table>
<thead></thead>
<tbody>
- <tr>
- <td>
- <div class="android-title mdl-layout-title">Current Release :</div>
- </td>
- <td>
- <div class="android-title mdl-layout-title">{{releaseName}}</div>
- </td>
- </tr>
- <tr>
- <td>
- <div class="android-title mdl-layout-title">Current Version :</div>
- </td>
- <td>
- <div class="android-title mdl-layout-title">{{versionNo}}</div>
- </td>
- </tr>
+ <tr>
+ <td>
+ <div class="android-title mdl-layout-title">Current Release :</div>
+ </td>
+ <td>
+ <div class="android-title mdl-layout-title">{{releaseName}}</div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div class="android-title mdl-layout-title">Current Version :</div>
+ </td>
+ <td>
+ <div class="android-title mdl-layout-title">{{versionNo}}</div>
+ </td>
+ </tr>
</tbody>
</table>
</div>
<div class="text-right">
<div class="mdl-dialog__content">
- <a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary"
- (click)="open(content)" (click)="versionLogFile()">VIEW CHANGE LOG</a>
+ <a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)="open(content)" (click)="versionLogFile()">VIEW CHANGE LOG</a>
</div>
</div>
@@ -84,7 +81,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<html>
<body>
- <textarea class="textarea">{{this.data}}</textarea>
+ <textarea class="textarea">{{this.data}}</textarea>
</body>
</html>
diff --git a/src/app/about-us/aboutus.component.spec.ts b/src/app/about-us/aboutus.component.spec.ts
index 175f8d1..9f71c8f 100644
--- a/src/app/about-us/aboutus.component.spec.ts
+++ b/src/app/about-us/aboutus.component.spec.ts
@@ -17,9 +17,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
+
import { async, ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing';
import { Http, HttpModule, ConnectionBackend, BaseRequestOptions, Response, ResponseOptions } from '@angular/http';
import { MockBackend } from '@angular/http/testing';
@@ -55,9 +55,7 @@ describe('ContacUsComponent', () => {
{ provide: MockBackend, useClass: MockBackend },
{ provide: BaseRequestOptions, useClass: BaseRequestOptions },
{provide: Http, useValue: http}]
-
- })
- .compileComponents();
+ }).compileComponents();
}));
beforeEach(() => {
@@ -70,26 +68,15 @@ describe('ContacUsComponent', () => {
expect(component).toBeTruthy();
});
- it('test', inject([Http], (http: Http) => {
- let spy = spyOn(http, 'get').and.returnValue(Observable.of('some value'))
-
- component.versionLogFile();
-
- expect(http).toBeTruthy();
- expect(spy).toHaveBeenCalled()
-
- }));
-
it('should open modal', inject([NgbModule],(ngbModule: NgbModule) => {
- let content = 'test';
- component.open(content);
+ let content = 'test';
+ component.open(content);
}));
it('should download log file', () => {
var blob = new Blob(['test'], {
type: 'text/plain;charset=utf-8'
});
-
component.downloadLogFile();
});
});
diff --git a/src/app/about-us/aboutus.component.ts b/src/app/about-us/aboutus.component.ts
index 1c237e8..de983c7 100644
--- a/src/app/about-us/aboutus.component.ts
+++ b/src/app/about-us/aboutus.component.ts
@@ -16,8 +16,6 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -36,7 +34,7 @@ export class AboutUsComponent implements OnInit {
public releaseName: any;
public versionNo: any;
-
+ public contactUsMail: any;
public data: any;
closeResult: string;
@@ -46,6 +44,7 @@ export class AboutUsComponent implements OnInit {
ngOnInit() {
this.versionNo = require('./appVersion.json').versionNo;
this.releaseName = require('./appVersion.json').releaseName;
+ this.contactUsMail = require('../cdt.application.properties.json').CONTACT_US;
}
versionLogFile() {
diff --git a/src/app/cdt.application.properties.json b/src/app/cdt.application.properties.json
new file mode 100644
index 0000000..07f40bb
--- /dev/null
+++ b/src/app/cdt.application.properties.json
@@ -0,0 +1,8 @@
+{
+ "CONTACT_US": {
+ "CONTACT_US_EMAIL": "cdtSupportTeam@yourCompany.com",
+ "CONTACT_US_SUBJECT": "1710CDTContactus"
+ },
+ "username" : "appc123@appc.onap.org",
+ "password" : "test"
+}
diff --git a/src/app/home/home/home.component.html b/src/app/home/home/home.component.html
index dd06f29..78189e5 100644
--- a/src/app/home/home/home.component.html
+++ b/src/app/home/home/home.component.html
@@ -20,10 +20,10 @@ limitations under the License.
============LICENSE_END============================================ -->
<div class="android-more-section">
- <div class="android-section-title mdl-typography--display-1-color-contrast">WELCOME TO APPC SELF SERVICE CONTROLLER DESIGN TOOL
+ <div class="android-section-title mdl-typography--display-1-color-contrast">WELCOME TO CONTROLLER DESIGN TOOL
</div>
<div class="mdl-card__title">
- <h4 class="mdl-card__title-text">The Application Configuration (AppC) Configuration Design Tool allows technology owners to create artifacts for Configuration and Life Cycle Management functions that are required to manage the lifecycle of Virtual Network Functions (VNFs).<br> Select My VNFS to enter credentials and view existing designs or create new ones.
+ <h4 class="mdl-card__title-text">The Controller Design Tool allows technology owners to create artifacts for Configuration and Life Cycle Management functions that are required to manage the lifecycle of Virtual Network Functions (VNFs).<br> Select My VNFS to enter credentials and view existing designs or create new ones.
</h4>
</div>
diff --git a/src/app/shared/services/httpUtil/http-util.service.ts b/src/app/shared/services/httpUtil/http-util.service.ts
index 35c5047..33b3c9e 100644
--- a/src/app/shared/services/httpUtil/http-util.service.ts
+++ b/src/app/shared/services/httpUtil/http-util.service.ts
@@ -16,8 +16,6 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
import { observable } from 'rxjs/symbol/observable';
@@ -30,13 +28,14 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http';
export class HttpUtilService {
headers: Headers;
options: RequestOptions
- constructor (private http: Http) {
+ private username = require('../../../cdt.application.properties.json').username;
+ private password = require('../../../cdt.application.properties.json').password;
+ constructor(private http: Http) {
this.headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON
// this.options = new RequestOptions({headers: this.headers}); //
}
get(req) {
-
return this
.http
.get(req.url, this.options)
@@ -44,10 +43,8 @@ export class HttpUtilService {
}
post(req) {
-
- this.headers.append('Authorization', 'Basic ' + btoa('m97292@appc.att.com:enc:Ai8KDxN7EANwATsV'));
+ this.headers.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password));
this.options = new RequestOptions({ headers: this.headers });
-
return this
.http
.post(req.url, req.data, this.options)
diff --git a/src/app/test/test.component.html b/src/app/test/test.component.html
index c2eb22e..5e65435 100644
--- a/src/app/test/test.component.html
+++ b/src/app/test/test.component.html
@@ -114,9 +114,7 @@ limitations under the License.
<div style="padding-left:60%;padding-bottom:0.5cm">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" [disabled]="!enableDownload" (click)="download()">Download Raw Request/Response
</button>
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" type="button" [disabled]="!enableAbort" (click)="abortTest()">Abort Test
- </button>
-
+ <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" type="button" [disabled]="!enableAbort" (click)="abortTest()">Abandon Test</button>
</div>
</div>
<br>
@@ -135,7 +133,7 @@ limitations under the License.
<span style="margin-left: 18.5%"><b>POLL TEST STATUS RESPONSE</b></span>
</div>
- <div style="margin-left: 18.5%;height:100px;width:60%;border:solid 2px grey;overflow:scroll;overflow-x:hidden;overflow-y:hidden;">
+ <div style="margin-left: 18.5%;height:130px;width:60%;border:solid 2px grey;overflow:scroll;overflow-x:hidden;overflow-y:hidden;">
<div *ngIf="showStatusResponseDiv">
<div *ngIf="enableCounterDiv"><b>Poll test no {{pollCounter}}</b></div>
diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts
index 2fd8525..dd8871e 100644
--- a/src/app/test/test.component.ts
+++ b/src/app/test/test.component.ts
@@ -148,7 +148,7 @@ export class TestComponent implements OnInit {
this.enableTestButton = true;
this.enablePollButton = true;
if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe();
-
+ this.nService.info("Information","Test has been abandoned and polling stopped");
}
diff --git a/src/app/vnfs/build-artifacts/build-artifacts.component.html b/src/app/vnfs/build-artifacts/build-artifacts.component.html
index e0b2e05..feb5be8 100644
--- a/src/app/vnfs/build-artifacts/build-artifacts.component.html
+++ b/src/app/vnfs/build-artifacts/build-artifacts.component.html
@@ -17,17 +17,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
-->
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
- <ul class="nav nav-tabs custom-heade-nav" style=" margin-bottom: 12px;">
- <li [ngClass]="{'active-tab':((router.url.indexOf('/'+item.url))>-1 || router.url.indexOf(item.url)>-1 )}"
- *ngFor="let item of tabs">
- <a [routerLink]="[item.url]" [type]="item.type" class="nav-link">{{item.name}}</a>
+ <ul class="nav nav-tabs custom-heade-nav" style="margin-bottom: 12px;">
+ <li [ngClass]="{'active-tab':((router.url.indexOf('/'+item.url))>-1 || router.url.indexOf(item.url)>-1 )}" *ngFor="let item of tabs">
+ <a *ngIf="this.refDataRequiredFiels == true" [routerLink]="[item.url]" [type]="item.type" class="nav-link">{{item.name}}</a>
+ <a *ngIf="this.refDataRequiredFiels == false" [type]="item.type" class="nav-link">{{item.name}}</a>
</li>
</ul>
</div>
diff --git a/src/app/vnfs/build-artifacts/build-artifacts.component.spec.ts b/src/app/vnfs/build-artifacts/build-artifacts.component.spec.ts
index 508ca8c..16d7029 100644
--- a/src/app/vnfs/build-artifacts/build-artifacts.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/build-artifacts.component.spec.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -94,4 +93,12 @@ describe('BuildDesignComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('Should validate getRefData method', () => {
+ let refData = {"action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE"};
+ component.refDataRequiredFiels = false;
+ component.getRefData(refData);
+ expect(component.refDataRequiredFiels).toBeTruthy();
+ });
+
});
diff --git a/src/app/vnfs/build-artifacts/build-artifacts.component.ts b/src/app/vnfs/build-artifacts/build-artifacts.component.ts
index 7641aa5..265fd77 100644
--- a/src/app/vnfs/build-artifacts/build-artifacts.component.ts
+++ b/src/app/vnfs/build-artifacts/build-artifacts.component.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -29,8 +28,9 @@ import * as _ from 'underscore';
export class BuildDesignComponent implements OnInit {
tabs: Array<Object> = [];
private allowOtherUpdates: boolean = true;
+ public refDataRequiredFiels: boolean = false;
- constructor (private router: Router) {
+ constructor(private router: Router) {
}
ngOnInit() {
@@ -79,4 +79,14 @@ export class BuildDesignComponent implements OnInit {
return false;
}
}
+
+ public getRefData(referenceList) {
+ if (referenceList.action !== '' && referenceList['vnf-type'] !== '' && referenceList['device-protocol'] !== '') {
+ this.refDataRequiredFiels = true;
+ }
+ else {
+ this.refDataRequiredFiels = false;
+ }
+ }
+
}
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
index effd854..e7e60c3 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -190,7 +189,7 @@ export class ParameterComponent implements OnInit {
identifier: any;
private selectedActionReference: any;
- constructor (private httpService: HttpUtilService,
+ constructor(private httpService: HttpUtilService,
private parameterDefinitionService: ParameterDefinitionService,
private paramShareService: ParamShareService,
private mappingEditorService: MappingEditorService,
@@ -212,7 +211,19 @@ export class ParameterComponent implements OnInit {
for (let i = 0; i < this.selectedActionReference['artifact-list'].length; i++) {
let artifactList = this.selectedActionReference['artifact-list'];
if (artifactList[i]['artifact-type'] === 'parameter_definitions') {
- this.artifact_fileName = artifactList[i]['artifact-name'];
+ var artifactName = artifactList[i]['artifact-name'];
+ var artifactNameWithoutExtension = '';
+ if (artifactName) artifactNameWithoutExtension = artifactName.substring(0, artifactName.lastIndexOf("."))
+ var identifier = artifactNameWithoutExtension.split("_");
+ var id = '';
+ if (identifier) id = identifier[identifier.length - 1];
+ if (this.mappingEditorService.identifier) {
+ if (id === this.mappingEditorService.identifier) this.artifact_fileName = artifactName;
+
+ }
+ else {
+ this.artifact_fileName = artifactName;
+ }
}
}
this.parameterDefinitionService.setValues(this.vnfType, this.vnfcType, this.protocol, this.action, this.artifact_fileName);
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
index 302fd60..5aeb7ff 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.html
@@ -16,11 +16,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
============LICENSE_END============================================
-->
<simple-notifications [options]="options"></simple-notifications>
-<ng-progress [positionUsing]="'marginLeft'" [minimum]="0.15" [maximum]="1" [speed]="200" [showSpinner]="false" [direction]="'leftToRightIncreased'" [color]="'#6ab344'" [trickleSpeed]="250" [thick]="true" [ease]="'linear'"></ng-progress>
+<ng-progress [positionUsing]="'marginLeft'" [minimum]="0.15" [maximum]="1" [speed]="200" [showSpinner]="false" [direction]="'leftToRightIncreased'"
+ [color]="'#6ab344'" [trickleSpeed]="250" [thick]="true" [ease]="'linear'"></ng-progress>
<form class="" novalidate #userForm="ngForm" (ngSubmit)="save(userForm.value,userForm.valid)">
<div class="card">
@@ -28,7 +30,8 @@ limitations under the License.
<div class="row" style="padding: 15px 25px">
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
<label>Action*</label>
- <select class="form-control" required id="cmbAction" [(ngModel)]="referenceDataObject.action" (ngModelChange)="updateSessionValues($event,'action');actionChange($event,content,userForm);" #action="ngModel" name="action">
+ <select class="form-control" required id="cmbAction" [(ngModel)]="referenceDataObject.action" (ngModelChange)="updateSessionValues($event,'action');actionChange($event,content,userForm);"
+ #action="ngModel" name="action">
<option [value]="actionType"
[ngClass]="{'selectedAction':selectedActions.indexOf(actionType)>-1}"
[selected]="referenceDataObject.action===actionType"
@@ -39,16 +42,20 @@ limitations under the License.
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
<label>VNF Type* </label>
- <input type="text" readonly class="form-control" id="txtVnfType" required [(ngModel)]="referenceDataObject['scope']['vnf-type']" (ngModelChange)="updateSessionValues($event,'vnfType')" #vnftype="ngModel" name="vnftype">
+ <input type="text" readonly class="form-control" id="txtVnfType" required [(ngModel)]="referenceDataObject['scope']['vnf-type']"
+ (ngModelChange)="updateSessionValues($event,'vnfType')" #vnftype="ngModel" name="vnftype">
<span class="error-message" [hidden]="vnfParams?.vnfType || vnftype.valid || (vnftype.pristine && !userForm.submitted)">Required Field</span>
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
<label>VNFC Type</label>
- <input type="text" class="form-control" readonly id="txtVnfcType" [(ngModel)]="referenceDataObject.scope['vnfc-type']" (blur)="setVnfcType($event.target.value)" (ngModelChange)="updateSessionValues($event,'vnfcType')" #vnfcType="ngModel" name="vnfcType">
+ <input type="text" class="form-control" readonly id="txtVnfcType" [(ngModel)]="referenceDataObject.scope['vnfc-type']" (blur)="setVnfcType($event.target.value)"
+ (ngModelChange)="updateSessionValues($event,'vnfcType')" #vnfcType="ngModel" name="vnfcType">
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
<label>Device Protocol*</label>
- <select class="form-control" required id="txtDeviceProtocol" [(ngModel)]="referenceDataObject['device-protocol']" #deviceProtocol="ngModel" name="deviceProtocol">
+ <select class="form-control" required id="txtDeviceProtocol" [(ngModel)]="referenceDataObject['device-protocol']" (ngModelChange)="deviceProtocolChange()"
+ #deviceProtocol="ngModel" name="deviceProtocol">
+
<option [value]="device" [selected]="referenceDataObject.deviceProtocol===device"
*ngFor="let device of deviceProtocols">{{device}}
</option>
@@ -57,7 +64,8 @@ limitations under the License.
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="isConfigScaleOut">
<label>Template Identifier</label>
- <select class="form-control" required id="tempIdentifier" (ngModelChange)="dataModified()" [(ngModel)]="templateIdentifier" #deviceProtocol="ngModel" name="templateIdentifier">
+ <select class="form-control" required id="tempIdentifier" (ngModelChange)="dataModified();idChange($event,content,userForm)"
+ [(ngModel)]="templateIdentifier" #deviceProtocol="ngModel" name="templateIdentifier">
<option [value]="val" *ngFor="let val of referenceDataObject['template-id-list']">{{val}}
</option>
</select>
@@ -74,16 +82,20 @@ limitations under the License.
<div class="col-12" *ngIf="!(referenceDataObject.action === 'OpenStack Actions')">
<div class="input-group">
<input id="inputFile" class="file" #myInput type='file' (change)="fileChange($event)">
- <input [(ngModel)]="fileName" type="text" class="input-lg" disabled placeholder="Upload Reference File from PC" name="browse" style="width:80%">
- <button (click)="browseOption($event)" class="browse mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary input-lg" type="button">Upload Reference File
+ <input [(ngModel)]="fileName" type="text" class="input-lg" disabled placeholder="Upload Reference File from PC" name="browse"
+ style="width:80%">
+ <button (click)="browseOption($event)" class="browse mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary input-lg"
+ type="button">Upload Reference File
</button>
</div>
</div>
<div class="col-12" *ngIf="referenceDataObject.action === 'OpenStack Actions'">
<div class="input-group">
<input id="excelInputFile" #myInput1 class="file" type="file" (change)="upload($event)">
- <input [(ngModel)]="uploadFileName" type="text" class="input-lg" disabled placeholder="Upload VM Capabilities File" name="uploadFileName" style="width:80%">
- <button (click)="excelBrowseOption($event)" class="browse mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary input-lg" type="button">Upload VM Capabilities File
+ <input [(ngModel)]="uploadFileName" type="text" class="input-lg" disabled placeholder="Upload VM Capabilities File" name="uploadFileName"
+ style="width:80%">
+ <button (click)="excelBrowseOption($event)" class="browse mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary input-lg"
+ type="button">Upload VM Capabilities File
</button>
</div>
</div>
@@ -98,7 +110,8 @@ limitations under the License.
<div class="text-right col-6">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="submit">Download All To PC
</button>&emsp;&emsp;
- <button id="saveToAppc" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" (click)="saveToAppc(userForm.valid, userForm)">Save All to APPC
+ <button id="saveToAppc" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button"
+ (click)="saveToAppc(userForm.valid, userForm)">Save All to APPC
</button>&emsp;&emsp;
</div>
</div>
@@ -126,7 +139,8 @@ limitations under the License.
<input type="text" class="form-control" id="txtIpaddress" [(ngModel)]="referenceDataObject['url']" name="contextUrl">
</div>
</div>
- <div class="card-block" *ngIf="(referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' || referenceDataObject.action ==undefined)" style="border-top: 5px solid #6ab344;border-top-right-radius: 7px;border-top-left-radius: 7px;">
+ <div class="card-block" *ngIf="(referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' || referenceDataObject.action ==undefined)"
+ style="border-top: 5px solid #6ab344;border-top-right-radius: 7px;border-top-left-radius: 7px;">
<div class="col-12">
<h5 style="margin-top: 0.5rem;font-family: Roboto"> VNFC Information
<span class="pull-right">
@@ -139,12 +153,13 @@ limitations under the License.
</div>
<div class="row" *ngIf="(( referenceDataObject.action =='ConfigScaleOut' ||referenceDataObject.action =='Configure'|| referenceDataObject.action =='' || referenceDataObject.action ==undefined ) && isCollapsedContent) ">
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
- <label style="font-size:12px;">VNFC Type*</label>
+ <label style="font-size:12px;">VNFC Type</label>
<input type="text" class="form-control" id="txtVnfcTypeInColl" [(ngModel)]="Sample['vnfc-type']" #vnfcType="ngModel" name="samplevnfcType">
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
- <label style="font-size:12px">VNFC Function Code*</label>
- <input type="text" class="form-control" id="txtVnfcFunctionCode" [(ngModel)]="Sample['vnfc-function-code']" #vnfcFunctionCode="ngModel" name="samplevnfcFunctionCode">
+ <label style="font-size:12px">VNFC Function Code</label>
+ <input type="text" class="form-control" id="txtVnfcFunctionCode" [(ngModel)]="Sample['vnfc-function-code']" #vnfcFunctionCode="ngModel"
+ name="samplevnfcFunctionCode">
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
<label style="font-size:12px;">IPAddress V4 OAM VIP</label>
@@ -161,33 +176,39 @@ limitations under the License.
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
<label style="font-size:12px;">Group Notation Value</label>
- <input type="text" class="form-control" [readonly]="disableGrpNotationValue" id="txtGroupValue" [(ngModel)]="Sample['group-notation-value']" name="sampleGroupValue">
+ <input type="text" class="form-control" [readonly]="disableGrpNotationValue" id="txtGroupValue" [(ngModel)]="Sample['group-notation-value']"
+ name="sampleGroupValue">
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
- <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent clear-btn" (click)="clearVnfcData()">Clear VNFC Info
+ <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent clear-btn"
+ (click)="clearVnfcData()">Clear VNFC Info
</button>
</div>
</div>
<hr>
- <div *ngIf="(referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' )" class="row">
+ <div *ngIf="(referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' )"
+ class="row">
<div class="col-lg-2 col-md-2 hdden-sm-down">
<label style="margin-top: 17px;" class="headlinesInBold"> Number Of VM(s): </label>
</div>
<div class="col-lg-5 col-md-5 col-sm-6 col-xs-6">
<div class="form-group">
- <input type="text" placeholder="Number of VM(s)" class="form-control" id="txtVmnumber22" [(ngModel)]="refernceScopeObj.from" (ngModelChange)="numberValidation($event)" name="txtNumber23">
+ <input type="text" placeholder="Number of VM(s)" class="form-control" id="txtVmnumber22" [(ngModel)]="refernceScopeObj.from"
+ (ngModelChange)="numberValidation($event)" name="txtNumber23">
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-6 col-xs-6 text-right">
<div class="form-group">
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" [disabled]="!refernceScopeObj.from || !numberOfVmTest" (click)="addVms()">Add VM Information
+ <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" [disabled]="!refernceScopeObj.from || !numberOfVmTest"
+ (click)="addVms()">Add VM Information
</button>
</div>
</div>
</div>
<div *ngIf="referenceDataObject.vm?.length>0">
<div class="row" *ngFor="let noOfvm of referenceDataObject.vm | vmFiltering:referenceDataObject?.action:templateIdentifier; let j=index">
- <div *ngIf="((referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' || referenceDataObject.action ==undefined ))" class="col-12">
+ <div *ngIf="((referenceDataObject.action =='ConfigScaleOut' || referenceDataObject.action =='Configure'|| referenceDataObject.action =='' || referenceDataObject.action ==undefined ))"
+ class="col-12">
<div class="row" *ngFor="let item of noOfvm.vnfc; let i=index">
<div class="col-md-12" *ngIf="i==0">
<h5 class="headlinesInBold">VM Number: {{j+1}}</h5>
@@ -198,12 +219,14 @@ limitations under the License.
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
<label style="font-size:12px;">VNFC Type*</label>
- <input type="text" class="form-control" id="txtVnfcTypeInColl" required [(ngModel)]="item['vnfc-type']" #vnfcType="ngModel" name="vnfcType{{j}}">
+ <input type="text" class="form-control" id="txtVnfcTypeInColl" required [(ngModel)]="item['vnfc-type']" #vnfcType="ngModel"
+ name="vnfcType{{j}}">
<span class="error-message" [hidden]="vnfcType.valid || (vnfcType.pristine && !userForm.submitted)">Required Field</span>
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
<label style="font-size:12px;">VNFC Function Code*</label>
- <input type="text" class="form-control" id="txtVnfcFunctionCode" required [(ngModel)]="item['vnfc-function-code']" #vnfcFunctionCode="ngModel" name="vnfcFunctionCode{{j}}">
+ <input type="text" class="form-control" id="txtVnfcFunctionCode" required [(ngModel)]="item['vnfc-function-code']" #vnfcFunctionCode="ngModel"
+ name="vnfcFunctionCode{{j}}">
<span class="error-message" [hidden]="vnfcFunctionCode.valid || (vnfcFunctionCode.pristine && !userForm.submitted)">Required Field</span>
</div>
<div class="col-lg-2 col-sm-6 col-md-2 col-xs-12">
@@ -228,7 +251,8 @@ limitations under the License.
</div>
<div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
<div class="removevnfcClass" *ngIf="refernceScopeObj.sourceType !='vnfcType'">
- <a role="button" style="color: white" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" (click)="removeFeature(j,i,templateIdentifier)">Remove Vm</a>
+ <a role="button" style="color: white" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
+ (click)="removeFeature(j,i,templateIdentifier)">Remove Vm</a>
</div>
<div>
<a *ngIf="(referenceDataObject.vm[j].vnfc.length-1) == i " [hidden]="true" role="button" (click)="addVnfcData(j)">Add VNFC
@@ -313,8 +337,10 @@ limitations under the License.
</div>
<div class="modal-footer">
<div>
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" data-dismiss="modal" (click)="addToIdentDrp()">Add</button>
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)="templateId=''" data-dismiss="modal">cancel</button>
+ <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" data-dismiss="modal"
+ (click)="addToIdentDrp()">Add</button>
+ <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)="templateId=''"
+ data-dismiss="modal">cancel</button>
</div>
</div>
</div>
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts
index 1570e9c..72f56a7 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts
@@ -22,82 +22,104 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
/* tslint:disable:no-unused-variable */
-import {ComponentFixture, TestBed, async, inject} from '@angular/core/testing';
-import {Http, Response, ResponseOptions, XHRBackend} from '@angular/http';
-import {BuildDesignComponent} from '../build-artifacts.component';
-import {DialogService} from 'ng2-bootstrap-modal';
-import {FormsModule} from '@angular/forms';
-import {HttpModule} from '@angular/http';
-import {HttpUtilService} from '../../../shared/services/httpUtil/http-util.service';
-import {MappingEditorService} from '../../..//shared/services/mapping-editor.service';
-import {NO_ERRORS_SCHEMA} from '@angular/core';
-import {NgModule} from '@angular/core';
-import {NgProgress} from 'ngx-progressbar';
-import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
-import {NotificationService} from '../../../shared/services/notification.service';
-import {Observable} from 'rxjs/Observable';
-import {ParamShareService} from '../../..//shared/services/paramShare.service';
-import {ReferenceDataformComponent} from './reference-dataform.component';
-import {RouterTestingModule} from '@angular/router/testing';
-import {SharedModule} from '../../../shared/shared.module';
-import {environment} from '../../../../environments/environment';
+import { ComponentFixture, TestBed, async, inject } from '@angular/core/testing';
+import { Http, Response, ResponseOptions, XHRBackend } from '@angular/http';
+
+import { BuildDesignComponent } from '../build-artifacts.component';
+import { DialogService } from 'ng2-bootstrap-modal';
+import { FormsModule } from '@angular/forms';
+import { HttpModule } from '@angular/http';
+import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
+import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { NgModule } from '@angular/core';
+import { NgProgress } from 'ngx-progressbar';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import { NotificationService } from '../../../shared/services/notification.service';
+import { Observable } from 'rxjs/Observable';
+import { ParamShareService } from '../../..//shared/services/paramShare.service';
+import { ReferenceDataformComponent } from './reference-dataform.component';
+import { RouterTestingModule } from '@angular/router/testing';
+import { SharedModule } from '../../../shared/shared.module';
+import { environment } from '../../../../environments/environment';
describe('ReferenceDataformComponent', () => {
- let component : ReferenceDataformComponent;
- let fixture : ComponentFixture < ReferenceDataformComponent >;
- let service : MockMappingService;
+ let component: ReferenceDataformComponent;
+ let fixture: ComponentFixture<ReferenceDataformComponent>;
+ let service: MockMappingService;
- let httpMock : HttpUtilService
+ let httpMock: HttpUtilService
//mockingthe data for mappingEditorService
class HttpMock {
post(req) {
- if(req.url==""){
-
- return Observable.of({
- output: {
- data: {block:'{"artifactInfo": [ {"artifact-content": "{"reference_data": [{ "action": "Configure","scopeType":"tetsScope"}] }" } ]}'},
- status:{code:"400",message:"success"}
+
+ return Observable.of(
+
+
+ {
+ "output": { "data": { "block": "{\"userID\":null,\"designInfo\":null,\"statusInfo\":null,\"artifactInfo\":[{\"artifact-content\":\" {\\\"reference_data\\\":[{\\\"action\\\":\\\"Configure\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"template\\\":\\\"Y\\\",\\\"vm\\\":[],\\\"device-protocol\\\":\\\"ANSIBLE\\\",\\\"user-name\\\":\\\"root\\\",\\\"port-number\\\":\\\"830\\\",\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"template_Configure_Btesting123_0.0.1V.json\\\",\\\"artifact-type\\\":\\\"config_template\\\"},{\\\"artifact-name\\\":\\\"pd_Configure_Btesting123_0.0.1V.yaml\\\",\\\"artifact-type\\\":\\\"parameter_definitions\\\"}],\\\"scopeType\\\":\\\"vnf-type\\\"},{\\\"action\\\":\\\"AllAction\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"reference_AllAction_Btesting123_0.0.1V.json\\\",\\\"artifact-type\\\":\\\"reference_template\\\"}]},{\\\"action\\\":\\\"ConfigScaleOut\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"template\\\":\\\"Y\\\",\\\"vm\\\":[{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":1,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]},{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":2,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]},{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":3,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]}],\\\"device-protocol\\\":\\\"CHEF\\\",\\\"user-name\\\":\\\"root\\\",\\\"port-number\\\":\\\"830\\\",\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"template_ConfigScaleOut_Btesting123_0.0.1V_id1.json\\\",\\\"artifact-type\\\":\\\"config_template\\\"},{\\\"artifact-name\\\":\\\"pd_ConfigScaleOut_Btesting123_0.0.1V_id1.yaml\\\",\\\"artifact-type\\\":\\\"parameter_definitions\\\"}],\\\"scopeType\\\":\\\"vnf-type\\\",\\\"template-id-list\\\":[\\\"id1\\\"]}]}\"}]}", "requestId": "563507520187" }, "status": { "code": "400", "message": "success" } },
+
+ "status": { code: "400", message: "success" }
+ }
+
+
+ )
}
- })
- } }
+ }
+ class MockMappingService {
+ public latestAction; // = {"action":"Configure"}
+ appDataObject = {
+ reference: {},
+ template: {
+ templateData: {},
+ nameValueData: {}
+ },
+ pd: {}
+ };
+ downloadDataObject = {
+ reference: {},
+ template: {
+ templateData: {},
+ nameValueData: {},
+ templateFileName: '',
+ nameValueFileName: ''
+ },
+ pd: {
+ pdData: '',
+ pdFileName: ''
+ }
}
- class MockMappingService {
- public latestAction; // = {"action":"Configure"}
- appDataObject= { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
- downloadDataObject={reference: {},
- template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
- pd: { pdData: '', pdFileName: '' }}
- referenceNameObjects = [
+ referenceNameObjects = [
{
- action: "Configure"
+ action: "Configure"
}, {
- action: "StartApplication"
+ action: "StartApplication"
}
- ]
-
- setTemplateMappingDataFromStore(data){
+ ]
+
+ setTemplateMappingDataFromStore(data) {
return "test"
- }
- getReferenceList() {
+ }
+ getReferenceList() {
return ["test data"]
- }
- changeNav() {
+ }
+ changeNav() {
return "test data"
- }
- setParamContent(data){
+ }
+ setParamContent(data) {
return "test"
- }
- setSessionParamData(data){
+ }
+ setSessionParamData(data) {
return "test"
- }
-
- saveLatestAction() {}
- saveLatestIdentifier() {}
- changeNavDownloadData() {}
- changeNavAppData() {}
- }
- class MockreferenceDataObject {}
+ }
+
+ saveLatestAction() { }
+ saveLatestIdentifier() { }
+ changeNavDownloadData() { }
+ changeNavAppData() { }
+ }
+ class MockreferenceDataObject { }
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ReferenceDataformComponent],
@@ -123,14 +145,14 @@ describe('ReferenceDataformComponent', () => {
}).compileComponents();
}));
beforeEach(() => {
-
+
fixture = TestBed.createComponent(ReferenceDataformComponent);
component = fixture.componentInstance;
// component = new ReferenceDataformComponent(service)
fixture.detectChanges();
service = TestBed.get(MappingEditorService)
httpMock = TestBed.get(HttpUtilService)
- sessionStorage.setItem('vnfParams',JSON.stringify({vnfType:"test",vnfcType:"testVnfcType"}));
+ sessionStorage.setItem('vnfParams', JSON.stringify({ vnfType: "test", vnfcType: "testVnfcType" }));
// component = new ReferenceDataformComponent(service)
});
it('should create reference component', () => {
@@ -145,13 +167,17 @@ describe('ReferenceDataformComponent', () => {
expect(component.tempAllData.length).toBe(2)
})
- it("should set app data from service", ()=>{
+ it("should set app data from service", () => {
component.ngOnInit()
- expect(component.appData).not.toBe(undefined)
+ expect(component.appData)
+ .not
+ .toBe(undefined)
})
- it("should set download from service", ()=>{
+ it("should set download from service", () => {
component.ngOnInit()
- expect(component.downloadData).not.toBe(undefined)
+ expect(component.downloadData)
+ .not
+ .toBe(undefined)
})
it('Should reset form', () => {
component.resetForm()
@@ -473,7 +499,7 @@ describe('ReferenceDataformComponent', () => {
it("should remove feature from the reference object ", () => {
component.referenceDataObject = {
- action: '',
+ action: 'Configure',
'action-level': 'vnf',
scope: {
'vnf-type': '',
@@ -503,11 +529,61 @@ describe('ReferenceDataformComponent', () => {
'artifact-list': []
};
- component.removeFeature(0, 0)
+ component.removeFeature(0, 0, 0)
expect(component.referenceDataObject.vm.length).toBe(1)
})
+ it("remove templateIds vm if action is confiogscaleout", () => {
+ component.referenceDataObject = {
+ action: 'ConfigScaleOut',
+ 'action-level': 'vnf',
+ scope: {
+ 'vnf-type': '',
+ 'vnfc-type': ''
+ },
+ 'template': 'Y',
+ "vm": [
+ {
+ "template-id": "klmklj",
+ "vm-instance": 1,
+ "vnfc": [
+ {
+ "vnfc-instance": "1",
+ "vnfc-function-code": "klkl",
+ "ipaddress-v4-oam-vip": "",
+ "group-notation-type": "",
+ "group-notation-value": "",
+ "vnfc-type": "nnk"
+ }
+ ]
+ }, {
+ "template-id": "test 12",
+ "vm-instance": 2,
+ "vnfc": [
+ {
+ "vnfc-instance": "1",
+ "vnfc-function-code": "klkl",
+ "ipaddress-v4-oam-vip": "",
+ "group-notation-type": "",
+ "group-notation-value": "",
+ "vnfc-type": "nnk"
+ }
+ ]
+ }
+ ],
+ 'device-protocol': '',
+ 'user-name': '',
+ 'port-number': '',
+ 'artifact-list': []
+ };
+
+ component.removeFeature(0, 0, 'test 12')
+
+ expect(component.referenceDataObject.vm.length).toBe(2)
+
+ })
+
it("should add capabilities", () => {
component.uploadedDataArray = [
['y', 'n']
@@ -544,7 +620,7 @@ describe('ReferenceDataformComponent', () => {
expect(component.referenceDataObject['action-level']).toBe("vnf")
})
- it("should add capabilities", () => {
+ it("should add capabilities", () => {
service.latestAction = {
action: 'OpenStack Actions',
'action-level': 'vnf',
@@ -560,7 +636,7 @@ describe('ReferenceDataformComponent', () => {
'artifact-list': []
}
- component.referenceDataObject.action="OpenStack Actions"
+ component.referenceDataObject.action = "OpenStack Actions"
service.referenceNameObjects = [
{
action: "Configure"
@@ -664,177 +740,236 @@ describe('ReferenceDataformComponent', () => {
})
it('Should call get artifact', () => {
- sessionStorage.setItem('updateParams', JSON.stringify({vnf: 123, userID: 'testUser'}))
+ sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
component.getArtifact()
- expect(component.tempAllData.length).toBe(2)
+ expect(component.tempAllData.length).toBe(3)
})
it('Save file - should not process if action is null ', () => {
- component.referenceDataObject.action =""
- let fileSaved = component.save({},true)
+ component.referenceDataObject.action = ""
+ let fileSaved = component.save({}, true)
expect(fileSaved).toBe(undefined)
})
- it('Save file - should not process if device protocol is null ', () => {
- component.referenceDataObject['device-protocol'] =""
- let fileSaved = component.save({},true)
+ it('Save file - should not process if device protocol is null ', () => {
+ component.referenceDataObject.action = "Configure"
+ component.referenceDataObject['device-protocol'] = ''
+ let fileSaved = component.save({}, true)
expect(fileSaved).toBe(undefined)
})
it('Save file - should not process if device protocol is null ', () => {
- component.referenceDataObject.action ="Configure"
- component.referenceDataObject['device-protocol'] ="test"
- let fileSaved = component.save({},true)
+ component.referenceDataObject.action = "Configure"
+ component.referenceDataObject['device-protocol'] = "test"
+ component.downloadData.template.templateData = { "test": "test" }
+ component.downloadData.template.nameValueData = { "test": "test" }
+ component.downloadData.pd.pdData = "test"
+ let fileSaved = component.save({}, true)
//expect(fileSaved).toBe(undefined)
})
- it('Save to appc file - should not process if action is null ', () => {
- component.referenceDataObject.action =""
- let fileSaved = component.saveToAppc(true,{})
+ it('Save to appc file - should not process if action is null ', () => {
+ component.referenceDataObject.action = ""
+ let fileSaved = component.saveToAppc(true, {}, onclick)
expect(fileSaved).toBe(undefined)
})
- it('Save to app cfile - should not process if device protocol is null ', () => {
- component.referenceDataObject['device-protocol'] =""
- let fileSaved = component.saveToAppc(true,{})
+ it('Save to app cfile - should not process if device protocol is null ', () => {
+ component.referenceDataObject['device-protocol'] = ""
+ component.referenceDataObject.action = "Configure"
+ let fileSaved = component.saveToAppc(true, {}, onclick)
expect(fileSaved).toBe(undefined)
})
it('Save to appc file - should not process if device protocol is null ', () => {
- component.referenceDataObject.action ="Configure"
- component.referenceDataObject['device-protocol'] ="test"
- let fileSaved = component.saveToAppc(true,{})
- //expect(fileSaved).toBe(undefined)
- })
-
- // it('uploadfile ', () => {
-
- // let files = { 0: {name:'foo.XLS', size: 500001} };
- // var mockEVet = {
- // target:{files:files}
- // }
- // component.upload(mockEVet)
- // //expect(fileSaved).toBe(undefined)
- // })
-
- it('downloadTemplate() of reference dataform',()=>{
- component.downloadTemplate()
-
- })
- it('downloadNameValue() of reference dataform',()=>{
+ component.referenceDataObject.action = "Configure"
+ component.referenceDataObject['device-protocol'] = "test"
+ component.appData.template.templateData = { "test": "test" }
+ component.appData.template.nameValueData = { "test": "test" }
+ component.appData.pd = { "test": "test" }
+ component.actionChanged = true
+ component.currentAction = "COnfigure"
+ let fileSaved = component.saveToAppc(true, {}, onclick)
+ })
+ it('downloadTemplate() of reference dataform', () => {
+ expect(component.downloadTemplate());
+ })
+ it('downloadNameValue() of reference dataform', () => {
component.downloadNameValue()
})
-
- it('downloadPd() of reference dataform',()=>{
+ it('downloadPd() of reference dataform', () => {
component.downloadPd()
})
- it('validateTempAllData() of reference dataform',()=>{
+ it('validateTempAllData() of reference dataform', () => {
component.validateTempAllData()
})
- it('retriveFromAppc() of reference dataform',()=>{
- sessionStorage.setItem('updateParams', JSON.stringify({vnf: 123, userID: 'testUser'}))
+ it('retriveFromAppc() of reference dataform', () => {
+ sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
component.retriveFromAppc()
expect(component.noCacheData).toBeFalsy()
})
- it('retriveFromAppc() of reference dataform for false',()=>{
-
+ it('retriveFromAppc() of reference dataform for false', () => {
+ sessionStorage.setItem('updateParams', 'undefined')
component.retriveFromAppc()
- expect(component.noCacheData).toBeFalsy()
+ expect(component.noCacheData).toBeTruthy()
})
- it(' cloneMessage(servermessage) of reference dataform',()=>{
- let servermessage = {test:"test"}
+ it(' cloneMessage(servermessage) of reference dataform', () => {
+ let servermessage = {
+ test: "test"
+ }
component.cloneMessage(servermessage)
})
- it('resetGroupNotation() of reference dataform for false case',()=>{
+ it('resetGroupNotation() of reference dataform for false case', () => {
component.resetGroupNotation()
expect(component.disableGrpNotationValue).toBeFalsy()
})
- it('resetGroupNotation() of reference dataform for true case',()=>{
- component.Sample['group-notation-type'] == "existing-group-name"
+ it('resetGroupNotation() of reference dataform for true case', () => {
+ component.Sample['group-notation-type'] = "existing-group-name"
component.resetGroupNotation()
expect(component.disableGrpNotationValue).toBeTruthy()
})
- it('resetVms() of reference dataform',()=>{
+ it('resetVms() of reference dataform', () => {
component.resetVms()
- expect(component.referenceDataObject.vm).toBe([])
+ expect(component.referenceDataObject.vm).toBeNull
})
- it('dataModified() of reference dataform',()=>{
- component.dataModified()
- expect(component.referenceDataObject.vm).toBe(this.referenceDataObject.vm)
- })
-
it('Clear cache ', () => {
component.clearCache()
expect(component.downloadData.reference['name']).toBe(undefined);
- //expect(fileSaved).toBe(undefined)
- })
-
- it('sholud reset group notification ', () => {
- component.Sample['group-notation-type'] = "existing-group-name"
+ })
+ it('sholud reset group notification ', () => {
+ component.Sample['group-notation-type'] = "existing-group-name"
component.resetGroupNotation()
expect(component.disableGrpNotationValue).toBe(true);
- //expect(fileSaved).toBe(undefined)
- })
- it('sholud reset group notification if value does not match ', () => {
- component.Sample['group-notation-type'] = "123"
+ })
+ it('sholud reset group notification if value does not match ', () => {
+ component.Sample['group-notation-type'] = "123"
component.resetGroupNotation()
expect(component.disableGrpNotationValue).toBe(false);
- //expect(fileSaved).toBe(undefined)
- })
- it('add identity group', () => {
- component.referenceDataObject['template-id-list'] = undefined
- component.templateId="test"
+ })
+ it('add identity group', () => {
+ component.referenceDataObject['template-id-list'] = undefined
+ component.templateId = "test"
component.addToIdentDrp()
expect(component.referenceDataObject['template-id-list'].length).toBe(1);
- //expect(fileSaved).toBe(undefined)
- })
-
- it('add identity group', () => {
-
+ })
+
+ it('add identity group', () => {
+
component.resetVms()
expect(component.referenceDataObject.vm.length).toBe(0);
- //expect(fileSaved).toBe(undefined)
- })
- it('data modified', () => {
-
+ })
+ it('data modified', () => {
+
component.dataModified()
-
- component.referenceDataObject.vm =[1,2]
+ component.referenceDataObject.vm = [1, 2]
expect(component.referenceDataObject.vm.length).toBe(2);
- //expect(fileSaved).toBe(undefined)
- })
-
- it("should set values on action change ConfigScaleOut",()=>{
- component.actionChange("ConfigScaleOut","",{})
-
- expect(component.groupAnotationType.length).toBe(5)
- })
-
- it("should set values on action change when action is HealthCheck ",()=>{
- component.populateExistinAction("HealthCheck")
-
- expect(component.deviceProtocols.length).toBe(4)
-
-
- })
- it("should set values on action change when action is UpgradeBackout",()=>{
- component.populateExistinAction("UpgradeBackout")
-
- expect(component.deviceProtocols.length).toBe(3)
-
-
- })
- it("should set values on action change when action is OpenStack Actions",()=>{
- component.populateExistinAction("OpenStack Actions")
-
- expect(component.deviceProtocols.length).toBe(2)
-
-
- })
- it("should set values on action change when action is Configure",()=>{
-
- component.tempAllData=[{action:"Configure",scope:{'vnf-type':"testVnf"}}]
- component.populateExistinAction("Configure")
-
- expect(component.referenceDataObject.scope['vnf-type']).toBe('testVnf')
-
-
+ })
+
+ it("should set values on action change ConfigScaleOut", () => {
+ component.actionChange("ConfigScaleOut", "", {})
+
+ expect(component.groupAnotationType.length).toBe(5)
+ })
+ it("shpukd return false if its very first action", () => {
+ component.actionChange(null, "", "")
+
+ expect(component.disableGrpNotationValue).toBe(false)
+ })
+ it("sholud check no configuration actions", () => {
+ component.tempAllData = [
+ {
+ action: "Configure",
+ scope: {
+ 'vnf-type': "testVnf"
+ }
+ }
+ ]
+ component.actionChange("Configure", "", "")
+
+ expect(component.nonConfigureAction).toBe(false)
+ })
+
+ it("should set values on action change when action is HealthCheck ", () => {
+ component.populateExistinAction("HealthCheck")
+
+ expect(component.deviceProtocols.length).toBe(4)
+
+ })
+ it("should set values on action change when action is UpgradeBackout", () => {
+ component.populateExistinAction("UpgradeBackout")
+
+ expect(component.deviceProtocols.length).toBe(3)
+
+ })
+ it("should set values on action change when action is OpenStack Actions", () => {
+ component.populateExistinAction("OpenStack Actions")
+
+ expect(component.deviceProtocols.length).toBe(2)
+
+ })
+ it("should set values on action change when action is Configure", () => {
+ component.tempAllData = [
+ {
+ action: "Configure",
+ scope: {
+ 'vnf-type': "testVnf"
+ }
+ }
+ ]
+ component.populateExistinAction("Configure")
+ expect(component.referenceDataObject.scope['vnf-type']).toBe('testVnf')
+
+ })
+ it("shoukd clear vnf data ", () => {
+ component.clearVnfcData()
+ expect(component.Sample['vnfc-instance']).toBe('1')
+ })
+ it("shoudl showUpload", () => {
+ component.uploadTypes = [
+ {
+ value: 'Reference Data',
+ display: 'Sample Json Param File'
+ },
+ {
+ value: 'Mapping Data',
+ display: 'Sample Json Param File'
+ }
+ ]
+ component.showUpload()
+
+ expect(component.selectedUploadType).toBe('Reference Data')
+ })
+ it("set vm instance", () => {
+
+ component.referenceDataObject.vm = [
+ {
+ 'vm-instance': 1
+ }
+ ]
+ component.setVmInstance(0)
+ expect(component.referenceDataObject.vm[0]['vm-instance']).toBe(1)
+
+ })
+ it("set vnfc type", () => {
+ component.setVnfcType("test")
+ expect(component.Sample['vnfc-type']).toBe("test")
+ })
+ it("getChange", () => {
+ component.getChange("vnfType")
+ expect(component.referenceDataObject.scope['vnfc-type']).toBe("")
})
+ it("idChange", () => {
+ component.idChange(null, "", { valid: true })
+ component.oldAction = "Configure"
+ expect(component.actionChanged).toBeFalsy()
+ })
+ it("idChange", () => {
+ component.oldAction = "Configure"
+ component.idChange("test", "", { valid: true })
+ expect(component.actionChanged).toBeTruthy()
+ })
+ it('Should test deviceProtocolChange method', () => {
+ let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
+ let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
+ component.deviceProtocolChange();
+ expect(spy).toHaveBeenCalled()
+ });
+
});
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
index fa3be63..f7d501b 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
@@ -16,6 +16,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
============LICENSE_END============================================
*/
@@ -331,26 +332,26 @@ export class ReferenceDataformComponent implements OnInit {
}
//to remove the VM's created by the user
- removeFeature(vmNumber: any, index: any,templateId) {
- if(this.referenceDataObject.action == "Configure"){
+ removeFeature(vmNumber: any, index: any, templateId) {
+ if (this.referenceDataObject.action == "Configure") {
this.referenceDataObject.vm.splice(vmNumber, 1);
- this.referenceDataObject.vm.forEach((obj,arrIndex)=>{
- if(arrIndex>=vmNumber){
- obj["vm-instance"] = obj["vm-instance"]-1
+ this.referenceDataObject.vm.forEach((obj, arrIndex) => {
+ if (arrIndex >= vmNumber) {
+ obj["vm-instance"] = obj["vm-instance"] - 1
}
})
console.log(this.referenceDataObject.vm)
- } else{
- let data = this.referenceDataObject.vm.filter(obj=>{
+ } else {
+ let data = this.referenceDataObject.vm.filter(obj => {
return obj['template-id'] == templateId;
})
this.referenceDataObject.vm.splice(data[index]['vm-instance'], 1);
- this.referenceDataObject.vm.forEach((obj,arrIndex)=>{
-
- obj["vm-instance"] = arrIndex+1
+ this.referenceDataObject.vm.forEach((obj, arrIndex) => {
+
+ obj["vm-instance"] = arrIndex + 1
})
}
-
+
}
//add new VM's to the configure
@@ -372,10 +373,10 @@ export class ReferenceDataformComponent implements OnInit {
}
//Reference object to create reference data
- prepareReferenceObject(isSaving?:any){
- let scopeName = this. resetParamsOnVnfcType();
- let extension = this.decideExtension();
- this.prepareArtifactList(scopeName,extension);
+ prepareReferenceObject(isSaving?: any) {
+ let scopeName = this.resetParamsOnVnfcType();
+ let extension = this.decideExtension();
+ this.prepareArtifactList(scopeName, extension);
if (this.referenceDataObject.action === 'OpenStack Actions') {
this.referenceDataObject['template'] = 'N';
@@ -385,9 +386,9 @@ export class ReferenceDataformComponent implements OnInit {
let newObj = $.extend(true, {}, this.referenceDataObject);
let action = this.referenceDataObject.action;
//preparing Obj for save/download
- newObj = this.deleteVmsforNonActions(newObj,action)
- this.pushOrReplaceTempData(newObj,action);
- this. addAllActionObj(newObj,scopeName);
+ newObj = this.deleteVmsforNonActions(newObj, action)
+ this.pushOrReplaceTempData(newObj, action);
+ this.addAllActionObj(newObj, scopeName);
this.resetTempData()
//saving data to service
this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
@@ -414,35 +415,8 @@ export class ReferenceDataformComponent implements OnInit {
}
upload(evt: any) {
- /* // console.log("This uploaded array==" + JSON.stringify(this.uploadedDataArray))
- // // console.log("This template data before==" + JSON.stringify(this.tempAllData))
- if (this.uploadedDataArray && this.uploadedDataArray != undefined && this.uploadedDataArray.length!=0) {
- /* for (var i = 0; i < this.uploadedDataArray.length; i++) {
- var action = this.uploadedDataArray[i][0];
- for (var j = 0; j < this.tempAllData.length; j++) {
- if (action === this.tempAllData[j].action) {
- this.tempAllData.splice(j);
- // console.log("This template data===" + this.tempAllData[j]);
- }
- }
- }
- if (this.tempAllData && this.tempAllData != undefined) {
- for (var i = 0; i < this.tempAllData.length; i++) {
- // alert(this.checkIfelementExistsInArray(this.tempAllData[i].action,this.actions))
- var result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
- if (this.tempAllData[i].action === "AllAction") result = true;
- if (!result) {
- // console.log("Removing VM action==" + this.tempAllData[i].action)
- this.tempAllData.splice(i, 1);
- }
-
- }
- }
- }
- // // console.log("This template data after==" + JSON.stringify(this.tempAllData))
- /* wire up file reader */
+ /* wire up file reader */
const target: DataTransfer = <DataTransfer>(evt.target);
- //// console.log("filename========" + evt.target.files[0].name)
this.uploadFileName = evt.target.files[0].name;
var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
if (target.files.length != 1) {
@@ -453,19 +427,10 @@ export class ReferenceDataformComponent implements OnInit {
reader.onload = (e: any) => {
/* read workbook */
const bstr = e.target.result;
- // // console.log("print 1---" + bstr);
const wb = XLSX.read(bstr, { type: 'binary' });
- // // console.log("print 2---" + JSON.stringify(wb));
- /* grab first sheet */
const wsname = wb.SheetNames[0];
- // // console.log("Name:---" + wsname);
const ws = wb.Sheets[wsname];
-
- /* save data */
-
let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
- //// console.log("row======" + (XLSX.utils.sheet_to_json(ws, { header: 1 })).toString())
- // // console.log("Array data---" + JSON.stringify(arrData));
this.uploadedDataArray = arrData;
this.firstArrayElement = arrData[0];
var remUploadedDataArray = arrData;
@@ -481,7 +446,6 @@ export class ReferenceDataformComponent implements OnInit {
}
};
reader.readAsBinaryString(target.files[0]);
- // console.log('TARGET files---' + JSON.stringify(evt.target));
}
else {
this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
@@ -585,7 +549,7 @@ export class ReferenceDataformComponent implements OnInit {
saveAs(blob, fileName);
}
- saveToAppc(valid, form,event) {
+ saveToAppc(valid, form, event) {
if (this.referenceDataObject.action === '') {
this.nService.error('Error', 'Select a valid Action');
return;
@@ -611,7 +575,9 @@ export class ReferenceDataformComponent implements OnInit {
if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.saveNameValue();
if (pdData != '{}' && pdData != null && pdData != undefined) this.savePd();
if (this.actionChanged) {
- this.referenceDataObject.action = this.currentAction;
+ if (this.currentAction) {
+ this.referenceDataObject.action = this.currentAction;
+ }
this.populateExistinAction(this.referenceDataObject.action);
this.actionChanged = false;
}
@@ -839,7 +805,7 @@ export class ReferenceDataformComponent implements OnInit {
} else if (data == 'OpenStack Actions') {
this.deviceProtocols = ['', 'OpenStack'];
} else if (data == 'ConfigScaleOut') {
- this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML','RESTCONF'];
+ this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
}
else {
this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
@@ -925,48 +891,53 @@ export class ReferenceDataformComponent implements OnInit {
} else {
this.nonConfigureAction = true;
}
+ this.buildDesignComponent.getRefData(this.referenceDataObject);
+
}
+
+ deviceProtocolChange() {
+ this.buildDesignComponent.getRefData(this.referenceDataObject)
+ }
+
// For the issue with multiple template changes
- // idChange(data, content, userForm) {
- // if (data == null) {
- // return;
- // }
- // if ((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
- // let referenceObject = this.prepareReferenceObject();
- // this.actionChanged = true;
- // if(this.templateIdentifier)
- // {
- // this.modalService.open(content).result.then(res => {
- // if (res == 'yes') {
- // this.validateTempAllData();
- // let theJSON = JSON.stringify(this.tempAllData, null, '\t');
- // let fileName = 'reference_AllAction_' + referenceObject.scopeName + '_' + '0.0.1V.json';
- // this.uploadArtifact(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
- // var templateData = JSON.stringify(this.appData.template.templateData);
- // var nameValueData = JSON.stringify(this.appData.template.nameValueData);
- // var pdData = JSON.stringify(this.appData.pd);
- // if (templateData != '{}' && templateData != null && templateData != undefined) this.saveTemp();
- // if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.saveNameValue();
- // if (pdData != '{}' && pdData != null && pdData != undefined) this.savePd();
- // this.clearTemplateCache();
- // this.clearPdCache();
- // }
- // else{
- // this.clearTemplateCache();
- // this.clearPdCache();
- // }
- // });
- // }
- // }
- // }
-
- clearCache()
+ idChange(data, content, userForm) {
+ if (data == null) {
+ return;
+ }
+ if ((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
+ let referenceObject = this.prepareReferenceObject();
+ this.actionChanged = true;
+ if (this.templateIdentifier) {
+ this.modalService.open(content).result.then(res => {
+ if (res == 'yes') {
+ this.validateTempAllData();
+ let theJSON = JSON.stringify(this.tempAllData, null, '\t');
+ let fileName = 'reference_AllAction_' + referenceObject.scopeName + '_' + '0.0.1V.json';
+ this.uploadArtifact(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
+ var templateData = JSON.stringify(this.appData.template.templateData);
+ var nameValueData = JSON.stringify(this.appData.template.nameValueData);
+ var pdData = JSON.stringify(this.appData.pd);
+ if (templateData != '{}' && templateData != null && templateData != undefined) this.saveTemp();
+ if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.saveNameValue();
+ if (pdData != '{}' && pdData != null && pdData != undefined) this.savePd();
+ this.clearTemplateCache();
+ this.clearPdCache();
+ }
+ else {
+ this.clearTemplateCache();
+ this.clearPdCache();
+ }
+ });
+ }
+ }
+ }
+
+ clearCache()
+ //needed for the the clearing template cache.
{
- // get the value and save the userid and persist it.
- this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
- localStorage['paramsContent'] = '{}';
- this.mappingEditorService.setParamContent(undefined);
- this.paramShareService.setSessionParamData(undefined);
+ // get the value and save the userid and persist it.
+ this.clearTemplateCache();
+ this.clearPdCache();
this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
this.downloadData = {
reference: {},
@@ -975,54 +946,38 @@ export class ReferenceDataformComponent implements OnInit {
};
}
- // needed for the the clearing template cache.
- //{
- // // get the value and save the userid and persist it.
- // this.clearTemplateCache();
- // this.clearPdCache();
- // this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
- // this.downloadData = {
- // reference: {},
- // template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
- // pd: { pdData: '', pdFileName: '' }
- // };
- // }
-
- // clearTemplateCache()
- // {
- // this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
- // localStorage['paramsContent'] = '{}';
- // }
- // clearPdCache()
- // {
- // this.mappingEditorService.setParamContent(undefined);
- // this.paramShareService.setSessionParamData(undefined);
- // }
+ clearTemplateCache() {
+ this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
+ localStorage['paramsContent'] = '{}';
+ }
+ clearPdCache() {
+ this.mappingEditorService.setParamContent(undefined);
+ this.paramShareService.setSessionParamData(undefined);
+ }
saveTemp() {
this
.httpUtils
.post(
- { url: environment.getDesigns, data: this.appData.template.templateData })
+ { url: environment.getDesigns, data: this.appData.template.templateData })
.subscribe(resp => {
if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
this.nService.success('Status', 'Successfully uploaded the Template Data');
}
if (resp.output.status.code === '401') {
this.nService.warn('Status', 'Error in saving the Template to Appc');
-
}
},
- (err) => this.nService.error('Status', 'Error Connecting to the APPC Network'));
+ (err) => this.nService.error('Status', 'Error Connecting to the APPC Network'));
}
saveNameValue() {
this
.httpUtils
.post(
- {
- url: environment.getDesigns, data: this.appData.template.nameValueData
- })
+ {
+ url: environment.getDesigns, data: this.appData.template.nameValueData
+ })
.subscribe(resp => {
if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
this.nService.success('Status', 'Successfully uploaded the Name Value Pairs');
@@ -1031,19 +986,19 @@ export class ReferenceDataformComponent implements OnInit {
this.nService.warn('Status', 'Error in saving the Name value pairs to Appc');
}
},
- error => {
- this.nService.error('Status', 'Error Connecting to the APPC Network');
- return false;
- });
+ error => {
+ this.nService.error('Status', 'Error Connecting to the APPC Network');
+ return false;
+ });
}
savePd() {
this
.httpUtils
.post(
- {
- url: environment.getDesigns, data: this.appData.pd
- })
+ {
+ url: environment.getDesigns, data: this.appData.pd
+ })
.subscribe(resp => {
if (resp.output.status.code === '400' && resp.output.status.message === 'success') {
this.nService.success('Status', 'Successfully uploaded PD file');
@@ -1052,10 +1007,10 @@ export class ReferenceDataformComponent implements OnInit {
this.nService.warn('Status', 'Error in saving the PD to Appc');
}
},
- error => {
- this.nService.error('Status', 'Error Connecting to the APPC Network');
- return false;
- });
+ error => {
+ this.nService.error('Status', 'Error Connecting to the APPC Network');
+ return false;
+ });
}
openModel(toShow: any, message: any, title: any) {
@@ -1080,7 +1035,7 @@ export class ReferenceDataformComponent implements OnInit {
if (!(this.referenceDataObject['template-id-list'])) {
this.referenceDataObject['template-id-list'] = [];
}
- if(!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim())>-1)){
+ if (!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim()) > -1)) {
this.referenceDataObject['template-id-list'].push(this.templateId.trim());
}
}
@@ -1090,7 +1045,7 @@ export class ReferenceDataformComponent implements OnInit {
}
dataModified() {
- // this.referenceDataObject.vm = this.referenceDataObject.vm;
+ // this.referenceDataObject.vm = this.referenceDataObject.vm;
}
resetGroupNotation() {
@@ -1103,25 +1058,25 @@ export class ReferenceDataformComponent implements OnInit {
}
}
- resetVmsForScaleout(action){
- //reset currentform vms based on action
- if (action == "ConfigScaleOut") {
+ resetVmsForScaleout(action) {
+ //reset currentform vms based on action
+ if (action == "ConfigScaleOut") {
let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
- return obj['action'] ==action
+ return obj['action'] == action
});
if (ConfigScaleOutIndex > -1) {
this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
} else {
- if(this.actionChanged ){
- this.referenceDataObject.vm = []
- }
- //
+ if (this.actionChanged) {
+ this.referenceDataObject.vm = []
+ }
+ //
}
}
}
- resetParamsOnVnfcType(){
- let scopeName = '';
+ resetParamsOnVnfcType() {
+ let scopeName = '';
//if only vnf is there
if (this.referenceDataObject.scope['vnfc-type'] == '' || this.referenceDataObject.scope['vnfc-type'] == null || this.referenceDataObject.scope['vnfc-type'] == 'null') {
scopeName = this.referenceDataObject.scope['vnf-type'];
@@ -1140,13 +1095,13 @@ export class ReferenceDataformComponent implements OnInit {
this.referenceDataObject['scopeType'] = 'vnf-type';
}
}
- //replacing / with _ and removing spaces in the scopeName
- if (scopeName) {
+ //replacing / with _ and removing spaces in the scopeName
+ if (scopeName) {
scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
}
return scopeName
- }
- decideExtension(){
+ }
+ decideExtension() {
//marking the extension based on the device-protocol selected by the user
let extension = 'json';
if (this.referenceDataObject['device-protocol'] == 'ANSIBLE' || this.referenceDataObject['device-protocol'] == 'CHEF' || this.referenceDataObject['device-protocol'] == 'CLI') {
@@ -1156,10 +1111,10 @@ export class ReferenceDataformComponent implements OnInit {
}
return extension
}
- prepareArtifactList(scopeName,extension){
- this.referenceDataObject['artifact-list'] = [];
+ prepareArtifactList(scopeName, extension) {
+ this.referenceDataObject['artifact-list'] = [];
- //preparing the artifact list array file names along with extension
+ //preparing the artifact list array file names along with extension
let config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.' + extension;
let pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
let reference_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
@@ -1184,7 +1139,7 @@ export class ReferenceDataformComponent implements OnInit {
if (identifiers) {
for (var x = 0; x < identifiers.length; x++) {
//for replacing spaces and "/" with "_"
- identifiers[x]=identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
+ identifiers[x] = identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V_' + identifiers[x] + '.yaml';
config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V_' + identifiers[x] + '.' + extension;
@@ -1204,8 +1159,8 @@ export class ReferenceDataformComponent implements OnInit {
}
}
- deleteVmsforNonActions(newObj,action){
- let configureObject = (action == 'Configure');
+ deleteVmsforNonActions(newObj, action) {
+ let configureObject = (action == 'Configure');
let ConfigScaleOut = (action == 'ConfigScaleOut');
//delete VM's if selected action is not configure.
if (!ConfigScaleOut && !configureObject && this.tempAllData.length != 0) {
@@ -1225,7 +1180,7 @@ export class ReferenceDataformComponent implements OnInit {
}
return newObj
}
- pushOrReplaceTempData(newObj,action){
+ pushOrReplaceTempData(newObj, action) {
let actionObjIndex = this.tempAllData.findIndex(obj => {
return obj['action'] == action;
@@ -1233,7 +1188,7 @@ export class ReferenceDataformComponent implements OnInit {
if (newObj.action != 'HealthCheck') {
delete newObj['url'];
}
-
+
if (actionObjIndex > -1) {
this.tempAllData[actionObjIndex] = newObj;
this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
@@ -1245,11 +1200,11 @@ export class ReferenceDataformComponent implements OnInit {
this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
}
}
-
+
}
- addAllActionObj(newObj,scopeName){
-
+ addAllActionObj(newObj, scopeName) {
+
//Creating all action block to allow mulitple actions at once
let allAction = {
action: 'AllAction',
@@ -1270,9 +1225,9 @@ export class ReferenceDataformComponent implements OnInit {
}
}
- resetTempData(){
- if (this.uploadedDataArray && this.uploadedDataArray != undefined && this.uploadedDataArray.length != 0) {
-
+ resetTempData() {
+ if (this.uploadedDataArray && this.uploadedDataArray != undefined && this.uploadedDataArray.length != 0) {
+
if (this.tempAllData && this.tempAllData != undefined) {
for (var i = 0; i < this.tempAllData.length; i++) {
// alert(this.checkIfelementExistsInArray(this.tempAllData[i].action,this.actions))
@@ -1295,4 +1250,4 @@ export class ReferenceDataformComponent implements OnInit {
this.addVmCapabilitiesData();
}
}
-}
+} \ No newline at end of file
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
index c9a7c4d..0ec9d9f 100644
--- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
@@ -223,6 +223,7 @@ describe('GoldenConfigurationMappingComponent', () => {
component.vnfType = "testVnf";
component.userId = "abc";
component.item.action = "Configure";
+ mappingEditorService.identifier="id1";
component.retrieveNameValueFromAppc();
expect(localStorage["localStorage['paramsContent']"]).not.toBe(null);
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
index a3c5a8e..b098ab7 100644
--- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
@@ -51,7 +51,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
enableMappingSave: boolean = false;
aceText: string = '';
fileName: string = '';
- actionType: any='';
+ actionType: any = '';
modal: any;
configMappingEditorContent: any;
fileType: any = '';
@@ -69,8 +69,8 @@ export class GoldenConfigurationMappingComponent implements OnInit {
enableDownload: boolean = false;
showMappingDownloadDiv: boolean = false;
mapppingDownloadType: any;
- action: any='';
- artifactName: any='';
+ action: any = '';
+ artifactName: any = '';
enableMerge: boolean = false;
apiToken = localStorage['apiToken'];
userId = localStorage['userId'];
@@ -98,13 +98,13 @@ export class GoldenConfigurationMappingComponent implements OnInit {
@ContentChildren(Tab) tabs: QueryList<Tab>;
public subscription: any;
public item: any = {};
- vnfType: any='';
- vnfcType: any='';
- protocol: any='';
+ vnfType: any = '';
+ vnfcType: any = '';
+ protocol: any = '';
refObj: any;
public paramsContent = localStorage['paramsContent'];
- constructor (private buildDesignComponent: BuildDesignComponent, private paramShareService: ParamShareService, private router: Router, private httpUtil: HttpUtilService, private dialogService: DialogService, private activeRoutes: ActivatedRoute, private mappingEditorService: MappingEditorService, private notificationService: NotificationService, private nService: NotificationsService, private ngProgress: NgProgress) {
+ constructor(private buildDesignComponent: BuildDesignComponent, private paramShareService: ParamShareService, private router: Router, private httpUtil: HttpUtilService, private dialogService: DialogService, private activeRoutes: ActivatedRoute, private mappingEditorService: MappingEditorService, private notificationService: NotificationService, private nService: NotificationsService, private ngProgress: NgProgress) {
this.artifactRequest.action = '';
this.artifactRequest.version = '';
this.artifactRequest.paramKeysContent = '';
@@ -155,7 +155,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
this.activeRoutes.url.subscribe(UrlSegment => {
this.actionType = UrlSegment[0].path;
});
-
+
if (this.actionType === 'myTemplates') {
this.mappingEditorService.fromScreen = 'MappingScreen';
}
@@ -171,7 +171,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of browseOption() Method============================================
-
+
ngOnDestroy() {
this.prepareFileName();
}
@@ -201,8 +201,8 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of ngAfterViewInit() Method============================================
-
-
+
+
public fileParamChange(input) {
if (input.files && input.files[0]) {
this.enableMappingSave = true;
@@ -264,7 +264,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of onParamChanges() Method============================================
-
+
updateFileName(action: any, scopeName: any, versionNo: any) {
let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V.json';
this.downloadedFileName = fileName;
@@ -272,19 +272,29 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of updateFileName() Method============================================
+ updateFileNameForConfigScaleOut(action: any, scopeName: any, versionNo: any, id: any) {
+ let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V_' + id + '.json';
+ this.downloadedFileName = fileName;
+ return fileName;
+ }
+ //========================== End of updateFileNameForConfigScaleOut() Method============================================
prepareFileName(): any {
let fileNameObject: any = this.mappingEditorService.latestAction;
return fileNameObject;
}
//========================== End of prepareFileName() Method============================================
-
+
retrieveNameValueFromAppc() {
let refObj = this.refObj;
if (refObj && refObj != undefined) {
this.enableMerge = true;
var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
- let fileName = this.updateFileName(this.item.action, scopeName, this.versionNo);
+ let fileName = '';
+ let id = this.mappingEditorService.identifier;
+ if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.versionNo, id);
+ else fileName = this.updateFileName(this.item.action, scopeName, this.versionNo);
+
let payload = '{"userID": "' + this.userId + '", "action": "' + this.item.action + '", "vnf-type" : "' + this.vnfType + '", "artifact-type":"APPC-CONFIG", "artifact-name":"' + fileName + '"}';
let input = {
'input': {
@@ -337,7 +347,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of retrieveNameValueFromAppc() Method============================================
-
+
formatNameValuePairs(namevaluePairs: string) {
var string = namevaluePairs.substring(1, namevaluePairs.length - 1);
var stringArr = string.split(',');
@@ -431,7 +441,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
'ruleTypeValues': arr2item.ruleTypeValues
};
pdDataArrayForSession.splice(i, 1, json);
-
+
}
});
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
index 02b5a02..52a2734 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
@@ -41,7 +41,8 @@ limitations under the License.
<label>Protocol</label><input class="form-control" type="text" disabled value="{{protocol}}" />
</div>
<div *ngIf="(action === 'ConfigScaleOut')" class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
- <label>Template Identifier</label><input class="form-control" type="text" disabled value="{{identifier}}" />
+ <label>Template Identifier</label><input class="form-control" type="text" [(ngModel)]="identifier" disabled />
+
</div>
</div>
</div>
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
index da422c3..8ad635b 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -218,6 +217,7 @@ describe('GoldenConfigurationComponent', () => {
component.userId = "sj108s";
component.apiToken = "87264736473";
+ mappingEditorService.identifier = "id1";
component.prepareAppData();
var paramData = { "input": ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"sj108s","vnf-type":"testVnf","action":"Configure","artifact-name":"param_Configure_testVnf_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"[{\"sync_auto-pop_name1\":\"10.0.1.34\",\"sync_auto-pop_address1\":\"\",\"node0_tacplus_server_name2\":\"192.34.45.5\"}]"}' }) }) };
var templateData = { input: ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"sj108s","vnf-type":"testVnf","action":"Configure","artifact-name":"template_Configure_test_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n<version>15.1X49-D50.3</version>\n <groups>\n <name>node0</name>\n <system>\n <tacplus-server>\n <name>${sync_auto-pop_name1}</name>\n <source-address>${sync_auto-pop_address1}</source-address>\n </tacplus-server>\n <tacplus-server>\n <name>${node0_tacplus_server_name2}</name>\n <source-address>${sync_auto-pop_address1}</source-address>\n </tacplus-server>\n </system> \n </groups>\n </configuration>"}' }) }) };
@@ -375,54 +375,54 @@ describe('GoldenConfigurationComponent', () => {
// fileChange method
it('Should validatte fileChange method if file type is xml', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.xml", {type: "text/xml"});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo.xml", { type: "text/xml" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validatte fileChange method if file type is json', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.json", {type: "text/json"});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo.json", { type: "text/json" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validatte fileChange method if file type is none ', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo", {type: ""});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo", { type: "" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(typeof sessionStorage.getItem('fileType')).toEqual('string')
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validate if files is false', () => {
let spy = spyOn(NotificationsService.prototype, 'error');
let reader = new FileReader();
- let input = {files: []};
+ let input = { files: [] };
component.refObj = true;
component.fileChange(input);
@@ -433,7 +433,7 @@ describe('GoldenConfigurationComponent', () => {
it('Should validate if refObj is undefined', () => {
let spy = spyOn(NotificationsService.prototype, 'error');
let reader = new FileReader();
- let input = {files: []};
+ let input = { files: [] };
component.refObj = undefined;
component.fileChange(input);
@@ -443,4 +443,14 @@ describe('GoldenConfigurationComponent', () => {
// End fileChange method
+ it('should give the correct template artifact name when multiple template identifiers are provided from reference page', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
+ fixture = TestBed.createComponent(GoldenConfigurationComponent);
+ component = fixture.componentInstance;
+ mappingEditorService.identifier = "id1";
+ mappingEditorService.latestAction = { "action": "ConfigScaleOut", "action-level": "vnf", "scope": { "vnf-type": "test", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_ConfigScaleOut_test_0.0.1V_id1.json", "artifact-type": "config_template" }, { "artifact-name": "pd_ConfigScaleOut_test_0.0.1V_id1.yaml", "artifact-type": "parameter_definitions" }, { "artifact-name": "template_ConfigScaleOut_test_0.0.1V_id2.json", "artifact-type": "config_template" }, { "artifact-name": "pd_ConfigScaleOut_test_0.0.1V_id2.yaml", "artifact-type": "parameter_definitions" }], "template-id-list": ["id1", "id2"], "scopeType": "vnf-type" };
+ component.ngAfterViewInit();
+ expect(component.artifactName).toBe("template_ConfigScaleOut_test_0.0.1V_id1.json");
+ }));
+
+
});
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
index 750b979..3868485 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
@@ -129,9 +129,9 @@ export class GoldenConfigurationComponent implements OnInit {
enableValidateTemplate: boolean = false;;
public selectedUploadType: string = this.uploadTypes[0].value;
identifier: any;
- public tempRetrievalResponse:any;
- public mergeStatus:boolean=false;
-
+ public tempRetrievalResponse: any;
+ public mergeStatus: boolean = false;
+
//======================================Start of ngOnInit() Method============================================
ngOnInit() {
var refObj = this.refObj = this.prepareFileName();
@@ -186,7 +186,19 @@ export class GoldenConfigurationComponent implements OnInit {
for (let i = 0; i < this.refNameObj['artifact-list'].length; i++) {
let artifactList = this.refNameObj['artifact-list'];
if (artifactList[i]['artifact-type'] === 'config_template') {
- this.artifactName = artifactList[i]['artifact-name'];
+ var artifactName = artifactList[i]['artifact-name'];
+ var artifactNameWithoutExtension = '';
+ if (artifactName) artifactNameWithoutExtension = artifactName.substring(0, artifactName.lastIndexOf("."))
+ var identifier = artifactNameWithoutExtension.split("_");
+ var id = '';
+ if (identifier) id = identifier[identifier.length - 1];
+ if (this.mappingEditorService.identifier) {
+ if (id === this.mappingEditorService.identifier) this.artifactName = artifactName;
+ }
+ else {
+ this.artifactName = artifactName;
+ }
+
}
}
}
@@ -255,7 +267,7 @@ export class GoldenConfigurationComponent implements OnInit {
if (this.fileType === '') {
sessionStorage.setItem('fileType', '');
}
- }
+ }
}
//========================== End of saveTemplate() Method============================================
retrieveTemplateFromAppc() {
@@ -281,7 +293,7 @@ export class GoldenConfigurationComponent implements OnInit {
}).subscribe(resp => {
if (resp.output.status.code === '400' && resp.output.status.message === "success") {
this.nService.success("Success", "Template retrieved successfully from APPC");
- this.tempRetrievalResponse=resp;
+ this.tempRetrievalResponse = resp;
let result = JSON.parse(resp.output.data.block).artifactInfo[0];
result = result['artifact-content'];
if ('Generated Template' === this.selectedUploadType) {
@@ -303,7 +315,7 @@ export class GoldenConfigurationComponent implements OnInit {
}
this.ngProgress.done();
},
- error => this.nService.error("Error", "Error in connecting to APPC Server"));
+ error => this.nService.error("Error", "Error in connecting to APPC Server"));
setTimeout(() => {
this.ngProgress.done();
}, 3500);
@@ -324,7 +336,11 @@ export class GoldenConfigurationComponent implements OnInit {
this.showTemplateVersionDiv = true;
let action = this.item.action;
var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
- let fileName = this.updateParamFileName(refObj.action, scopeName, this.templateVersionNo);
+ var fileName = '';
+ let id = this.mappingEditorService.identifier;
+ if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.templateVersionNo, id);
+ else fileName = this.updateParamFileName(this.item.action, scopeName, this.templateVersionNo);
+
let vnfType = this.vnfType;
let Json = [paramsKeyValueFromEditor];
let slashedPayload = this.appendSlashes(JSON.stringify(Json));
@@ -349,7 +365,7 @@ export class GoldenConfigurationComponent implements OnInit {
}
}
}
- this.appDataObject.template.nameValueData = data;
+ this.appDataObject.template.nameValueData = data;
}
if (this.configMappingEditorContent) {
let actualContent = this.configMappingEditorContent;
@@ -412,7 +428,7 @@ export class GoldenConfigurationComponent implements OnInit {
let refObj = this.refObj;
if (refObj) {
let paramsKeyValueFromEditor: JSON;
- try {
+ try {
paramsKeyValueFromEditor = JSON.parse(localStorage["paramsContent"]);
}
catch (error) {
@@ -425,7 +441,10 @@ export class GoldenConfigurationComponent implements OnInit {
this.showTemplateVersionDiv = true;
let fileName: any;
var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
- fileName = this.updateParamFileName(refObj.action, scopeName, this.templateVersionNo);
+ let id = this.mappingEditorService.identifier;
+ if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.templateVersionNo, id);
+ else fileName = this.updateParamFileName(this.item.action, scopeName, this.templateVersionNo);
+
this.downloadDataObject.template.nameValueData = theJSON;
this.downloadDataObject.template.nameValueFileName = fileName;
}
@@ -441,13 +460,19 @@ export class GoldenConfigurationComponent implements OnInit {
return fileName;
}
//========================== End of updateParamFileName() Method============================================
+ updateFileNameForConfigScaleOut(action: any, scopeName: any, versionNo: any, id: any) {
+ let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V_' + id + '.json';
+ this.downloadedParamFileName = fileName;
+ return fileName;
+ }
+ //========================== End of updateFileNameForConfigScaleOut() Method============================================
public onDownloadTemplate(artifact: string) {
let actualContent = this.configMappingEditorContent;
var textToSaveAsBlob: any;
var config_template_fileName: any
let refObj = this.refObj;
let versionandFileType: string;
- if (artifact == 'Template' && this.artifactRequest && this.configMappingEditorContent && refObj) {
+ if (artifact == 'Template' && this.artifactRequest && this.configMappingEditorContent && refObj) {
this.showTemplateVersionDiv = true;
if (this.fileType === "text/xml") {
textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
@@ -523,7 +548,7 @@ export class GoldenConfigurationComponent implements OnInit {
this.saveTemplate();
});
- }
+ }
else {
this.nService.error("Error", "Failed to read file");
}
@@ -582,11 +607,11 @@ export class GoldenConfigurationComponent implements OnInit {
var templateData = this.mappingEditorService.paramData; //template data array
var pdData = this.paramShareService.getSessionParamData(); //PD data array
var paramsContent = localStorage["paramsContent"];
-
+
if (paramsContent && paramsContent != undefined) {
try {
var paramTabData = JSON.parse(paramsContent);
- }
+ }
catch (error) {
console.log("error is : " + error)
}
@@ -693,7 +718,7 @@ export class GoldenConfigurationComponent implements OnInit {
"ruleTypeValues": arr2item.ruleTypeValues
};
resultArr.splice(i, 1, json)
- }
+ }
});
@@ -723,7 +748,7 @@ export class GoldenConfigurationComponent implements OnInit {
public handleAnnotation(modal) {
this.selectedWord = this.templateeditor.getEditor().session.getTextRange(this.templateeditor.getEditor().selectionRange);
- if(this.selectedWord && this.selectedWord!=undefined) modal.open();
+ if (this.selectedWord && this.selectedWord != undefined) modal.open();
}
//========================== End of handleAnnotations() Method============================================
public submitNameValues() {
@@ -732,14 +757,14 @@ export class GoldenConfigurationComponent implements OnInit {
if (this.selectedWord) {
if (this.selectedWord.startsWith('${(')) {
- var replaceWord: any =this.replaceWord = this.selectedWord.substring(3, this.selectedWord.indexOf(')=(')) + this.tempName;
+ var replaceWord: any = this.replaceWord = this.selectedWord.substring(3, this.selectedWord.indexOf(')=(')) + this.tempName;
this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
-
+
} else {
let mappingKey = this.mappingEditorService.getKeysForValues(this.selectedWord);
- var replaceWord: any = this.replaceWord='${(' + this.selectedWord + ')=(' + this.tempName + ')}';
+ var replaceWord: any = this.replaceWord = '${(' + this.selectedWord + ')=(' + this.tempName + ')}';
this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
-
+
}
}
this.mappingEditorService.refreshEditor();