Jump to content
MartynKeigher

Progess Bars Widget

Recommended Posts

Martyn,

 

OMG...this is fucking bad ass dude. I will hope to get some time later this week to play with this more. I have nearly completed the core of all my dashing and can't wait to get started with the possibilities of this one. Thanks for creating more work for me :lol:

 

-jeff

Share this post


Link to post
Share on other sites

Any of you guys get a ruby job working for this? I've been able to get the title, but no data for example. I'd ultimately like to return a MySQL query of a name and value to populate this.

Share this post


Link to post
Share on other sites

Yeah, sadly not. I bashed my head so much on this I gave up and wanted to get back to it, but I've been pulled away on so many diff things since then so i never got around to re-address much of the dashing stuff.

 

If time free's up a bit then i'll look to do more of it again, just that right now... i've not got the time. :(

Share this post


Link to post
Share on other sites

I thought about this last night and figured it out. There was some futzing with the widget config to get it running, but essentially the coffee script references ProgressBars as the name so make sure you keep that name for the ID and name your widget folder "progress_bars". After that, you should be able to run info into the widget to ensure it works. I was struggling to figure out the ruby job, but here's a sample for feeding generic info to the widget and see if it works.

 

SCHEDULER.every '5s', :first_in => 0 do |job|
progress_items = [{ name: "Blue", progress: rand(100) }, { name: "Green", progress: rand(100) }, { name: "Red", progress: rand(100) }, { name: "Yellow", progress: rand(100) }]
send_event( 'progress_bars', {title: "Client Health Scores", progress_items: progress_items} )
end

 

After that I figured out how to populate MySQL data into the widget. Sample job below

require 'mysql2'

SCHEDULER.every '1d', :first_in => 0 do |job|

       db = Mysql2::Client.new(:host => "server", :username => "readonly", :password => "password", :port => 3306, :database => "labtech" )

       sql = "SELECT name, value as 'progress' from table where condition like something"

       results = db.query(sql)

       max_used = results.map do |row|
               row = {
                       :name => row['name'],
                       :progress => row['progress']
                       }
               end

       send_event('progress_bars', { title: "Client Health Scores", progress_items: max_used} )
db.close
end

 

You just have to feed the query to return a 'name' and 'progress' value where progress is your percentage. Some math may be required, but drive free space would be fairly straight forward. Let me know if this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×