X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=validation.git;a=blobdiff_plain;f=ui%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FAECBlueprintValidationUI%2FNewSubmission%2FAECNewSubmissionController.js;fp=ui%2Fsrc%2Fmain%2Fwebapp%2Fresources%2Fjs%2FAECNewSubmissionController.js;h=f7d0085684a8175ba1b63f19bff2b23213871a71;hp=1cfafc476bfd712324a0246b3d435734b7af5425;hb=2879b2ee5e1e2815e5f43cb802352bf2878397af;hpb=ce4ad29dc48317cc7cb60fe433072ac46dea2ebb diff --git a/ui/src/main/webapp/resources/js/AECNewSubmissionController.js b/ui/src/main/webapp/app/AECBlueprintValidationUI/NewSubmission/AECNewSubmissionController.js similarity index 62% rename from ui/src/main/webapp/resources/js/AECNewSubmissionController.js rename to ui/src/main/webapp/app/AECBlueprintValidationUI/NewSubmission/AECNewSubmissionController.js index 1cfafc4..f7d0085 100644 --- a/ui/src/main/webapp/resources/js/AECNewSubmissionController.js +++ b/ui/src/main/webapp/app/AECBlueprintValidationUI/NewSubmission/AECNewSubmissionController.js @@ -14,26 +14,24 @@ * limitations under the License. */ -var AECBlueprintValidationUIApp = angular - .module('BlueprintValidationUIManagement'); - -AECBlueprintValidationUIApp +var app = angular.module('AECNewSubmission'); +app .controller( 'AECNewSubmissionController', - function($scope, appContext, restAPISvc) { + function($scope, restAPISvc) { initialize(); function initialize() { restAPISvc .getRestAPI( - "/api/blueprintInstance/", + "/api/blueprintInstanceForValidation/", function(data) { - $scope.blueprintInstances = data; + $scope.blueprintInstancesForValidation = data; $scope.blueprintNames = []; angular .forEach( - $scope.blueprintInstances, + $scope.blueprintInstancesForValidation, function( blueprintInstance) { if ($scope.blueprintNames @@ -43,14 +41,30 @@ AECBlueprintValidationUIApp } }); }); + restAPISvc.getRestAPI("/api/timeslots/", + function(data) { + $scope.timeslots = data; + $scope.declerativeTimeslots = []; + angular.forEach($scope.timeslots, function( + timeslot) { + var temp = "id: " + timeslot.timeslotId + + " Start date and time: " + + timeslot.startDateTime + /* + * + " duration(in sec) :" + + * blueprintInstance["timeslot"].duration + */ + + " lab :" + timeslot.lab.lab; + $scope.declerativeTimeslots.push(temp); + }); + }); } $scope.selectedBluePrintNameChange = function() { $scope.blueprintVersions = []; $scope.blueprintLayers = []; - $scope.declerativeTimeslots = []; angular .forEach( - $scope.blueprintInstances, + $scope.blueprintInstancesForValidation, function(blueprintInstance) { if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) { if ($scope.blueprintVersions @@ -63,10 +77,9 @@ AECBlueprintValidationUIApp } $scope.selectedBluePrintVersionChange = function() { $scope.blueprintLayers = []; - $scope.declerativeTimeslots = []; angular .forEach( - $scope.blueprintInstances, + $scope.blueprintInstancesForValidation, function(blueprintInstance) { if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) { if ($scope.selectedBlueprintVersion === blueprintInstance["version"]) { @@ -79,61 +92,41 @@ AECBlueprintValidationUIApp } }); } - $scope.selectedBluePrintLayerChange = function() { - $scope.declerativeTimeslots = []; - angular - .forEach( - $scope.blueprintInstances, - function(blueprintInstance) { - if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) { - if ($scope.selectedBlueprintVersion === blueprintInstance["version"]) { - if ($scope.selectedBlueprintLayer === blueprintInstance["layer"]) { - var temp = "id: " - + blueprintInstance["timeslot"].timeslotId - + " Start date and time: " - + blueprintInstance["timeslot"].startDateTime - + " duration(in sec) :" - + blueprintInstance["timeslot"].duration - + " lab :" - + blueprintInstance["timeslot"].lab; - if ($scope.declerativeTimeslots - .indexOf(temp) === -1) { - $scope.declerativeTimeslots - .push(temp); - } - } - } - } - }); - } + $scope.submit = function() { var finalBlueprint; + var finalTimeslot; angular .forEach( - $scope.blueprintInstances, + $scope.blueprintInstancesForValidation, function(blueprintInstance) { if (blueprintInstance["blueprint"]["blueprintName"] === $scope.selectedBlueprintName) { if (blueprintInstance["version"] === $scope.selectedBlueprintVersion) { if (blueprintInstance["layer"] === $scope.selectedBlueprintLayer) { - var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot - .substring( - $scope.selectedDeclerativeTimeslot - .indexOf("id:") + 4, - $scope.selectedDeclerativeTimeslot - .indexOf("Start date and time:") - 1); - if (selectedDeclerativeTimeslotId - .toString() - .trim() === blueprintInstance["timeslot"]["timeslotId"] - .toString() - .trim()) { - finalBlueprint = blueprintInstance; - } + finalBlueprint = blueprintInstance; } } } }); + var selectedDeclerativeTimeslotId = $scope.selectedDeclerativeTimeslot + .substring( + $scope.selectedDeclerativeTimeslot + .indexOf("id:") + 4, + $scope.selectedDeclerativeTimeslot + .indexOf("Start date and time:") - 1); + angular + .forEach( + $scope.timeslots, + function(timeslot) { + if (selectedDeclerativeTimeslotId + .toString().trim() === timeslot.timeslotId + .toString().trim()) { + finalTimeslot = timeslot; + } + }); var submission = { - "blueprintInstance" : finalBlueprint + "blueprintInstanceForValidation" : finalBlueprint, + "timeslot" : finalTimeslot }; restAPISvc .postRestAPI(