Class: Vifi
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Vifi
- Defined in:
- lib/vifi.rb,
lib/vifi/version.rb
Constant Summary collapse
- VERSION =
"1.0.7"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.version ⇒ Object
4 5 6 |
# File 'lib/vifi/version.rb', line 4 def self.version VERSION end |
Instance Method Details
#build_chart ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vifi.rb', line 7 def build_chart chart = ChartJS.line do data do labels [] dataset WillowRun::Status.new.getinfo.ssid do color :random data [] end end end chart.to_html end |
#build_updater(source: '/update_source', chart_obj: 'line_chart') ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vifi.rb', line 20 def build_updater(source: '/update_source', chart_obj: 'line_chart') # why not "<script> var source = new EventSource('#{source}'); var json; source.onmessage = function(e) { json = JSON.parse(e.data); #{chart_obj}.data.datasets[0].data.push(json.value); #{chart_obj}.data.labels.push(json.label); #{chart_obj}.update(); }; </script> " end |