Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Dashboards #22

Closed
nikitsaraf opened this issue Dec 28, 2013 · 9 comments
Closed

Multiple Dashboards #22

nikitsaraf opened this issue Dec 28, 2013 · 9 comments
Labels

Comments

@nikitsaraf
Copy link

How, should I go about adding multiple dashboards, say for each of the user in my database.
I know I can handle user authorization, by following from here https://github.com/Shopify/dashing/wiki/How-to%3A-Add-authentication, and redirect user to its specific dashboard.
But, what would be the best practice to create multiple dashboard ? Should I just create a new Job file for each dashboard/user, and give all the widgets unique Id for all the dashboard ?

@gottfrois
Copy link
Owner

I would create unique ids for all widgets. You could prefix them with your dashboard's name for example or whatever. Dashing-rails also handle Devise authentications. Please see here

Dashboard are basically just HTML placeholders, you can even use Shopify JS libraries to navigate between your different dashboards here.

@nikitsaraf
Copy link
Author

Thanks for the help ! This is just great, that I can use the devise authentication is dashing-rails. But, this was no where to be found in the dashing-rails wiki. Should we document it ?
Sinatra_Cyclist is looking perfect, for what I was looking for. I just hope it would be easy to port for dashing-rails
Thanks !

@gottfrois
Copy link
Owner

Yes we should probably add a "how to" in the readme. Let me know if you run into any issue regarding sinatra_cyclist.

@shangardezi
Copy link

Hey, I have a question around this too.
I have around 30 different clients, for which I wish to display a dashboard with their relevant data/widgets. I understand that I'll require 30 sets of widgets, what's the best way to implement this without the view files getting too crowded? (Sorry total newb)

Thanks!!

@gottfrois
Copy link
Owner

Well the naive approach is to create 30 dashboard layouts with unique widget ids (per user, using the user id maybe?). But that's not really DRY nor scalable. So you could define one layout file and inject widget ids dynamically using local view variable.

Here is an example of a widget defined dymanically:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="synergy-<%= user.id %>" data-view="Meter" data-title="Synergy" data-min="0" data-max="100"></div>
</li>

Given that you provide the user variable it will generate a widget id of synergy-1 and so on.

@RaresSalcudean
Copy link

RaresSalcudean commented Jun 12, 2017

@gottfrois I'm so glad that I found this thread, I had in mind the same implementation plan but not 100% sure.

I have a couple of questions, but first I would like to present my idea. I want to create a dashboard / user, basically users can register -> log in -> create dashboards -> add widgets for each dashboard

I would have the following models: User, Dashboard, Widget ( I would use inheritance for widgets, so I can have multiple types )

But my question is, how would you send the data from the jobs. It is really ok to have something like:

Lets say we have 3 users, all of the have one dashboard and one git hub pull request widget.
And send data from the job:

  ` Dashing.scheduler.every '2s' do
  pull_request_widgets = Widget.where(type: "Widgets::PullRequest")

  pull_request_widgets.each do |widget|

     **** code to get pull requests from the GitHub API ****
     pull_requests_count = .... git hub api to get count .... (returns count)
     Dashing.send_event("pull_request_#{widget.id}", count: pull_requests_count)
  end
 end

Is this a ok way to send data dynamically for individual widgets corresponding to different users?

Thank you, all your answers really help, you're doing an amazing job!

@gottfrois
Copy link
Owner

it will surely work but won't scale very well as you add more widgets. You don't want to be doing too much requests against github api.
But yeah, as a naive approach, that would work just fine.

@RaresSalcudean
Copy link

Oh I did not notice I was scheduling every 2 seconds, it will be done every 15 minutes.

However my concern is about the 'Widget.where(type: "Widgets::PullRequest")', if there are 1000 users each with 1 pull request widget, this job will iterate and send them data ( even if they are not 'online' or viwing the dashboard ).

How would you approach this problem? A better data model? I was thinking about using ActionCable and subscribe to a channel for each dashboard, and this will allow me to know if the dashboard is live or no, therefore send data only to live dashboards.

@gottfrois
Copy link
Owner

honestly, if you plan to have a lot of users active on your dashboard, rails and action cable is not the right tool for the job https://dockyard.com/blog/2016/08/09/phoenix-channels-vs-rails-action-cable

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

No branches or pull requests

4 participants