summaryrefslogtreecommitdiffstats
path: root/cds-ui/client/src/app/feature-modules/resource-definition
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/resource-definition')
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html4
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts76
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