Created
July 22, 2015 16:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dashing.Teammood extends Dashing.Widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'>