2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
20 import { Component, OnInit, Inject } from '@angular/core';
21 import { FormBuilder, FormGroup, Validators } from '@angular/forms';
22 import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
23 import { Store } from '@ngrx/store';
24 import { Observable } from 'rxjs';
26 import { ICatalog } from 'src/app/common/core/store/models/catalog.model';
27 import { ICatalogState } from 'src/app/common/core/store/models/catalogState.model';
28 import { IAppState } from 'src/app/common/core/store/state/app.state';
31 selector: 'app-catalog-data-dialog',
32 templateUrl: './catalog-data-dialog.component.html',
33 styleUrls: ['./catalog-data-dialog.component.scss']
35 export class CatalogDataDialogComponent implements OnInit{
39 CatalogFormData: FormGroup;
40 ccState: Observable<ICatalogState>;
41 isDisabled: boolean=true;
42 optionSelected:string;
43 // derivedFrom: any[] = [{derivedFrom: 'tosca.nodes.Component'},{derivedFrom:'tosca.nodes.VNF'},{derivedFrom:'tosca.nodes.Artifact'},{derivedFrom:'tosca.nodes.ResourceSource'}, {derivedFrom:'tosca.nodes.Workflow'},{derivedFrom:'tosca.nodes.Root'}];
44 // definitionType: any[] = [{definitionType: 'node_type'}];
46 constructor(public dialogRef: MatDialogRef<CatalogDataDialogComponent>, @Inject(MAT_DIALOG_DATA) public item: any,private formBuilder: FormBuilder, private store: Store<IAppState> ) {
48 this.optionSelected=item['option'];
49 for (let key in item['item']) {
50 this.catalog.push(item['item'][key]);
52 console.log(this.catalog);
53 for (let key in this.catalog) {
54 this.property.push(this.catalog[key]);
56 if(this.optionSelected == 'Info'){
57 this.isDisabled = true;
60 this.isDisabled = false;
63 this.ccState = this.store.select('catalog');
64 this.CatalogFormData = this.formBuilder.group({
65 modelName: [{value:this.property[0], disabled: this.isDisabled}, Validators.required],
66 derivedFrom: [{value:this.property[1], disabled: this.isDisabled}, Validators.required],
67 definitionType: [{value:this.property[2], disabled: this.isDisabled}, Validators.required],
68 definition: [{value:JSON.stringify(this.property[3]), disabled: this.isDisabled}, Validators.required],
69 tags: [{value:this.property[6], disabled: this.isDisabled}, Validators.required],
70 updatedBy: [{value:this.property[8], disabled: this.isDisabled}, Validators.required],
78 this.dialogRef.close();
82 //this.catalog = Object.assign({}, this.CatalogFormData.value);
83 this.dialogRef.close(this.CatalogFormData.value);