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 <%@ page import="java.util.*" %>
21 <%@ page import="com.fasterxml.jackson.databind.ObjectMapper" %>
22 <%@ page import="org.json.JSONObject" %>
23 <%@ page import="java.io.StringWriter" %>
24 <%@ page import="org.openecomp.portalsdk.core.web.support.ControllerProperties" %>
25 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
26 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
27 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
29 <script src="static/fusion/raptor/dy3/js/moment.min.js"></script>
31 function editMessage(messageLocationId, messageLocation, messageId) {
32 window.location='broadcast.htm?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : '');
36 <div class="pageTitle">
42 <%-- Display a table for the broadcast messages of each message location --%>
43 <div ng-controller="broadcastListController" >
45 <div ng-repeat="location in messageLocations" >
46 {{location.label}} Messages
47 <div title="{{location.label}} Messages" >
49 <table att-table table-data="location.messages" current-page="1">
50 <thead att-table-row type="header">
52 <th att-table-header sortable="false" width="10%">No.</th>
53 <th att-table-header sortable="false" width="30%">Message Text</th>
54 <th att-table-header sortable="false" width="10%">Start Date</th>
55 <th att-table-header sortable="false" width="10%">End Date</th>
56 <th att-table-header sortable="false" width="10%">Sort Order</th>
57 <th att-table-header sortable="false" width="10%">Server</th>
58 <th att-table-header sortable="false" width="10%">Active?</th>
59 <th att-table-header sortable="false" width="10%">Delete?</th>
62 <tbody att-table-row type="body" row-repeat="message in location.messages" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
65 <td width="10%"><a href="javascript:editMessage({{location.value}},'{{location.label}}',{{message.id}});">{{$index+1}}</a></td>
66 <td width="30%">{{message.messageText}}</td>
68 {{message.displayStartDate}}
70 <td width="10%">{{message.displayEndDate}}</td>
71 <td width="10%">{{message.sortOrder}}</td>
72 <td width="10%">{{message.siteCd}}</td>
74 <div ng-click="toggleActive(message);">
75 <input type="checkbox" ng-model="message.active" att-toggle-main>
78 <td att-table-body width="10%">
79 <div ng-click="remove(message);" style="font-size:20px;"><a href="javascript:void(0)" class="ion-trash-b"></a></div>
86 <input att-button btn-type="primary" size="small" class="button" type="button" value="Add" ng-click="editMessage(location);"/>
92 app.controller('broadcastListController', function ($scope){
93 //$scope.model.messagesList=${model.messagesList};
96 ObjectMapper mapper = new ObjectMapper();
97 HashMap hmMessages = new HashMap();
99 HashMap objModel = (HashMap)request.getAttribute("model");
101 Object objMessages = objModel.get("messagesList");
102 //System.out.println("messagesList: "+objMessages);
103 if((objMessages!=null) && (objMessages instanceof HashMap))
105 hmMessages= (HashMap)objMessages;
106 Iterator it = hmMessages.entrySet().iterator();
107 while (it.hasNext()) {
108 Map.Entry pair = (Map.Entry)it.next();
109 //System.out.println(pair.getKey() + " = " + pair.getValue());
110 String pairValue = mapper.writeValueAsString(pair.getValue());
111 //System.out.println(pairValue);
113 messagesMap['<%=pair.getKey()%>'] = '<%=pairValue%>'
118 Object messageLocationsObject = objModel.get("messageLocations");
119 //System.out.println("messageLocations: "+messageLocationsObject);
120 String messageLocationsString = mapper.writeValueAsString(messageLocationsObject);
121 //System.out.println(messageLocationsString);
123 $scope.messagesList=messagesMap;
124 $scope.messageLocations=<%=messageLocationsString%>;
125 console.log($scope.messageLocations);
127 $.each($scope.messageLocations, function(i, a){
129 angular.forEach($scope.messagesList, function(value, key) {
130 if (key+'' === a.value+'') {
131 var objsJSON = JSON.parse(value);
133 $.each(objsJSON, function(i, a){
134 var startDateLong = a.startDate;
135 var tempStartDate = new Date(startDateLong);
136 tempStartDate = moment(tempStartDate).format('DD MMM YYYY');//03 Jun 2013 04:15PM EDT - 'DD MMM YYYY hh:mmA zz'
137 a.displayStartDate=tempStartDate.toString();
139 var endDateLong = a.endDate;
140 var tempEndDate = new Date(endDateLong);
141 tempEndDate = moment(tempEndDate).format('DD MMM YYYY');//03 Jun 2013 04:15PM EDT
142 a.displayEndDate=tempEndDate.toString();
144 a.messages = objsJSON;
147 console.log(a.messages);
151 $scope.editMessage = function(location) {
152 editMessage(location.value, location.label);
155 $scope.toggleActive = function(broadcastMessage) {
157 //alert('deleted'+role.name);
158 var uuu = "broadcast_list/toggleActive";
159 var postData={broadcastMessage:broadcastMessage};
164 contentType: 'application/json',
165 data: JSON.stringify(postData),
166 success : function(data){
167 //window.location.reload();
169 error : function(data){
171 alert("Error while toggling: "+ data.responseText);
178 $scope.remove = function(broadcastMessage) {
180 //alert('deleted'+role.name);
181 var uuu = "broadcast_list/remove";
182 var postData={broadcastMessage:broadcastMessage};
187 contentType: 'application/json',
188 data: JSON.stringify(postData),
189 success : function(data){
190 window.location.reload();
192 error : function(data){
194 alert("Error while deleting: "+ data.responseText);