Skip to content

Commit

Permalink
Stopping now
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Dec 31, 2015
1 parent e065095 commit 0460f6d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
5 changes: 5 additions & 0 deletions config/lookups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ snake-data:

sheds:
date-field: Shed completed

feeds:
special-fields:
- Eaten
- Food
6 changes: 5 additions & 1 deletion lib/assets/css/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
text-align: center;
}

#numbers h1, h2, h3 {
#numbers h1, h2, h3, h4 {
padding: 0px;
margin: 0px;
}
Expand All @@ -16,3 +16,7 @@
#numbers h3 {
font-size: 1em;
}

#numbers div {
padding: 5px;
}
1 change: 0 additions & 1 deletion lib/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
module Dashboard
class App < Sinatra::Base
set :views, 'lib/views'
set :sass, { :load_paths => [ "#{App.root}/../assets/css" ] }

get '/' do
@content = '<h1>Home Dashboard</h1>'
Expand Down
3 changes: 2 additions & 1 deletion lib/dashboard/cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def self.sanitized_data url
j['name'] = d['name']
j['id'] = trim d['name']
j['date-field'] = lookups.dig(d['repo'], 'datasets', trim(d['name']), 'date-field') || 'Date'
# require "pry" ; binding.pry
j['type'] = lookups.dig(d['repo'], 'datasets', trim(d['name']), 'type') || 'latest'
j['url'] = d['_links']['html']
sf = lookups.dig(d['repo'], 'datasets', trim(d['name']), 'special-fields')
j['special_fields'] = sf if sf
j['data'] = jsonise d['data']

j
Expand Down
26 changes: 22 additions & 4 deletions lib/views/grid.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<h1><%= @title %> dashboard</h1>
<hr />

<div class='row' id='numbers'></div>

Expand Down Expand Up @@ -40,9 +42,9 @@
color: '#7f7f7f'
}
},
margin: { // update the left, bottom, right, top margin
margin: {
l: 40, r: 10
}
}
}

$('#charts').append("<div id='" + json['id'] + "' class='col-md-6' style='height: 400px'></div>")
Expand All @@ -51,9 +53,25 @@

function latestCell(json) {
d = json['data'][json['data'].length -1][json['date-field']]
fixedDate = moment(d, 'YYYY-MM-DD').format('dddd Do MMMM')
fixedDate = moment(d, 'YYYY-MM-DD').format('Do MMMM')
age = moment(d, 'YYYY-MM-DD').fromNow()
content = '<h1><small>Last</small> ' + json['title'] + ' <small>was on</small></h1><h2>' + fixedDate + '</h2><h3>(' + age + ')</h3>'
content = '<h1><small>Last</small> '
content += json['title'] + ':</h1>'
if(json['special_fields']) {
debugger
content += '<h4>'

json['special_fields'].forEach(function(field) {
content += json['data'][json['data'].length -1][field]
content += ' '
})

content += '</h4>'
}
content += '<h2>' + fixedDate + '</h2>'
content += '<h3>(' + age + ')</h3>'
content += '<hr />'

return cellContent(json['id'], content)
}

Expand Down
26 changes: 13 additions & 13 deletions lib/views/includes/nav.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<nav class="navbar navbar-default">
<div class="container-fluid">
<nav class='navbar navbar-default' role='navigation'>
<div class='container-fluid'>
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<div class='navbar-header'>
<button type='button' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#navbar-collapse' aria-expanded='false'>
<span class='sr-only'>Toggle navigation</span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
</button>
<a class="navbar-brand" href="/">Home</a>
<a class='navbar-brand' href='/'>Home</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
<div class='collapse navbar-collapse' id='navbar-collapse'>
<ul class='nav navbar-nav'>
<% lookups = Dashboard::Cleaner.lookups %>
<% lookups.keys.each do |dashboard| %>
<li
<% if lookups[dashboard]['url'] == request.env['REQUEST_URI']%>
class="active"
class='active'
<% end %>
><a href="<%= lookups[dashboard]['url'] %>"><%= lookups[dashboard]['title'] %></a></li>
><a href='<%= lookups[dashboard]["url"] %>'><%= lookups[dashboard]['title'] %></a></li>
<% end %>
</ul>
</div><!-- /.navbar-collapse -->
Expand Down
6 changes: 4 additions & 2 deletions lib/views/index.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<%= @content %>

<ul>
<li><a href='catface'>Catface</a></li>
<li><a href='snake'>Snake</a></li>
<% lookups = Dashboard::Cleaner.lookups %>
<% lookups.keys.each do |dashboard| %>
<li><a href='<%= lookups[dashboard]["url"] %>'><%= lookups[dashboard]['title'] %></a></li>
<% end %>
</ul>

0 comments on commit 0460f6d

Please sign in to comment.