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() {
28 "/api/v1/blueprintinstanceforvalidation/",
30 $scope.blueprintInstancesForValidation = data;
31 $scope.blueprintNames = [];
34 $scope.blueprintInstancesForValidation,
37 if ($scope.blueprintNames
38 .indexOf(blueprintInstance["blueprint"]["blueprintName"]) === -1) {
40 .push(blueprintInstance["blueprint"]["blueprintName"]);
44 restAPISvc.getRestAPI("/api/v1/timeslots/", function(
46 $scope.timeslots = data;
47 $scope.declerativeTimeslots = [];
48 angular.forEach($scope.timeslots,
50 var temp = "id: " + timeslot.timeslotId
51 + " Start date and time: "
52 + timeslot.startDateTime
54 * + " duration(in sec) :" +
55 * blueprintInstance["timeslot"].duration
57 + " lab :" + timeslot.lab.lab;
58 $scope.declerativeTimeslots.push(temp);
62 $scope.selectedBluePrintNameChange = function() {
63 $scope.blueprintVersions = [];
64 $scope.blueprintLayers = [];
65 $scope.optionals = [];
66 $scope.selectedBlueprintVersion = {};
67 $scope.selectedBlueprintLayer = {};
68 $scope.selectedOptional = "";
71 $scope.blueprintInstancesForValidation,
72 function(blueprintInstance) {
73 if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
74 if ($scope.blueprintVersions
75 .indexOf(blueprintInstance["version"]) === -1) {
76 $scope.blueprintVersions
77 .push(blueprintInstance["version"]);
82 $scope.selectedBluePrintVersionChange = function() {
83 if (!$scope.selectedBlueprintName) {
86 $scope.blueprintLayers = [];
87 $scope.optionals = [];
88 $scope.selectedBlueprintLayer = {};
89 $scope.selectedOptional = "";
92 $scope.blueprintInstancesForValidation,
93 function(blueprintInstance) {
94 if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
95 if ($scope.selectedBlueprintVersion === blueprintInstance["version"]) {
96 if ($scope.blueprintLayers
97 .indexOf(blueprintInstance["layer"]) === -1) {
98 $scope.blueprintLayers
99 .push(blueprintInstance["layer"]);
104 $scope.blueprintLayers.push("all");
107 $scope.selectedBluePrintLayerChange = function() {
108 $scope.optionals = [ 'true', 'false' ];
111 $scope.submit = function() {
112 if (!$scope.selectedBlueprintName
113 || !$scope.selectedBlueprintVersion
114 || !$scope.selectedBlueprintLayer
115 || !$scope.selectedOptional
116 || !$scope.selectedDeclerativeTimeslot) {
117 confirm("You must specify all data fields");
121 var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot
123 $scope.selectedDeclerativeTimeslot
125 $scope.selectedDeclerativeTimeslot
126 .indexOf("Start date and time:") - 1);
131 if (selectedDeclerativeTimeslotId
132 .toString().trim() === timeslot.timeslotId
133 .toString().trim()) {
134 finalTimeslot = timeslot;
137 var allLayers = "false";
138 if ($scope.selectedBlueprintLayer === 'all') {
141 var wRobotTestResults = [];
142 if (allLayers === "false") {
143 wRobotTestResults = [ {
144 "blueprintLayer" : $scope.selectedBlueprintLayer
148 var validationNexusTestResult = {
149 "blueprintName" : $scope.selectedBlueprintName,
150 "version" : $scope.selectedBlueprintVersion,
151 "allLayers" : allLayers,
152 "wRobotNexusTestResults" : wRobotTestResults,
153 "optional" : $scope.selectedOptional
155 var submissionData = {
156 "validationNexusTestResult" : validationNexusTestResult,
157 "timeslot" : finalTimeslot
161 "/api/v1/submission/",
164 if (data !== undefined) {
165 var confirmText = "The blueprint instance for validation has been submitted successfully. Submission id:"
167 confirm(confirmText);
169 confirm("Error when committing the submission");
172 $scope.selectedBlueprintName = {};
173 $scope.selectedBlueprintVersion = {};
174 $scope.selectedBlueprintLayer = {};
175 $scope.selectedOptional = "";
176 $scope.selectedDeclerativeTimeslot = {};