@@ -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
5157orgEdgexFoundry . 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} ) ( ) ;
0 commit comments