2 * ================================================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ================================================================================
20 app.controller('broadcastListController', function ($scope, modalService, $modal,AdminService){
21 //$scope.broadcastMessage=${broadcastMessage};
22 //$scope.broadcastSites=${broadcastSites};
23 //console.log($scope.broadcastMessage);
25 AdminService.getBroadcastList().then(function(data){
28 $scope.data = JSON.parse(j.data);
29 $scope.messagesList=(($scope.data.messagesList===null) ? [""]:$scope.data.messagesList);
30 $scope.messageLocations=(($scope.data.messageLocations===null) ? [""]:$scope.data.messageLocations);
31 console.log("messages: "+$scope.messagesList);
32 console.log("location: "+$scope.messageLocations);
33 $.each($scope.messageLocations, function(i, a){
35 angular.forEach($scope.messagesList, function(value, key) {
36 if (key+'' === a.value+'') {
37 //var objsJSON = JSON.parse(value);
39 $.each(value, function(i, a){
40 var startDateLong = a.startDate;
41 var tempStartDate = new Date(startDateLong);
42 tempStartDate = moment(tempStartDate).format('DD MMM YYYY hh:mmA zz');//03 Jun 2013 04:15PM EDT
43 a.displayStartDate=tempStartDate.toString();
45 var endDateLong = a.endDate;
46 var tempEndDate = new Date(endDateLong);
47 tempEndDate = moment(tempEndDate).format('DD MMM YYYY hh:mmA zz');//03 Jun 2013 04:15PM EDT
48 a.displayEndDate=tempEndDate.toString();
53 console.log(a.messages);
59 console.log("failed");
64 $scope.editMessage = function(location) {
66 editMessage(location.value, location.label);
69 $scope.toggleActive = function(broadcastMessage) {
71 //alert('deleted'+role.name);
72 var uuu = "broadcast_list/toggleActive";
73 var postData={broadcastMessage:broadcastMessage};
78 contentType: 'application/json',
79 data: JSON.stringify(postData),
80 success : function(data){
81 //window.location.reload();
83 error : function(data){
85 modalService.showFailure("Fail","Error while toggling: "+ data.responseText);
93 $scope.remove = function(broadcastMessage) {
95 //alert('deleted'+role.name);
96 var uuu = "broadcast_list/remove";
97 var postData={broadcastMessage:broadcastMessage};
102 contentType: 'application/json',
103 data: JSON.stringify(postData),
104 success : function(data){
105 window.location.reload();
107 error : function(data){
109 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
118 function editMessage(messageLocationId, messageLocation, messageId) {
119 window.location='admin#/broadcast/'+messageLocationId + '/' + messageLocation + ((messageId != null) ? '/' + messageId : '');