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 } 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';
33 selector: 'app-sources-template',
34 templateUrl: './sources-template.component.html',
35 styleUrls: ['./sources-template.component.scss']
37 export class SourcesTemplateComponent implements OnInit {
38 rdState: Observable<IResourcesState>;
39 resources: IResources;
44 constructor(private store: Store<IAppState>) {
45 this.rdState = this.store.select('resources');
49 this.rdState.subscribe(
51 var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
52 this.sources = resourcesState.resources.sources;
53 for (let key in this.sources) {
54 if (this.sources.hasOwnProperty(key)) {
55 this.sourcesOptions.push(this.sources[key]);
58 console.log(this.sourcesOptions);
62 drop(event: CdkDragDrop<string[]>) {
63 if (event.previousContainer === event.container) {
64 moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
66 transferArrayItem(event.previousContainer.data,