Shopify / dashing

The exceptionally handsome dashboard framework in Ruby and Coffeescript.
http://shopify.github.com/dashing/
MIT License
10.98k stars 1.18k forks source link

Dynamically getting values based on data-id #747

Open uppak opened 7 years ago

uppak commented 7 years ago

Hi,

I have been working very recently with the dashing framework. I was displaying a list of tasks assigned to a team. Till now, It was only one team to list and no issues so far. Now I have a set of teams & I want to display data based on data-id from .erb file. For example, the below is my erb sample.

<html>
<li data-switcher-interval="20000" data-row="2" data-col="3" data-sizex="2" data-sizey="1">
     <div data-id="Team A" data-view="List" data-title="Bugs Trend for Team A" data-moreinfo=""  data-top-margin="10"></div></li>
</html>

I wrote a scheduled job to get the list of all teams into an array in jobs.rb. Is there a way to send data-id to jobs.rb file, so I can filter the values from the array and call the event.

Regards, Kalyan

slowjoe007 commented 7 years ago

Hi Kalyan, maybe I missed it, but where is the dynamic part of it? If you specify a static ID in your .erb file, then you always will see the data for that ID, e.g. Team A in your example. What is your goal?

  1. A single widget showing the tasks of all teams, e.g. rotating (showing one team at a time)
  2. A dedicated widget for each team
  3. A widget on a universal dashboard that displays the tasks of a team based on some context information

(1) and (2) are trivial. For (1) you can send the corresponding data by the server's background job on a schedule. For (2) you would have a dedicated widget ID for each widget and the job sends the corresponding data to the widget IDs.

For (3) you could work with a request parameter that dynamically sets the ID of the widget in the .erb file, e.g. data-id="tasklist_<%= params[:team] %>". The background job would send data (sendevent) to IDs it can generate from the data it read, e.g. `targetWidgetID = "tasklist" + $team`.

Hope this helps, Johannes

Diluke commented 7 years ago

Check this Dashing Workshop from Monitorama, Part about data binding at ~30min mark might solve your question. https://vimeo.com/95307499