broadcastproxy_mydashboard.html
1 <style >
2 a.updateUserSubscriptions {
3 color:white !important;
4 }
5 .modalLoading {
6 display: none;
7 position: fixed;
8 z-index: 1000;
9 top: 0;
10 left: 0;
11 height: 100%;
12 width: 100%;
13 background: rgba( 255, 255, 255, .8 )
14 url('images/loading.gif')
15 50% 50%
16 no-repeat;
17 }
18
19 body.loading .modalLoading {
20 overflow: hidden;
21 }
22
23 body.loading .modalLoading {
24 display: block;
25 }
26
27 .hide {
28 display:none;
29 }
30
31 .custom-control-input:checked ~ .custom-control-label::before {
32 background-color: #28a745;
33 border-color: #28a745;
34 }
35 </style>
36
37 <section class="subscriptions mt-3">
38 <div class="container px-5 py-3 subscriptionGroup" id="subscriptionsDiv">
39 <h2 class='main-color'>Mes abonnements</h2><br/>
40 <#if listSubscriptions??>
41 <div class="row">
42 <#list listSubscriptions as sub>
43 <#if sub.enabled && sub.group == 'Newsletters'>
44 <div class="col-md-6">
45 <div class="SubscriptionDiv">
46 <div class="custom-control custom-switch">
47 <input type="checkbox" class="custom-control-input subscriptionSwitch subscriptionCheckBox sub-${(sub.subscriptionId)!}"
48 name="${(sub.label)!}" id="${(sub.subscriptionId)!}" subtype="NEWSLETTER" groupname="${(sub.label)!}" data-size="large"
49 data-on="success" data-off="warning" aria-describedby="label-${(sub.code)!}" onchange="onChange(this)">
50 <label for="${(sub.subscriptionId)!}" class="custom-control-label">
51 <span class="h3">${(sub.label)!}</span>
52 </label>
53 </div>
54 <p class="py-2 font-m-light" id="label-"${(sub.label)!}'="">${(sub.description)!}
55 <br>
56 <br> Fr�quence : ${(sub.frequency)!}</p>
57 </div>
58 </div>
59 </#if>
60 </#list>
61 <div class="container subscriptionsTypeDiv" id="div_subscription_typeALERT">
62 <br>
63 <h3 class="h2 main-color">Mes alertes</h3>
64 <p class="py-2 font-m-light" id="label-" alert'="">
65 Abonnez-vous aux sujets qui vous interessent et soyez alert�s par mail
66 lorsqu'une information importante est lanc�e : dates d'inscriptions,
67 r�sultats du vote du budget participatif, nouvelle r�glementation,
68 etc...<br> <br> Ces notifications vous sont adress�es par
69 mail et/ou sms selon votre choix et selon l'actualit�.
70 </p>
71 <#if listSubscriptions??>
72 <div class="row">
73 <#list listSubscriptions as sub>
74 <#if sub.enabled && sub.group == 'Alertes'>
75 <div class="col-md-6">
76 <div class="SubscriptionDiv">
77 <div class="custom-control custom-switch">
78 <input type="checkbox"
79 class="custom-control-input subscriptionSwitch subscriptionCheckBox sub-${(sub.subscriptionId)!}"
80 name="${(sub.label)!}" id="${(sub.subscriptionId)!}" subtype="ALERT"
81 groupname="${(sub.label)!}" data-size="large" data-on="success"
82 data-off="warning" aria-describedby="label-${(sub.code)!}"
83 onchange="onChange(this)">
84 <label for="${(sub.subscriptionId)!}" class="custom-control-label"> <span class="h3">${(sub.label)!}</span>
85 </label>
86 </div>
87 </div>
88 </div>
89 </#if>
90 </#list>
91 </div>
92 </#if>
93 </div>
94 </div>
95 </#if>
96 <@messages errors=errors />
97 <@messages infos=infos />
98 </div>
99 </section>
100
101
102 <div class="modalLoading"><!-- modal loading splash screen while waiting ajax calls --> </div>
103
104 <!-- update subscriptions -->
105 <script type="text/javascript" >
106
107 var urlUpdateSubscriptions = "jsp/site/Portal.jsp?page=broadcastproxyMyDashboard&action=updateUserSubscriptions";
108
109 //Ajax call
110 function push ( json ) {
111 $.ajax({
112 type: "POST",
113 url: urlUpdateSubscriptions,
114 dataType: "json",
115 contentType: "application/json",
116 beforeSend: function() {
117 // start loading screen
118 $("body").addClass("loading");
119 },
120 complete:function(){
121 // hide loading screen
122 $("body").removeClass("loading");
123 },
124 success: function(data, e, f){
125 if (data.status !== "OK")
126 {
127 alert( "Un problème est survenu lors de la mise à jour des abonnements : " + data.result);
128 }
129 },
130 failure: function(errMsg) {
131 alert( "Un problème est survenu lors de la mise à jour des abonnements : " + errMsg.result);
132 },
133 error: function (jqXHR, timeout, message) {
134 var contentType = jqXHR.getResponseHeader("Content-Type");
135 if (jqXHR.status === 200 && contentType.toLowerCase().indexOf("text/html") >= 0) {
136 // assume that our login has expired - reload our current page
137 window.location.reload(true);
138 }
139 },
140
141 data: JSON.stringify(json)
142 });
143 }
144
145 function onChange(element) {
146 var jsonSub = {
147 "id": $( element ).attr( "id" ),
148 "active": false,
149 "account": "default"
150 }
151
152 if( $(element).is(':checked') ){
153 jsonSub.active = true;
154 }
155
156 push( jsonSub );
157 }
158
159 var urlGetUserSubscriptions = "jsp/site/Portal.jsp?page=broadcastproxyMyDashboard&action=getUserSubscriptions";
160
161 //on page load event do ...
162 $(function() {
163 // ajax call
164 $("#subscriptionsDiv").hide();
165 $.ajax({
166 type: "GET",
167 url: urlGetUserSubscriptions,
168 dataType: "json",
169 contentType: "application/json",
170 success: function(data){
171 if ( data.status === "OK" ) {
172 var user_subscriptions = JSON.parse(data.result) ;
173 if (user_subscriptions !== null && user_subscriptions.length > 0 && user_subscriptions !== undefined) {
174 for ( let i=0; i < user_subscriptions.length ; i++) {
175 if( user_subscriptions[i] !== null && user_subscriptions[i] !== undefined){
176 $(".sub-" + user_subscriptions[i].id ).prop("checked", true );
177 }
178 }
179 $("#subscriptionsDiv").show();
180 }
181 else {
182 let errorMsg = "<div class='alert alert-danger'><p class='fa fa-solid fa-warning'> Vos abonnements sont temporairement indisponibles.</p></div>"
183 $('#subscriptionsDiv').append( errorMsg ).append( "<br/>" );
184 }
185 }
186 else if ( data.status === "ERROR" ) {
187 let errorMsg = "<div class='alert alert-danger'><p class='fa fa-solid fa-warning'> ERREUR : " + data.errorCode + "</p></div>";
188 $('#subscriptionsDiv').append( errorMsg ).append( "<br/>" );
189 }
190 },
191 failure: function(errMsg) {
192 let errorMsg = "<div class='alert alert-danger'><p class='fa fa-solid fa-warning'> Un problème est survenu lors du chargement de vos abonnements : "
193 + errMsg.result + "</p></div>";
194 $('#subscriptionsDiv').append( errorMsg ).append( "<br/>" );
195 },
196 error: function (jqXHR, timeout, message) {
197 var contentType = jqXHR.getResponseHeader("Content-Type");
198 if (jqXHR.status === 200 && contentType.toLowerCase().indexOf("text/html") >= 0) {
199 // assume that our login has expired - reload our current page
200 window.location.reload(true);
201 }
202 }
203 });
204 });
205 </script>