Highlight my backlog » History » Version 3
Nancy Ouyang, 07/15/2015 09:06 AM
added abram's version
| 1 | 1 | Tom Clegg | h1. Highlight my backlog |
|---|---|---|---|
| 2 | |||
| 3 | <pre><code class="javascript"> |
||
| 4 | // ==UserScript== |
||
| 5 | // @name Highlight my redmine backlog |
||
| 6 | 2 | Tom Clegg | // @namespace https://arvados.org/projects/arvados/wiki/Highlight_my_backlog |
| 7 | 1 | Tom Clegg | // @version 0.1 |
| 8 | // @description Highlights issues assigned to you in redmine Backlogs view. |
||
| 9 | // @author Tom Clegg |
||
| 10 | // @match https://arvados.org/rb/master_backlog/* |
||
| 11 | // @grant none |
||
| 12 | // ==/UserScript== |
||
| 13 | |||
| 14 | $.ajax('/my/account', {success: function(data, _, _) { |
||
| 15 | var key = $('#api-access-key',data).text(); |
||
| 16 | var url = '/issues.json?assigned_to_id=me&limit=100'; |
||
| 17 | var ajaxopts = { |
||
| 18 | dataType: 'json', |
||
| 19 | headers: {'X-Redmine-API-Key': key}, |
||
| 20 | success: dopage |
||
| 21 | }; |
||
| 22 | $.ajax(url, ajaxopts); |
||
| 23 | function dopage(data, _, _) { |
||
| 24 | for (var i=0; i<data.issues.length; i++) { |
||
| 25 | $('#story_'+data.issues[i].id).css({ |
||
| 26 | //background:'#faa', |
||
| 27 | 'font-weight':'bold' |
||
| 28 | }); |
||
| 29 | } |
||
| 30 | if (data.total_count > data.offset + data.limit) { |
||
| 31 | $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | }}); |
||
| 35 | </code></pre> |
||
| 36 | 3 | Nancy Ouyang | |
| 37 | h1. puts in parens the total point count you have for each sprint |
||
| 38 | |||
| 39 | <code><pre> |
||
| 40 | |||
| 41 | // ==UserScript== |
||
| 42 | // @name Highlight my redmine backlog |
||
| 43 | // @namespace https://arvados.org/projects/arvados/wiki/Highlight_my_backlog |
||
| 44 | // @version 0.1b |
||
| 45 | // @description Highlights issues assigned to you in redmine Backlogs view and |
||
| 46 | // puts in parens the total point count you have for each sprint. |
||
| 47 | // @author Abram Connelly |
||
| 48 | // @match https://arvados.org/rb/master_backlog/* |
||
| 49 | // @grant none |
||
| 50 | // ==/UserScript== |
||
| 51 | |||
| 52 | $.ajax('/my/account', {success: function(data, _, _) { |
||
| 53 | var key = $('#api-access-key',data).text(); |
||
| 54 | var url = '/issues.json?assigned_to_id=me&limit=100'; |
||
| 55 | var ajaxopts = { |
||
| 56 | dataType: 'json', |
||
| 57 | headers: {'X-Redmine-API-Key': key}, |
||
| 58 | success: dopage |
||
| 59 | }; |
||
| 60 | $.ajax(url, ajaxopts); |
||
| 61 | function dopage(data, _, _) { |
||
| 62 | |||
| 63 | var my_sprint_info = {}; |
||
| 64 | |||
| 65 | for (var i=0; i<data.issues.length; i++) { |
||
| 66 | |||
| 67 | if ("fixed_version" in data.issues[i]) { |
||
| 68 | var sprint_id = data.issues[i].fixed_version.id; |
||
| 69 | var sprint_name = data.issues[i].fixed_version.name; |
||
| 70 | if (!(sprint_id in my_sprint_info)) { |
||
| 71 | my_sprint_info[sprint_id]={"story_points" : 0, "sprint_id" : sprint_id, "sprint_name" : sprint_name }; |
||
| 72 | } |
||
| 73 | if ("story_points" in data.issues[i]) { |
||
| 74 | my_sprint_info[sprint_id].story_points += data.issues[i].story_points; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | $('#story_'+data.issues[i].id).css({ |
||
| 79 | //background:'#faa', |
||
| 80 | 'font-weight':'bold' |
||
| 81 | }); |
||
| 82 | } |
||
| 83 | |||
| 84 | if (data.total_count > data.offset + data.limit) { |
||
| 85 | $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts); |
||
| 86 | } |
||
| 87 | |||
| 88 | for (var sprint_id in my_sprint_info) { |
||
| 89 | var cur_pnt = $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text(); |
||
| 90 | cur_pnt += " (" + my_sprint_info[sprint_id].story_points +")"; |
||
| 91 | $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text(cur_pnt); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | }}); |
||
| 95 | |||
| 96 | </code></pre> |
||
| 97 | |||
| 98 | h1. useful links |
||
| 99 | http://www.redmine.org/projects/redmine/wiki/Rest_api |