Skip to content

Instantly share code, notes, and snippets.

@mordonez
Last active March 23, 2021 08:01
Show Gist options
  • Save mordonez/7091924 to your computer and use it in GitHub Desktop.
Save mordonez/7091924 to your computer and use it in GitHub Desktop.
Trello Job for Dashing

#Preview# test

#Description#

Simple Dashing Job to display Trello info about your boards. Uses Trello API.

#Dependencies# ruby-trello

Add it to dashing's gemfile:

gem 'ruby-trello' and run bundle install. Everything should work now :)

#Usage# To use this widget, put the trello.rb file in your /jobs folder.

To include the widget in a dashboard, add the following snippet to the dashboard layout

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="my-trello-board" data-view="List" data-title="Trello Board"></div>
  <i class="icon-trello icon-background"></i>
</li>
require 'trello'
include Trello
Trello.configure do |config|
config.developer_public_key = 'YOUR_DEVELOPER_KEY'
config.member_token = 'YOUR_MEMBER_TOKEN'
end
boards = {
"my-trello-board" => "YOUR_TRELLO_BOARD_ID",
}
class MyTrello
def initialize(widget_id, board_id)
@widget_id = widget_id
@board_id = board_id
end
def widget_id()
@widget_id
end
def board_id()
@board_id
end
def status_list()
status = Array.new
Board.find(@board_id).lists.each do |list|
status.push({label: list.name, value: list.cards.size})
end
status
end
end
@MyTrello = []
boards.each do |widget_id, board_id|
begin
@MyTrello.push(MyTrello.new(widget_id, board_id))
rescue Exception => e
puts e.to_s
end
end
SCHEDULER.every '5m', :first_in => 0 do |job|
@MyTrello.each do |board|
status = board.status_list()
send_event(board.widget_id, { :items => status })
end
end
@YSmetana
Copy link

Hey @danharper83. I just figured it out. You can get a developer_public_key here: https://trello.com/1/appKey/generate# .

Then get your member_token visiting https://trello.com/1/authorize?key=KEY&name=Dashing&expiration=never&response_type=token . Replace the KEY by your actual key from previous step.

You can see some debug messages running dashing start in the console. Dashing will update your Trello data once in 5 minutes by default.

It will display cards summary:

@mordonez thanks a lot!

@usamaaftab80
Copy link

Is there any way we can get the card instead of the whole board summary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment