forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveDefectCharts.html
201 lines (177 loc) · 6.88 KB
/
ActiveDefectCharts.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="Name" content="Mashup: Active Defect Charts"/>
<meta name="Version" content="2009.4"/>
<meta name="Vendor" content="Rally Software"/>
<link rel="stylesheet" type="text/css" href="/slm/css/rally/core.css" charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/slm/css/slm.css" charset="utf-8"/>
<style type="text/css">
body {
text-align: center;
}
#chartContainer {
background-color: white;
width: 930;
height: 300;
margin-left: auto;
margin-right: auto;
border: 1px solid black;
padding-top: 20px;
}
div.chart {
float: left;
margin-right: 10px;
width: 450;
}
div.chart h4 {
text-align: center;
}
</style>
<script type="text/javascript" src="/slm/js-lib/dojo/1.3.1/dojo/dojo.js"></script>
<script type="text/javascript" src="/slm/js/slm.js"></script>
<script type="text/javascript" src="/slm/mashup/1.13/js/batch-toolkit.js"></script>
<script type="text/javascript" src="/slm/mashup/1.13/js/utilities.js"></script>
<script type="text/javascript" description="Defect Mashup specific code.">
/*
Copyright (c) 2002-2009 Rally Software Development Corp. All rights reserved.
*/
dojo.require('dojo.io.script')
dojo.addOnLoad(runAllowedValuesQuery);
var batchToolkit;
function runAllowedValuesQuery() {
batchToolkit = new RALLY.Mashup.BatchToolkit('__WORKSPACE_OID__', '__PROJECT_OID__', '__PROJECT_SCOPING_UP__', '__PROJECT_SCOPING_DOWN__');
RALLY.Mashup.Utilities.showPrintButton();
var queryArray = [];
queryArray[0] = {
key: 'priorities',
type: 'Defect',
attribute: 'Priority'
};
queryArray[1] = {
key: 'severities',
type: 'Defect',
attribute: 'Severity'
};
batchToolkit.find(queryArray, runDefectQuery);
}
function runDefectQuery(allowedValuesResult) {
var priorities = removeEmptyValues(allowedValuesResult.priorities);
var severities = removeEmptyValues(allowedValuesResult.severities);
var defectQuery = buildDefectQuery(priorities, severities);
var callback = function(results) {
showResults(priorities, severities, results);
};
batchToolkit.find(defectQuery, callback);
}
function removeEmptyValues(arr) {
var nonEmpty = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
nonEmpty.push(arr[i]);
}
}
return nonEmpty;
}
function buildDefectQuery(priorities, severities) {
var defectQueryArray = [];
var count = 0;
for (var i = 0; i < priorities.length; i++) {
var keyName = "pri" + i;
defectQueryArray[count++] = {
key: "#" + keyName,
type: 'defect',
fetch: false,
query: "((State != Closed) and (Priority = \"" + priorities[i] + "\"))"
}
defectQueryArray[count++] = {
key: keyName,
placeholder: "${#pri" + i + "/size}"
}
}
for (var i = 0; i < severities.length; i++) {
var keyName = "sev" + i;
defectQueryArray[count++] = {
key: "#" + keyName,
type: 'defect',
fetch: false,
query: "((State != Closed) and (Severity = \"" + severities[i] + "\"))"
}
defectQueryArray[count++] = {
key: keyName,
placeholder: "${#sev" + i + "/size}"
}
}
return defectQueryArray;
}
function collectValuesByPrefix(results, prefix, numKeys) {
var values = [];
for (var i = 0; i < numKeys; i++) {
values[i] = results[prefix + i];
}
return values;
}
function showResults(priorities, severities, results) {
var priorityValues = collectValuesByPrefix(results, 'pri', priorities.length);
showGoogleChart('priorityChart', priorities, priorityValues);
var severityValues = collectValuesByPrefix(results, 'sev', severities.length)
showGoogleChart('severityChart', severities, severityValues);
}
function showGoogleChart(chartId, labels, values) {
var gChartUrl = "http://chart.apis.google.com/chart?cht=p3&chs=450x150&chd=t:";
gChartUrl += values.join();
gChartUrl += "&chl=";
var sectionLabels = [];
for (var i = 0; i < values.length; i++) {
var label = labels[i];
if (label.length > 15) {
label = label.substring(0, 12) + '...';
}
sectionLabels.push(label + "(" + values[i] + ")");
}
gChartUrl += sectionLabels.join('|');
document.getElementById(chartId).title = sectionLabels.join(',');
document.getElementById(chartId).src = gChartUrl;
}
</script>
</head>
<body>
<table>
<tr>
<td style="text-align: left; width: 99%;">
<td style="text-align: right; width: 1%;">
<img id="do" onmouseover="RALLY.Mashup.Utilities.showcbButton();" onmouseout="hidecbMenu('buttons',event);"
style="vertical-align: middle;" src="/slm/images/menu_actions.gif"/>
<div style="position:relative;top:5px" align="left">
<div id="buttons" class="do-menu" style="left:0px;"
onmouseover="document.body.style.cursor='pointer';"
onmouseout="hidecbMenu('buttons',event);">
<a id="print" onclick="RALLY.Mashup.Utilities.printPage()">
Print...
</a>
</div>
</div>
</td>
</tr>
</table>
<div style="clear:both">
</div>
<div id="chartContainer">
<div class="chart">
<h3>
Active Defects by Priority
</h3>
<img id="priorityChart" src="http://chart.apis.google.com/chart?cht=p3&chs=450x150&chd=t:100"
/>
</div>
<div class="chart">
<h3>
Active Defects by Severity
</h3>
<img id="severityChart" src="http://chart.apis.google.com/chart?cht=p3&chs=450x150&chd=t:100"
/>
</div>
<br style="clear:both"/>
</div>
</body>
</html>