Skip to content

Instantly share code, notes, and snippets.

@dragonai
Last active June 7, 2019 20:09
Show Gist options
  • Save dragonai/a1dae02d476f6055f82a to your computer and use it in GitHub Desktop.
Save dragonai/a1dae02d476f6055f82a 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 a1dae02d476f6055f82a.

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
  • https://your-jira-instance.atlassian.net => 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'
SCHEDULER.every '5m', :first_in => 0 do |job|
client = JIRA::Client.new({
:username => ENV['JIRA_USERNAME'],
:password => ENV['JIRA_PASSWORD'],
:site => "https://your-jira-instance.atlassian.net",
: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);
}
}
@SergioGomez321
Copy link

SergioGomez321 commented Jun 7, 2019

I m getting JIRA::HTTPERROR that is a 401 error, Why is this happening? how can i solve it? help me please!
@lhtdesignde what did you do? :(

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