Skip to content

Instantly share code, notes, and snippets.

@nrichand
Created July 22, 2015 16:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nrichand/265342903eabc4ad0050 to your computer and use it in GitHub Desktop.
Save nrichand/265342903eabc4ad0050 to your computer and use it in GitHub Desktop.
Dashing.io widget for http://www.teammood.com/ users. Display the moods of the day for the team
class Dashing.Teammood extends Dashing.Widget
<h1 class="title" data-bind="title"></h1>
<a data-bind-href="url" target="_blank">
<span class="column" data-foreach-mood="moods">
<i data-bind-class="mood.code"></i>
</span>
</a>
<p class="updated-at" data-bind="updatedAtMessage"></p>
require 'httparty'
require 'json'
SCHEDULER.every '1m', :first_in => 0 do |job|
teamApiKey = "[YOUR API KEY]"
teamMooodApiUrl = "http://beta.teammood.com/api/"+ teamApiKey +"/moods?since=30"
response = HTTParty.get(teamMooodApiUrl)
moodDatas = JSON.parse(response.body)
day = moodDatas["days"][0]["date"]
moods = []
moodDatas["days"][0]["values"].each do |mood|
dayMood = mood["mood"]
if dayMood == "excellent"
moods.push({code: "icon icon-thumbs-up"})
elsif dayMood == "good"
moods.push({code: "icon icon-smile"})
elsif dayMood == "average"
moods.push({code: "icon icon-meh"})
elsif dayMood == "hard"
moods.push({code: "icon icon-frown"})
elsif dayMood == "bad"
moods.push({code: "icon icon-thumbs-down"})
end
end
teamMoodLinkUrl = "http://beta.teammood.com/app#/"+ teamApiKey +"/calendar"
send_event( 'teammood', {title: "Moods du : "+day, moods: moods, url: teamMoodLinkUrl})
end
$background-color: #333
.widget-teammood
background-color: $background-color
transition: background-color 2s linear
-moz-transition: background-color 2s linear
-o-transition: background-color 2s linear
-webkit-transition: background-color 2s linear
.icon
font-size: 6em
.icon-thumbs-up
color: #1abc9c
.icon-smile
color: #5c91df
.icon-meh
color: #f1c40f
.icon-frown
color: #ff7a23
.icon-thumbs-down
color: #8c3b5b
@nrichand
Copy link
Author

How to install :

  • copy the html, sass & coffee file into the folder widgets/teammood
  • copy the rb file into the jobs folder & fill your API key
  • declare your widget into your dashboard like this :
    <li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
      <div data-id="teammood" data-view="Teammood"></div>
    </li>

Result :
image

Don't forget to install the two gems httparty & json.

@dannyhw
Copy link

dannyhw commented Oct 24, 2016

To get the icons to show up I had to add another font in the layout.erb since it wasn't loading from the google one. I used this one:
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" type='text/css'>

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