From 07f6cafc47a651b49b1dfa4c99f7570aef81cebb Mon Sep 17 00:00:00 2001 From: Swapnali Shadanan Pode Date: Wed, 20 Mar 2019 13:34:45 +0530 Subject: sources template changes json editor added in panels Change-Id: I99430bc4bcc3be2e729b551a77a2677dcd74d46e Issue-ID: CCSDK-804 Signed-off-by: sp00501638 --- .../resource-edit/resource-edit.module.ts | 5 +-- .../sources-template.component.html | 12 +++---- .../sources-template/sources-template.component.ts | 40 +++++++++++++++++----- 3 files changed, 41 insertions(+), 16 deletions(-) (limited to 'cds-ui/client') diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.module.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.module.ts index 8f28021c8..2b25ae339 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.module.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.module.ts @@ -29,6 +29,7 @@ import { SharedModule } from '../../../../app/common/shared/shared.module'; import { SourcesTemplateComponent } from './sources-template/sources-template.component'; import { ResourceMetadataComponent } from './resource-metadata/resource-metadata.component'; import { DragDropModule } from '@angular/cdk/drag-drop'; +import { NgJsonEditorModule } from 'ang-jsoneditor'; @NgModule({ declarations: [ ResourceEditComponent,SourcesTemplateComponent,ResourceMetadataComponent ], @@ -38,8 +39,8 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; SharedModule, FormsModule,ReactiveFormsModule, DragDropModule, - MatExpansionModule,MatToolbarModule,MatIconModule, MatButtonModule, MatSidenavModule, MatCheckboxModule, MatListModule, MatGridListModule, MatCardModule, MatMenuModule, MatTableModule, MatPaginatorModule, MatSortModule, MatInputModule, MatSelectModule, MatRadioModule, MatFormFieldModule, MatStepperModule - + MatExpansionModule,MatToolbarModule,MatIconModule, MatButtonModule, MatSidenavModule, MatCheckboxModule, MatListModule, MatGridListModule, MatCardModule, MatMenuModule, MatTableModule, MatPaginatorModule, MatSortModule, MatInputModule, MatSelectModule, MatRadioModule, MatFormFieldModule, MatStepperModule, + NgJsonEditorModule ], exports: [ ResourceEditComponent,SharedModule ] }) diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html index 123594a50..903c6d319 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html @@ -21,17 +21,17 @@
-
+
- {{item.type}} + {{item}} - {{item}} +
@@ -47,10 +47,10 @@

-
{{item.type}}
+
{{item}}
\ No newline at end of file diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts index 8c6d99ca7..c43d1debd 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; import { IResources } from 'src/app/common/core/store/models/resources.model'; import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model'; @@ -28,6 +28,7 @@ import { IAppState } from '../../../../common/core/store/state/app.state'; import { A11yModule } from '@angular/cdk/a11y'; import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action'; import { ISourcesData } from 'src/app/common/core/store/models/sourcesData.model'; +import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor'; @Component({ selector: 'app-sources-template', @@ -35,14 +36,29 @@ import { ISourcesData } from 'src/app/common/core/store/models/sourcesData.model styleUrls: ['./sources-template.component.scss'] }) export class SourcesTemplateComponent implements OnInit { +// rdState: Observable; +// resources: IResources; +// todo = []; +// sources:ISourcesData; +// sourcesOptions = []; + + @ViewChild(JsonEditorComponent) editor: JsonEditorComponent; + options = new JsonEditorOptions(); + rdState: Observable; resources: IResources; - todo = []; + option = ['mdsal','default']; sources:ISourcesData; sourcesOptions = []; - + sourcesData = []; + constructor(private store: Store) { - this.rdState = this.store.select('resources'); + this.rdState = this.store.select('resources'); + this.options.mode = 'text'; + this.options.modes = [ 'text', 'tree', 'view']; + this.options.statusBar = false; + this.options.onChange = () => console.log(this.editor.get()); + } ngOnInit() { @@ -51,14 +67,22 @@ export class SourcesTemplateComponent implements OnInit { var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess }; this.sources = resourcesState.resources.sources; for (let key in this.sources) { - if (this.sources.hasOwnProperty(key)) { - this.sourcesOptions.push(this.sources[key]); - } + this.sourcesOptions.push(key); } - console.log(this.sourcesOptions); + //console.log(this.sourcesOptions); }) } + onChange() { + console.log(this.editor.get()) + }; + + selected(value){ + console.log(value); + this.sourcesData=this.sources[value]; + return this.sourcesData; + } + drop(event: CdkDragDrop) { if (event.previousContainer === event.container) { moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); -- cgit 1.2.3-korg