aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2019-07-19 15:09:44 +0530
committerArundathi Patil <arundpil@in.ibm.com>2019-07-19 15:09:50 +0530
commit11d85d45cff55a57a8a250fdc90912b67e32f903 (patch)
tree15416c00b56c082972aa9fa8f7b7bf6d37cb0c1e /cds-ui/client/src/app/feature-modules/resource-definition/resource-edit
parent086f23e7dbe0cc7df7105002628ee3e84cf29c76 (diff)
resource-edit changes
made changes to fetch sources Issue-ID: CCSDK-707 Change-Id: If7d07eb9cd49db61cbb8d8016c7f0dca01d00490 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/resource-definition/resource-edit')
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts10
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html10
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts40
3 files changed, 48 insertions, 12 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts
index bd06abbc1..417f6edb3 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts
@@ -36,4 +36,14 @@ export class ResourceEditService {
saveResource(resource) {
return this.api.post(ResourceDictionaryURLs.saveResourceDictionary, resource);
}
+
+ getSources() {
+ // to do
+ return this.api.get('ResourceDictionaryURLs.getSources');
+ }
+
+ getModelType(name) {
+ // to do
+ return this.api.get("ResourceDictionaryURLs.getModelType + '/' + name");
+ }
} \ 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.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
index b1474d2a2..b179f011d 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
@@ -27,13 +27,13 @@
class="sources-list"
(cdkDropListDropped)="drop($event)">
<div class="sources-box" *ngFor="let item of sourcesOptions;let i = index" cdkDrag>
- <mat-expansion-panel class="expansion-panel">
+ <mat-expansion-panel class="expansion-panel" (opened)="selected(item)">
<mat-expansion-panel-header>
<mat-panel-title>
- {{item}}
+ {{item.name}}
</mat-panel-title>
</mat-expansion-panel-header>
- <json-editor [options]="options" [data]="selected(item)" on-change="onChange(item,$event)"></json-editor>
+ <json-editor [options]="options" [data]="item.data" on-change="onChange(item,$event)"></json-editor>
</mat-expansion-panel>
<button matSuffix mat-icon-button (click)="delete(item,i)"><mat-icon class="icon">delete</mat-icon></button>
</div>
@@ -44,7 +44,7 @@
<h3>Source Options</h3>
<mat-form-field>
<input [(ngModel)]="searchText" type="input" matInput placeholder="search sources">
- <button matSuffix mat-icon-button><mat-icon>search</mat-icon></button>
+ <button matSuffix mat-icon-button (click)="getResources()"><mat-icon>search</mat-icon></button>
<mat-hint>db,mdsal,input,default,..</mat-hint>
</mat-form-field>
<br><br>
@@ -53,7 +53,7 @@
[cdkDropListData]="option"
class="options-list"
(cdkDropListDropped)="drop($event)">
- <div class="options-box" *ngFor="let item of option | search :searchText" cdkDrag>{{item}}</div>
+ <div class="options-box" *ngFor="let item of option | search :searchText" cdkDrag>{{item.name}}</div>
</div>
</div>
<div>
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 52b19f728..c4ad83d67 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
@@ -31,6 +31,7 @@ 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';
+import { ResourceEditService } from '../resource-edit.service';
@Component({
selector: 'app-sources-template',
@@ -43,13 +44,13 @@ export class SourcesTemplateComponent implements OnInit {
options = new JsonEditorOptions();
rdState: Observable<IResourcesState>;
resources: IResources;
- option = ['mdsal','default'];
+ option = [];
sources:ISourcesData;
sourcesOptions = [];
- sourcesData = [];
+ sourcesData = {};
@Output() resourcesData = new EventEmitter();
- constructor(private store: Store<IAppState>) {
+ constructor(private store: Store<IAppState>, private apiService: ResourceEditService) {
this.rdState = this.store.select('resources');
this.options.mode = 'text';
this.options.modes = [ 'text', 'tree', 'view'];
@@ -79,10 +80,35 @@ export class SourcesTemplateComponent implements OnInit {
this.resources.sources = Object.assign({},originalSources);
};
- selected(value){
- this.sourcesData=this.sources[value];
- return this.sourcesData;
- }
+ selected(sourceValue){
+ this.sourcesData= [];//this.sources[value];
+ this.apiService.getModelType(sourceValue.value)
+ .subscribe(data=>{
+ console.log(data);
+ data.forEach(item =>{
+ if(typeof(item)== "object") {
+ for (let key1 in item) {
+ if(key1 == 'properties') {
+ let newPropOnj = {}
+ for (let key2 in item[key1]) {
+ console.log(item[key1][key2]);
+ let varType = item[key1][key2].type
+ // let property : varType =
+ newPropOnj[key2] = item[key1][key2];
+ }
+ }
+ }
+ }
+ });
+ this.sourcesData = data;
+ this.sourcesOptions.forEach(item=>{
+ if(item.name == sourceValue.name) {
+ item.data = data;
+ }
+ })
+ return this.sourcesData;
+ })
+}
delete(item,i){
if(confirm("Are sure you want to delete this source ?")) {