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 { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
 
  23 import { IResources } from 'src/app/common/core/store/models/resources.model';
 
  24 import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
 
  25 import { Observable } from 'rxjs';
 
  26 import { Store } from '@ngrx/store';
 
  27 import { IAppState } from '../../../../common/core/store/state/app.state';
 
  28 import { A11yModule } from '@angular/cdk/a11y';
 
  29 import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
 
  30 import { ISourcesData } from 'src/app/common/core/store/models/sourcesData.model';
 
  31 import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
 
  34   selector: 'app-sources-template',
 
  35   templateUrl: './sources-template.component.html',
 
  36   styleUrls: ['./sources-template.component.scss']
 
  38 export class SourcesTemplateComponent implements OnInit {
 
  39 //    rdState: Observable<IResourcesState>;
 
  40 //    resources: IResources;
 
  42 //    sources:ISourcesData; 
 
  43 //    sourcesOptions = [];
 
  45     @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
 
  46     options = new JsonEditorOptions();
 
  48     rdState: Observable<IResourcesState>;
 
  49     resources: IResources;
 
  50     option = ['mdsal','default'];
 
  55  constructor(private store: Store<IAppState>) {
 
  56    this.rdState = this.store.select('resources');
 
  57       this.options.mode = 'text';
 
  58     this.options.modes = [ 'text', 'tree', 'view'];
 
  59     this.options.statusBar = false;
 
  60     this.options.onChange = () => console.log(this.editor.get());
 
  65     this.rdState.subscribe(
 
  67         var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
 
  68         this.sources = resourcesState.resources.sources;
 
  69         for (let key in this.sources) {
 
  70             this.sourcesOptions.push(key);  
 
  72         //console.log(this.sourcesOptions);
 
  77      console.log(this.editor.get())
 
  82         this.sourcesData=this.sources[value];
 
  83         return this.sourcesData;    
 
  86  drop(event: CdkDragDrop<string[]>) {
 
  87     if (event.previousContainer === event.container) {
 
  88       moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
 
  90       transferArrayItem(event.previousContainer.data,