Highlight my backlog » History » Version 8
Tom Clegg, 09/08/2015 07:53 PM
1 | 1 | Tom Clegg | h1. Highlight my backlog |
---|---|---|---|
2 | |||
3 | <pre><code class="javascript"> |
||
4 | // ==UserScript== |
||
5 | // @name Highlight my redmine backlog |
||
6 | 8 | Tom Clegg | // @namespace https://dev.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 | 8 | Tom Clegg | // @match https://dev.arvados.org/rb/master_backlog/* |
11 | 1 | Tom Clegg | // @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 | 6 | Abram Connelly | <pre><code class="javascript"> |
40 | 3 | Nancy Ouyang | |
41 | // ==UserScript== |
||
42 | // @name Highlight my redmine backlog |
||
43 | 8 | Tom Clegg | // @namespace https://dev.arvados.org/projects/arvados/wiki/Highlight_my_backlog |
44 | 3 | Nancy Ouyang | // @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 | 6 | Abram Connelly | // @author Tom Clegg, Abram Connelly |
48 | 8 | Tom Clegg | // @match https://dev.arvados.org/rb/master_backlog/* |
49 | 3 | Nancy Ouyang | // @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 | 5 | Nancy Ouyang | h1. Useful stuff |
99 | 1 | Tom Clegg | |
100 | 5 | Nancy Ouyang | h2. Links |
101 | |||
102 | 8 | Tom Clegg | * Test it out on a backlog page: https://dev.arvados.org/rb/master_backlog/arvados |
103 | * The tooltips on the backlog page are loaded dynamically on mouseover: https://dev.arvados.org/rb/story/6394/tooltip?project_id=39 |
||
104 | 4 | Nancy Ouyang | * Redmine Backlog, github page: https://github.com/backlogs/redmine_backlogs/ |
105 | 1 | Tom Clegg | * The Redmine REST API: http://www.redmine.org/projects/redmine/wiki/Rest_api |
106 | 5 | Nancy Ouyang | |
107 | h2. Example of changing the background color and the font (in short, use 'font-family' not 'font') |
||
108 | |||
109 | 'background':'#F49C54', //orange |
||
110 | 'font-family':'URW Bookman L, serif', |
||
111 | 'font-size':'1.2em', |
||
112 | 7 | Abram Connelly | |
113 | h2. Possible extensions |
||
114 | |||
115 | It would be nice to color each element in the backlog page by who owns it. It would also be nice to be able to add up point totals per sprint for each person as this is a common task. |
||
116 | |||
117 | Here is an API call that can get the process started: |
||
118 | |||
119 | <pre><code class="javascript"> |
||
120 | function dopage(data) { console.log(data); } |
||
121 | var ajaxopts = { dataType: 'json', headers: {'X-Redmine-API-Key' : key}, success: dopage }; |
||
122 | var url0 = "/issues.json?project_id=39&limit=100&offset=0"; |
||
123 | var url1 = "/issues.json?project_id=39&limit=100&offset=100"; |
||
124 | $.ajax(url0,ajaxopts); |
||
125 | $.ajax(url1,ajaxopts); |
||
126 | </code></pre> |
||
127 | |||
128 | (39 is the lightning project id). |
||
129 | |||
130 | The idea being, collect points by sprint name/id for each person seen (stored in a hash). Color each story appropriate as referenced in the 'assigned_to' structure. Not sure where to put the point totals. |