From 66b9cbf682b8adfe7f763a90a3bff7e2aa791d70 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 23 Jul 2019 19:47:59 +0530 Subject: Resource dictionary- displaying exsisting sources Implemented feature to display the exsisting sources in source panel Issue-ID: CCSDK-707 Change-Id: Iec9231176c00be31b4565507a1869b0bafded076 Signed-off-by: Arundathi Patil --- .../common/core/store/models/resources.model.ts | 1 + .../resource-edit/resource-edit.component.ts | 4 +++ .../sources-template/sources-template.component.ts | 30 +++++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) (limited to 'cds-ui/client/src') diff --git a/cds-ui/client/src/app/common/core/store/models/resources.model.ts b/cds-ui/client/src/app/common/core/store/models/resources.model.ts index 019c2684a..e89094bb1 100644 --- a/cds-ui/client/src/app/common/core/store/models/resources.model.ts +++ b/cds-ui/client/src/app/common/core/store/models/resources.model.ts @@ -27,4 +27,5 @@ export interface IResources { updated_bt:string; property: IPropertyData; sources: ISourcesData; + definition?: any; } \ No newline at end of file diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts index 2da1287ba..aa8a1064d 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts @@ -47,6 +47,7 @@ export class ResourceEditComponent implements OnInit { viewText: string = "Open in Editor Mode"; @ViewChild(JsonEditorComponent) editor: JsonEditorComponent; options = new JsonEditorOptions(); + sourcesList = []; constructor(private store: Store, private resourceEditService: ResourceEditService, private alertService: NotificationHandlerService) { this.rdState = this.store.select('resources'); @@ -60,6 +61,9 @@ export class ResourceEditComponent implements OnInit { resourcesdata => { var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess }; this.resources=resourcesState.resources; + if(resourcesdata.resources.definition && resourcesdata.resources.definition.sources) { + this.sourcesList = resourcesdata.resources.definition.sources; + } }) } 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 c4ad83d67..42f990a24 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 @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -import { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, ViewChild, EventEmitter, Output, Input } 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'; @@ -62,9 +62,17 @@ export class SourcesTemplateComponent implements OnInit { resourcesdata => { var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess }; this.resources=resourcesState.resources; - this.sources = resourcesState.resources.sources; + // this.sources = resourcesState.resources.sources; + if(resourcesState.resources.definition && resourcesState.resources.definition.sources) { + this.sources = resourcesState.resources.definition.sources; + } for (let key in this.sources) { - this.sourcesOptions.push(key); + // this.sourcesOptions.push(key); + let source = { + name : key, + data: this.sources[key] + } + this.sourcesOptions.push(source); } }) } @@ -136,5 +144,19 @@ export class SourcesTemplateComponent implements OnInit { event.previousIndex, event.currentIndex); } - } + } + + getResources() { + this.apiService.getSources() + .subscribe(data=>{ + console.log(data); + for (let key in data[0]) { + let sourceObj = { name: key, value: data[0][key] } + this.option.push(sourceObj); + } + // this.sourcesOptions = data; + }, error=>{ + console.log(error); + }) + } } -- cgit 1.2.3-korg