summaryrefslogtreecommitdiffstats
path: root/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2019-03-11 17:11:20 +0530
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>2019-03-11 17:11:27 +0530
commit9be2111e0f9070b97744ad7d47a3bd6339fce5e1 (patch)
tree96bfb248aaebce6a3704e62355340c0660ae6f9b /cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
parentfbdd8c6d2ed62b2de8429083a06813faa22b0988 (diff)
Save edited changes
Implemented code to save chnages to store on click of save button in editor view Issue-ID: CCSDK-1135 Change-Id: I8a2c911a94daea50c14730540f8b2e9183b5edb3 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts')
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts76
1 files changed, 27 insertions, 49 deletions
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 96aececcf..ac701806e 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
@@ -34,55 +34,16 @@ import { IAppState } from '../../../../common/core/store/state/app.state';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model';
-import { LoadBlueprintSuccess } from '../../../../common/core/store/actions/blueprint.action'
+import { LoadBlueprintSuccess, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action'
-interface FoodNode {
+interface Node {
name: string;
- children?: FoodNode[];
+ children?: Node[];
data?: any
}
-// const TREE_DATA: FoodNode[] = [
-// {
-// name: 'Definitions',
-// children: [
-// { name: 'activation-blueprint.json' },
-// { name: 'artifacts_types.json' },
-// { name: 'data_types.json' },
-// ]
-// },
-// {
-// name: 'Scripts',
-// children: [
-// {
-// name: 'kotlin',
-// children: [
-// { name: 'ScriptComponent.cba.kts' },
-// { name: 'ResourceAssignmentProcessor.cba.kts' },
-// ]
-// }
-// ]
-// },
-// {
-// name: 'Templates',
-// children: [
-// {
-// name: 'baseconfig-template'
-// }
-// ]
-// },
-// {
-// name: 'TOSCA-Metada',
-// children: [
-// {
-// name: 'TOSCA.meta'
-// }
-// ]
-// },
-// ];
-
-const TREE_DATA: FoodNode[] = [
+const TREE_DATA: Node[] = [
{
name: 'Definitions',
children: [
@@ -117,9 +78,10 @@ export class EditorComponent implements OnInit {
filesData: any = [];
selectedFile: string;
zipFolder: any;
+ blueprintName: string;
private zipFile: JSZip = new JSZip();
- private transformer = (node: FoodNode, level: number) => {
+ private transformer = (node: Node, level: number) => {
return {
expandable: !!node.children && node.children.length > 0,
name: node.name,
@@ -172,6 +134,7 @@ export class EditorComponent implements OnInit {
this.filesTree = blueprintdata.files;
this.filesData = blueprintdata.filesData;
this.dataSource.data = this.filesTree;
+ this.blueprintName = blueprintdata.name;
let blueprint = [];
for (let key in this.blueprintdata) {
if (this.blueprintdata.hasOwnProperty(key)) {
@@ -188,13 +151,28 @@ export class EditorComponent implements OnInit {
}
updateBlueprint() {
- if (this.selectedFile == 'activation-blueprint.json') {
- // to do
+ console.log(this.blueprint);
+ this.filesData.forEach(fileNode=>{
+ if(fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) {
+ fileNode.data = this.text;
+ } else if(fileNode.name.includes(this.selectedFile.trim())) {
+ fileNode.data = this.text;
+ }
+ });
+
+ if(this.selectedFile == this.blueprintName) {
+ this.blueprint = JSON.parse(this.text);
} else {
- // to do
+ this.blueprint = this.blueprintdata;
+ }
+
+ let blueprintState = {
+ blueprint: this.blueprint,
+ name: this.blueprintName,
+ files: this.filesTree,
+ filesData: this.filesData
}
- this.blueprint = JSON.parse(this.text);
- this.store.dispatch(new LoadBlueprintSuccess(this.blueprint));
+ this.store.dispatch(new SetBlueprintState(blueprintState));
// console.log(this.text);
}