Skip to content

Instantly share code, notes, and snippets.

@camillebaldock
Last active April 17, 2020 11:05
Show Gist options
  • Save camillebaldock/6562178 to your computer and use it in GitHub Desktop.
Save camillebaldock/6562178 to your computer and use it in GitHub Desktop.
Dashing widget to display Outlook calendar events

Outlook calendar events

Dashing widget to display Outlook calendar events Gets all the events over the next two days, and display the two next ones

Live demo:

http://camilledashing.herokuapp.com/dashboard

Usage

Put the exchange_calendar.rb file in your /jobs folder

Create a new exchange_calendar folder in your /widgets folder, and add the three following files to that folder:

  • exchange_calendar.scss
  • exchange_calendar.html
  • exchange_calendar.coffee

Add the following gem to your Gemfile:

gem 'viewpoint', :git => "git://github.com/zenchild/Viewpoint.git"

then run:

bundle

To include the widgets in a dashboard, add the following snippet:

<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
  <div data-id="exchange_calendar" data-view="ExchangeCalendar"></div>
  <i class="icon-calendar icon-background"></i>
</li>

Settings

Four configuration values are necessary, which you can set by adding the following line in your config.ru file (the whole example of config.ru is available lower in the gist):

set :ewsEndpoint, 'https://servername/ews/Exchange.asmx'
set :ewsUser, '[email protected]'
set :ewsPassword, 'password'
set :timeZoneBias, 0
require 'dashing'
configure do
set :ewsEndpoint, 'https://pod11111.outlook.com/ews/Exchange.asmx'
set :ewsUser, '[email protected]'
set :ewsPassword, 'password'
set :timeZoneBias, 0
helpers do
def protected!
# Put any authentication code you want in here.
# This method is run before accessing any resource.
end
end
end
map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets
end
run Sinatra::Application
Batman.mixin Batman.Filters,
startText: (str_start)->
now = moment.utc()
console.log(now)
start = moment(str_start)
console.log(start)
"#{start.from(now)}"
class Dashing.ExchangeCalendar extends Dashing.Widget
<div data-foreach-event="events">
<div class="event">
<div class="start" data-bind="event.start | startText"></div>
<h1>
<span data-bind='event.title' class="title"></span>
</h1>
</div>
</div>
require 'viewpoint'
include Viewpoint::EWS
SCHEDULER.every '1m' do |job|
cli = Viewpoint::EWSClient.new settings.ewsEndpoint, settings.ewsUser, settings.ewsPassword
now = Time.now
roomEvents = cli.get_user_availability([settings.ewsUser],
start_time: now.iso8601,
end_time: (now + 48*3600).iso8601,
time_zone: {bias: settings.timeZoneBias},
requested_view: :detailed_merged).calendar_event_array
events = Array.new
roomEvents.each_with_index.map {|roomEvent|
events.push(Hash[:start => (Time.parse(cli.event_start_time(roomEvent))),
:title => roomEvent[:calendar_event][:elems][3][:calendar_event_details][:elems][1][:subject][:text]])
}
send_event('exchange_calendar', events: events[0..1])
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: #0000A0;
$title-color: rgba(255, 255, 255, 0.7);
$moreinfo-color: rgba(255, 255, 255, 0.7);
$moreinfo-color: rgba(255, 255, 255, 0.7);
// ----------------------------------------------------------------------------
// Widget-comment styles
// ----------------------------------------------------------------------------
.widget-exchange-calendar {
background-color: $background-color;
.event {
overflow: hidden;
}
.title {
color: white;
font-size: 46px;
width: 100%;
overflow: hidden;
text-overflow: elipsis;
white-space: nowrap;
}
.start {
color: #ccccff;
font-size: 25px;
}
}
@juannesi
Copy link

juannesi commented Apr 17, 2020

pi@raspberrypi:~/aaaa $ smashing start
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 0.0.0.0:3030, CTRL+C to stop
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!
Please configure icinga_cgi in config.ru!

please help cant get this working

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