From b0e2477271cd21606fb18d02103694d020163ad2 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Mon, 22 Apr 2019 15:15:27 +0530 Subject: Resouce creation- save resouce to backend Integrated UI with loopback to save the resource dictionary in backend for exsisting and uploaded resource templates Issue-ID: CCSDK-1217 Change-Id: I714a20344d6df278f891e303eebceff21b74c2af Signed-off-by: Arundathi Patil --- .../resource-edit/resource-edit.component.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts') 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 55b80628d..77e901717 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 @@ -27,6 +27,7 @@ import { IAppState } from '../../../common/core/store/state/app.state'; import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor'; import { Observable } from 'rxjs'; import { A11yModule } from '@angular/cdk/a11y'; +import { ResourceEditService } from './resource-edit.service'; @Component({ selector: 'app-resource-edit', @@ -38,13 +39,13 @@ export class ResourceEditComponent implements OnInit { resources:IResources; data:IResources; rdState: Observable; - designerMode: boolean = true; - editorMode: boolean = false; + designerMode: boolean = false; + editorMode: boolean = true; viewText: string = "Open in Editor Mode"; @ViewChild(JsonEditorComponent) editor: JsonEditorComponent; options = new JsonEditorOptions(); - constructor(private store: Store) { + constructor(private store: Store, private resourceEditService: ResourceEditService) { this.rdState = this.store.select('resources'); this.options.mode = 'text'; this.options.modes = [ 'text', 'tree', 'view']; @@ -92,5 +93,15 @@ export class ResourceEditComponent implements OnInit { this.designerMode = true; this.viewText = 'Open in Editor Mode' } - } + } + + saveToBackend() { + this.resourceEditService.saveResource(this.data) + .subscribe(response=>{ + window.alert("save success"); + }, + error=>{ + window.alert('Error saving resources'); + }) + } } -- cgit 1.2.3-korg