sensu-dashboard 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sensu-dashboard/app.rb +51 -0
- data/lib/sensu-dashboard/public/js/functions.js +90 -72
- data/lib/sensu-dashboard/version.rb +1 -1
- data/lib/sensu-dashboard/views/client_templates.erb +17 -1
- data/lib/sensu-dashboard/views/clients.erb +6 -4
- data/lib/sensu-dashboard/views/event_templates.erb +22 -1
- data/lib/sensu-dashboard/views/index.erb +4 -5
- data/lib/sensu-dashboard/views/sonian.sass +12 -12
- metadata +4 -4
data/lib/sensu-dashboard/app.rb
CHANGED
@@ -173,6 +173,57 @@ EventMachine.run do
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
+
# api proxy
|
177
|
+
aget '/clients/autocomplete.json' do
|
178
|
+
multi = EventMachine::MultiRequest.new
|
179
|
+
|
180
|
+
requests = [
|
181
|
+
"#{api_server}/clients"
|
182
|
+
]
|
183
|
+
|
184
|
+
requests.each do |url|
|
185
|
+
multi.add EventMachine::HttpRequest.new(url).get
|
186
|
+
end
|
187
|
+
|
188
|
+
multi.callback do
|
189
|
+
events = {}
|
190
|
+
clients = []
|
191
|
+
|
192
|
+
multi.responses[:succeeded].each do |request|
|
193
|
+
body = JSON.parse(request.response)
|
194
|
+
case body
|
195
|
+
when Array
|
196
|
+
clients = body
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
if clients
|
201
|
+
autocomplete = []
|
202
|
+
subscriptions = {}
|
203
|
+
|
204
|
+
# searching by client
|
205
|
+
clients.each do |client|
|
206
|
+
client_name = client['name']
|
207
|
+
autocomplete.push({:value => [client_name], :type => 'client', :name => client_name})
|
208
|
+
client['subscriptions'].each do |subscription|
|
209
|
+
subscriptions[subscription] ||= []
|
210
|
+
subscriptions[subscription].push(client_name)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# searching by subscription
|
215
|
+
subscriptions.each do |k, v|
|
216
|
+
autocomplete.push({:value => v.uniq, :type => 'subscription', :name => k})
|
217
|
+
end
|
218
|
+
|
219
|
+
body autocomplete.to_json
|
220
|
+
else
|
221
|
+
status 404
|
222
|
+
body '{"error":"could not retrieve clients from the sensu api"}'
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
176
227
|
aget '/client/:id.json' do |id|
|
177
228
|
begin
|
178
229
|
http = EventMachine::HttpRequest.new("#{api_server}/client/#{id}").get
|
@@ -198,8 +198,42 @@ function fetchClients() {
|
|
198
198
|
|
199
199
|
$('table#clients > tbody').empty();
|
200
200
|
|
201
|
+
// iterate through the filters
|
202
|
+
grouped_filters = {};
|
203
|
+
for (var i in selected_filters) {
|
204
|
+
var current_filter = selected_filters[i];
|
205
|
+
|
206
|
+
// store client filters in the grouped filters array
|
207
|
+
if (current_filter['type'] == 'client') {
|
208
|
+
grouped_filters['client'] || (grouped_filters['client'] = []);
|
209
|
+
for (var j in current_filter['value']) {
|
210
|
+
grouped_filters['client'].push(current_filter['value'][j]);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
// store subscription filters in the grouped filters array
|
215
|
+
if (current_filter['type'] == 'subscription') {
|
216
|
+
grouped_filters['subscription'] || (grouped_filters['subscription'] = []);
|
217
|
+
for (var j in current_filter['value']) {
|
218
|
+
grouped_filters['subscription'].push(current_filter['value'][j]);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
// iterate through each node
|
201
224
|
for (var clientkey in data) {
|
202
225
|
var client = data[clientkey];
|
226
|
+
|
227
|
+
// skip node if client filters exist and the client is not in the filter
|
228
|
+
if ((Object.size(grouped_filters['client']) > 0) && ($.inArray(client['name'], grouped_filters['client']) == -1)) {
|
229
|
+
continue;
|
230
|
+
}
|
231
|
+
|
232
|
+
// skip node if subscription filters exist and the subscription is not in the filter
|
233
|
+
if ((Object.size(grouped_filters['subscription']) > 0) && ($.inArray(client['name'], grouped_filters['subscription']) == -1)) {
|
234
|
+
continue;
|
235
|
+
}
|
236
|
+
|
203
237
|
client['subscriptions'] = client['subscriptions'].join(', ');
|
204
238
|
m_clients.push(client);
|
205
239
|
}
|
@@ -227,64 +261,66 @@ function fetchStashes() {
|
|
227
261
|
type: 'GET',
|
228
262
|
url: '/stashes.json',
|
229
263
|
success: function(data, textStatus, xhr) {
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
264
|
+
if (data.legnth > 0) {
|
265
|
+
$.ajax({
|
266
|
+
type: 'POST',
|
267
|
+
url: '/stashes.json',
|
268
|
+
data: JSON.stringify(data),
|
269
|
+
success: function(stash_data, textStatus, xhr) {
|
270
|
+
stashes = new Array();
|
271
|
+
for (var stash in stash_data) {
|
272
|
+
stash_keys = new Array();
|
273
|
+
stash_values = new Array();
|
274
|
+
for (var stash_value in stash_data[stash]) {
|
275
|
+
stash_keys.push(stash_value);
|
276
|
+
stash_values.push({
|
277
|
+
name: stash_value,
|
278
|
+
value: stash_data[stash][stash_value]
|
279
|
+
});
|
280
|
+
}
|
281
|
+
stashes.push({
|
282
|
+
identifier: SHA1(stash),
|
283
|
+
name: stash,
|
284
|
+
keys: stash_keys.join(', '),
|
285
|
+
values: stash_values
|
244
286
|
});
|
245
287
|
}
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
$('div#delete_stash > img').attr("src", "/img/cross.png");
|
271
|
-
console.log('XHR: ' + xhr);
|
272
|
-
console.log('textStatus: ' + textStatus);
|
273
|
-
console.log('errorThrown: ' + errorThrown);
|
274
|
-
alert('Error deleting stash');
|
275
|
-
}
|
288
|
+
$('table#events > tbody').empty();
|
289
|
+
$('#stashTemplate').tmpl(stashes).appendTo('table#events > tbody');
|
290
|
+
$('tbody > tr').click(function() {
|
291
|
+
$('div#event_details_modal').empty();
|
292
|
+
var row = $(this).parent().children().index($(this));
|
293
|
+
$('#stashDetailsTemplate').tmpl(stashes[row]).appendTo('div#event_details_modal');
|
294
|
+
$('div#delete_stash').click(function() {
|
295
|
+
$('div#delete_stash > img').attr("src", "/img/loading_circle.gif");
|
296
|
+
$.ajax({
|
297
|
+
type: 'DELETE',
|
298
|
+
url: '/stash/'+stashes[row]['name']+'.json',
|
299
|
+
success: function(data, textStatus, xhr) {
|
300
|
+
$("#lean_overlay").fadeOut(200);
|
301
|
+
$("#event_details_modal").css({'display':'none'});
|
302
|
+
fetchStashes();
|
303
|
+
},
|
304
|
+
error: function(xhr, textStatus, errorThrown) {
|
305
|
+
$('div#delete_stash > img').attr("src", "/img/cross.png");
|
306
|
+
console.log('XHR: ' + xhr);
|
307
|
+
console.log('textStatus: ' + textStatus);
|
308
|
+
console.log('errorThrown: ' + errorThrown);
|
309
|
+
alert('Error deleting stash');
|
310
|
+
}
|
311
|
+
});
|
276
312
|
});
|
277
313
|
});
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
}
|
287
|
-
|
314
|
+
$('tr[rel*=leanModal]').leanModal({ top : 50, bottom : 50 });
|
315
|
+
},
|
316
|
+
error: function(xhr, textStatus, errorThrown) {
|
317
|
+
console.log('XHR: ' + xhr);
|
318
|
+
console.log('textStatus: ' + textStatus);
|
319
|
+
console.log('errorThrown: ' + errorThrown);
|
320
|
+
alert('Error retrieving stashes');
|
321
|
+
}
|
322
|
+
});
|
323
|
+
}
|
288
324
|
},
|
289
325
|
error: function(xhr, textStatus, errorThrown) {
|
290
326
|
console.log('XHR: ' + xhr);
|
@@ -298,19 +334,6 @@ function fetchStashes() {
|
|
298
334
|
/* trigger when page is ready */
|
299
335
|
$(document).ready(function() {
|
300
336
|
|
301
|
-
$("input[type=text]").autoSuggest("http://" + location.hostname + ":" + location.port + "/autocomplete.json", {
|
302
|
-
startText: "Enter keywords to filter by",
|
303
|
-
selectedItemProp: "name",
|
304
|
-
searchObjProps: "name",
|
305
|
-
selectionAdded: function(elem) {
|
306
|
-
fetchEvents();
|
307
|
-
},
|
308
|
-
selectionRemoved: function(elem) {
|
309
|
-
elem.fadeTo("fast", 0, function() { elem.remove(); });
|
310
|
-
fetchEvents();
|
311
|
-
}
|
312
|
-
});
|
313
|
-
|
314
337
|
$(document).keyup(function(e) {
|
315
338
|
if (e.keyCode == 27) { // esc
|
316
339
|
$("#lean_overlay").fadeOut(200);
|
@@ -318,11 +341,6 @@ $(document).ready(function() {
|
|
318
341
|
}
|
319
342
|
});
|
320
343
|
|
321
|
-
$('#filter_unknown_checks').change(function() {
|
322
|
-
filter_unknown_checks = !filter_unknown_checks;
|
323
|
-
fetchEvents();
|
324
|
-
});
|
325
|
-
|
326
344
|
// TODO: fix clipboard support
|
327
345
|
/*$('div#event_details_modal > div.event_detail_group > div.copy').click(function() {
|
328
346
|
var currentVal = $(this).parent().find('div.event_detail').children().last().text();
|
@@ -1,7 +1,10 @@
|
|
1
1
|
<!-- Client template -->
|
2
2
|
<script id="clientTemplate" type="text/x-jquery-tmpl">
|
3
3
|
<tr id="${name}" rel="leanModal" href="#event_details_modal">
|
4
|
-
<td id="client_id">${name}</td
|
4
|
+
<td id="client_id">${name}</td>
|
5
|
+
<td id="public_ip">${address}</td>
|
6
|
+
<td id="timestamp">${timestamp}</td>
|
7
|
+
<td id="subscriptions">${subscriptions}</td>
|
5
8
|
</tr>
|
6
9
|
</script>
|
7
10
|
|
@@ -48,4 +51,17 @@ $("#remove_client").click(function() {
|
|
48
51
|
}
|
49
52
|
});
|
50
53
|
});
|
54
|
+
|
55
|
+
$("input[type=text]").autoSuggest("http://" + location.hostname + ":" + location.port + "/clients/autocomplete.json", {
|
56
|
+
startText: "Enter keywords to filter by",
|
57
|
+
selectedItemProp: "name",
|
58
|
+
searchObjProps: "name",
|
59
|
+
selectionAdded: function(elem) {
|
60
|
+
fetchClients();
|
61
|
+
},
|
62
|
+
selectionRemoved: function(elem) {
|
63
|
+
elem.fadeTo("fast", 0, function() { elem.remove(); });
|
64
|
+
fetchClients();
|
65
|
+
}
|
66
|
+
});
|
51
67
|
</script>
|
@@ -1,14 +1,16 @@
|
|
1
1
|
<h1>Current Clients <span class="clients_count">(<span id="client_count">0</span>)</span></h1>
|
2
2
|
|
3
|
+
<input type="text" id="autosuggest_filter" style="width: 300px;"/>
|
4
|
+
|
3
5
|
<table id="clients">
|
4
6
|
|
5
7
|
<thead>
|
6
8
|
|
7
9
|
<tr>
|
8
|
-
<
|
9
|
-
<
|
10
|
-
<
|
11
|
-
<
|
10
|
+
<th class="col_clients">Client</th>
|
11
|
+
<th class="col_public_ip">Public IP</th>
|
12
|
+
<th class="col_timestamp">Timestamp</th>
|
13
|
+
<th class="col_output">Subscriptions</th>
|
12
14
|
</tr>
|
13
15
|
|
14
16
|
</thead>
|
@@ -5,7 +5,9 @@
|
|
5
5
|
{{else}}
|
6
6
|
<tr class="status${status}" id="${identifier}" rel="leanModal" href="#event_details_modal">
|
7
7
|
{{/if}}
|
8
|
-
<td id="client">${client}</td
|
8
|
+
<td id="client">${client}</td>
|
9
|
+
<td id="check">${check}</td>
|
10
|
+
<td id="output">${output}</td>
|
9
11
|
</tr>
|
10
12
|
</script>
|
11
13
|
|
@@ -147,6 +149,7 @@ $("#disable_client_check_alerts").click(function() {
|
|
147
149
|
});
|
148
150
|
}
|
149
151
|
});
|
152
|
+
|
150
153
|
$("#resolve_event").click(function() {
|
151
154
|
var client = $("#client_id_value").html();
|
152
155
|
var check = $("#check_name_value").html();
|
@@ -165,4 +168,22 @@ $("#resolve_event").click(function() {
|
|
165
168
|
}
|
166
169
|
});
|
167
170
|
});
|
171
|
+
|
172
|
+
$("input[type=text]").autoSuggest("http://" + location.hostname + ":" + location.port + "/autocomplete.json", {
|
173
|
+
startText: "Enter keywords to filter by",
|
174
|
+
selectedItemProp: "name",
|
175
|
+
searchObjProps: "name",
|
176
|
+
selectionAdded: function(elem) {
|
177
|
+
fetchEvents();
|
178
|
+
},
|
179
|
+
selectionRemoved: function(elem) {
|
180
|
+
elem.fadeTo("fast", 0, function() { elem.remove(); });
|
181
|
+
fetchEvents();
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
185
|
+
$('#filter_unknown_checks').change(function() {
|
186
|
+
filter_unknown_checks = !filter_unknown_checks;
|
187
|
+
fetchEvents();
|
188
|
+
});
|
168
189
|
</script>
|
@@ -4,17 +4,16 @@
|
|
4
4
|
<input type="checkbox" checked="checked" id="filter_unknown_checks" style="margin-right: 7px;"/>Filter Unknown Checks
|
5
5
|
</div>
|
6
6
|
|
7
|
-
<input type="text" id="
|
7
|
+
<input type="text" id="autosuggest_client_filter" style="width: 300px;"/>
|
8
8
|
|
9
9
|
<table id="events">
|
10
10
|
|
11
11
|
<thead>
|
12
12
|
|
13
13
|
<tr>
|
14
|
-
<
|
15
|
-
<
|
16
|
-
<
|
17
|
-
<td class="col_output">Output</td>
|
14
|
+
<th class="col_clients">Client</th>
|
15
|
+
<th class="col_checks">Check</th>
|
16
|
+
<th class="col_output">Output</th>
|
18
17
|
</tr>
|
19
18
|
|
20
19
|
</thead>
|
@@ -59,22 +59,16 @@ section#main_content
|
|
59
59
|
*-moz-box-shadow: 0 -1px 0 rgba(0,0,0,0.15);
|
60
60
|
*box-shadow: 0 -1px 0 rgba(0,0,0,0.15);
|
61
61
|
table
|
62
|
-
table-layout: fixed
|
62
|
+
//table-layout: fixed
|
63
63
|
width: 100%
|
64
64
|
thead tr
|
65
65
|
cursor: pointer
|
66
|
-
|
66
|
+
th
|
67
67
|
padding: 7px
|
68
68
|
font-weight: 600
|
69
69
|
font-size: 14px
|
70
70
|
text-shadow: 0 1px 0 white
|
71
|
-
|
72
|
-
width: 100px
|
73
|
-
&.col_checks
|
74
|
-
width: 150px
|
75
|
-
&.col_status
|
76
|
-
width: 80px
|
77
|
-
display: none
|
71
|
+
text-align: left
|
78
72
|
tbody tr
|
79
73
|
background-color: #fff
|
80
74
|
cursor: pointer
|
@@ -103,9 +97,15 @@ section#main_content
|
|
103
97
|
border-top: 1px solid #880000
|
104
98
|
td
|
105
99
|
padding: 7px
|
106
|
-
|
107
|
-
&#
|
108
|
-
|
100
|
+
white-space: nowrap
|
101
|
+
&#output
|
102
|
+
white-space: normal
|
103
|
+
word-break: break-all
|
104
|
+
width: 100%
|
105
|
+
&#subscriptions
|
106
|
+
white-space: normal
|
107
|
+
word-break: break-all
|
108
|
+
width: 100%
|
109
109
|
table#clients
|
110
110
|
table-layout: auto
|
111
111
|
tbody
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-dashboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 3
|
10
|
+
version: 0.9.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Kolberg
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
19
|
+
date: 2011-12-27 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|