2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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=========================================================
21 import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
22 import { SdcUiCommon, SdcUiServices } from 'onap-ui-angular';
23 import { Subject } from 'rxjs/Rx';
24 import { ArtifactModel } from '../../../../models/artifacts';
25 import { CacheService } from '../../../services/cache.service';
27 export interface IPoint {
33 selector: 'env-params',
34 templateUrl: './env-params.component.html',
35 styleUrls: ['../../../../../assets/styles/table-style.less', './env-params.component.less']
37 export class EnvParamsComponent implements OnInit {
39 @Input() public artifact: ArtifactModel;
40 @Input() public isInstanceSelected: boolean;
41 @Input() public isViewOnly: boolean;
43 @ViewChild('textArea') textArea: ElementRef;
44 private copiedWorkingArtifactHeatParameters = [];
45 private onValidationChange: Subject<boolean> = new Subject();
46 private displayRegexValid = SdcUiCommon.RegexPatterns.numberOrEmpty;
48 // Deployment timeout in minutes
49 private maxDeploymentTimeout: number = 120;
50 private minDeploymentTimeout: number = 1;
51 private defaultDeploymentTimeout: number = 60;
53 constructor(private cacheService: CacheService, private popoverService: SdcUiServices.PopoverService) {
54 const configuration = cacheService.get('UIConfiguration');
55 if (configuration && configuration.heatDeploymentTimeout) {
56 this.maxDeploymentTimeout = configuration.heatDeploymentTimeout.maxMinutes;
57 this.minDeploymentTimeout = configuration.heatDeploymentTimeout.minMinutes;
58 this.defaultDeploymentTimeout = configuration.heatDeploymentTimeout.defaultMinutes;
63 this.copiedWorkingArtifactHeatParameters = [...this.artifact.heatParameters];
66 public clearCurrentValue = (name: string) => {
67 this.artifact.heatParameters.filter((param) => param.name === name)[0].currentValue = '';
70 public timeoutChanged(timeout) {
71 this.artifact.timeout = timeout;
75 const val = event.target.value.toLowerCase();
77 const temp = this.copiedWorkingArtifactHeatParameters.filter((param) => {
78 return !val || param.name ? param.name.toLowerCase().indexOf(val) !== -1 : -1 || param.currentValue ? param.currentValue.toLowerCase().indexOf(val) !== -1 : -1;
81 this.artifact.heatParameters = temp;
84 private openPopOver = (title: string, content: string, positionOnPage: IPoint, location: string) => {
85 this.popoverService.createPopOver(title, content, positionOnPage, location);
88 private onValidityChange = (isValid: boolean): void => {
89 this.onValidationChange.next(isValid);