Skip to content

Commit 14c578b

Browse files
wshengqibadboy-huaqiao
andauthored
Issue #257 (#260)
* clean up notifications Signed-off-by: wshengqi <wshengqi@vmware.com> * delete notifications and transmissions Signed-off-by: wshengqi <wshengqi@vmware.com> Co-authored-by: badboy-huaqiao <huaqiaoz@vmware.com>
1 parent e4aaba1 commit 14c578b

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ table.table td i.delete {
8585
color: #E34724;
8686
}
8787

88+
#clean_up_model .modal-dialog{
89+
position:fixed;
90+
top:10%;
91+
right:0;
92+
left:0;
93+
bottom:10%;
94+
margin:auto;
95+
}
8896

8997
#transmission_model .modal-dialog{
9098
position:fixed;

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ $(document).ready(function(){
4444
time_24hr:true,
4545
allowInput:false
4646
});
47+
$("#clean_up_age").flatpickr({
48+
dateFormat:"Y-m-d H:i:S",
49+
enableTime:true,
50+
enableSeconds:true,
51+
time_24hr:true,
52+
allowInput:false
53+
});
54+
$("#transmission_age").flatpickr({
55+
dateFormat:"Y-m-d H:i:S",
56+
enableTime:true,
57+
enableSeconds:true,
58+
time_24hr:true,
59+
allowInput:false
60+
});
4761
orgEdgexFoundry.supportNotification.loadNotificationList();
4862
orgEdgexFoundry.supportNotification.loadSubscriptionList();
4963
orgEdgexFoundry.supportNotification.loadTransmissionList();
@@ -90,6 +104,7 @@ orgEdgexFoundry.supportNotification = (function(){
90104
commitSubscriptionChannelBtn: null,
91105
cancelAddOrUpdateSubscriptionChannelBtn:null,
92106

107+
toCleanUp: null,
93108
cleanUp: null,
94109
deleteNotificationBySlug: null,
95110
toDeleteTransmission: null,
@@ -218,6 +233,12 @@ orgEdgexFoundry.supportNotification = (function(){
218233
$("#edgex-support-notification-list table tfoot").show();
219234
}
220235

236+
SupportNotification.prototype.toCleanUp = function(){
237+
$('#clean_up_model').modal({
238+
backdrop: "static"
239+
});
240+
}
241+
221242
SupportNotification.prototype.cleanUp = function(){
222243
bootbox.confirm({
223244
buttons: {
@@ -234,8 +255,17 @@ orgEdgexFoundry.supportNotification = (function(){
234255
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!',
235256
callback: function(result) {
236257
if(result) {
258+
var clean_up_age = $("#clean_up_age").val();
259+
if (!clean_up_age) {
260+
clean_up_age = new Date().valueOf()
261+
} else {
262+
clean_up_age = new Date(clean_up_age).valueOf();
263+
}
264+
console.log(new Date().valueOf())
265+
console.log(clean_up_age)
266+
console.log(new Date().valueOf() - 1600134667000 < clean_up_age)
237267
$.ajax({
238-
url:'/support-notification/api/v1/cleanup',
268+
url:'/support-notification/api/v1/cleanup/age/'+clean_up_age,
239269
type:'DELETE',
240270
success: function(){
241271
bootbox.alert({
@@ -848,6 +878,13 @@ orgEdgexFoundry.supportNotification = (function(){
848878
message: 'Delete all the transmissions by Status. Are you sure to delete this data? The operation is not recoverable!',
849879
callback: function(result) {
850880
if(result) {
881+
var transmission_age = $("#transmission_age").val();
882+
if (!transmission_age) {
883+
transmission_age = new Date().valueOf()
884+
} else {
885+
transmission_age = new Date(transmission_age).valueOf();
886+
}
887+
851888
var statusArr = $('#transstatus').val();
852889
if(statusArr == null || statusArr == '' || statusArr.length ==0){
853890
bootbox.alert({
@@ -859,7 +896,7 @@ orgEdgexFoundry.supportNotification = (function(){
859896
}
860897
for(var i=0;i<statusArr.length;i++){
861898
$.ajax({
862-
url:'/support-notification/api/v1/transmission/'+statusArr[i]+'/age/10000',
899+
url:'/support-notification/api/v1/transmission/'+statusArr[i]+'/age/'+transmission_age,
863900
type:'DELETE',
864901
error: function(){
865902
bootbox.alert({

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h3 class="panel-title">Notification</h3>
3838
<button type="button" class="btn btn-warning" onclick="orgEdgexFoundry.supportNotification.deleteNotificationBySlug();">
3939
<i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;Delete notification
4040
</button>
41-
<button type="button" class="btn btn-danger" onclick="orgEdgexFoundry.supportNotification.cleanUp();">
41+
<button type="button" class="btn btn-danger" onclick="orgEdgexFoundry.supportNotification.toCleanUp();">
4242
<i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;Clean Up
4343
</button>
4444
</form>
@@ -352,6 +352,33 @@ <h3 class="panel-title">Transmission</h3>
352352
</div>
353353
<!-- transmission section end -->
354354

355+
<div class="modal fade" id="clean_up_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">Clean up notifications</h4>
361+
</div>
362+
<div class="modal-body" id="clean_up_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">Select age</label>
367+
<div class="col-md-8">
368+
<input id="clean_up_age" type="text" class="form-control">
369+
</div>
370+
</div>
371+
</form>
372+
</div>
373+
</div>
374+
<div class="modal-footer">
375+
<button type="button" class="btn btn-default" data-dismiss="modal"><span aria-hidden="true"></span>Close</button>
376+
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="orgEdgexFoundry.supportNotification.cleanUp();"><span aria-hidden="true"></span>Ok</button>
377+
</div>
378+
</div>
379+
</div>
380+
</div>
381+
355382
<div class="modal fade" id="transmission_model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
356383
<div class="modal-dialog" role="document">
357384
<div class="modal-content">
@@ -373,6 +400,13 @@ <h4 class="modal-title">Delete transmission</h4>
373400
</select>
374401
</div>
375402
</div>
403+
<div class="form-group">
404+
<label class="col-md-2 control-label">Select age</label>
405+
<div class="col-md-8">
406+
<input id="transmission_age" type="text" class="form-control">
407+
</div>
408+
</div>
409+
376410
</form>
377411
</div>
378412
</div>

0 commit comments

Comments
 (0)