From 89624bfa125dad591da7d0bed15bb4079d72440d Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 13 Feb 2019 23:50:55 +0530 Subject: GUI for test blueprint Added test blueprint component Issue-ID: CCSDK-1069 Change-Id: Ic8d948228b75d3da792e188287a9183483ff3a0a Signed-off-by: Arundathi Patil --- .../test-template/test-template.component.html | 36 ++++++++- .../test-template/test-template.component.ts | 85 +++++++++++++++++++++- .../test-template/test-template.module.ts | 2 + 3 files changed, 118 insertions(+), 5 deletions(-) (limited to 'cds-ui/client/src/app/feature-modules/blueprint/test-template') 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 443d7a31b..1fca8d1b7 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,7 +18,35 @@ See the License for the specific language governing permissions and limitations under the License. ============LICENSE_END============================================ --> -

- test-template works! -

- +
+
+ + + + + + {{node.name}} + + + + + {{node.name}} + + +
+
+
+ +
+ +
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 4fce0ba91..2c87e8739 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 @@ -20,6 +20,65 @@ limitations under the License. */ import { Component, OnInit } from '@angular/core'; +import {FlatTreeControl} from '@angular/cdk/tree'; +import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; + + + +interface FoodNode { + name: string; + children?: FoodNode[]; +} + +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' + } + ] + }, +]; + +/** Flat node with expandable and level information */ +interface ExampleFlatNode { + expandable: boolean; + name: string; + level: number; +} + + + + @Component({ selector: 'app-test-template', @@ -28,9 +87,33 @@ import { Component, OnInit } from '@angular/core'; }) export class TestTemplateComponent implements OnInit { - constructor() { } + private transformer = (node: FoodNode, level: number) => { + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + }; + } + + treeControl = new FlatTreeControl( + node => node.level, node => node.expandable); + + treeFlattener = new MatTreeFlattener( + this.transformer, node => node.level, node => node.expandable, node => node.children); + + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + + constructor() { + this.dataSource.data = TREE_DATA; + } + + hasChild = (_: number, node: ExampleFlatNode) => node.expandable; ngOnInit() { } + fileClicked(file) { + console.log('selected file:' + file); + } + } 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 09be58a56..677c6fedc 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 @@ -23,6 +23,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TestTemplateComponent } from './test-template.component'; import { TestTemplateRoutingModule } from './test-template-routing.module'; +import { AppMaterialModule } from '../../../common/modules/app-material.module'; @NgModule({ declarations: [ @@ -33,6 +34,7 @@ import { TestTemplateRoutingModule } from './test-template-routing.module'; ], imports: [ CommonModule, + AppMaterialModule, TestTemplateRoutingModule ] }) -- cgit 1.2.3-korg