Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Excel data with dashing #737

Closed
poalcospe opened this issue Feb 15, 2017 · 6 comments
Closed

Excel data with dashing #737

poalcospe opened this issue Feb 15, 2017 · 6 comments

Comments

@poalcospe
Copy link

Hi all,

I'm trying to get information from an Excel file and to display that into a dashing widget. I've seen that the best way would be to modify the sample.rb file. After many try and exceptions resolved, I'm stuck on an exception I didn't find on existing issues.

Here's my sample.rb file:

require 'roo-xls'

EM.kqueue = EM.kqueue?
file_path = "#{Dir.pwd}/spreadsheet.xls"

def fetch_spreadsheet_data(path)
  s = Roo::Excel.new(path)
  send_event('valuation',   { current: s.cell(1, 2) })
end

module Handler
  def file_modified
    fetch_spreadsheet_data(path)
  end
end

fetch_spreadsheet_data(file_path)

EM.next_tick do
  EM.watch_file(file_path, Handler)
end

When I run dashing start, I have the following error message raised:

C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:1311:in watch_filename': no file watching support on this system (EventMachine::Unsupported) from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:1311:in watch_file'
from D:/Projets/dashing/jobs/sample.rb:26:in block in <top (required)>' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:977:in call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:977:in block in run_deferred_callbacks' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:974:in times'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:974:in run_deferred_callbacks' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:194:in run_machine'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.2-x86-mingw32/lib/eventmachine.rb:194:in run' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/lib/thin/backends/base.rb:73:in start'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/lib/thin/server.rb:162:in start' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/lib/thin/controllers/controller.rb:87:in start'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/lib/thin/runner.rb:200:in run_command' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/lib/thin/runner.rb:156:in run!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.4/bin/thin:6:in <top (required)>' from C:/Ruby22/bin/thin:23:in load'
from C:/Ruby22/bin/thin:23:in `

'

It seems that there is a compatibility issue with eventmachine. Does anyone has already face this issue ?

Thanks

@ghost
Copy link

ghost commented Feb 15, 2017

Take a look at this thread https://github.com/Shopify/dashing/issues/735 I suspect the sample.rb and instructions you followed are a little out of date.

@poalcospe
Copy link
Author

Thanks for your quick reply :)

I had a look at the issue #735 , and I tried to be as complient as possible with the environment used to resolve this issue. So first, I have downgraded 'roo' from 2.7 to 2.1 for being able tu run gem 'roo', '~> 2.1.0' in my Gemfile. Then I've modified the sample.rb below:

require 'roo'
require 'roo-xls'

SCHEDULER.every '2s', :first_in => 0 do |job|
file_path = "#{Dir.pwd}/spreadsheet.xls"

def fetch_spreadsheet_data(path)
  s = Roo::Excel.new(path)
  send_event('valuation',   { current: s.cell(1, 2) })
end

module Handler
  def file_modified
    fetch_spreadsheet_data(path)
  end
end

I don't know which one of both modification resolved this, but anyway, I don't have any exception running 'dashing start' now.

However, nothing is displayed in my dashboard. I have the following code in my sampletv.erb:

<li data-row="1" data-col="7" data-sizex="1" data-sizey="1">
      <div data-id="valuation" data-view="Number" data-title="Current Valuation" data-prefix="$"></div>
</li>

Am I doing something wrong with this part ?

@ghost
Copy link

ghost commented Feb 17, 2017

Before we go any further, is that all you have in the sampletv.erb? Do you have any other widgets showing aka the sample.erb dashboard contains the following

`<% content_for(:title) { "My super sweet dashboard" } %>

  • <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
      <div data-id="valuation" data-view="Number" data-title="Current Valuation" data-prefix="$"></div>
    </li>
    
`

Lastly are you running dashing or smashing?

thanks

@poalcospe
Copy link
Author

No it's not the only widget displayed on my dashoard. Here is my complete sampletv.erb:

<script type='text/javascript'>
$(function() {
  // These settings override the defaults set in application.coffee. You can do this on a per dashboard basis.
   Dashing.gridsterLayout('[{"col":2,"row":1,"size_x":1,"size_y":1},{"col":1,"row":1,"size_x":0,"size_y":0},{"col":3,"row":1,"size_x":1,"size_y":1},{"col":4,"row":1,"size_x":1,"size_y":1},{"col":1,"row":2,"size_x":1,"size_y":1},{"col":2,"row":2,"size_x":2,"size_y":1},{"col":4,"row":2,"size_x":1,"size_y":1}]')
  Dashing.widget_base_dimensions = [370, 340]
  Dashing.numColumns = 5
});
</script>


<% content_for :title do %>1080p dashboard<% end %>

<div class="gridster">
  <ul>
    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
      <div data-view="Clock"></div>
      <i class="fa fa-clock-o icon-background"></i>
    </li>

    <li data-row="1" data-col="1" data-sizex="0.5" data-sizey="0.5">
      <div data-view="Image" data-image="/sample.png"></div>
    </li>

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
	<div data-id="filter1" data-view="Number" data-title="Opened tasks"></div>
    </li>
	
    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
	<div data-id="filter2" data-view="Number" data-title="Closed tasks"></div>
    </li>
	
    <li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
	<div data-id="quote" data-view="Quote"></div>
    </li>
	
    <li data-row="1" data-col="2" data-sizex="1" data-sizey="1">
      <div data-id="valuation" data-view="Number" data-title="Current Valuation" data-prefix="$">    </div>
    </li>

  </ul>
</div>

I am running dashing; by the way, what is smashing exactly compare to dashing ?

@poalcospe
Copy link
Author

Ok, I know why it didn't display any value. I've forgotten one line in the .rb file. Now it's "almost" good.

I can display values but only with line under 9. For exemple, s.cell(8,2,s.sheets[1]) will work but s.cell(9,2,s.sheets[1]) won't. The table has 11 lines, so basically I can display values for lines between 1 and 8, but not between 9 and 11.

Do you knwo if there is any limitation regarding this ?

@ghost
Copy link

ghost commented Feb 21, 2017

Good to hear that you are past the initial problem. See my previous post with links to Smashing & Dashing, you'll find out what that is all about.

As for your new problem, that's beyond the scope of this thread and most likely smashing. Have a read of the roo documentation http://www.rubydoc.info/gems/roo/2.5.1 Personally I haven't accessed a spreadsheet table in this manner only individual cells

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant