-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
281 lines (267 loc) · 12 KB
/
index.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="http://cms-sw.github.com/cmssw/faq.html">CMS Topic Collector</a>
<ul class="nav">
<li class="active"><a href=".">Pull requests</a></li>
<li><a href="externals">Externals</a></li>
<li><a href="buildrequests">Build requests</a></li>
</ul>
<ul class="nav pull-right">
<li>
<form id="formbox" class="navbar-search pull-left" target="_blank" action="https://github.com/cms-sw/cmssw/search">
<input name="q" type="text" class="search-query" placeholder="Search"/>
</form>
<li>
<li id="dropdownMenu" class="dropdown"></li>
<li><a href="http://cms-sw.github.com/cmssw/faq.html">Help</a></li>
</ul>
</div>
</div>
</div>
<div class="row-fluid">
<div class="container-fluid">
<div id="myAlert" class="span12" style='padding: 15px;'></div>
</div>
</div>
<div class="row-fluid">
<div class="container-fluid">
<div id="releaseTabs" class="span12"></div>
</div>
</div>
<div class="row-fluid">
<div class="container-fluid">
<div id="myTable" class="span10"></div>
<div style="padding-top: 10px" id="legend" class="span2">
<table>
<tr><td class='approved'>●</td><td>:</td><td>Approved</td></tr>
<tr><td class='rejected'>■</td><td>:</td><td>Rejected</td></tr>
<tr><td class='pending'>▲</td><td>:</td><td>Signature pending</td></tr>
<tr><td class='unaffected'>-</td><td>:</td><td>Unaffected</td></tr>
</table>
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/mustache.min.js"></script>
<script>
function mainLoop() {
var currentBranch = window.location.hash.slice(1, window.location.hash.length);
$("#queuesTabs li.active").removeClass("active");
$("#nav_tab_" + currentBranch).addClass("active");
var view = {
"current_branch": currentBranch,
"github_user": userInfo["githubUser"],
"repository": userInfo["repository"],
"github_owner": userInfo["github_owner"],
"github_repo": userInfo["github_repo"],
"has_fork": userInfo["has_fork"],
};
var emptyTableTemplate = "<h2 class='releaseLink'>" +
"Open topics for <a class='relLink' href='https://github.com/{{repository}}/tree/{{current_branch}}'>{{current_branch}}</a>" +
" branch.</h2>" +
"<table class='table table-striped table-condensed table-bordered'><thead></thead><tbody></tbody></table>" +
"{{#has_fork}}<a class='actionLink' target='_blank' href='https://github.com/{{github_user}}" +
"/{{github_repo}}/pull/new/{{github_owner}}:{{current_branch}}...{{github_user}}:{{current_branch}}'>" +
"Create a new pull request for {{current_branch}}</a>{{/has_fork}}" +
"{{^has_fork}}You do not have a fork of {{github_repo}}." +
"<a class='actionLink' target='_blank' href='https://github.com/{{repository}}/fork'>" +
"Fork it to propose changes.</a>{{/has_fork}}<br/>" +
"<a href='externals#{{current_branch}}' target='_blank'>" +
"Show me architectures & externals for this release series.</a>";
$("#myTable").html(Mustache.render(emptyTableTemplate, view));
$.post("api/queues/" + currentBranch).done(function(d,a,b) {
if (!d)
{
$("#myTable").html("Cannot find any open pull request.");
return;
}
var headers = [];
var categories = d["signing_categories"];
for (var sci in categories)
{
headers[categories[sci]] = '<th><div class="vertical-text"><div class="vertical-text__inner">' + sci + "</div></div></th>";
}
$("#myTable thead").html("<tr><th>id</th><th>Pull request title</th>" + headers.join("") + "<th>Actions</th></tr>");
var pullRequests = [];
var compiledRow = Mustache.compile(rowTemplate);
$("#myTable tbody").html("");
for (var pri in d["pull_requests"])
{
var pr = d["pull_requests"][pri];
var signatures = updateSignatures(pr["number"], pr["signatures"], categories);
var view = {
"number": pr["number"],
"title": pr["title"],
"html_url": pr["html_url"],
"repository": userInfo["repository"],
"signature_buttons": signatures.join("")
}
var row = compiledRow(view);
$("#myTable tbody").append(Mustache.render(rowTemplate, view));
function signAlert(message) {
$("#myAlert").html('<div class="alert alert-info">' + message + '.<a class="close" data-dismiss="alert" href="#">×</a></div></div>');
}
function errorAlert(message) {
$("#myAlert").html('<div class="alert alert-error">' + message + '.<a class="close" data-dismiss="alert" href="#">×</a></div></div>');
}
function updateSuccessful(d,a,c)
{
// Update signarures
view["number"] = d["pullRequest"];
view["signature_buttons"] = updateSignatures(d["pullRequest"], d["signatures"], categories);
var newRow = $(Mustache.render(rowTemplate, view));
var oldCells = $("#pr" + d["pullRequest"] + " td");
for (var uri = 2; uri < 2+Object.keys(categories).length; ++uri)
{
var newTd = $($(newRow[0]).children('td')[2]);
$(oldCells[uri]).replaceWith(newTd);
}
$(".alert").alert('close');
}
function createActionCallback(n, api, action) {
return function () {
var actionLower = action.toLowerCase();
signAlert("<strong>" + action + " pull request " + n + "<strong>");
$.post("api/pulls/" + n + "/" + api).success(updateSuccessful).error(function(){errorAlert("An error occurred while " + actionLower + " " + n)});
return false;
};
}
$("#sign_" + pr["number"]).click(createActionCallback(pr["number"], "sign", "Signing")).error(function(){alert("Error while signing")});
$("#reject_" + pr["number"]).click(createActionCallback(pr["number"], "reject", "Rejecting")).error(function(){alert("Error while rejecting")});
$("#signAll_" + pr["number"]).click(createActionCallback(pr["number"], "signAll", "Signing all")).error(function(){alert("Error while rejecting")});
}
});
}
var userInfo;
function enqueue() {
}
function updateSignatures(pullRequestId, newSignatures, categories)
{
var signatures = [];
var signatureValues = {
"signed": "<td style='text-align: center;' align='middle' class='approved'>●</td>",
"pending": "<td style='text-align: center;' align='middle' class='pending'>▲</td>",
"rejected": "<td style='text-align: center;' align='middle' class='rejected'>■</td>",
}
// Reset all signatures.
for (var si = 0; si < Object.keys(categories).length; ++si)
signatures[si] = "<td style='text-align: center;' align='middle'>-</td>";
var canSign = false;
// Change to active those for which we have a signature
for (var signature in newSignatures)
{
for (var signable in userInfo["canSign"])
if (signable == signature)
canSign = true;
signatures[categories[signature]] = signatureValues[newSignatures[signature]];
}
var view = {
"can_sign": canSign,
"is_admin": userInfo["isAdmin"],
"pullrequest_id": pullRequestId
};
var signatureTemplate = "<td>" +
"{{#can_sign}}" +
"<a class='btn btn-success btn-mini' id='sign_{{pullrequest_id}}'><i class='icon-thumbs-up icon-white'></i> sign</a>" +
" <a class='btn btn-danger btn-mini' id='reject_{{pullrequest_id}}'><i class='icon-thumbs-down icon-white'></i> reject</a>" +
"{{/can_sign}}" +
"{{#is_admin}}" +
" <a class='btn btn-inverse btn-mini' id='signAll_{{pullrequest_id}}'><i class='icon-thumbs-up icon-white'></i> sign all</a>" +
"{{/is_admin}}" +
"</td>";
signatures[signatures.length] = Mustache.render(signatureTemplate, view);
return signatures;
}
var rowTemplate = "<tr id='pr{{number}}' class='ui-widget-content'><td>{{number}}" +
"</td><td class='title_cell'><a href='{{html_url}}' target='_blank'>{{title}}</a>" +
"<span class='pullActions'>(<a target='_blank' href='https://github.com/{{repository}}/pull/{{number}}/files'>diff</a>, " +
"<a target='_blank' href='https://github.com/{{repository}}/pull/{{number}}/commits'>history</a>," +
"<a target='_blank' href='https://github.com/{{repository}}/pull/{{number}}.patch'>patch</a>)</span>" +
"</td>{{{signature_buttons}}}" +
"</tr>";
$(document).ready(function() {
$(window).bind('hashchange', mainLoop);
var userInfoPromise = $.post("api/auth").done(function(d,a,b) {
$("#formbox").attr("action", "https://github.com/" + d["repository"] + "/search");
var userCategories = d["categories"];
var userCanSign = {}
var mapEgroups = {
"cms-git-core": "Core",
"cms-git-analysis": "Analysis",
"cms-git-alca": "Calibration and Alignment",
"cms-git-daq": "DAQ",
"cms-git-dqm": "DQM",
"cms-git-db": "Database",
"cms-git-docs": "Docs",
"cms-git-fastsim": "Fast Simulation",
"cms-git-simulation": "Full Simulation",
"cms-git-generators": "Generators",
"cms-git-geometry": "Geometry",
"cms-git-hlt": "HLT",
"cms-git-l1": "L1",
"cms-git-operations": "Operations",
"cms-git-reconstruction": "Reconstruction",
"cms-git-visualization": "Visualization"
}
userInfo = d;
var realCategories = [];
for (var i = 0; i < userCategories.length; ++i) {
if (userCategories[i] == "cms-git-admins")
userInfo["isAdmin"] = true;
var realName = mapEgroups[userCategories[i]];
if (!realName)
continue;
userCanSign[realName] = true;
realCategories[realCategories.length] = realName;
}
var view = {
"repository": d["repository"],
"firstname": d["firstname"],
"user": d["user"],
"githubUser": d["githubUser"],
"categories": realCategories
};
var userMenuTmpl = "" +
'<a id="userInfo" class="dropdown-toggle" data-toggle="dropdown" href="#">Welcome {{firstname}}<b class="caret"></b></a>' +
'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">' +
' <li><a href="https://account.cern.ch/account/">CERN: {{user}}</a></li>' +
' <li><a href="https://github.com/{{githubUser}}">GitHub: {{githubUser}}</a></li>' +
' <li class="divider"></li>' +
' <li>' +
' <a>Signs for: <ul>{{#categories}}<li>{{.}}</li>{{/categories}}</ul></a>' +
' </li>' +
' <li class="divider"></li>' +
' <li><a href="https://login.cern.ch/adfs/ls/?wa=wsignout1.0">Logout</a></li>';
'</ul>'
userInfo["canSign"] = userCanSign;
$("#dropdownMenu").html(Mustache.render(userMenuTmpl, view));
});
var currentBranch = undefined;
userInfoPromise.done(function () {
var currentBranchPromise = $.post("api/queues").done(function(d, a, b) {
if (d.length == 0)
{
$("#myAlert").html('<div class="alert alert-error"><strong>No CMSSW_X_Y_Z branches found.</strong></div></div>');
$("#legend").hide();
return;
}
var currentBranch = d[0]["ref"];
if (window.location.hash)
currentBranch = window.location.hash.slice(1, window.location.hash.length);
window.location.hash = "#" + currentBranch;
// Create the tab container.
var tabsTemplate = '<div class="navbar"><div class="navbar-inner"><ul id="queuesTabs" class="nav">' +
"{{#queues}}<li id='nav_tab_{{ref}}' ><a href='#{{ref}}'>{{ref}}</a></i>{{/queues}}" +
"</ul></div></div>";
$("#releaseTabs").html(Mustache.render(tabsTemplate, {queues: d}));
}).done(function(d1, a1, b1) {
mainLoop();
});
});
return;
});
</script>
</body>