Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / jsp / broadcast.jsp
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 <%@ page import="org.openecomp.portalsdk.core.web.support.UserUtils" %>
21 <%@ page import="org.openecomp.portalsdk.core.web.support.ControllerProperties" %>
22 <%@ page import="org.openecomp.portalsdk.core.util.SystemProperties" %>
23
24 <%-- <%@ include file="/WEB-INF/fusion/jsp/include.jsp" %> --%>
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" %>
28 <link rel="stylesheet" type="text/css" href="static/fusion/css/jquery-ui.css">
29
30   <c:set var="clustered" value="<%=(\"true\".equals(SystemProperties.getProperty(SystemProperties.CLUSTERED)))%>"/>
31
32   <script src="static/fusion/js/moment.min.js"></script>
33   
34   <div class="pageTitle">
35    <h3>
36         <c:choose>
37                 <c:when test="${!empty param.message_id}">
38                         <h1 class="heading1" style="margin-top:20px;">Broadcast Message Edit</h1>
39                 </c:when>
40                 <c:otherwise>
41                         <h1 class="heading1" style="margin-top:20px;">Broadcast Message Create</h1>
42                 </c:otherwise>
43         </c:choose>
44    </h3>
45   </div>
46
47 <div ng-controller="broadcastController" >    
48                  Please edit the broadcast message details below:&nbsp;<br><br>
49         <div class="fn-ebz-container" >
50                 <label class="fn-ebz-text-label"><sup><b>*</b></sup>Message Text:</label><BR>
51                 <textarea name="comment" ng-model="broadcastMessage.messageText" rows="5" cols="200" style="height:100px"></textarea>
52         </div>
53         <br>
54         <div class="fn-ebz-container" >
55                   <label class="fn-ebz-text-label"><sup><b>*</b></sup>Start Date:</label><BR>
56                   <input style="display:none" name="startDateHidden" ng-model="broadcastMessage.startDate">
57                   <input type="text" class="fn-ebz-text" id="startDatepicker" />
58         </div>
59         
60         <div class="fn-ebz-container" style="margin-left:3em" >
61                   <label class="fn-ebz-text-label"><sup><b>*</b></sup>End Date:</label><BR>
62                   <input style="display:none" name="endDateHidden" ng-model="broadcastMessage.endDate">
63                   <input type="text" class="fn-ebz-text" id="endDatepicker" />
64         </div>
65
66         <div class="fn-ebz-container" style="margin-left:3em"  >
67                 <label class="fn-ebz-text-label"><sup><b>*</b></sup>Sort Order:</label><BR>
68                 <input type="text" class="fn-ebz-text" ng-model="broadcastMessage.sortOrder"
69                         maxlength="30" /> 
70         </div>
71         
72           <c:if test="${clustered}">
73                                 <div class="fn-ebz-container" style="margin-left:1em" > 
74                                                 <label  class="fn-ebz-text-label">Server:</label><BR>
75                                                 <div class="form-field" att-select="broadcastSites" ng-model="broadcastMessage.siteCd"></div>
76                                         </div>
77           </c:if>
78                 <br>
79         <div align="left" >
80                 <button type="submit" ng-click="save();" att-button
81                         btn-type="primary" size="small">Save</button>
82         </div>
83 </div>
84 <script>
85 app.controller('broadcastController', function ($scope, modalService, $modal){
86         $scope.broadcastMessage=${broadcastMessage};
87         $scope.broadcastSites=${broadcastSites};
88         console.log($scope.broadcastMessage);
89         
90         $scope.save = function() {
91                   var uuu = "broadcast/save";
92                   var postData={broadcastMessage: $scope.broadcastMessage};
93                   $.ajax({
94                          type : 'POST',
95                          url : uuu,
96                          dataType: 'json',
97                          contentType: 'application/json',
98                          data: JSON.stringify(postData),
99                          success : function(data){
100                                 //console.log(data);
101                                 window.location.href = "broadcast_list";
102                          },
103                          error : function(data){
104                                  alert("Error while saving.");
105                          }
106                   });
107         };
108         
109         $(function() {
110             $( "#startDatepicker" ).datepicker();
111             $( "#endDatepicker" ).datepicker();
112             
113             var startDateLong = $scope.broadcastMessage.startDate;
114                 var tempStartDate = new Date(startDateLong);
115                 tempStartDate = moment(tempStartDate).format('MM/DD/YY');//03 Jun 2013 04:15PM EDT
116                 console.log(tempStartDate.toString());
117                 $( "#startDatepicker" ).val(tempStartDate.toString());
118             
119             var endDateLong = $scope.broadcastMessage.endDate;
120                 var tempendDate = new Date(endDateLong);
121                 tempendDate = moment(tempendDate).format('MM/DD/YY');//03 Jun 2013 04:15PM EDT
122                 console.log(tempendDate.toString());
123                 $( "#endDatepicker" ).val(tempendDate.toString());
124                 
125             $( "#startDatepicker" ).change(function() {
126                 var tempStartDate = moment($( "#startDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S');
127                 $scope.broadcastMessage.startDate = new Date(tempStartDate.toString());
128             });
129             $( "#endDatepicker" ).change(function() {
130                 var tempEndDate = moment($( "#endDatepicker" ).val()).format('YYYY-MM-DD hh:mm:ss.S');
131                 $scope.broadcastMessage.endDate = new Date(tempEndDate.toString());
132                 });
133           });
134 });
135
136
137 </script>