============LICENSE_END============================================
*/
-import { Component, OnInit } from '@angular/core';
-import {FlatTreeControl} from '@angular/cdk/tree';
-import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { FlatTreeControl } from '@angular/cdk/tree';
+import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
import { Observable, Subscription } from 'rxjs';
import { Store } from '@ngrx/store';
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'
-
-
-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;
-}
-
-
-
-
+import "ace-builds/webpack-resolver";
+import 'brace';
+import 'brace/ext/language_tools';
+import 'ace-builds/src-min-noconflict/snippets/html';
@Component({
selector: 'app-test-template',
})
export class TestTemplateComponent implements OnInit {
private blueprintpState: Subscription;
- private request ;
+ private request;
private workflows = [];
+ @ViewChild('editor') editor;
+ options: any = { fontSize: "100%", printMargin: false, tabSize: 2 };
+ requestText: string;
+ responseText: string;
- 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(private store: Store<IAppState>) {
+ constructor(private store: Store<IAppState>, private testTemplateService: TestTemplateService) {
this.blueprintpState = this.store.select('blueprint')
- .subscribe((data: any)=>{
- console.log(data);
- if(data.blueprint.topology_template && data.blueprint.topology_template.workflows) {
- this.buildWorkflowData(data.blueprint.topology_template.workflows);
- // this.request = JSON.stringify(data.blueprint.topology_template.workflows[0], undefined, 4);
- }
- });
- this.dataSource.data = TREE_DATA;
- }
+ .subscribe((data: any) => {
+ console.log(data);
+ if (data && data.blueprint && data.blueprint.topology_template && data.blueprint.topology_template.workflows) {
+ this.buildWorkflowData(data.blueprint.topology_template.workflows);
+ // this.request = JSON.stringify(data.blueprint.topology_template.workflows[0], undefined, 4);
+ }
+ });
- hasChild = (_: number, node: ExampleFlatNode) => node.expandable;
+ }
ngOnInit() {
}
}
+ submitRequest() {
+ this.testTemplateService.submitRequest(this.requestText)
+ .subscribe((response) =>{
+ this.responseText = response;
+ window.alert('Success');
+ },
+ (error)=>{
+ this.responseText = "Error in processing request";
+ })
+ }
+
}