diff options
author | Swapnali Shadanan Pode <sp00501638@techmahindra.com> | 2019-03-07 15:54:49 +0530 |
---|---|---|
committer | Swapnali Shadanan Pode <sp00501638@techmahindra.com> | 2019-03-07 15:54:49 +0530 |
commit | 625bf17ee72370d15a90ad94d27ad649d658b96c (patch) | |
tree | 6ad8a324a3f61434768846eed67d9f22aea8d4d3 | |
parent | 3a5ecdcf6129611e1f8a016bd4e5260c1096af88 (diff) |
Resource metadata changes
Change-Id: I700b7e2bb5848272a744637c48b97880694cf89d
Issue-ID: CCSDK-807
Signed-off-by: sp00501638 <sp00501638@techmahindra.com>
2 files changed, 65 insertions, 15 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html index 3ad578d36..0bbc0b7c1 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html @@ -27,14 +27,14 @@ <mat-form-field class="form-field"> <mat-select matInput placeholder="Data Type" formControlName="_type"> <mat-option value="string">string</mat-option> - <mat-option value="string">list</mat-option> + <mat-option value="list">list</mat-option> </mat-select> </mat-form-field> <mat-form-field class="form-field" > <input matInput placeholder="entry_schema" formControlName="entry_schema"> </mat-form-field> <mat-form-field class="form-field" > - <mat-select placeholder="required" formControlName="_required"> + <mat-select matInput placeholder="required" formControlName="required"> <mat-option value="true">true</mat-option> <mat-option value="false">false</mat-option> </mat-select> 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 |