diff options
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts')
-rw-r--r-- | cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts new file mode 100644 index 000000000..2327a5839 --- /dev/null +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts @@ -0,0 +1,88 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Observable } from 'rxjs'; +import { Store } from '@ngrx/store'; +import { A11yModule } from '@angular/cdk/a11y'; + +import { IAppState } from '../../../../common/core/store/state/app.state'; +import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model'; +import { IBlueprint } from 'src/app/common/core/store/models/blueprint.model'; +import { IMetaData } from '../../../../common/core/store/models/metadata.model'; +import { LoadBlueprintSuccess } from 'src/app/common/core/store/actions/blueprint.action'; + +@Component({ + selector: 'app-metadata', + templateUrl: './metadata.component.html', + styleUrls: ['./metadata.component.scss'] +}) +export class MetadataComponent implements OnInit { + CBAMetadataForm: FormGroup; + metadata: IMetaData; + bpState: Observable<IBlueprintState>; + blueprint: IBlueprint; + + constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) { + this.bpState = this.store.select('blueprint'); + this.CBAMetadataForm = this.formBuilder.group({ + template_author: ['', Validators.required], + author_email: ['', Validators.required], + user_groups: ['', Validators.required], + template_name: ['', Validators.required], + template_version: ['', Validators.required], + template_tags: ['', Validators.required] + }); + } + + ngOnInit() { + this.bpState.subscribe( + blueprintdata => { + var blueprintState: IBlueprintState = { blueprint: blueprintdata.blueprint, isLoadSuccess: blueprintdata.isLoadSuccess, isSaveSuccess: blueprintdata.isSaveSuccess, isUpdateSuccess: blueprintdata.isUpdateSuccess }; + this.metadata = blueprintState.blueprint.metadata; + this.blueprint = blueprintState.blueprint; + let metadatavalues = []; + for (let key in this.metadata) { + if (this.metadata.hasOwnProperty(key)) { + metadatavalues.push(this.metadata[key]); + } + } + let temp_author = metadatavalues[0]; + console.log(temp_author); + this.CBAMetadataForm = this.formBuilder.group({ + template_author: [metadatavalues[0], Validators.required], + author_email: [metadatavalues[1], Validators.required], + user_groups: [metadatavalues[2], Validators.required], + template_name: [metadatavalues[3], Validators.required], + template_version: [metadatavalues[4], Validators.required], + template_tags: [metadatavalues[5], Validators.required] + }); + }) + } + + UploadMetadata() { + this.metadata = Object.assign({}, this.CBAMetadataForm.value); + this.blueprint.metadata = this.metadata; + this.store.dispatch(new LoadBlueprintSuccess(this.blueprint)); + } + +}
\ No newline at end of file |