2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import { Component, OnInit, ViewChild } from '@angular/core';
22 import { IResources } from 'src/app/common/core/store/models/resources.model';
23 import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
24 import { LoadResourcesSuccess,UpdateResources,SetResourcesState } from 'src/app/common/core/store/actions/resources.action';
25 import { Store } from '@ngrx/store';
26 import { IAppState } from '../../../common/core/store/state/app.state';
27 import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
28 import { Observable } from 'rxjs';
29 import { A11yModule } from '@angular/cdk/a11y';
32 selector: 'app-resource-edit',
33 templateUrl: './resource-edit.component.html',
34 styleUrls: ['./resource-edit.component.scss']
36 export class ResourceEditComponent implements OnInit {
40 rdState: Observable<IResourcesState>;
41 designerMode: boolean = true;
42 editorMode: boolean = false;
43 viewText: string = "Open in Editor Mode";
44 @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
45 options = new JsonEditorOptions();
47 constructor(private store: Store<IAppState>) {
48 this.rdState = this.store.select('resources');
49 this.options.mode = 'text';
50 this.options.modes = [ 'text', 'tree', 'view'];
51 this.options.statusBar = false;
55 this.rdState.subscribe(
57 var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
58 this.resources=resourcesState.resources;
62 metaDataDetail(data: IResources) {
66 sourcesDetails(data: IResources) {
71 this.data=JSON.parse($event.srcElement.value);
74 updateResourcesState(){
75 console.log(this.data);
76 let resourcesState = {
82 this.store.dispatch(new SetResourcesState(resourcesState));
86 if(this.viewText == 'Open in Editor Mode') {
87 this.editorMode = true;
88 this.designerMode = false;
89 this.viewText = 'Open in Form Mode'
91 this.editorMode = false;
92 this.designerMode = true;
93 this.viewText = 'Open in Editor Mode'