2 * Created by ob0695 on 4/18/2018.
5 * ============LICENSE_START=======================================================
7 * ================================================================================
8 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 import {Component, Input, Inject, forwardRef} from "@angular/core";
25 import {TranslateService} from "../../shared/translator/translate.service";
26 import {ServiceContainerToUpgradeUiObject} from "./automated-upgrade-models/ui-component-to-upgrade";
27 import {AutomatedUpgradeService} from "./automated-upgrade.service";
30 selector: 'upgrade-vsp',
31 templateUrl: './automated-upgrade.component.html',
32 styleUrls: ['./automated-upgrade.component.less']
34 export class AutomatedUpgradeComponent {
36 @Input() componentsToUpgrade: Array<ServiceContainerToUpgradeUiObject>;
37 @Input() certificationStatusText: string;
38 @Input() informationText: string;
39 @Input() disabled: string;
40 private selectedComponentsToUpgrade: Array<string> = [];
42 constructor (@Inject(forwardRef(() => AutomatedUpgradeService)) private automatedUpgradeService: AutomatedUpgradeService) {
45 ngOnInit(): void { // We need to check all elements that needed upgrade as default
46 this.selectedComponentsToUpgrade = _.filter(this.componentsToUpgrade, (componentToUpgrade:ServiceContainerToUpgradeUiObject) => {
47 return !componentToUpgrade.isAlreadyUpgrade && !componentToUpgrade.isLock;
48 }).map(element => element.uniqueId)
51 onComponentSelected = (uniqueId:string):void => {
53 if(this.selectedComponentsToUpgrade.indexOf(uniqueId) > -1) {
54 this.selectedComponentsToUpgrade = _.without(this.selectedComponentsToUpgrade, uniqueId);
56 this.selectedComponentsToUpgrade.push(uniqueId);
58 if(this.selectedComponentsToUpgrade.length === 0) {
59 this.automatedUpgradeService.changeUpgradeButtonState(true);
61 this.automatedUpgradeService.changeUpgradeButtonState(false);