baseboard 1.0.1
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.
- checksums.yaml +15 -0
- data/README.md +4 -0
- data/bin/baseboard +9 -0
- data/javascripts/batman.jquery.js +163 -0
- data/javascripts/batman.js +13680 -0
- data/javascripts/dashing.coffee +125 -0
- data/javascripts/es5-shim.js +1021 -0
- data/javascripts/jquery.js +4 -0
- data/lib/baseboard/app.rb +178 -0
- data/lib/baseboard/cli.rb +109 -0
- data/lib/baseboard/downloader.rb +18 -0
- data/lib/baseboard.rb +6 -0
- data/templates/dashboard/%name%.erb.tt +7 -0
- data/templates/job/%name%.rb +4 -0
- data/templates/project/.gitignore +2 -0
- data/templates/project/Gemfile +6 -0
- data/templates/project/README.md +1 -0
- data/templates/project/assets/fonts/fontawesome-webfont.eot +0 -0
- data/templates/project/assets/fonts/fontawesome-webfont.svg +399 -0
- data/templates/project/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/templates/project/assets/fonts/fontawesome-webfont.woff +0 -0
- data/templates/project/assets/images/logo.png +0 -0
- data/templates/project/assets/javascripts/application.coffee +25 -0
- data/templates/project/assets/javascripts/d3-3.2.8.js +5 -0
- data/templates/project/assets/javascripts/dashing.gridster.coffee +37 -0
- data/templates/project/assets/javascripts/gridster/jquery.gridster.js +3263 -0
- data/templates/project/assets/javascripts/gridster/jquery.leanModal.min.js +5 -0
- data/templates/project/assets/javascripts/jquery.knob.js +646 -0
- data/templates/project/assets/javascripts/rickshaw-1.4.3.min.js +2 -0
- data/templates/project/assets/stylesheets/application.scss +258 -0
- data/templates/project/assets/stylesheets/font-awesome.css +1479 -0
- data/templates/project/assets/stylesheets/jquery.gridster.css +57 -0
- data/templates/project/config.ru +18 -0
- data/templates/project/dashboards/layout.erb +32 -0
- data/templates/project/dashboards/sample.erb +25 -0
- data/templates/project/dashboards/sampletv.erb +56 -0
- data/templates/project/jobs/buzzwords.rb +9 -0
- data/templates/project/jobs/convergence.rb +14 -0
- data/templates/project/jobs/sample.rb +13 -0
- data/templates/project/jobs/twitter.rb +28 -0
- data/templates/project/lib/.empty_directory +1 -0
- data/templates/project/public/404.html +26 -0
- data/templates/project/public/favicon.ico +0 -0
- data/templates/project/widgets/clock/clock.coffee +18 -0
- data/templates/project/widgets/clock/clock.html +2 -0
- data/templates/project/widgets/clock/clock.scss +13 -0
- data/templates/project/widgets/comments/comments.coffee +24 -0
- data/templates/project/widgets/comments/comments.html +7 -0
- data/templates/project/widgets/comments/comments.scss +33 -0
- data/templates/project/widgets/graph/graph.coffee +37 -0
- data/templates/project/widgets/graph/graph.html +5 -0
- data/templates/project/widgets/graph/graph.scss +65 -0
- data/templates/project/widgets/iframe/iframe.coffee +9 -0
- data/templates/project/widgets/iframe/iframe.html +1 -0
- data/templates/project/widgets/iframe/iframe.scss +8 -0
- data/templates/project/widgets/image/image.coffee +9 -0
- data/templates/project/widgets/image/image.html +1 -0
- data/templates/project/widgets/image/image.scss +13 -0
- data/templates/project/widgets/list/list.coffee +6 -0
- data/templates/project/widgets/list/list.html +18 -0
- data/templates/project/widgets/list/list.scss +60 -0
- data/templates/project/widgets/meter/meter.coffee +14 -0
- data/templates/project/widgets/meter/meter.html +7 -0
- data/templates/project/widgets/meter/meter.scss +35 -0
- data/templates/project/widgets/number/number.coffee +24 -0
- data/templates/project/widgets/number/number.html +11 -0
- data/templates/project/widgets/number/number.scss +39 -0
- data/templates/project/widgets/text/text.coffee +1 -0
- data/templates/project/widgets/text/text.html +7 -0
- data/templates/project/widgets/text/text.scss +32 -0
- data/templates/widget/%name%/%name%.coffee.tt +9 -0
- data/templates/widget/%name%/%name%.html +1 -0
- data/templates/widget/%name%/%name%.scss.tt +3 -0
- metadata +339 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#= require jquery
|
|
2
|
+
#= require es5-shim
|
|
3
|
+
#= require batman
|
|
4
|
+
#= require batman.jquery
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Batman.Filters.prettyNumber = (num) ->
|
|
8
|
+
num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") unless isNaN(num)
|
|
9
|
+
|
|
10
|
+
Batman.Filters.dashize = (str) ->
|
|
11
|
+
dashes_rx1 = /([A-Z]+)([A-Z][a-z])/g;
|
|
12
|
+
dashes_rx2 = /([a-z\d])([A-Z])/g;
|
|
13
|
+
|
|
14
|
+
return str.replace(dashes_rx1, '$1_$2').replace(dashes_rx2, '$1_$2').replace(/_/g, '-').toLowerCase()
|
|
15
|
+
|
|
16
|
+
Batman.Filters.shortenedNumber = (num) ->
|
|
17
|
+
return num if isNaN(num)
|
|
18
|
+
if num >= 1000000000
|
|
19
|
+
(num / 1000000000).toFixed(1) + 'B'
|
|
20
|
+
else if num >= 1000000
|
|
21
|
+
(num / 1000000).toFixed(1) + 'M'
|
|
22
|
+
else if num >= 1000
|
|
23
|
+
(num / 1000).toFixed(1) + 'K'
|
|
24
|
+
else
|
|
25
|
+
num
|
|
26
|
+
|
|
27
|
+
class window.Baseboard extends Batman.App
|
|
28
|
+
@on 'reload', (data) ->
|
|
29
|
+
window.location.reload(true)
|
|
30
|
+
|
|
31
|
+
@root ->
|
|
32
|
+
Baseboard.params = Batman.URI.paramsFromQuery(window.location.search.slice(1));
|
|
33
|
+
|
|
34
|
+
class Baseboard.Widget extends Batman.View
|
|
35
|
+
constructor: ->
|
|
36
|
+
# Set the view path
|
|
37
|
+
@constructor::source = Batman.Filters.underscore(@constructor.name)
|
|
38
|
+
super
|
|
39
|
+
|
|
40
|
+
@mixin($(@node).data())
|
|
41
|
+
Baseboard.widgets[@id] ||= []
|
|
42
|
+
Baseboard.widgets[@id].push(@)
|
|
43
|
+
@mixin(Baseboard.lastEvents[@id]) # in case the events from the server came before the widget was rendered
|
|
44
|
+
|
|
45
|
+
type = Batman.Filters.dashize(@view)
|
|
46
|
+
$(@node).addClass("widget widget-#{type} #{@id}")
|
|
47
|
+
|
|
48
|
+
@accessor 'updatedAtMessage', ->
|
|
49
|
+
if updatedAt = @get('updatedAt')
|
|
50
|
+
timestamp = new Date(updatedAt * 1000)
|
|
51
|
+
hours = timestamp.getHours()
|
|
52
|
+
minutes = ("0" + timestamp.getMinutes()).slice(-2)
|
|
53
|
+
"Last updated at #{hours}:#{minutes}"
|
|
54
|
+
|
|
55
|
+
@::on 'ready', ->
|
|
56
|
+
Baseboard.Widget.fire 'ready'
|
|
57
|
+
|
|
58
|
+
receiveData: (data) =>
|
|
59
|
+
@mixin(data)
|
|
60
|
+
@onData(data)
|
|
61
|
+
|
|
62
|
+
onData: (data) =>
|
|
63
|
+
# Widgets override this to handle incoming data
|
|
64
|
+
|
|
65
|
+
Baseboard.AnimatedValue =
|
|
66
|
+
get: Batman.Property.defaultAccessor.get
|
|
67
|
+
set: (k, to) ->
|
|
68
|
+
if !to? || isNaN(to)
|
|
69
|
+
@[k] = to
|
|
70
|
+
else
|
|
71
|
+
timer = "interval_#{k}"
|
|
72
|
+
num = if (!isNaN(@[k]) && @[k]?) then @[k] else 0
|
|
73
|
+
unless @[timer] || num == to
|
|
74
|
+
to = parseFloat(to)
|
|
75
|
+
num = parseFloat(num)
|
|
76
|
+
up = to > num
|
|
77
|
+
num_interval = Math.abs(num - to) / 90
|
|
78
|
+
@[timer] =
|
|
79
|
+
setInterval =>
|
|
80
|
+
num = if up then Math.ceil(num+num_interval) else Math.floor(num-num_interval)
|
|
81
|
+
if (up && num > to) || (!up && num < to)
|
|
82
|
+
num = to
|
|
83
|
+
clearInterval(@[timer])
|
|
84
|
+
@[timer] = null
|
|
85
|
+
delete @[timer]
|
|
86
|
+
@[k] = num
|
|
87
|
+
@set k, to
|
|
88
|
+
, 10
|
|
89
|
+
@[k] = num
|
|
90
|
+
|
|
91
|
+
Baseboard.widgets = widgets = {}
|
|
92
|
+
Baseboard.lastEvents = lastEvents = {}
|
|
93
|
+
Baseboard.debugMode = false
|
|
94
|
+
|
|
95
|
+
source = new EventSource('events')
|
|
96
|
+
source.addEventListener 'open', (e) ->
|
|
97
|
+
console.log("Connection opened", e)
|
|
98
|
+
|
|
99
|
+
source.addEventListener 'error', (e)->
|
|
100
|
+
console.log("Connection error", e)
|
|
101
|
+
if (e.currentTarget.readyState == EventSource.CLOSED)
|
|
102
|
+
console.log("Connection closed")
|
|
103
|
+
setTimeout (->
|
|
104
|
+
window.location.reload()
|
|
105
|
+
), 5*60*1000
|
|
106
|
+
|
|
107
|
+
source.addEventListener 'message', (e) ->
|
|
108
|
+
data = JSON.parse(e.data)
|
|
109
|
+
if lastEvents[data.id]?.updatedAt != data.updatedAt
|
|
110
|
+
if Baseboard.debugMode
|
|
111
|
+
console.log("Received data for #{data.id}", data)
|
|
112
|
+
if widgets[data.id]?.length > 0
|
|
113
|
+
lastEvents[data.id] = data
|
|
114
|
+
for widget in widgets[data.id]
|
|
115
|
+
widget.receiveData(data)
|
|
116
|
+
|
|
117
|
+
source.addEventListener 'dashboards', (e) ->
|
|
118
|
+
data = JSON.parse(e.data)
|
|
119
|
+
if Baseboard.debugMode
|
|
120
|
+
console.log("Received data for dashboards", data)
|
|
121
|
+
if data.dashboard is '*' or window.location.pathname is "/#{data.dashboard}"
|
|
122
|
+
Baseboard.fire data.event, data
|
|
123
|
+
|
|
124
|
+
$(document).ready ->
|
|
125
|
+
Baseboard.run()
|