Skip to content

Instantly share code, notes, and snippets.

@Dufgui
Forked from dragonai/README.md
Last active April 18, 2017 21:39
Show Gist options
  • Save Dufgui/1b4b99e449c628e77957c8a6d6bb5793 to your computer and use it in GitHub Desktop.
Save Dufgui/1b4b99e449c628e77957c8a6d6bb5793 to your computer and use it in GitHub Desktop.
Atlassian JIRA Sprint Progress Meter

##Preview

Description

Simple Dashing widget that displays a progress meter for your current JIRA sprint, with the completed and total point values at the bottom.

##Usage

#####Dependencies

Add jira-ruby to the gemfile:

gem 'jira-ruby'

and then just run

$ bundle install

#####Setup

To install this widget, simply run dashing install 1b4b99e449c628e77957c8a6d6bb5793.

Then substitute the following placeholders in sprint_progress.rb with the appropriate values:

  • ENV['JIRA_USERNAME'] => your JIRA username (optionally can be placed in your environment variables file
  • ENV['JIRA_PASSWORD'] => your JIRA password (also optionally can be placed in your environment variables file
  • ENV['JIRA_URL'], => the location of your JIRA instance
  • SPRINT_WIDGET_DATA_ID => the target HTML element's data-id attribute in your layout

Finally, to include the widget on a dashboard, drop the following snippet into your layout:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-view="SprintProgress" data-id="whatever_id_you_like"></div>
</li>
class Dashing.SprintProgress extends Dashing.Widget
@accessor 'value', Dashing.AnimatedValue
constructor: ->
super
@observe 'value', (value) ->
$(@node).find(".meter").val(value).trigger('change')
ready: ->
meter = $(@node).find(".meter")
meter.attr("data-bgcolor", meter.css("background-color"))
meter.attr("data-fgcolor", meter.css("color"))
meter.knob()
<h1 class="title" data-bind="title"></h1>
<input class="meter" data-angleOffset=-125 data-angleArc=250 data-width=200 data-readOnly=true data-bind-value="value | shortenedNumber | append '%'" data-bind-data-min="min" data-bind-data-max="max">
<p class="more-info" data-bind="moreinfo"></p>
<p class="updated-at" data-bind="updatedAtMessage"></p>
require 'jira-ruby'
SCHEDULER.every '5m', :first_in => 0 do |job|
client = JIRA::Client.new({
:username => ENV['JIRA_USERNAME'] || "username",
:password => ENV['JIRA_PASSWORD'] || "password",
:site => ENV['JIRA_URL'] || "http://localhost:8080/",
:auth_type => :basic,
:context_path => ""
})
closed_points = client.Issue.jql("sprint in openSprints() and status = \"closed\"").map{ |issue| issue.fields['customfield_10004'] }.reduce(:+) || 0
total_points = client.Issue.jql("sprint in openSprints()").map{ |issue| issue.fields['customfield_10004'] }.reduce(:+) || 0
if total_points == 0
percentage = 0
moreinfo = "No sprint currently in progress"
else
percentage = ((closed_points/total_points)*100).to_i
moreinfo = "#{closed_points.to_i} / #{total_points.to_i}"
end
send_event('SPRINT_WIDGET_DATA_ID', { title: "Sprint Progress", min: 0, value: percentage, max: 100, moreinfo: moreinfo })
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: steelblue;
$title-color: rgba(255, 255, 255, 0.7);
$moreinfo-color: rgba(255, 255, 255, 0.5);
$meter-background: darken($background-color, 7%);
// ----------------------------------------------------------------------------
// Widget-sprint-progress styles
// ----------------------------------------------------------------------------
.widget-sprint-progress {
background-color: $background-color;
input.meter {
background-color: $meter-background;
color: #fff;
}
.title {
color: $title-color;
}
.more-info {
color: $moreinfo-color;
}
.updated-at {
color: rgba(0, 0, 0, 0.3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment