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('NewSubmission');
20 'NewSubmissionController',
21 function($scope, restAPISvc) {
25 function initialize() {
26 $scope.blueprintInstances = [];
27 $scope.blueprintInstance = '';
28 $scope.blueprintNames = [];
29 $scope.blueprintVersions = [];
30 $scope.declerativeTimeslots = [];
31 $scope.blueprintLayers = [];
32 $scope.optionals = [];
33 $scope.selectedBlueprintName = '';
34 $scope.selectedBlueprintVersion = '';
35 $scope.selectedDeclerativeTimeslot = '';
36 $scope.selectedBlueprintLayer = '';
37 $scope.selectedOptional = '';
40 "/api/v1/blueprintinstance/",
42 $scope.blueprintInstances = data;
45 $scope.blueprintInstances,
48 if ($scope.blueprintNames
49 .indexOf(blueprintInstance["blueprint"]["blueprintName"]
52 .push(blueprintInstance["blueprint"]["blueprintName"]
58 $scope.selectedBlueprintNameChange = function() {
59 $scope.blueprintInstance = '';
60 $scope.blueprintVersions = [];
61 $scope.declerativeTimeslots = [];
62 $scope.blueprintLayers = [];
63 $scope.optionals = [];
64 $scope.selectedBlueprintVersion = '';
65 $scope.selectedDeclerativeTimeslot = '';
66 $scope.selectedBlueprintLayer = '';
67 $scope.selectedOptional = '';
70 $scope.blueprintInstances,
71 function(blueprintInstance) {
72 if ($scope.selectedBlueprintName
73 .trim() === blueprintInstance["blueprint"]["blueprintName"]
75 if ($scope.blueprintVersions
76 .indexOf(blueprintInstance["version"]
78 $scope.blueprintVersions
79 .push(blueprintInstance["version"]
85 $scope.selectedBlueprintVersionChange = function() {
86 if (!$scope.selectedBlueprintName) {
89 $scope.blueprintInstance = '';
90 $scope.declerativeTimeslots = [];
91 $scope.blueprintLayers = [];
92 $scope.optionals = [];
93 $scope.selectedDeclerativeTimeslot = '';
94 $scope.selectedBlueprintLayer = '';
95 $scope.selectedOptional = '';
98 $scope.blueprintInstances,
99 function(blueprintInstance) {
100 if ($scope.selectedBlueprintName
101 .trim() === blueprintInstance["blueprint"]["blueprintName"]
103 if ($scope.selectedBlueprintVersion
104 .trim() === blueprintInstance["version"]
106 $scope.blueprintInstance = blueprintInstance;
110 if (!$scope.blueprintInstance
111 || !$scope.blueprintInstance.timeslots
112 || $scope.blueprintInstance.timeslots.length === 0) {
113 confirm("No available timeslots for this blueprint instance in this lab");
116 angular.forEach($scope.blueprintInstance.timeslots,
118 var temp = "id: " + timeslot.timeslotId
119 + " Start date and time: "
120 + timeslot.startDateTime
122 * + " duration(in sec) :" +
123 * blueprintInstance["timeslot"].duration
125 + " lab :" + timeslot.labInfo.lab;
126 $scope.declerativeTimeslots.push(temp);
130 $scope.selectedDeclerativeTimeslotChange = function() {
131 $scope.blueprintLayers = [];
132 $scope.optionals = [];
133 $scope.selectedBlueprintLayer = {};
134 $scope.selectedOptional = "";
136 $scope.blueprintInstance.blueprintLayers,
138 $scope.blueprintLayers.push(layer.layer);
140 $scope.blueprintLayers.push("all");
143 $scope.selectedBlueprintLayerChange = function() {
144 $scope.optionals = [];
145 $scope.selectedOptional = "";
146 $scope.optionals = [ 'true', 'false' ];
149 $scope.submit = function() {
150 if (!$scope.selectedBlueprintName
151 || !$scope.selectedBlueprintVersion
152 || !$scope.blueprintInstance
153 || !$scope.selectedBlueprintLayer
154 || !$scope.selectedOptional
155 || !$scope.selectedDeclerativeTimeslot) {
156 confirm("You must specify all data fields");
160 var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot
162 $scope.selectedDeclerativeTimeslot
164 $scope.selectedDeclerativeTimeslot
165 .indexOf("Start date and time:") - 1);
168 $scope.blueprintInstance.timeslots,
170 if (selectedDeclerativeTimeslotId
171 .toString().trim() === timeslot.timeslotId
172 .toString().trim()) {
173 finalTimeslot = timeslot;
176 var allLayers = "false";
177 if ($scope.selectedBlueprintLayer === 'all') {
180 var wrobotTestResults = [];
181 if (allLayers === "false") {
182 wrobotTestResults = [ {
183 "layer" : $scope.selectedBlueprintLayer
187 var validationDbTestResult = {
188 "blueprintInstance" : $scope.blueprintInstance,
189 "allLayers" : allLayers,
190 "wrobotDbTestResults" : wrobotTestResults,
191 "optional" : $scope.selectedOptional,
192 "lab" : finalTimeslot.labInfo
195 "validationDbTestResult" : validationDbTestResult,
196 "timeslot" : finalTimeslot
200 "/api/v1/submission/",
204 var confirmText = "The blueprint instance for validation has been submitted successfully. Submission id:"
206 confirm(confirmText);
208 confirm("Error when committing the submission");
211 $scope.selectedBlueprintName = '';
212 $scope.selectedBlueprintVersion = '';
213 $scope.selectedBlueprintLayer = '';
214 $scope.selectedOptional = "";
215 $scope.selectedDeclerativeTimeslot = '';
216 $scope.blueprintInstance = '';