Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
IBM602-PC0F1E3C\Arundathi | f7b02a1 | 2018-07-10 17:16:08 +0530 | [diff] [blame] | 5 | |
| 6 | Copyright (C) 2018 IBM Intellectual Property. All rights reserved. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 7 | =================================================================== |
| 8 | |
| 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 |
| 13 | |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 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 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 22 | ============LICENSE_END============================================ |
| 23 | */ |
| 24 | |
| 25 | import { Component, OnInit } from '@angular/core'; |
| 26 | import { Router } from '@angular/router'; |
| 27 | import * as _ from 'underscore'; |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 28 | import { NotificationsService } from 'angular2-notifications'; |
IBM602-PC0F1E3C\Arundathi | f7b02a1 | 2018-07-10 17:16:08 +0530 | [diff] [blame] | 29 | import { appConstants } from '../../../constants/app-constants'; |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 30 | |
Lukasz Rajewski | c63fafc | 2019-03-16 18:18:14 +0100 | [diff] [blame] | 31 | export const ACTIONS_REQUIRED_DROPDOWN = ['Configure', 'ConfigModify', 'ConfigScaleOut', 'DistributeTraffic', 'DistributeTrafficCheck'] |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 32 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 33 | |
| 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; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 38 | public refDataRequiredFiels: boolean = false; |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 39 | public refList; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 40 | |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 41 | constructor (private router: Router, private notificationsService: NotificationsService) { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | ngOnInit() { |
IBM602-PC0F1E3C\Arundathi | f7b02a1 | 2018-07-10 17:16:08 +0530 | [diff] [blame] | 45 | this.tabs = appConstants.tabs; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 46 | } |
| 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 | } |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 73 | |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 74 | public getRefData(referenceList, reqObj?) { |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 75 | this.refList = referenceList; |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 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') { |
| 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) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 94 | } |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 95 | else this.refDataRequiredFiels = true; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 96 | } |
| 97 | else { |
asgar | af56b68 | 2019-03-08 19:52:33 +0530 | [diff] [blame] | 98 | this.refDataRequiredFiels = false; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | |
IBM602-PC0F1E3C\Arundathi | f7b02a1 | 2018-07-10 17:16:08 +0530 | [diff] [blame] | 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); |
| 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) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 120 | } |