Deploy component 67/79167/1
authorArundathi Patil <arundpil@in.ibm.com>
Tue, 26 Feb 2019 10:31:13 +0000 (16:01 +0530)
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>
Tue, 26 Feb 2019 10:31:21 +0000 (16:01 +0530)
Created UI for buleprint deploy and save

Issue-ID: CCSDK-1102
Change-Id: I1c3874361cffc5e446f187d7ea4e4622c94948c8
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
cds-ui/client/src/app/feature-modules/blueprint/deploy-template/deploy-template.component.html
cds-ui/client/src/app/feature-modules/blueprint/deploy-template/deploy-template.component.ts
cds-ui/client/src/app/feature-modules/blueprint/deploy-template/deploy-template.module.ts

index fc7083d..739ef04 100644 (file)
@@ -18,8 +18,39 @@ See the License for the specific language governing permissions and
 limitations under the License.
 ============LICENSE_END============================================
 -->
+<div style="height: 556px;">
+<div style="height: 90%;overflow-y: scroll;border: 1px solid grey">
+  <mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
+    <!-- This is the tree node template for leaf nodes -->
+    <mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
+      <!-- use a disabled button to provide padding for tree leaf -->
+      <button mat-icon-button disabled></button>
+      <span (click)="fileClicked(node.name)">{{node.name}}</span>
+    </mat-tree-node>
+    <!-- This is the tree node template for expandable nodes -->
+    <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
+      <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>
+      <span (click)="fileClicked(node.name)">{{node.name}}</span>
+    </mat-tree-node>
+  </mat-tree>
+</div>
 
-<p>
-  deploy-template works!
-</p>
-<router-outlet></router-outlet>
+<div style="height: 10%">
+  <button style="margin: 1em;
+  background-color: #3f51b5;
+  color: white;
+  border-radius: 2em;
+  padding: 0.5em;">Deploy/Save</button>
+  <button style="margin: 1em;
+  background-color: #3f51b5;
+  color: white;
+  border-radius: 2em;
+  padding: 0.5em;">Download</button>
+</div>
+
+</div>
index 22854e6..ab636b9 100644 (file)
@@ -19,6 +19,59 @@ limitations under the License.
 ============LICENSE_END============================================
 */
 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-deploy-template',
@@ -27,9 +80,33 @@ import { Component, OnInit } from '@angular/core';
 })
 export class DeployTemplateComponent 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<ExampleFlatNode>(
+      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);
+  }
+
 }
index e39beac..5d5a600 100644 (file)
@@ -22,6 +22,7 @@ import { NgModule } from '@angular/core';
 import { CommonModule } from '@angular/common';
 import { DeployTemplateComponent } from './deploy-template.component';
 import { DeployTemplateRoutingModule } from './deploy-template-routing.module';
+import { AppMaterialModule } from '../../../common/modules/app-material.module';
 
 @NgModule({
   declarations: [
@@ -32,7 +33,8 @@ import { DeployTemplateRoutingModule } from './deploy-template-routing.module';
   ],
   imports: [
     CommonModule,
-    DeployTemplateRoutingModule
+    DeployTemplateRoutingModule,
+    AppMaterialModule
   ]
 })
 export class DeployTemplateModule { }