diff options
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/blueprint')
9 files changed, 127 insertions, 32 deletions
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html index 5a3973a5e..619412c17 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html @@ -35,13 +35,13 @@ limitations under the License. <button mat-icon-button disabled></button> <button mat-icon-button (click)="selectFileToView(node)">{{node.name}}</button> </mat-tree-node> - <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)="activeNode = node" [ngClass]="{ 'background-highlight': activeNode === node }"> + <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)="selectFolder(node);activeNode = node" [ngClass]="{ 'background-highlight': activeNode === node }"> <button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name"> <mat-icon class="mat-icon-rtl-mirror"> {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} </mat-icon> </button> - <button mat-icon-button (click)="selectFolder(node)">{{node.name}}</button> + <button mat-icon-button>{{node.name}}</button> </mat-tree-node> </mat-tree> </div> @@ -49,7 +49,7 @@ limitations under the License. <!-- <i class="fa fa-save save-icon" style="font-size:24px" (click)="updateBlueprint()"></i> <ace-editor [(text)]="text" [(mode)]="mode" #editor class="aceEditor"></ace-editor> --> <div class="normal-editor-mode" [ngClass]="{ 'resource-mapping-mode': viewTemplateMode}"> - <i class="fa fa-save save-icon" style="font-size:24px" (click)="updateBlueprint()"></i> + <i class="fa fa-save save-icon" style="font-size:24px" (click)="saveEditedChanges()"></i> <ace-editor [(text)]="text" [(mode)]="mode" #editor class="aceEditor"></ace-editor> </div> <button *ngIf="viewTemplateMode" class="btn-active" (click)="loadConfigParams()">Load Config Parameters</button> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts index 73cc72cfd..1f8526a53 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts @@ -165,7 +165,7 @@ export class EditorComponent implements OnInit { blueprint.push(this.blueprintdata[key]); } } - this.metadata=blueprintState.blueprint.metadata; + this.metadata = blueprintState.blueprint.metadata; let metadatavalues = []; for (let key in this.metadata) { if (this.metadata.hasOwnProperty(key)) { @@ -181,21 +181,21 @@ export class EditorComponent implements OnInit { } updateBlueprint() { - console.log(this.blueprint); - this.filesData.forEach(fileNode => { - if (this.selectedFile && fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) { - fileNode.data = this.text; - } else if (this.selectedFile && fileNode.name.includes(this.currentFilePath)) { - // this.selectedFile && fileNode.name.includes(this.selectedFile.trim())) { - fileNode.data = this.text; - } - }); + // console.log(this.blueprint); + // this.filesData.forEach(fileNode => { + // if (this.selectedFile && fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) { + // fileNode.data = this.text; + // } else if (this.selectedFile && fileNode.name.includes(this.currentFilePath)) { + // // this.selectedFile && fileNode.name.includes(this.selectedFile.trim())) { + // fileNode.data = this.text; + // } + // }); - if (this.selectedFile && this.selectedFile == this.blueprintName.trim()) { - this.blueprint = JSON.parse(this.text); - } else { - this.blueprint = this.blueprintdata; - } + // if (this.selectedFile && this.selectedFile == this.blueprintName.trim()) { + // this.blueprint = JSON.parse(this.text); + // } else { + // this.blueprint = this.blueprintdata; + // } let blueprintState = { blueprint: this.blueprint, @@ -243,11 +243,11 @@ export class EditorComponent implements OnInit { console.log("processed"); } }); - window.alert('Blueprint enriched successfully' ); + window.alert('Blueprint enriched successfully'); }); }); } - + saveToBackend() { @@ -300,7 +300,9 @@ export class EditorComponent implements OnInit { create() { this.filesData.forEach((path) => { - this.zipFile.file(path.name, path.data); + let index = path.name.indexOf("/"); + let name = path.name.slice(index + 1, path.name.length); + this.zipFile.file(name, path.data); }); } @@ -318,6 +320,13 @@ export class EditorComponent implements OnInit { // console.log(error); // } // ); + + // this.create(); + // var zipFilename = "baseconfiguration.zip"; + // this.zipFile.generateAsync({ type: "blob" }) + // .then(blob => { + // saveAs(blob, zipFilename); + // }); } setEditorMode() { switch (this.fileExtension) { @@ -436,7 +445,7 @@ export class EditorComponent implements OnInit { this.blueprintName = (((toscaData['Entry-Definitions']).split('/'))[1]).toString();; console.log(toscaData); } - + arrangeTreeData(paths) { const tree = []; @@ -557,4 +566,23 @@ export class EditorComponent implements OnInit { return paramValue; } } + + saveEditedChanges() { + this.filesData.forEach(fileNode => { + if (this.selectedFile && fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) { + fileNode.data = this.text; + } else if (this.selectedFile && fileNode.name.includes(this.currentFilePath)) { + // this.selectedFile && fileNode.name.includes(this.selectedFile.trim())) { + fileNode.data = this.text; + } + }); + + if (this.selectedFile && this.selectedFile == this.blueprintName.trim()) { + this.blueprint = JSON.parse(this.text); + } else { + this.blueprint = this.blueprintdata; + } + + this.updateBlueprint(); + } } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts index 98e43b6b1..63c8019c3 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts @@ -42,6 +42,7 @@ export class EditorService { .subscribe(response => { let blob = new Blob([response], { 'type': "application/octet-stream" }); saveAs(blob, "CBA.zip"); + window.alert('Blueprint download successfull' ); }); return "Download Success"; diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html index b3eeeeda2..546668d43 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/modify-template.component.html @@ -36,7 +36,7 @@ limitations under the License. <button class="mat-button-active" mat-button [matMenuTriggerFor]="menu">Deploy</button> <mat-menu #menu="matMenu"> <button mat-menu-item (click)="saveToBlueprintProcessor()">Deploy</button> - <button mat-menu-item (click)="processBlueprint()">Test</button> + <!-- <button mat-menu-item (click)="processBlueprint()">Test</button> --> </mat-menu> <button class="btn-active" (click)="publishToControllerBlueprint()">Publish</button> <button class="btn-active" (click)="saveToControllerBlueprint()">Save</button> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts index 36876233d..9c11f7684 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts @@ -42,7 +42,7 @@ export class SearchTemplateComponent implements OnInit { blueprintState: IBlueprintState; bpState: Observable<IBlueprintState>; validfile: boolean = false; - + uploadedFileName: string; @ViewChild('fileInput') fileInput; result: string = ''; @@ -62,6 +62,7 @@ export class SearchTemplateComponent implements OnInit { fileChanged(e: any) { this.paths = []; this.file = e.target.files[0]; + this.uploadedFileName = (this.file.name.split('.'))[0]; this.zipFile.files = {}; this.zipFile.loadAsync(this.file) .then((zip) => { @@ -88,7 +89,9 @@ export class SearchTemplateComponent implements OnInit { this.paths = []; for (var file in zip.files) { this.fileObject = { - name: zip.files[file].name, + // nameForUIDisplay: this.uploadedFileName + '/' + zip.files[file].name, + // name: zip.files[file].name, + name: this.uploadedFileName + '/' + zip.files[file].name, data: '' }; const value = <any>await zip.files[file].async('string'); diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html index da3580cd5..fe322fada 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html @@ -18,21 +18,30 @@ See the License for the specific language governing permissions and limitations under the License. ============LICENSE_END============================================ --> -<div class="testTemplateContainer"> +<div style="border: 1px solid #3f51b5; padding: 1em;"> + <i class="fa fa-exclamation-circle" style="color: #3f51b5" aria-hidden="true"></i> + Disclaimer*: The Test CBA Certification page allow the testing/certification team with the certification + of the CBA workflow action. Workflow action may include various action and subaction that result in content + resolution (using mS such as naming , netbox , and etc.), content generation (Jinja/Velocity) and content + distribution (netconf, restconf etc.) . Once the certification is complete, it is the responsibility of the + testing/certification team to rollback all the resource assignment and network function configuration that has + been reserved and distributed during the certification. +</div> +<div class="testTemplateContainer"> <div class="editorContainer"> <div class="editorDiv"> <p>Request</p> - <ace-editor [(text)]="text" mode="json" [theme]="eclipse" [options]="options" #editor class="aceEditor"></ace-editor> + <ace-editor [(text)]="requestText" mode="json" [theme]="eclipse" [options]="options" #editor class="aceEditor"></ace-editor> <div class="btnContainer"> - <button class="button">Submit</button> + <button class="button" (click)="submitRequest()">Submit</button> <button class="button">Clear</button> </div> </div> <div class="editorDiv"> <p>Response</p> - <ace-editor [(text)]="text" mode="json" [theme]="eclipse" [options]="options" #editor class="aceEditor"></ace-editor> + <ace-editor [(text)]="responseText" mode="json" [theme]="eclipse" [options]="options" #editor class="aceEditor"></ace-editor> </div> </div> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.ts index 9a7a570ad..63c00e508 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.ts @@ -30,6 +30,7 @@ import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState import { IBlueprint } from 'src/app/common/core/store/models/blueprint.model'; import { IMetaData } from '../../../common/core/store/models/metadata.model'; import { LoadBlueprintSuccess } from 'src/app/common/core/store/actions/blueprint.action'; +import { TestTemplateService } from './test-template.service' import "ace-builds/webpack-resolver"; import 'brace'; @@ -47,8 +48,10 @@ export class TestTemplateComponent implements OnInit { private workflows = []; @ViewChild('editor') editor; options: any = { fontSize: "100%", printMargin: false, tabSize: 2 }; + requestText: string; + responseText: string; - constructor(private store: Store<IAppState>) { + constructor(private store: Store<IAppState>, private testTemplateService: TestTemplateService) { this.blueprintpState = this.store.select('blueprint') .subscribe((data: any) => { console.log(data); @@ -81,4 +84,15 @@ export class TestTemplateComponent implements OnInit { } + submitRequest() { + this.testTemplateService.submitRequest(this.requestText) + .subscribe((response) =>{ + this.responseText = response; + window.alert('Success'); + }, + (error)=>{ + this.responseText = "Error in processing request"; + }) + } + } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.module.ts b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.module.ts index ea5b5ffb2..6eca01877 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.module.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.module.ts @@ -25,7 +25,7 @@ import { TestTemplateComponent } from './test-template.component'; import { TestTemplateRoutingModule } from './test-template-routing.module'; import { AppMaterialModule } from '../../../common/modules/app-material.module'; import { AceEditorModule } from 'ng2-ace-editor'; - +import { TestTemplateService } from './test-template.service'; @NgModule({ declarations: [ TestTemplateComponent @@ -38,6 +38,7 @@ import { AceEditorModule } from 'ng2-ace-editor'; AppMaterialModule, TestTemplateRoutingModule, AceEditorModule - ] + ], + providers: [TestTemplateService] }) export class TestTemplateModule { } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.service.ts new file mode 100644 index 000000000..8df8e78a6 --- /dev/null +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.service.ts @@ -0,0 +1,39 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +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============================================ +*/ + + +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable, observable } from 'rxjs'; +import { ApiService } from '../../../common/core/services/api.service'; +import { LoopbackConfig } from '../../../common/constants/app-constants'; + +@Injectable() +export class TestTemplateService { + // blueprintUrl = '../../constants/blueprint.json'; + + constructor(private _http: HttpClient, private api: ApiService) { + } + + submitRequest(request) { + return this.api.get('', request); + } +}
\ No newline at end of file |