diff options
author | 2019-03-07 15:54:49 +0530 | |
---|---|---|
committer | 2019-03-07 15:54:49 +0530 | |
commit | 625bf17ee72370d15a90ad94d27ad649d658b96c (patch) | |
tree | 6ad8a324a3f61434768846eed67d9f22aea8d4d3 /cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts | |
parent | 3a5ecdcf6129611e1f8a016bd4e5260c1096af88 (diff) |
Resource metadata changes
Change-Id: I700b7e2bb5848272a744637c48b97880694cf89d
Issue-ID: CCSDK-807
Signed-off-by: sp00501638 <sp00501638@techmahindra.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts')
-rw-r--r-- | cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts | 76 |
1 files changed, 63 insertions, 13 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts index f44c9b0d1..f99bddc13 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts @@ -20,6 +20,16 @@ import { Component, OnInit } from '@angular/core'; import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import { IResources } from 'src/app/common/core/store/models/resources.model'; +import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model'; +import { IResourcesMetaData } from '../../../../common/core/store/models/resourcesMetadata.model'; +import { Observable } from 'rxjs'; +import { Store } from '@ngrx/store'; +import { IAppState } from '../../../../common/core/store/state/app.state'; +import { A11yModule } from '@angular/cdk/a11y'; +import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action'; +import { IPropertyData } from 'src/app/common/core/store/models/propertyData.model'; +import { IEntrySchema } from 'src/app/common/core/store/models/entrySchema.model'; @Component({ selector: 'app-resource-metadata', @@ -27,19 +37,59 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms'; styleUrls: ['./resource-metadata.component.scss'] }) export class ResourceMetadataComponent implements OnInit { - + entry_schema:IEntrySchema; + properties: IPropertyData; ResourceMetadata: FormGroup; - - constructor(private _formBuilder: FormBuilder) { - this.ResourceMetadata = this._formBuilder.group({ - Resource_Name: ['', Validators.required], - _tags: ['', Validators.required], - _description : ['', Validators.required], - _type: ['string', Validators.required], - _required: ['false', Validators.required], - entry_schema: [''] + resource_name: string; + tags: string; + rdState: Observable<IResourcesState>; + resources: IResources; + propertyValues = []; + property = []; + + constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) { + this.rdState = this.store.select('resources'); + this.ResourceMetadata = this.formBuilder.group({ + Resource_Name: ['', Validators.required], + _tags: ['', Validators.required], + _description : ['', Validators.required], + _type: ['', Validators.required], + required: ['', Validators.required], + entry_schema: [''] }); - } + } - ngOnInit() {} -} + ngOnInit() { + this.rdState.subscribe( + resourcesdata => { + var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess }; + this.resource_name = resourcesState.resources.name; + this.tags = resourcesState.resources.tags; + this.resources = resourcesState.resources; + this.properties= resourcesState.resources.property; + this.propertyValues= this.checkNested(this.properties); + this.ResourceMetadata = this.formBuilder.group({ + Resource_Name: [this.resource_name, Validators.required], + _tags: [this.tags, Validators.required], + _description : [ this.propertyValues[0], Validators.required], + _type: [ this.propertyValues[1], Validators.required], + required: [ this.propertyValues[2], Validators.required], + entry_schema: [this.propertyValues[3]] + }); + }) + } + + checkNested(obj) { + for (let key in obj) { + if (obj.hasOwnProperty(key)) { + if (typeof obj[key] == "object"){ + console.log(`Key: ${key}`) + this.checkNested(obj[key]); + } else { + this.property.push(obj[key]); + } + } + } + return this.property + } +}
\ No newline at end of file |