2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
5 ===================================================================
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ============LICENSE_END============================================
22 import { Component, OnInit, ViewChild } from '@angular/core';
23 import { FlatTreeControl } from '@angular/cdk/tree';
24 import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
25 import { Observable, Subscription } from 'rxjs';
26 import { Store } from '@ngrx/store';
28 import { IAppState } from '../../../common/core/store/state/app.state';
29 import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model';
30 import { IBlueprint } from 'src/app/common/core/store/models/blueprint.model';
31 import { IMetaData } from '../../../common/core/store/models/metadata.model';
32 import { LoadBlueprintSuccess } from 'src/app/common/core/store/actions/blueprint.action';
34 import "ace-builds/webpack-resolver";
36 import 'brace/ext/language_tools';
37 import 'ace-builds/src-min-noconflict/snippets/html';
41 children?: FoodNode[];
44 const TREE_DATA: FoodNode[] = [
48 { name: 'activation-blueprint.json' },
49 { name: 'artifacts_types.json' },
50 { name: 'data_types.json' },
59 { name: 'ScriptComponent.cba.kts' },
60 { name: 'ResourceAssignmentProcessor.cba.kts' },
69 name: 'baseconfig-template'
83 /** Flat node with expandable and level information */
84 interface ExampleFlatNode {
95 selector: 'app-test-template',
96 templateUrl: './test-template.component.html',
97 styleUrls: ['./test-template.component.scss']
99 export class TestTemplateComponent implements OnInit {
100 private blueprintpState: Subscription;
102 private workflows = [];
103 @ViewChild('editor') editor;
104 options: any = { fontSize: "100%", printMargin: false, tabSize: 2 };
105 private transformer = (node: FoodNode, level: number) => {
107 expandable: !!node.children && node.children.length > 0,
113 treeControl = new FlatTreeControl<ExampleFlatNode>(
114 node => node.level, node => node.expandable);
116 treeFlattener = new MatTreeFlattener(
117 this.transformer, node => node.level, node => node.expandable, node => node.children);
119 dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
121 constructor(private store: Store<IAppState>) {
122 this.blueprintpState = this.store.select('blueprint')
123 .subscribe((data: any) => {
125 if (data.blueprint.topology_template && data.blueprint.topology_template.workflows) {
126 this.buildWorkflowData(data.blueprint.topology_template.workflows);
127 // this.request = JSON.stringify(data.blueprint.topology_template.workflows[0], undefined, 4);
130 this.dataSource.data = TREE_DATA;
134 hasChild = (_: number, node: ExampleFlatNode) => node.expandable;
140 console.log('selected file:' + file);
143 buildWorkflowData(data) {
145 for (var property1 in data) {
146 data[property1].name = property1;
147 this.workflows.push(data[property1])
149 this.request = this.workflows[0];
152 createRequest(workflow) {
153 this.request = JSON.stringify(workflow, undefined, 4);