@@ -35,6 +35,32 @@ t.preload = function () {
3535 e . preventDefault ( ) ;
3636 } ) ;
3737
38+ $ ( "#console-list-group" ) . on ( 'click' , '.fixAllButton' , function ( e ) {
39+ selectedId = $ ( this ) . attr ( "id" ) ;
40+ var matches = findAllIdsWithMatchingQueue ( selectedId ) ;
41+ swal ( {
42+ title : "Are you sure?" ,
43+ text : "You will not be able to undo this action!!" ,
44+ type : "warning" ,
45+ showCancelButton : true ,
46+ confirmButtonClass : "btn-danger" ,
47+ confirmButtonText : "Yes, fix all!" ,
48+ cancelButtonText : "Cancel" ,
49+ closeOnConfirm : false ,
50+ closeOnCancel : false
51+ } ,
52+ function ( isConfirm ) {
53+ if ( isConfirm ) {
54+ fixMultiple ( matches ) ;
55+ reset ( ) ;
56+ clearConsole ( ) ;
57+ e . preventDefault ( ) ;
58+ swal ( "Done!" , "All documents of matching queue have been marked as fixed!" , "success" ) ;
59+ }
60+ } ) ;
61+
62+ } ) ;
63+
3864
3965 $ ( "#dashboardMenu li a" ) . on ( 'click' , function ( ) {
4066 reset ( ) ;
@@ -61,6 +87,22 @@ function findLog(id) {
6187 return null ;
6288}
6389
90+ function findAllIdsWithMatchingQueue ( id ) {
91+ var log = findLog ( id ) ;
92+ var queue = log . queue ;
93+ var matches = [ ] ;
94+ for ( var i = 0 ; i < logHistory . length ; i ++ ) {
95+ if ( logHistory [ i ] . queue == queue ) {
96+ var match = {
97+ id : logHistory [ i ] . id ,
98+ index : logHistory [ i ] . index
99+ }
100+ matches . push ( match ) ;
101+ }
102+ }
103+ return matches ;
104+ }
105+
64106function reset ( ) {
65107 $ . fn . overlayout ( ) ;
66108 logStack = [ ] ;
@@ -166,13 +208,21 @@ function fixed(log) {
166208 "dashboard/fixed/" ,
167209 {
168210 id : log . id ,
169- date : log . date ,
170211 index : log . index
171212 }
172213 )
173214 }
174215}
175216
217+ function fixMultiple ( list ) {
218+ list . forEach ( function ( entry ) {
219+ $ . post ( "dashboard/fixed/" , {
220+ id : entry . id ,
221+ index : entry . index
222+ } ) ;
223+ } ) ;
224+ }
225+
176226function addLogToStack ( logs ) {
177227 //we got a valid response, remove service errors if they exist
178228 if ( logs . length > 0 )
@@ -212,7 +262,8 @@ function addLogToStack(logs) {
212262 correlationHtml = '<br><strong>Correlation ID: </strong>' + messageId ;
213263 correlationId = messageId ;
214264 buttonHtml = '<button id="' + log . _id + '"class="btn btn-warning retryButton"><span class="glyphicon glyphicon-repeat"></span> Retry</button> ' +
215- '<button id="' + log . _id + '" class="btn btn-success fixedButton"><span class="glyphicon glyphicon-ok"></span> Fixed</button>' ;
265+ '<button id="' + log . _id + '" class="btn btn-success fixedButton"><span class="glyphicon glyphicon-ok"></span> Fixed</button> ' +
266+ '<button id="' + log . _id + '" class="btn btn-danger fixAllButton"><span class="glyphicon glyphicon-fire"></span> Fix All (of matching queue)</button>' ;
216267 }
217268
218269 selectedId = log . _id ;
0 commit comments