Skip to content

Commit c6ba8f6

Browse files
wshengqibadboy-huaqiao
authored andcommitted
clean up notifications
Signed-off-by: wshengqi <wshengqi@vmware.com>
1 parent 4235889 commit c6ba8f6

File tree

3 files changed

+256
-3
lines changed

3 files changed

+256
-3
lines changed

cmd/edgex-ui-server/static/css/notification.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,48 @@ table.table td i.edit {
8383
}
8484
table.table td i.delete {
8585
color: #E34724;
86+
}
87+
88+
89+
#transmission_model .modal-dialog{
90+
position:fixed;
91+
top:10%;
92+
right:0;
93+
left:0;
94+
bottom:10%;
95+
margin:auto;
96+
}
97+
98+
#transmission_model .modal-content {
99+
position: absolute;
100+
top: 0;
101+
bottom: 0;
102+
width: 100%;
103+
height: 40%;
104+
}
105+
106+
#transmission_model .modal-body {
107+
max-height:79%;
108+
overflow-y:auto;
109+
position: absolute;
110+
top: 55px;
111+
bottom: 65px;
112+
width: 100%;
113+
}
114+
115+
#transmission_model .modal-header .close {margin-right: 15px;}
116+
#transmission_model .modal-footer {
117+
position: absolute;
118+
width: 100%;
119+
bottom: 0;
120+
}
121+
122+
#transmission_model #json-renderer {
123+
padding-left: 5%;
124+
}
125+
126+
.modal-backdrop {
127+
z-index: -1 !important;
128+
opacity: 0 !important;
129+
filter: alpha(opacity=0) !important;
86130
}

cmd/edgex-ui-server/static/js/pages/notification.js

Lines changed: 170 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ $(document).ready(function(){
4646
});
4747
orgEdgexFoundry.supportNotification.loadNotificationList();
4848
orgEdgexFoundry.supportNotification.loadSubscriptionList();
49+
orgEdgexFoundry.supportNotification.loadTransmissionList();
50+
51+
$("#notification_check_all").click(function() {
52+
$(":checkbox[name='notification_checkbox']").prop("checked", this.checked);
53+
});
54+
4955
});
5056

5157
orgEdgexFoundry.supportNotification = (function(){
@@ -83,6 +89,11 @@ orgEdgexFoundry.supportNotification = (function(){
8389
addNewSubscriptionChannelBtn: null,
8490
commitSubscriptionChannelBtn: null,
8591
cancelAddOrUpdateSubscriptionChannelBtn:null,
92+
93+
cleanUp: null,
94+
deleteNotificationBySlug: null,
95+
toDeleteTransmission: null,
96+
deleteTransmissionByStatus: null
8697
};
8798

8899
var notification = new SupportNotification();
@@ -136,7 +147,7 @@ orgEdgexFoundry.supportNotification = (function(){
136147
// rowData += '<td class="scheduler-delete-icon"><input type="hidden" value="'+v.id+'"><div class="edgexIconBtn"><i class="fa fa-trash-o fa-lg" aria-hidden="true"></i> </div></td>';
137148
// rowData += '<td class="scheduler-edit-icon"><input type="hidden" value=\''+JSON.stringify(v)+'\'><div class="edgexIconBtn"><i class="fa fa-edit fa-lg" aria-hidden="true"></i> </div></td>';
138149
// rowData += '<td><input type="radio" name="notificationRowRadio" value="'+v.id+'"></td>';
139-
rowData += "<td>" + (i + 1) +"</td>";
150+
rowData += "<td><input type='checkbox' name='notification_checkbox' id='" + v.slug +"'></td>";
140151
rowData += "<td>" + v.id + "</td>";
141152
rowData += "<td>" + v.slug + "</td>";
142153
rowData += "<td>" + v.sender + "</td>";
@@ -207,6 +218,104 @@ orgEdgexFoundry.supportNotification = (function(){
207218
$("#edgex-support-notification-list table tfoot").show();
208219
}
209220

221+
SupportNotification.prototype.cleanUp = function(){
222+
bootbox.confirm({
223+
buttons: {
224+
confirm: {
225+
label: 'delete',
226+
className: 'btn-success'
227+
},
228+
cancel: {
229+
label: 'cancel',
230+
className: 'btn-default'
231+
}
232+
},
233+
title: "Warning",
234+
message: 'This operation will delete all the notifications if the current timestamp minus their last modification timestamp is less than a default age setting, and the corresponding transmissions will also be deleted. Are you sure to delete this data? The operation is not recoverable!',
235+
callback: function(result) {
236+
if(result) {
237+
$.ajax({
238+
url:'/support-notification/api/v1/cleanup',
239+
type:'DELETE',
240+
success: function(){
241+
bootbox.alert({
242+
title:"Alert",
243+
message: "Operation succeeded!",
244+
className: 'red-green-buttons'
245+
});
246+
orgEdgexFoundry.supportNotification.loadNotificationList();
247+
},
248+
error: function(){
249+
bootbox.alert({
250+
title : "Error",
251+
message: "Operation failure!",
252+
className: 'red-green-buttons'
253+
});
254+
}
255+
});
256+
} else {
257+
return;
258+
}
259+
},
260+
});
261+
}
262+
263+
SupportNotification.prototype.deleteNotificationBySlug = function(){
264+
if($('input[name="notification_checkbox"]:checked').length == 0){
265+
bootbox.alert({
266+
title:"Alert",
267+
message: "Please select at least one data.",
268+
className: 'red-green-buttons'
269+
});
270+
}else{
271+
bootbox.confirm({
272+
buttons: {
273+
confirm: {
274+
label: 'delete',
275+
className: 'btn-success'
276+
},
277+
cancel: {
278+
label: 'cancel',
279+
className: 'btn-default'
280+
}
281+
},
282+
title: "Please input a Slug",
283+
message:"This operation will delete all selected notifications, Are you sure to delete this data? The operation is not recoverable!",
284+
callback: function(result) {
285+
if(result) {
286+
var eachcount = 0;
287+
$('input[name="notification_checkbox"]:checked').each(function(){
288+
$.ajax({
289+
url:'/support-notification/api/v1/notification/slug/'+$(this).attr('id'),
290+
type:'DELETE',
291+
success: function(){
292+
eachcount++
293+
if(eachcount >= $('input[name="notification_checkbox"]:checked').length){
294+
bootbox.alert({
295+
title:"Alert",
296+
message: "Operation succeeded!",
297+
className: 'red-green-buttons'
298+
});
299+
orgEdgexFoundry.supportNotification.loadNotificationList();
300+
}
301+
},
302+
error: function(){
303+
bootbox.alert({
304+
title : "Error",
305+
message: "Operation failure!",
306+
className: 'red-green-buttons'
307+
});
308+
}
309+
});
310+
});
311+
} else {
312+
return;
313+
}
314+
},
315+
});
316+
}
317+
}
318+
210319
//===============notification section end=========================
211320

212321
//===============subscription section begin=========================
@@ -634,7 +743,7 @@ orgEdgexFoundry.supportNotification = (function(){
634743
SupportNotification.prototype.seacrchTransmissionBtn = function(){
635744
var start = $("#edgex-foundry-support-transmission input[name='transmission_start_time']").val();
636745
var end = $("#edgex-foundry-support-transmission input[name='transmission_end_time']").val();
637-
var limit = $("#edgex-foundry-support-transmissions select[name='transmission_limit']").val();
746+
var limit = $("#edgex-foundry-support-transmission select[name='transmission_limit']").val();
638747
start = new Date(start).valueOf();
639748
end = new Date(end).valueOf();
640749
$.ajax({
@@ -715,6 +824,65 @@ orgEdgexFoundry.supportNotification = (function(){
715824
$("#edgex-support-transmission-list table tbody").append(rowData);
716825
});
717826
}
827+
828+
SupportNotification.prototype.toDeleteTransmission = function(){
829+
$('#transmission_model').modal({
830+
backdrop: "static"
831+
});
832+
$('.selectpicker').selectpicker('deselectAll');
833+
}
834+
835+
SupportNotification.prototype.deleteTransmissionByStatus = function(){
836+
bootbox.confirm({
837+
buttons: {
838+
confirm: {
839+
label: 'delete',
840+
className: 'btn-success'
841+
},
842+
cancel: {
843+
label: 'cancel',
844+
className: 'btn-default'
845+
}
846+
},
847+
title: "Delete Transmissions By Status",
848+
message: 'Delete all the transmissions by Status. Are you sure to delete this data? The operation is not recoverable!',
849+
callback: function(result) {
850+
if(result) {
851+
var statusArr = $('#transstatus').val();
852+
if(statusArr == null || statusArr == '' || statusArr.length ==0){
853+
bootbox.alert({
854+
title:"Alert",
855+
message: "Please select at least one status",
856+
className: 'red-green-buttons'
857+
});
858+
return;
859+
}
860+
for(var i=0;i<statusArr.length;i++){
861+
$.ajax({
862+
url:'/support-notification/api/v1/transmission/'+statusArr[i]+'/age/10000',
863+
type:'DELETE',
864+
error: function(){
865+
bootbox.alert({
866+
title : "Error",
867+
message: "Operation failure!",
868+
className: 'red-green-buttons'
869+
});
870+
return;
871+
}
872+
});
873+
}
874+
bootbox.alert({
875+
title:"Alert",
876+
message: "Operation succeeded!",
877+
className: 'red-green-buttons'
878+
});
879+
orgEdgexFoundry.supportNotification.loadTransmissionList();
880+
} else {
881+
return;
882+
}
883+
},
884+
});
885+
}
718886
//===============transmission section end=========================
719887
return notification;
720888
})();

cmd/edgex-ui-server/static/pages/notification.html

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ <h3 class="panel-title">Notification</h3>
3535
<div class="edgexIconBtn">
3636
<i class="fa fa-search fa-lg fa-fw" aria-hidden="true" onclick="orgEdgexFoundry.supportNotification.searchNotificationBtn()"></i>
3737
</div>
38+
<button type="button" class="btn btn-warning" onclick="orgEdgexFoundry.supportNotification.deleteNotificationBySlug();">
39+
<i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;Delete notification
40+
</button>
41+
<button type="button" class="btn btn-danger" onclick="orgEdgexFoundry.supportNotification.cleanUp();">
42+
<i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;Clean Up
43+
</button>
3844
</form>
3945
</div>
4046
</div>
@@ -45,7 +51,7 @@ <h3 class="panel-title">Notification</h3>
4551
<thead>
4652
<tr class="active">
4753
<!-- <th></th> -->
48-
<th>#</th>
54+
<th><input type="checkbox" id="notification_check_all"></th>
4955
<th>ID</th>
5056
<th>Slug</th>
5157
<th>Sender</th>
@@ -309,6 +315,9 @@ <h3 class="panel-title">Transmission</h3>
309315
<div class="edgexIconBtn">
310316
<i class="fa fa-search fa-lg fa-fw" aria-hidden="true" onclick="orgEdgexFoundry.supportNotification.seacrchTransmissionBtn()"></i>
311317
</div>
318+
<button type="button" class="btn btn-warning" onclick="orgEdgexFoundry.supportNotification.toDeleteTransmission();">
319+
<i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;Delete transmission
320+
</button>
312321
</form>
313322
</div>
314323
</div>
@@ -343,5 +352,37 @@ <h3 class="panel-title">Transmission</h3>
343352
</div>
344353
<!-- transmission section end -->
345354

355+
<div class="modal fade" id="transmission_model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
356+
<div class="modal-dialog" role="document">
357+
<div class="modal-content">
358+
<div class="modal-header">
359+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
360+
<h4 class="modal-title">Delete transmission</h4>
361+
</div>
362+
<div class="modal-body" id="transmission_paramsBox">
363+
<div class="panel-body" style="padding:0;">
364+
<form class="form-horizontal">
365+
<div class="form-group">
366+
<label class="col-md-2 control-label">Status</label>
367+
<div class="col-md-8">
368+
<select title="select transmission status" id="transstatus" name="transstatus" class='selectpicker show-tick form-control' multiple data-live-search='false'>
369+
<option value="acknowledged">acknowledged</option>
370+
<option value="escalated">escalated</option>
371+
<option value="failed">failed</option>
372+
<option value="sent">sent</option>
373+
</select>
374+
</div>
375+
</div>
376+
</form>
377+
</div>
378+
</div>
379+
<div class="modal-footer">
380+
<button type="button" class="btn btn-default" data-dismiss="modal"><span aria-hidden="true"></span>Close</button>
381+
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="orgEdgexFoundry.supportNotification.deleteTransmissionByStatus();"><span aria-hidden="true"></span>Ok</button>
382+
</div>
383+
</div>
384+
</div>
385+
</div>
386+
346387
</body>
347388
</html>

0 commit comments

Comments
 (0)