removing unused db file
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / fusion / scripts / controllers / broadcast-controller.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 app.controller('broadcastController', function ($scope, modalService, $modal,AdminService,$routeParams){
21         //$scope.broadcastMessage=${broadcastMessage};
22         //$scope.broadcastSites=${broadcastSites};
23         //console.log($scope.broadcastMessage); 
24         $scope.broadcastMessage=[];
25         $scope.broadcastSites=[];
26         AdminService.getBroadcast($routeParams.messageLocationId, $routeParams.messageLocation, $routeParams.messageId).then(function(data){
27                 var j = data;
28                 $scope.data = JSON.parse(j.data);
29                 $scope.broadcastMessage=JSON.parse($scope.data.broadcastMessage);
30                 $scope.broadcastSites=JSON.parse($scope.data.broadcastSites);
31                 console.log($scope.broadcastMessage);
32                 console.log($scope.broadcastMessage.id);
33                 console.log($scope.broadcastSites);
34                 //$scope.resetMenu();
35         
36         },function(error){
37                 console.log("failed");
38                 reloadPageOnce();
39     });
40         
41         $scope.save = function() {
42                   var uuu = "broadcast/save";
43                   var postData={broadcastMessage: $scope.broadcastMessage};
44                   $.ajax({
45                          type : 'POST',
46                          url : uuu,
47                          dataType: 'json',
48                          contentType: 'application/json',
49                          data: JSON.stringify(postData),
50                          success : function(data){
51                                 window.location.href = "admin#/broadcast_list";
52                          },
53                          error : function(data){
54                                  modalService.showFailure("Fail","Error while saving.");
55                          }
56                   });
57         };
58         
59         $scope.close = function() {
60         window.location.href = "admin#/broadcast_list";
61 };      
62         
63 });
64
65 $(function() {
66     $( "#startDatepicker" ).datepicker();
67     $( "#endDatepicker" ).datepicker();
68     
69     $( "#startDatepicker" ).change(function() {
70         var tempStartDate = moment($( "#startDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S');
71         $( "#startDateHidden" ).val(tempStartDate.toString());
72           //alert( $( "#startDateHidden" ).val() );
73     });
74     $( "#endDatepicker" ).change(function() {
75         var tempEndDate = moment($( "#endDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S');
76         $( "#endDateHidden" ).val(tempEndDate.toString());
77           //alert( $( "#endDateHidden" ).val() );
78         });
79 });