Skip to content

Commit 8e0443f

Browse files
authored
Merge pull request #107 from ShaneIsrael/feature/add-fix-all-functionality-for-when-shit-hits-the-fan
Adds Fix All (of matching queue) button.
2 parents 553083b + 1099da0 commit 8e0443f

7 files changed

Lines changed: 748 additions & 9 deletions

File tree

plugins/gui/public/javascripts/dashboard.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
64106
function 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+
176226
function 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;

plugins/gui/public/javascripts/sweetalert.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/gui/public/stylesheets/dashboard.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ h2.double:before {
156156
border-top: none;
157157
}
158158

159+
.sweet-alert h2 {
160+
border: initial;
161+
color: black;
162+
}
159163
.optionsHeader {
160164
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
161165
font-weight: lighter;

0 commit comments

Comments
 (0)