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('AECNewSubmission');
20 'AECNewSubmissionController',
21 function($scope, restAPISvc) {
25 function initialize() {
28 "/api/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/timeslots/",
46 $scope.timeslots = data;
47 $scope.declerativeTimeslots = [];
48 angular.forEach($scope.timeslots, function(
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 = [];
67 $scope.blueprintInstancesForValidation,
68 function(blueprintInstance) {
69 if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
70 if ($scope.blueprintVersions
71 .indexOf(blueprintInstance["version"]) === -1) {
72 $scope.blueprintVersions
73 .push(blueprintInstance["version"]);
78 $scope.selectedBluePrintVersionChange = function() {
79 $scope.blueprintLayers = [];
82 $scope.blueprintInstancesForValidation,
83 function(blueprintInstance) {
84 if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
85 if ($scope.selectedBlueprintVersion === blueprintInstance["version"]) {
86 if ($scope.blueprintLayers
87 .indexOf(blueprintInstance["layer"]) === -1) {
88 $scope.blueprintLayers
89 .push(blueprintInstance["layer"]);
96 $scope.submit = function() {
101 $scope.blueprintInstancesForValidation,
102 function(blueprintInstance) {
103 if (blueprintInstance["blueprint"]["blueprintName"] === $scope.selectedBlueprintName) {
104 if (blueprintInstance["version"] === $scope.selectedBlueprintVersion) {
105 if (blueprintInstance["layer"] === $scope.selectedBlueprintLayer) {
106 finalBlueprint = blueprintInstance;
111 var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot
113 $scope.selectedDeclerativeTimeslot
115 $scope.selectedDeclerativeTimeslot
116 .indexOf("Start date and time:") - 1);
121 if (selectedDeclerativeTimeslotId
122 .toString().trim() === timeslot.timeslotId
123 .toString().trim()) {
124 finalTimeslot = timeslot;
128 "blueprintInstanceForValidation" : finalBlueprint,
129 "timeslot" : finalTimeslot
136 if (data !== undefined) {
137 confirm("Submission committed successfully");
139 confirm("Error when committing the submission");