sensu-dashboard 0.7.0 → 0.8.0

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.
@@ -41,6 +41,12 @@ EventMachine.run do
41
41
  body erb :clients
42
42
  end
43
43
 
44
+ aget '/stashes' do
45
+ content_type 'text/html'
46
+ @js = erb :stash_templates, :layout => false
47
+ body erb :stashes
48
+ end
49
+
44
50
  aget '/css/sonian.css' do
45
51
  content_type 'text/css'
46
52
  body sass :sonian
@@ -278,6 +284,62 @@ EventMachine.run do
278
284
  end
279
285
  end
280
286
 
287
+ aget '/stashes.json' do
288
+ begin
289
+ request_options = {
290
+ # :body => request.body.read,
291
+ :head => {
292
+ 'content-type' => 'application/json'
293
+ }
294
+ }
295
+ http = EventMachine::HttpRequest.new("#{api_server}/stashes").get request_options
296
+ rescue => e
297
+ puts e
298
+ status 404
299
+ body '{"error":"could not retrieve a list of stashes from the sensu api"}'
300
+ end
301
+
302
+ http.errback do
303
+ status 404
304
+ body '{"error":"could not retrieve a list of stashes from the sensu api"}'
305
+ end
306
+
307
+ http.callback do
308
+ resp = http.response
309
+ puts resp
310
+ status http.response_header.status
311
+ body resp
312
+ end
313
+ end
314
+
315
+ apost '/stashes.json' do
316
+ begin
317
+ request_options = {
318
+ :body => request.body.read,
319
+ :head => {
320
+ 'content-type' => 'application/json'
321
+ }
322
+ }
323
+ http = EventMachine::HttpRequest.new("#{api_server}/stashes").post request_options
324
+ rescue => e
325
+ puts e
326
+ status 404
327
+ body '{\"error\":\"could not retrieve a list of stashes from the sensu api\"}'
328
+ end
329
+
330
+ http.errback do
331
+ status 404
332
+ body '{\"error\":\"could not retrieve a list of stashes from the sensu api\"}'
333
+ end
334
+
335
+ http.callback do
336
+ resp = http.response
337
+ puts resp
338
+ status http.response_header.status
339
+ body resp
340
+ end
341
+ end
342
+
281
343
  websocket_connections = Array.new
282
344
  EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 9000) do |websocket|
283
345
  websocket.onopen do
@@ -152,6 +152,79 @@ function fetchClients() {
152
152
  });
153
153
  }
154
154
 
155
+ function fetchStashes() {
156
+ $('table#events > tbody').empty();
157
+ $.ajax({
158
+ type: 'GET',
159
+ url: '/stashes.json',
160
+ success: function(data, textStatus, xhr) {
161
+ $.ajax({
162
+ type: 'POST',
163
+ url: '/stashes.json',
164
+ data: JSON.stringify(data),
165
+ success: function(stash_data, textStatus, xhr) {
166
+ stashes = new Array();
167
+ for (stash in stash_data) {
168
+ stash_keys = new Array();
169
+ stash_values = new Array();
170
+ for (stash_value in stash_data[stash]) {
171
+ stash_keys.push(stash_value);
172
+ stash_values.push({
173
+ name: stash_value,
174
+ value: stash_data[stash][stash_value]
175
+ });
176
+ }
177
+ stashes.push({
178
+ identifier: SHA1(stash),
179
+ name: stash,
180
+ keys: stash_keys.join(', '),
181
+ values: stash_values
182
+ });
183
+ }
184
+ $('#stashTemplate').tmpl(stashes).appendTo('table#events > tbody');
185
+ $('tbody > tr').click(function() {
186
+ $('div#event_details_modal').empty();
187
+ var row = $(this).parent().children().index($(this));
188
+ $('#stashDetailsTemplate').tmpl(stashes[row]).appendTo('div#event_details_modal');
189
+ $('div#delete_stash').click(function() {
190
+ $('div#delete_stash > img').attr("src", "/img/loading_circle.gif");
191
+ $.ajax({
192
+ type: 'DELETE',
193
+ url: '/stash/'+stashes[row]['name']+'.json',
194
+ success: function(data, textStatus, xhr) {
195
+ $("#lean_overlay").fadeOut(200);
196
+ $("#event_details_modal").css({'display':'none'});
197
+ fetchStashes();
198
+ },
199
+ error: function(xhr, textStatus, errorThrown) {
200
+ $('div#delete_stash > img').attr("src", "/img/cross.png");
201
+ console.log('XHR: ' + xhr);
202
+ console.log('textStatus: ' + textStatus);
203
+ console.log('errorThrown: ' + errorThrown);
204
+ alert('Error deleting stash');
205
+ }
206
+ });
207
+ });
208
+ });
209
+ $('tr[rel*=leanModal]').leanModal({ top : 50, bottom : 50 });
210
+ },
211
+ error: function(xhr, textStatus, errorThrown) {
212
+ console.log('XHR: ' + xhr);
213
+ console.log('textStatus: ' + textStatus);
214
+ console.log('errorThrown: ' + errorThrown);
215
+ alert('Error retrieving stashes');
216
+ }
217
+ });
218
+ },
219
+ error: function(xhr, textStatus, errorThrown) {
220
+ console.log('XHR: ' + xhr);
221
+ console.log('textStatus: ' + textStatus);
222
+ console.log('errorThrown: ' + errorThrown);
223
+ alert('Error retrieving stashes');
224
+ }
225
+ });
226
+ }
227
+
155
228
  function filterEvents() {
156
229
  var values = $("input[type=hidden]").val().split(",");
157
230
  filtered_events = [];
@@ -1,5 +1,5 @@
1
1
  module Sensu
2
2
  module Dashboard
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -63,6 +63,7 @@
63
63
 
64
64
  <ol>
65
65
  <li><a href="/clients">Clients</a></li>
66
+ <li><a href="/stashes">Stashes</a></li>
66
67
  <li><a href="/">Current Events</a></li>
67
68
  </ol>
68
69
 
@@ -78,6 +78,7 @@ section#main_content
78
78
  tbody tr
79
79
  background-color: #fff
80
80
  cursor: pointer
81
+ border-bottom: 1px solid #ccc
81
82
  &.status2
82
83
  background-color: #b55
83
84
  color: #fff
@@ -95,7 +96,7 @@ section#main_content
95
96
  border-top: 1px solid #ccc
96
97
  &.status3
97
98
  border-top: 1px solid #fffbb5
98
- &.status2:hover, &.status1:hover, &.status3:hover
99
+ &.status2:hover, &.status1:hover, &.status3:hover, &:hover
99
100
  background-color: #992222
100
101
  color: #fff
101
102
  border-bottom: 1px solid #880000
@@ -0,0 +1,44 @@
1
+ <!-- Stash template -->
2
+ <script id="stashTemplate" type="text/x-jquery-tmpl">
3
+ <tr id="${name}" rel="leanModal" href="#event_details_modal">
4
+ <td>${name}</td><td>${keys}</td>
5
+ </tr>
6
+ </script>
7
+
8
+ <!-- Stash details row template -->
9
+ <script id="stashDetailsTemplate" type="text/x-jquery-tmpl">
10
+ <h1 class="section_title">Actions</h1>
11
+ <div id="event_actions">
12
+ <div class="event_detail_group">
13
+ <div class="event_detail">
14
+ <div id="delete_stash" class="action_btn" style="margin-right: 7px;">
15
+ <img src="/img/cross.png" style="vertical-align: middle; padding-right: 7px;"/><strong>Delete Stash</strong>
16
+ </div>
17
+ </div>
18
+ <div style="clear: both;"></div>
19
+ </div>
20
+ </div>
21
+ <h1 class="section_title">Stash Information</h1>
22
+ <div class="event_detail_group">
23
+ <h1>Path</h1>
24
+ <p>${name}</p>
25
+ </div>
26
+ <div style="clear: both;"></div>
27
+ <h1 class="section_title">Stash Data</h1>
28
+ {{each values}}
29
+ <div class="event_detail_group">
30
+ <h1>${$value['name']}</h1>
31
+ <p>${$value['value']}</p>
32
+ </div>
33
+ {{/each}}
34
+ <div style="clear: both;"></div>
35
+ </script>
36
+
37
+ <script type="text/javascript">
38
+ fetchStashes();
39
+
40
+ ws = new WebSocket("ws://" + location.hostname + ":9000");
41
+ ws.onmessage = function(evt) {
42
+ fetchStashes();
43
+ }
44
+ </script>
@@ -0,0 +1,32 @@
1
+ <h1>Stashes</h1>
2
+
3
+ <table id="events">
4
+
5
+ <thead>
6
+
7
+ <tr>
8
+ <td class="col_clients">Path</td>
9
+ <td class="col_checks">Keys</td>
10
+ </tr>
11
+
12
+ </thead>
13
+
14
+ <tbody></tbody>
15
+
16
+ </table>
17
+
18
+ <div id="event_details_modal" class="event_details_modal">
19
+ <h1 class="section_title">Actions</h1>
20
+ <div id="event_actions">
21
+ <div class="event_detail_group">
22
+ <div class="event_detail">
23
+ <div id="delete_stash" class="action_btn" style="margin-right: 7px;">
24
+ <img src="/img/cross.png" style="vertical-align: middle; padding-right: 7px;"/><strong>Delete Stash</strong>
25
+ </div>
26
+ </div>
27
+ <div style="clear: both;"></div>
28
+ </div>
29
+ </div>
30
+ <h1 class="section_title">Stash Data</h1>
31
+ <div id="stash_data"></div>
32
+ </div>
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: 3
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.0
10
+ version: 0.8.0
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-11-30 00:00:00 -08:00
19
+ date: 2011-12-06 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -125,6 +125,8 @@ files:
125
125
  - lib/sensu-dashboard/views/index.erb
126
126
  - lib/sensu-dashboard/views/layout.erb
127
127
  - lib/sensu-dashboard/views/sonian.sass
128
+ - lib/sensu-dashboard/views/stash_templates.erb
129
+ - lib/sensu-dashboard/views/stashes.erb
128
130
  - sensu-dashboard.gemspec
129
131
  has_rdoc: true
130
132
  homepage: https://github.com/sonian/sensu-dashboard