pulse-meter 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -1
- data/README.md +32 -16
- data/Rakefile +29 -10
- data/examples/basic.ru +1 -1
- data/examples/full/server.ru +1 -1
- data/examples/minimal/server.ru +1 -1
- data/lib/pulse-meter.rb +1 -0
- data/lib/pulse-meter/observer.rb +117 -0
- data/lib/pulse-meter/sensor.rb +1 -0
- data/lib/pulse-meter/sensor/timeline.rb +3 -2
- data/lib/pulse-meter/sensor/timelined/multi_percentile.rb +43 -0
- data/lib/pulse-meter/version.rb +1 -1
- data/lib/pulse-meter/visualize/app.rb +28 -12
- data/lib/pulse-meter/visualize/coffee/application.coffee +40 -0
- data/lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee +17 -0
- data/lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee +4 -0
- data/lib/pulse-meter/visualize/coffee/collections/widget_list.coffee +14 -0
- data/lib/pulse-meter/visualize/coffee/extensions.coffee +26 -0
- data/lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee +34 -0
- data/lib/pulse-meter/visualize/coffee/models/page_info.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/models/sensor_info.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/models/widget.coffee +54 -0
- data/lib/pulse-meter/visualize/coffee/presenters/area.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/presenters/gauge.coffee +11 -0
- data/lib/pulse-meter/visualize/coffee/presenters/line.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/presenters/pie.coffee +20 -0
- data/lib/pulse-meter/visualize/coffee/presenters/series.coffee +44 -0
- data/lib/pulse-meter/visualize/coffee/presenters/table.coffee +10 -0
- data/lib/pulse-meter/visualize/coffee/presenters/timeline.coffee +13 -0
- data/lib/pulse-meter/visualize/coffee/presenters/widget.coffee +65 -0
- data/lib/pulse-meter/visualize/coffee/router.coffee +21 -0
- data/lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee +91 -0
- data/lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee +58 -0
- data/lib/pulse-meter/visualize/coffee/views/page_title.coffee +17 -0
- data/lib/pulse-meter/visualize/coffee/views/page_titles.coffee +15 -0
- data/lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee +19 -0
- data/lib/pulse-meter/visualize/coffee/views/widget.coffee +99 -0
- data/lib/pulse-meter/visualize/coffee/views/widget_chart.coffee +13 -0
- data/lib/pulse-meter/visualize/coffee/views/widget_list.coffee +15 -0
- data/lib/pulse-meter/visualize/layout.rb +4 -4
- data/lib/pulse-meter/visualize/public/css/application.css +13 -4
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css +1320 -0
- data/lib/pulse-meter/visualize/public/js/application.js +900 -691
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js +791 -0
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js +21 -0
- data/lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js +1687 -0
- data/lib/pulse-meter/visualize/sensor.rb +2 -2
- data/lib/pulse-meter/visualize/views/main.haml +2 -3
- data/lib/pulse-meter/visualize/views/sensors.haml +14 -1
- data/lib/pulse-meter/visualize/views/widgets/area.haml +46 -24
- data/lib/pulse-meter/visualize/views/widgets/line.haml +46 -23
- data/lib/pulse-meter/visualize/views/widgets/table.haml +37 -15
- data/lib/pulse-meter/visualize/widgets/timeline.rb +20 -5
- data/pulse-meter.gemspec +4 -0
- data/spec/pulse_meter/observer_spec.rb +252 -0
- data/spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb +21 -0
- data/spec/pulse_meter/visualize/sensor_spec.rb +5 -5
- data/spec/pulse_meter/visualize/widgets/area_spec.rb +1 -74
- data/spec/pulse_meter/visualize/widgets/line_spec.rb +1 -73
- data/spec/pulse_meter/visualize/widgets/table_spec.rb +1 -73
- data/spec/shared_examples/timeline_sensor.rb +10 -0
- data/spec/shared_examples/widget.rb +97 -0
- data/spec/spec_helper.rb +1 -0
- metadata +120 -5
- data/lib/pulse-meter/visualize/public/js/application.coffee +0 -616
@@ -0,0 +1,40 @@
|
|
1
|
+
#= require extensions
|
2
|
+
#= require models/page_info
|
3
|
+
#= require models/widget
|
4
|
+
#= require models/dinamic_widget
|
5
|
+
#= require models/sensor_info
|
6
|
+
#= require collections/page_info_list
|
7
|
+
#= require collections/sensor_info_list
|
8
|
+
#= require collections/widget_list
|
9
|
+
#= require presenters/widget
|
10
|
+
#= require presenters/pie
|
11
|
+
#= require presenters/timeline
|
12
|
+
#= require presenters/series
|
13
|
+
#= require presenters/line
|
14
|
+
#= require presenters/area
|
15
|
+
#= require presenters/table
|
16
|
+
#= require presenters/gauge
|
17
|
+
#= require views/page_title
|
18
|
+
#= require views/page_titles
|
19
|
+
#= require views/sensor_info_list
|
20
|
+
#= require views/dynamic_chart
|
21
|
+
#= require views/dynamic_widget
|
22
|
+
#= require views/widget_chart
|
23
|
+
#= require views/widget
|
24
|
+
#= require views/widget_list
|
25
|
+
#= require router
|
26
|
+
|
27
|
+
document.startApp = ->
|
28
|
+
pageInfos = new PageInfoList
|
29
|
+
pageTitlesApp = new PageTitlesView(pageInfos)
|
30
|
+
pageInfos.reset gon.pageInfos
|
31
|
+
|
32
|
+
widgetList = new WidgetList
|
33
|
+
widgetList.setContext(pageInfos)
|
34
|
+
widgetList.startPolling()
|
35
|
+
|
36
|
+
widgetListApp = new WidgetListView {widgetList: widgetList, pageInfos: pageInfos}
|
37
|
+
|
38
|
+
appRouter = new AppRouter(pageInfos, widgetList)
|
39
|
+
|
40
|
+
Backbone.history.start()
|
@@ -0,0 +1,17 @@
|
|
1
|
+
PageInfoList = Backbone.Collection.extend {
|
2
|
+
model: PageInfo
|
3
|
+
selected: ->
|
4
|
+
@find (m) ->
|
5
|
+
m.get 'selected'
|
6
|
+
|
7
|
+
selectFirst: ->
|
8
|
+
@at(0).set('selected', true) if @length > 0
|
9
|
+
|
10
|
+
selectNone: ->
|
11
|
+
@each (m) ->
|
12
|
+
m.set 'selected', false
|
13
|
+
|
14
|
+
selectPage: (id) ->
|
15
|
+
@each (m) ->
|
16
|
+
m.set 'selected', m.id == id
|
17
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
WidgetList = Backbone.Collection.extend {
|
2
|
+
model: Widget
|
3
|
+
|
4
|
+
setContext: (@pageInfos) ->
|
5
|
+
|
6
|
+
url: -> ROOT + 'pages/' + @pageInfos.selected().id + '/widgets'
|
7
|
+
|
8
|
+
startPolling: ->
|
9
|
+
setInterval( =>
|
10
|
+
if @pageInfos.selected()
|
11
|
+
@each (w) ->
|
12
|
+
w.refetch()
|
13
|
+
, 200)
|
14
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
String::capitalize = ->
|
2
|
+
@charAt(0).toUpperCase() + @slice(1)
|
3
|
+
String::strip = ->
|
4
|
+
if String::trim? then @trim() else @replace /^\s+|\s+$/g, ""
|
5
|
+
|
6
|
+
Number::humanize = ->
|
7
|
+
interval = this
|
8
|
+
res = ""
|
9
|
+
s = interval % 60
|
10
|
+
res = "#{s} s" if s > 0
|
11
|
+
interval = (interval - s) / 60
|
12
|
+
return res unless interval > 0
|
13
|
+
|
14
|
+
m = interval % 60
|
15
|
+
res = "#{m} m #{res}".strip() if m > 0
|
16
|
+
interval = (interval - m) / 60
|
17
|
+
return res unless interval > 0
|
18
|
+
|
19
|
+
h = interval % 24
|
20
|
+
res = "#{h} h #{res}".strip() if h > 0
|
21
|
+
d = (interval - h) / 24
|
22
|
+
if d > 0
|
23
|
+
"#{d} d #{res}".strip()
|
24
|
+
else
|
25
|
+
res
|
26
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
DynamicWidget = Backbone.Model.extend {
|
2
|
+
|
3
|
+
setStartTime: (@startTime) ->
|
4
|
+
|
5
|
+
setEndTime: (@endTime) ->
|
6
|
+
|
7
|
+
increaseTimespan: (inc) ->
|
8
|
+
@set('timespan', @timespan() + inc)
|
9
|
+
|
10
|
+
resetTimespan: ->
|
11
|
+
@startTime = null
|
12
|
+
@endTime = null
|
13
|
+
@set('timespan', null)
|
14
|
+
|
15
|
+
timespan: -> @get('timespan')
|
16
|
+
|
17
|
+
sensorArgs: ->
|
18
|
+
_.map(@get('sensorIds'), (name) -> "sensor[]=#{name}").join('&')
|
19
|
+
|
20
|
+
url: ->
|
21
|
+
timespan = @timespan()
|
22
|
+
url = "#{ROOT}dynamic_widget?#{@sensorArgs()}&type=#{@get('type')}"
|
23
|
+
url += "×pan=#{timespan}" if timespan? && !_.isNaN(timespan)
|
24
|
+
url += "&startTime=#{@startTime}" if @startTime
|
25
|
+
url += "&endTime=#{@endTime}" if @endTime
|
26
|
+
url
|
27
|
+
|
28
|
+
|
29
|
+
forceUpdate: ->
|
30
|
+
@fetch {
|
31
|
+
success: (model, response) ->
|
32
|
+
model.trigger('redraw')
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Widget = Backbone.Model.extend {
|
2
|
+
initialize: ->
|
3
|
+
@needRefresh = true
|
4
|
+
@setNextFetch()
|
5
|
+
@timespanInc = 0
|
6
|
+
|
7
|
+
setStartTime: (@startTime) ->
|
8
|
+
|
9
|
+
setEndTime: (@endTime) ->
|
10
|
+
|
11
|
+
increaseTimespan: (inc) ->
|
12
|
+
@timespanInc = @timespanInc + inc
|
13
|
+
@forceUpdate()
|
14
|
+
|
15
|
+
resetTimespan: ->
|
16
|
+
@timespanInc = 0
|
17
|
+
@startTime = null
|
18
|
+
@endTime = null
|
19
|
+
@forceUpdate()
|
20
|
+
|
21
|
+
timespan: -> @get('timespan') + @timespanInc
|
22
|
+
|
23
|
+
url: ->
|
24
|
+
timespan = @timespan()
|
25
|
+
url = "#{@collection.url()}/#{@get('id')}?"
|
26
|
+
url += "×pan=#{timespan}" unless _.isNaN(timespan)
|
27
|
+
url += "&startTime=#{@startTime}" if @startTime
|
28
|
+
url += "&endTime=#{@endTime}" if @endTime
|
29
|
+
url
|
30
|
+
|
31
|
+
time: -> (new Date()).getTime()
|
32
|
+
|
33
|
+
setNextFetch: ->
|
34
|
+
@nextFetch = @time() + @get('redrawInterval') * 1000
|
35
|
+
|
36
|
+
setRefresh: (needRefresh) ->
|
37
|
+
@needRefresh = needRefresh
|
38
|
+
|
39
|
+
needFetch: ->
|
40
|
+
interval = @get('redrawInterval')
|
41
|
+
@time() > @nextFetch && @needRefresh && interval? && interval > 0
|
42
|
+
|
43
|
+
refetch: ->
|
44
|
+
if @needFetch()
|
45
|
+
@forceUpdate()
|
46
|
+
@setNextFetch()
|
47
|
+
|
48
|
+
forceUpdate: ->
|
49
|
+
@fetch {
|
50
|
+
success: (model, response) ->
|
51
|
+
model.trigger('redraw')
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class PiePresenter extends WidgetPresenter
|
2
|
+
visualization: 'PieChart'
|
3
|
+
|
4
|
+
cutoff: ->
|
5
|
+
|
6
|
+
data: ->
|
7
|
+
data = super()
|
8
|
+
data.addColumn('string', 'Title')
|
9
|
+
data.addColumn('number', @get('valuesTitle'))
|
10
|
+
data.addRows(@get('series').data)
|
11
|
+
data
|
12
|
+
|
13
|
+
options: ->
|
14
|
+
$.extend true, super(), {
|
15
|
+
slices: @get('series').options
|
16
|
+
legend: {
|
17
|
+
position: 'bottom'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class SeriesPresenter extends TimelinePresenter
|
2
|
+
options: ->
|
3
|
+
secondPart = if @get('interval') % 60 == 0 then '' else ':ss'
|
4
|
+
format = if @model.timespan() > 24 * 60 * 60
|
5
|
+
"yyyy.MM.dd HH:mm#{secondPart}"
|
6
|
+
else
|
7
|
+
"HH:mm#{secondPart}"
|
8
|
+
|
9
|
+
$.extend true, super(), {
|
10
|
+
lineWidth: 1
|
11
|
+
chartArea: {
|
12
|
+
width: '100%'
|
13
|
+
}
|
14
|
+
legend: {
|
15
|
+
position: 'bottom'
|
16
|
+
}
|
17
|
+
vAxis: {
|
18
|
+
title: @valuesTitle()
|
19
|
+
textPosition: 'in'
|
20
|
+
}
|
21
|
+
hAxis: {
|
22
|
+
format: format
|
23
|
+
}
|
24
|
+
series: @get('series').options
|
25
|
+
axisTitlesPosition: 'in'
|
26
|
+
}
|
27
|
+
|
28
|
+
valuesTitle: ->
|
29
|
+
if @get('valuesTitle')
|
30
|
+
"#{@get('valuesTitle')} / #{@humanizedInterval()}"
|
31
|
+
else
|
32
|
+
@humanizedInterval()
|
33
|
+
|
34
|
+
|
35
|
+
humanizedInterval: ->
|
36
|
+
@get('interval').humanize()
|
37
|
+
|
38
|
+
cutoff: (min, max) ->
|
39
|
+
_.each(@get('series').rows, (row) =>
|
40
|
+
for i in [1 .. row.length - 1]
|
41
|
+
value = row[i]
|
42
|
+
value = 0 unless value?
|
43
|
+
row[i] = @cutoffValue(value, min, max)
|
44
|
+
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class TimelinePresenter extends WidgetPresenter
|
2
|
+
data: ->
|
3
|
+
data = super()
|
4
|
+
data.addColumn('datetime', 'Time')
|
5
|
+
dateOffset = @dateOffset() + @get('interval') * 1000
|
6
|
+
series = @get('series')
|
7
|
+
_.each series.titles, (t) ->
|
8
|
+
data.addColumn('number', t)
|
9
|
+
|
10
|
+
_.each series.rows, (row) ->
|
11
|
+
row[0] = new Date(row[0] + dateOffset)
|
12
|
+
data.addRow(row)
|
13
|
+
data
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class WidgetPresenter
|
2
|
+
constructor: (@pageInfos, @model, el) ->
|
3
|
+
chartClass = @chartClass()
|
4
|
+
@chart = new chartClass(el)
|
5
|
+
@draw()
|
6
|
+
|
7
|
+
get: (arg) -> @model.get(arg)
|
8
|
+
|
9
|
+
globalOptions: -> gon.options
|
10
|
+
|
11
|
+
dateOffset: ->
|
12
|
+
if @globalOptions.useUtc
|
13
|
+
(new Date).getTimezoneOffset() * 60000
|
14
|
+
else
|
15
|
+
0
|
16
|
+
|
17
|
+
options: ->
|
18
|
+
{
|
19
|
+
title: @get('title')
|
20
|
+
height: 300
|
21
|
+
chartArea:
|
22
|
+
left: 10
|
23
|
+
}
|
24
|
+
|
25
|
+
mergedOptions: ->
|
26
|
+
pageOptions = if @pageInfos.selected()
|
27
|
+
@pageInfos.selected().get('gchartOptions')
|
28
|
+
else
|
29
|
+
{}
|
30
|
+
|
31
|
+
$.extend(true,
|
32
|
+
@options(),
|
33
|
+
@globalOptions.gchartOptions,
|
34
|
+
pageOptions,
|
35
|
+
@get('gchartOptions')
|
36
|
+
)
|
37
|
+
|
38
|
+
data: -> new google.visualization.DataTable
|
39
|
+
|
40
|
+
chartClass: -> google.visualization[@visualization]
|
41
|
+
|
42
|
+
cutoff: ->
|
43
|
+
|
44
|
+
cutoffValue: (v, min, max) ->
|
45
|
+
if v?
|
46
|
+
if min? && v < min
|
47
|
+
min
|
48
|
+
else if max? && v > max
|
49
|
+
max
|
50
|
+
else
|
51
|
+
v
|
52
|
+
else
|
53
|
+
0
|
54
|
+
|
55
|
+
draw: (min, max) ->
|
56
|
+
@cutoff(min, max)
|
57
|
+
@chart.draw(@data(), @mergedOptions())
|
58
|
+
|
59
|
+
WidgetPresenter.create = (pageInfos, model, el) ->
|
60
|
+
type = model.get('type')
|
61
|
+
if type? && type.match(/^\w+$/)
|
62
|
+
presenterClass = eval("#{type.capitalize()}Presenter")
|
63
|
+
new presenterClass(pageInfos, model, el)
|
64
|
+
else
|
65
|
+
null
|
@@ -0,0 +1,21 @@
|
|
1
|
+
AppRouter = Backbone.Router.extend {
|
2
|
+
initialize: (@pageInfos, @widgetList) ->
|
3
|
+
routes: {
|
4
|
+
'pages/:id': 'getPage'
|
5
|
+
'custom': 'custom'
|
6
|
+
'*actions': 'defaultRoute'
|
7
|
+
}
|
8
|
+
getPage: (ids) ->
|
9
|
+
id = parseInt(ids)
|
10
|
+
@pageInfos.selectPage(id)
|
11
|
+
@widgetList.fetch()
|
12
|
+
custom: ->
|
13
|
+
@pageInfos.selectNone()
|
14
|
+
dynamicWidget = new DynamicWidgetView {pageInfos: @pageInfos}
|
15
|
+
dynamicWidget.render($('#widgets'))
|
16
|
+
defaultRoute: (actions) ->
|
17
|
+
if @pageInfos.length > 0
|
18
|
+
@navigate('//pages/1')
|
19
|
+
else
|
20
|
+
@navigate('//custom')
|
21
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
DynamicChartView = Backbone.View.extend {
|
2
|
+
initialize: (options) ->
|
3
|
+
@pageInfos = options['pageInfos']
|
4
|
+
@sensors = []
|
5
|
+
@type = 'Area'
|
6
|
+
@widget = new DynamicWidget
|
7
|
+
|
8
|
+
@widget.bind('destroy', @remove, this)
|
9
|
+
@widget.bind('redraw', @redrawChart, this)
|
10
|
+
|
11
|
+
tagName: 'div'
|
12
|
+
|
13
|
+
events: {
|
14
|
+
"click #refresh-chart": 'update'
|
15
|
+
"click #extend-timespan": 'extendTimespan'
|
16
|
+
"click #reset-timespan": 'resetTimespan'
|
17
|
+
"change #start-time input": 'maybeEnableStopTime'
|
18
|
+
"click #set-interval": 'setTimelineInterval'
|
19
|
+
}
|
20
|
+
|
21
|
+
template: -> _.template($("#dynamic-widget-plotarea").html())
|
22
|
+
|
23
|
+
render: ->
|
24
|
+
@$el.html(@template()())
|
25
|
+
@initDatePickers()
|
26
|
+
|
27
|
+
initDatePickers: ->
|
28
|
+
@$el.find(".datepicker").each (i) ->
|
29
|
+
$(this).datetimepicker
|
30
|
+
showOtherMonths: true
|
31
|
+
selectOtherMonths: true
|
32
|
+
@$el.find("#end-time input").prop("disabled", true)
|
33
|
+
|
34
|
+
setTimelineInterval: ->
|
35
|
+
start = @unixtimeFromDatepicker("#start-time input")
|
36
|
+
end = @unixtimeFromDatepicker("#end-time input")
|
37
|
+
@widget.setStartTime(start)
|
38
|
+
@widget.setEndTime(end)
|
39
|
+
@update()
|
40
|
+
|
41
|
+
dateFromDatepicker: (id) ->
|
42
|
+
@$el.find(id).datetimepicker("getDate")
|
43
|
+
|
44
|
+
unixtimeFromDatepicker: (id) ->
|
45
|
+
date = @dateFromDatepicker(id)
|
46
|
+
if date
|
47
|
+
date.getTime() / 1000
|
48
|
+
else
|
49
|
+
null
|
50
|
+
|
51
|
+
maybeEnableStopTime: ->
|
52
|
+
date = @dateFromDatepicker("#start-time input")
|
53
|
+
disabled = if date then false else true
|
54
|
+
@$el.find("#end-time input").prop("disabled", disabled)
|
55
|
+
|
56
|
+
extendTimespan: ->
|
57
|
+
select = @$el.find("#extend-timespan-val")
|
58
|
+
val = select.first().val()
|
59
|
+
@widget.increaseTimespan(parseInt(val))
|
60
|
+
@update()
|
61
|
+
|
62
|
+
resetTimespan: ->
|
63
|
+
@widget.resetTimespan()
|
64
|
+
@update()
|
65
|
+
|
66
|
+
sensorIds: -> _.map(@sensors, (s) -> s.id)
|
67
|
+
|
68
|
+
redrawChart: ->
|
69
|
+
if @presenter
|
70
|
+
@presenter.draw()
|
71
|
+
else
|
72
|
+
@presenter = WidgetPresenter.create(@pageInfos, @widget, @chartContainer())
|
73
|
+
|
74
|
+
|
75
|
+
chartContainer: ->
|
76
|
+
@$el.find('#chart')[0]
|
77
|
+
|
78
|
+
update: ->
|
79
|
+
@widget.forceUpdate() if @sensors.length > 0
|
80
|
+
|
81
|
+
draw: (sensors, type) ->
|
82
|
+
@sensors = sensors
|
83
|
+
@type = type
|
84
|
+
|
85
|
+
@widget.set('sensorIds', @sensorIds())
|
86
|
+
@widget.set('type', @type)
|
87
|
+
|
88
|
+
@presenter = null
|
89
|
+
$(@chartContainer()).empty()
|
90
|
+
@widget.forceUpdate()
|
91
|
+
}
|