2 * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var app = angular.module('RegisterBlueprintInstance');
20 'RegisterBlueprintInstanceController',
21 function($scope, restAPISvc) {
25 function initialize() {
26 $scope.loadingBlueprints = true;
27 $scope.loadingLayers = true;
28 $scope.blueprints = [];
29 $scope.blueprintInfos = [];
31 $scope.layerInfos = [];
32 $scope.selectedLayer = '';
33 $scope.configuredLayers = [];
39 $scope.blueprintInfos = data;
46 .push(blueprint.blueprintName);
53 $scope.layerInfos = data2;
60 .indexOf(layer.layer) === -1) {
66 confirm("No layers found");
71 confirm("No blueprints found");
73 $scope.loadingBlueprints = false;
74 $scope.loadingLayers = false;
78 $scope.addConfiguredLayer = function(configuredLayer) {
79 if ($scope.configuredLayers.indexOf(configuredLayer
81 $scope.configuredLayers.push(configuredLayer);
85 $scope.deleteConfiguredLayer = function(index) {
86 $scope.configuredLayers.splice(index, 1);
89 $scope.register = function() {
90 if (!$scope.selectedBlueprint || !$scope.definedVersion
91 || !$scope.configuredLayers
92 || $scope.configuredLayers.length === 0) {
93 confirm("You must specify all the fields");
99 $scope.blueprintInfos,
100 function(blueprintInfo) {
101 if (blueprintInfo.blueprintName
102 .toString().trim() === $scope.selectedBlueprint
103 .toString().trim()) {
104 blueprint = blueprintInfo;
108 confirm("Error in blueprint data");
111 var blueprintLayers = [];
112 angular.forEach($scope.layerInfos, function(layerInfo) {
113 if ($scope.configuredLayers
114 .indexOf(layerInfo.layer) !== -1) {
115 blueprintLayers.push(layerInfo);
118 if (!blueprintLayers || blueprintLayers.length === 0) {
119 confirm("Error in blueprint layers data");
122 var blueprintInstance = {
123 "blueprint" : blueprint,
124 "version" : $scope.definedVersion,
125 "blueprintLayers" : blueprintLayers
129 "/api/v1/blueprintinstance/",
133 var confirmText = "The blueprint instance has been registered successfully. Blueprint instance id:"
134 + data.blueprintInstanceId;
135 confirm(confirmText);
137 confirm("Error when registering the blueprint instance");