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() {
97 if (!$scope.selectedBlueprintName
98 || !$scope.selectedBlueprintVersion
99 || !$scope.selectedBlueprintLayer
100 || !$scope.selectedDeclerativeTimeslot) {
101 confirm("You must specify all data fields");
108 $scope.blueprintInstancesForValidation,
109 function(blueprintInstance) {
110 if (blueprintInstance["blueprint"]["blueprintName"] === $scope.selectedBlueprintName) {
111 if (blueprintInstance["version"] === $scope.selectedBlueprintVersion) {
112 if (blueprintInstance["layer"] === $scope.selectedBlueprintLayer) {
113 finalBlueprint = blueprintInstance;
118 var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot
120 $scope.selectedDeclerativeTimeslot
122 $scope.selectedDeclerativeTimeslot
123 .indexOf("Start date and time:") - 1);
128 if (selectedDeclerativeTimeslotId
129 .toString().trim() === timeslot.timeslotId
130 .toString().trim()) {
131 finalTimeslot = timeslot;
135 "blueprintInstanceForValidation" : finalBlueprint,
136 "timeslot" : finalTimeslot
143 if (data !== undefined) {
144 var confirmText = "The blueprint instance for validation has been submitted successfully. Submissionn id:"
146 confirm(confirmText);
148 confirm("Error when committing the submission");
151 $scope.selectedBlueprintName = {};
152 $scope.selectedBlueprintVersion = {};
153 $scope.selectedBlueprintLayer = {};
154 $scope.selectedDeclerativeTimeslot = {};