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. |
| 5 | =================================================================== |
| 6 | |
| 7 | Unless otherwise specified, all software contained herein is licensed |
| 8 | under the Apache License, Version 2.0 (the License); |
| 9 | you may not use this software except in compliance with the License. |
| 10 | You may obtain a copy of the License at |
| 11 | |
| 12 | http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | |
| 14 | Unless required by applicable law or agreed to in writing, software |
| 15 | distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | See the License for the specific language governing permissions and |
| 18 | limitations under the License. |
| 19 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 20 | ============LICENSE_END============================================ |
| 21 | */ |
| 22 | |
| 23 | import { Component, OnInit } from '@angular/core'; |
| 24 | import { Router } from '@angular/router'; |
| 25 | import * as _ from 'underscore'; |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame^] | 26 | import { NotificationsService } from 'angular2-notifications'; |
| 27 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 28 | |
| 29 | @Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] }) |
| 30 | export class BuildDesignComponent implements OnInit { |
| 31 | tabs: Array<Object> = []; |
| 32 | private allowOtherUpdates: boolean = true; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 33 | public refDataRequiredFiels: boolean = false; |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame^] | 34 | public refList; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 35 | |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame^] | 36 | constructor (private router: Router, private notificationsService: NotificationsService) { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | ngOnInit() { |
| 40 | this.tabs = [ |
| 41 | { |
| 42 | type: 'dropdown', |
| 43 | name: 'Reference Data', |
| 44 | url: 'references', |
| 45 | }, { |
| 46 | name: 'Template', |
| 47 | type: 'dropdown', |
| 48 | url: 'templates/myTemplates', |
| 49 | }, { |
| 50 | name: 'Parameter Definition', |
| 51 | type: 'dropdown', |
| 52 | url: 'parameterDefinitions/create' |
| 53 | } /*, { |
| 54 | name: "Test", |
| 55 | url: 'test', |
| 56 | }*/ |
| 57 | ]; |
| 58 | } |
| 59 | |
| 60 | public setAllowOtherUpdates(allowOtherUpdates: boolean) { |
| 61 | this.allowOtherUpdates = allowOtherUpdates; |
| 62 | } |
| 63 | |
| 64 | // Allow / block access to the update pages of GT and PD if no reference data present |
| 65 | public updateAccessUpdatePages(selectedAction, referenceList) { |
| 66 | // Disable/enable the menu items for update pages of GT and PD. |
| 67 | if (this.isReferenceFound(selectedAction, referenceList)) { |
| 68 | this.setAllowOtherUpdates(true); |
| 69 | } else { |
| 70 | //alert("false") |
| 71 | this.setAllowOtherUpdates(false); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | public isReferenceFound(selectedAction, referenceList) { |
| 76 | let selectedActioneObject = _.find(referenceList, function (obj) { |
| 77 | return obj['action'] == selectedAction; |
| 78 | }); |
| 79 | if (selectedActioneObject) { |
| 80 | return true; |
| 81 | } else { |
| 82 | return false; |
| 83 | } |
| 84 | } |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 85 | |
| 86 | public getRefData(referenceList) { |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame^] | 87 | this.refList = referenceList; |
| 88 | if(referenceList.action !== '' && referenceList.scope['vnf-type'] !== '' && referenceList['device-protocol'] !== '') { |
| 89 | if(referenceList.action === 'ConfigScaleOut') { |
| 90 | if(referenceList.hasOwnProperty('template-id') && referenceList['template-id'] !== undefined && referenceList['template-id'] != '') |
| 91 | this.refDataRequiredFiels = true; |
| 92 | } |
| 93 | else this.refDataRequiredFiels = true; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 94 | } |
| 95 | else { |
| 96 | this.refDataRequiredFiels = false; |
| 97 | } |
| 98 | } |
| 99 | |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame^] | 100 | public checkRefDataReqFields() { |
| 101 | if(this.refList.action == '' && this.refList.scope['vnf-type'] == '' && this.refList['device-protocol'] == '') { |
| 102 | this.notificationsService.error('Error', 'Select Valid Action, VNF Type, Device Protocol'); |
| 103 | } |
| 104 | else if(this.refList.action == '') { |
| 105 | this.notificationsService.error('Error', 'Select a valid Action'); |
| 106 | } |
| 107 | else if(this.refList.scope['vnf-type'] == '') { |
| 108 | this.notificationsService.error('Error', 'Select a valid VNF Type'); |
| 109 | } |
| 110 | else if(this.refList['device-protocol'] == '') { |
| 111 | this.notificationsService.error('Error', 'Select a valid Device Protocol'); |
| 112 | } |
| 113 | else if (this.refList.action === 'ConfigScaleOut') { |
| 114 | this.notificationsService.error('Error', 'Select a valid Template Identifier'); |
| 115 | } |
| 116 | } |
| 117 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 118 | } |