Skip to content

Instantly share code, notes, and snippets.

@gaving
Last active August 29, 2015 14:07
Show Gist options
  • Save gaving/e0b92c123a31516c5424 to your computer and use it in GitHub Desktop.
Save gaving/e0b92c123a31516c5424 to your computer and use it in GitHub Desktop.
class Dashing.Alert extends Dashing.Widget
ready: ->
onData: (data) ->
@accessor 'isHigh', ->
@get('level') in ['SEVERE', 'CRITICAL']
<h1 class="title" data-bind="title"></h1> <h2 class="level" data-bind="level"></h2>
.widget-alert {
background: #00ff99;
}
.widget-alert > h2 {
font-size: 50px;
}
.danger {
background: #FF7400;
}
<% content_for :title do %>Dashboard<% end %>
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="terror" data-view="Alert" data-addclass-danger="isHigh"></div>
<i class="icon-warning-sign icon-background"></i>
</li>
</ul>
</div>
require 'feedjira'
SCHEDULER.every '30s' do
feed = Feedjira::Feed.fetch_and_parse('https://www.mi5.gov.uk/UKThreatLevel/UKThreatLevel.xml')
entry = feed.entries.first
send_event('terror', {
title: entry.title,
level: entry.summary.scan(/\b[A-Z]+\b/)[1]
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment