blob: ba887173ee4702c8ffbf0c0f186ef2bfa5c42109 [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.
5===================================================================
6
7Unless otherwise specified, all software contained herein is licensed
8under the Apache License, Version 2.0 (the License);
9you may not use this software except in compliance with the License.
10You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14Unless required by applicable law or agreed to in writing, software
15distributed under the License is distributed on an "AS IS" BASIS,
16WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17See the License for the specific language governing permissions and
18limitations under the License.
19
Skip Wonnell2c977e22018-03-01 08:30:15 -060020============LICENSE_END============================================
21*/
22
23import { Component, OnInit } from '@angular/core';
24import { Router } from '@angular/router';
25import * as _ from 'underscore';
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053026import { NotificationsService } from 'angular2-notifications';
27
Skip Wonnell2c977e22018-03-01 08:30:15 -060028
29@Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] })
30export class BuildDesignComponent implements OnInit {
31 tabs: Array<Object> = [];
32 private allowOtherUpdates: boolean = true;
sj108sf27d5542018-04-02 14:46:25 +053033 public refDataRequiredFiels: boolean = false;
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053034 public refList;
Skip Wonnell2c977e22018-03-01 08:30:15 -060035
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053036 constructor (private router: Router, private notificationsService: NotificationsService) {
Skip Wonnell2c977e22018-03-01 08:30:15 -060037 }
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 }
sj108sf27d5542018-04-02 14:46:25 +053085
86 public getRefData(referenceList) {
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +053087 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;
sj108sf27d5542018-04-02 14:46:25 +053094 }
95 else {
96 this.refDataRequiredFiels = false;
97 }
98 }
99
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +0530100 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 Wonnell2c977e22018-03-01 08:30:15 -0600118}