2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
7 ===================================================================
9 Unless otherwise specified, all software contained herein is licensed
10 under the Apache License, Version 2.0 (the License);
11 you may not use this software 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.
22 ============LICENSE_END============================================
25 import { Component, OnInit } from '@angular/core';
26 import { Router } from '@angular/router';
27 import * as _ from 'underscore';
28 import { NotificationsService } from 'angular2-notifications';
29 import { appConstants } from '../../../constants/app-constants';
31 export const ACTIONS_REQUIRED_DROPDOWN = ['Configure', 'ConfigModify', 'ConfigScaleOut', 'DistributeTraffic', 'DistributeTrafficCheck', 'ConfigScaleIn']
34 @Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] })
35 export class BuildDesignComponent implements OnInit {
36 tabs: Array<Object> = [];
37 private allowOtherUpdates: boolean = true;
38 public refDataRequiredFiels: boolean = false;
41 constructor (private router: Router, private notificationsService: NotificationsService) {
45 this.tabs = appConstants.tabs;
48 public setAllowOtherUpdates(allowOtherUpdates: boolean) {
49 this.allowOtherUpdates = allowOtherUpdates;
52 // Allow / block access to the update pages of GT and PD if no reference data present
53 public updateAccessUpdatePages(selectedAction, referenceList) {
54 // Disable/enable the menu items for update pages of GT and PD.
55 if (this.isReferenceFound(selectedAction, referenceList)) {
56 this.setAllowOtherUpdates(true);
59 this.setAllowOtherUpdates(false);
63 public isReferenceFound(selectedAction, referenceList) {
64 let selectedActioneObject = _.find(referenceList, function (obj) {
65 return obj['action'] == selectedAction;
67 if (selectedActioneObject) {
74 public getRefData(referenceList, reqObj?) {
75 this.refList = referenceList;
76 if (referenceList.action !== '' && referenceList.scope['vnf-type'] !== '' && referenceList['device-protocol'] !== '') {
77 if(ACTIONS_REQUIRED_DROPDOWN.indexOf(referenceList.action) > -1) {
78 //if (referenceList.action === 'ConfigScaleOut') {
79 //console.log(typeof reqObj, selectedIdentifier)
80 // if (referenceList.hasOwnProperty('template-id') && referenceList['template-id'] !== undefined && referenceList['template-id'] != '')
81 // this.refDataRequiredFiels = true;
82 // else this.refDataRequiredFiels = false;
83 if(referenceList.action == 'ConfigScaleOut' || referenceList.action == 'ConfigScaleIn') {
84 if(reqObj != undefined && reqObj.hasOwnProperty('reqField') && reqObj.reqField != '') this.refDataRequiredFiels = true;
85 else this.refDataRequiredFiels = false;
88 // else if( referenceList.action == 'Configure' || referenceList.action == 'ConfigModify' ) {
89 // if(referenceList.displayVnfc == 'false') this.refDataRequiredFiels = true;
90 // else if( referenceList.displayVnfc != 'false' && referenceList.vnfcIdentifier ) this.refDataRequiredFiels = true;
93 else this.refDataRequiredFiels = true;
95 else this.refDataRequiredFiels = true;
98 this.refDataRequiredFiels = false;
102 public checkRefDataReqFields() {
103 if (this.refList.action == appConstants.Actions.blank && this.refList.scope['vnf-type'] == '' && this.refList['device-protocol'] == appConstants.DeviceProtocols.blank) {
104 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noActionVnfProtocolError);
106 else if (this.refList.action == appConstants.Actions.blank) {
107 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noActionError);
109 else if (this.refList.scope['vnf-type'] == '') {
110 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noVnfTypeError);
112 else if (this.refList['device-protocol'] == appConstants.DeviceProtocols.blank) {
113 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noDeviceProtocolError);
115 else if (this.refList.action === appConstants.Actions.configScaleOut || this.refList.action === appConstants.Actions.configScaleIn) {
116 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noValidTemplateIdentifierError);