blob: 4e003417fe87c3a1febaf96a1b02fe1a6bb56aa4 [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
IBM602-PC0F1E3C\Arundathif7b02a12018-07-10 17:16:08 +05305
6Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
Skip Wonnell2c977e22018-03-01 08:30:15 -06007===================================================================
8
9Unless otherwise specified, all software contained herein is licensed
10under the Apache License, Version 2.0 (the License);
11you may not use this software except in compliance with the License.
12You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing, software
17distributed under the License is distributed on an "AS IS" BASIS,
18WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19See the License for the specific language governing permissions and
20limitations under the License.
21
Skip Wonnell2c977e22018-03-01 08:30:15 -060022============LICENSE_END============================================
23*/
24
25import { Component, OnInit } from '@angular/core';
26import { Router } from '@angular/router';
27import * as _ from 'underscore';
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053028import { NotificationsService } from 'angular2-notifications';
IBM602-PC0F1E3C\Arundathif7b02a12018-07-10 17:16:08 +053029import { appConstants } from '../../../constants/app-constants';
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053030
Lukasz Rajewskic63fafc2019-03-16 18:18:14 +010031export const ACTIONS_REQUIRED_DROPDOWN = ['Configure', 'ConfigModify', 'ConfigScaleOut', 'DistributeTraffic', 'DistributeTrafficCheck']
asgaraf56b682019-03-08 19:52:33 +053032
Skip Wonnell2c977e22018-03-01 08:30:15 -060033
34@Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] })
35export class BuildDesignComponent implements OnInit {
36 tabs: Array<Object> = [];
37 private allowOtherUpdates: boolean = true;
sj108sf27d5542018-04-02 14:46:25 +053038 public refDataRequiredFiels: boolean = false;
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053039 public refList;
Skip Wonnell2c977e22018-03-01 08:30:15 -060040
asgaraf56b682019-03-08 19:52:33 +053041 constructor (private router: Router, private notificationsService: NotificationsService) {
Skip Wonnell2c977e22018-03-01 08:30:15 -060042 }
43
44 ngOnInit() {
IBM602-PC0F1E3C\Arundathif7b02a12018-07-10 17:16:08 +053045 this.tabs = appConstants.tabs;
Skip Wonnell2c977e22018-03-01 08:30:15 -060046 }
47
48 public setAllowOtherUpdates(allowOtherUpdates: boolean) {
49 this.allowOtherUpdates = allowOtherUpdates;
50 }
51
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);
57 } else {
58 //alert("false")
59 this.setAllowOtherUpdates(false);
60 }
61 }
62
63 public isReferenceFound(selectedAction, referenceList) {
64 let selectedActioneObject = _.find(referenceList, function (obj) {
65 return obj['action'] == selectedAction;
66 });
67 if (selectedActioneObject) {
68 return true;
69 } else {
70 return false;
71 }
72 }
sj108sf27d5542018-04-02 14:46:25 +053073
asgaraf56b682019-03-08 19:52:33 +053074 public getRefData(referenceList, reqObj?) {
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053075 this.refList = referenceList;
asgaraf56b682019-03-08 19:52:33 +053076 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') {
84 if(reqObj != undefined && reqObj.hasOwnProperty('reqField') && reqObj.reqField != '') this.refDataRequiredFiels = true;
85 else this.refDataRequiredFiels = false;
86 }
87
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;
91 // }
92
93 else this.refDataRequiredFiels = true;
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053094 }
asgaraf56b682019-03-08 19:52:33 +053095 else this.refDataRequiredFiels = true;
sj108sf27d5542018-04-02 14:46:25 +053096 }
97 else {
asgaraf56b682019-03-08 19:52:33 +053098 this.refDataRequiredFiels = false;
sj108sf27d5542018-04-02 14:46:25 +053099 }
100 }
101
IBM602-PC0F1E3C\Arundathif7b02a12018-07-10 17:16:08 +0530102 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);
105 }
106 else if (this.refList.action == appConstants.Actions.blank) {
107 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noActionError);
108 }
109 else if (this.refList.scope['vnf-type'] == '') {
110 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noVnfTypeError);
111 }
112 else if (this.refList['device-protocol'] == appConstants.DeviceProtocols.blank) {
113 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noDeviceProtocolError);
114 }
115 else if (this.refList.action === appConstants.Actions.configScaleOut) {
116 this.notificationsService.error(appConstants.errors.error, appConstants.errors.noValidTemplateIdentifierError);
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +0530117 }
118 }
119
Skip Wonnell2c977e22018-03-01 08:30:15 -0600120}