2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 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 {FormBuilder, FormGroup, Validators} from '@angular/forms';
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 { IResourcesMetaData } from '../../../../common/core/store/models/resourcesMetadata.model';
26 import { Observable } from 'rxjs';
27 import { Store } from '@ngrx/store';
28 import { IAppState } from '../../../../common/core/store/state/app.state';
29 import { A11yModule } from '@angular/cdk/a11y';
30 import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
31 import { IPropertyData } from 'src/app/common/core/store/models/propertyData.model';
32 import { IEntrySchema } from 'src/app/common/core/store/models/entrySchema.model';
35 selector: 'app-resource-metadata',
36 templateUrl: './resource-metadata.component.html',
37 styleUrls: ['./resource-metadata.component.scss']
39 export class ResourceMetadataComponent implements OnInit {
40 entry_schema:IEntrySchema;
41 properties: IPropertyData;
42 ResourceMetadata: FormGroup;
43 resource_name: string;
45 rdState: Observable<IResourcesState>;
46 resources: IResources;
50 constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) {
51 this.rdState = this.store.select('resources');
52 this.ResourceMetadata = this.formBuilder.group({
53 Resource_Name: ['', Validators.required],
54 _tags: ['', Validators.required],
55 _description : ['', Validators.required],
56 _type: ['', Validators.required],
57 required: ['', Validators.required],
63 this.rdState.subscribe(
65 var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
66 this.resource_name = resourcesState.resources.name;
67 this.tags = resourcesState.resources.tags;
68 this.resources = resourcesState.resources;
69 this.properties= resourcesState.resources.property;
70 this.propertyValues= this.checkNested(this.properties);
71 this.ResourceMetadata = this.formBuilder.group({
72 Resource_Name: [this.resource_name, Validators.required],
73 _tags: [this.tags, Validators.required],
74 _description : [ this.propertyValues[0], Validators.required],
75 _type: [ this.propertyValues[1], Validators.required],
76 required: [ this.propertyValues[2], Validators.required],
77 entry_schema: [this.propertyValues[3]]
83 for (let key in obj) {
84 if (obj.hasOwnProperty(key)) {
85 if (typeof obj[key] == "object"){
86 console.log(`Key: ${key}`)
87 this.checkNested(obj[key]);
89 this.property.push(obj[key]);