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.blueprintNames = [];
28 $scope.blueprintVersions = [];
29 $scope.blueprintLayers = [];
30 $scope.optionals = [];
31 $scope.selectedBlueprintName = {};
32 $scope.selectedBlueprintVersion = {};
33 $scope.selectedBlueprintLayer = {};
34 $scope.selectedOptional = "";
37 "/api/v1/blueprintinstance/",
39 $scope.blueprintInstances = data;
42 $scope.blueprintInstances,
45 if ($scope.blueprintNames
46 .indexOf(blueprintInstance["blueprint"]["blueprintName"]
49 .push(blueprintInstance["blueprint"]["blueprintName"]
54 restAPISvc.getRestAPI("/api/v1/timeslots/", function(
56 $scope.timeslots = data;
57 $scope.declerativeTimeslots = [];
58 angular.forEach($scope.timeslots,
60 var temp = "id: " + timeslot.timeslotId
61 + " Start date and time: "
62 + timeslot.startDateTime
64 * + " duration(in sec) :" +
65 * blueprintInstance["timeslot"].duration
68 + timeslot.labInfo.lab;
69 $scope.declerativeTimeslots.push(temp);
74 $scope.selectedBlueprintNameChange = function() {
75 $scope.blueprintVersions = [];
76 $scope.blueprintLayers = [];
77 $scope.optionals = [];
78 $scope.selectedBlueprintVersion = {};
79 $scope.selectedBlueprintLayer = {};
80 $scope.selectedOptional = "";
83 $scope.blueprintInstances,
84 function(blueprintInstance) {
85 if ($scope.selectedBlueprintName
86 .trim() === blueprintInstance["blueprint"]["blueprintName"]
88 if ($scope.blueprintVersions
89 .indexOf(blueprintInstance["version"]
91 $scope.blueprintVersions
92 .push(blueprintInstance["version"]
98 $scope.selectedBlueprintVersionChange = function() {
99 if (!$scope.selectedBlueprintName) {
102 $scope.blueprintLayers = [];
103 $scope.optionals = [];
104 $scope.selectedBlueprintLayer = {};
105 $scope.selectedOptional = "";
108 $scope.blueprintInstances,
109 function(blueprintInstance) {
110 if ($scope.selectedBlueprintName
111 .trim() === blueprintInstance["blueprint"]["blueprintName"]
113 if ($scope.selectedBlueprintVersion
114 .trim() === blueprintInstance["version"]
118 blueprintInstance.blueprintLayers,
121 $scope.blueprintLayers
127 $scope.blueprintLayers.push("all");
130 $scope.selectedBlueprintLayerChange = function() {
131 $scope.optionals = [ 'true', 'false' ];
134 $scope.submit = function() {
135 if (!$scope.selectedBlueprintName
136 || !$scope.selectedBlueprintVersion
137 || !$scope.selectedBlueprintLayer
138 || !$scope.selectedOptional
139 || !$scope.selectedDeclerativeTimeslot) {
140 confirm("You must specify all data fields");
144 var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot
146 $scope.selectedDeclerativeTimeslot
148 $scope.selectedDeclerativeTimeslot
149 .indexOf("Start date and time:") - 1);
154 if (selectedDeclerativeTimeslotId
155 .toString().trim() === timeslot.timeslotId
156 .toString().trim()) {
157 finalTimeslot = timeslot;
160 var allLayers = "false";
161 if ($scope.selectedBlueprintLayer === 'all') {
164 var wrobotTestResults = [];
165 if (allLayers === "false") {
166 wrobotTestResults = [ {
167 "layer" : $scope.selectedBlueprintLayer
171 var blueprintInstanceData = "";
174 $scope.blueprintInstances,
175 function(blueprintInstance) {
176 if ($scope.selectedBlueprintName
177 .trim() === blueprintInstance["blueprint"]["blueprintName"]
179 if ($scope.selectedBlueprintVersion
180 .trim() === blueprintInstance["version"]
182 blueprintInstanceData = blueprintInstance;
186 var validationDbTestResult = {
187 "blueprintInstance" : blueprintInstanceData,
188 "allLayers" : allLayers,
189 "wrobotDbTestResults" : wrobotTestResults,
190 "optional" : $scope.selectedOptional,
191 "lab" : finalTimeslot.labInfo
194 "validationDbTestResult" : validationDbTestResult,
195 "timeslot" : finalTimeslot
199 "/api/v1/submission/",
203 var confirmText = "The blueprint instance for validation has been submitted successfully. Submission id:"
205 confirm(confirmText);
207 confirm("Error when committing the submission");
210 $scope.selectedBlueprintName = {};
211 $scope.selectedBlueprintVersion = {};
212 $scope.selectedBlueprintLayer = {};
213 $scope.selectedOptional = "";
214 $scope.selectedDeclerativeTimeslot = {};