Skip to content

Instantly share code, notes, and snippets.

What would you like to do? widget for 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>
<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 = ""+ 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"})
teamMoodLinkUrl = ""+ teamApiKey +"/calendar"
send_event( 'teammood', {title: "Moods du : "+day, moods: moods, url: teamMoodLinkUrl})
$background-color: #333
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
font-size: 6em
color: #1abc9c
color: #5c91df
color: #f1c40f
color: #ff7a23
color: #8c3b5b
Copy link

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>

Result :

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

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="//" rel="stylesheet" type='text/css'>

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