-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathqueue.html
More file actions
178 lines (150 loc) · 6.42 KB
/
queue.html
File metadata and controls
178 lines (150 loc) · 6.42 KB
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Homu queue - {{repo_label}}</title>
<style>
* { font-family: sans-serif; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
p { font-size: 15px; }
table { border-collapse: collapse; }
td, th { border: 2px solid white; padding: 5px; font-size: 13px; }
tr:nth-child(even) { background: #ddd; }
.success { background-color: #80C0F0; }
.failure, .error { background-color: #F08080; }
.pending { background-color: #F0DE57; }
.approved { background-color: #85DB7B; }
.yes { color: green; }
.no { color: red; }
.sorting_asc:after { content: " ▲"; }
.sorting_desc:after { content: " ▼"; }
.dataTables_filter, .dataTables_info, .dataTables_empty { display: none; }
#search { width: 150px; }
.hide { display: none; }
th { cursor: pointer; }
</style>
</head>
<body>
<h1>Homu queue - {{repo_label}}</h1>
<p>
<button type="button" id="rollup">Create a rollup</button>
<button type="button" id="synch">Synchronize</button>
</p>
<p>
{{ total }} total, {{ approved }} approved, {{ rolled_up }} rolled up, {{ failed }} failed
/
<label><input type="checkbox" id="auto_reload">Auto reload</label>
/
<input type="search" id="search" placeholder="Search">
<button type="button" id="reset">Reset</button>
</p>
<table id="queue">
<thead>
<tr>
<th class="hide">Sort key</th>
<th><input type="checkbox"></th>
<th>#</th>
<th>Status</th>
<th>Priority</th>
<th>Head ref</th>
<th>Title</th>
<th>Approved by</th>
<th>Mergeable</th>
<th>Assignee</th>
</tr>
</thead>
<tbody>
{% for state in states %}
<tr>
<td class="hide">{{loop.index}}</td>
<td><input type="checkbox" data-num="{{state.num}}"></td>
<td><a href="{{state.url}}">{{state.num}}</a></td>
<td class="{{state.status}}">{{state.status}}{{state.status_ext}}</td>
<td>{{state.priority}}</td>
<td>{{state.head_ref}}</td>
<td>{{state.title}}</td>
<td>{{state.approved_by}}</td>
<td class="{{state.mergeable}}">{{state.mergeable}}</td>
<td>{{state.assignee}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script>
document.getElementById('rollup').onclick = function(ev) {
if (!confirm('This will create a new pull request. Proceed?')) return;
var nums = [];
var els = document.querySelectorAll('#queue tbody input[type=checkbox]:checked');
for (var i=0;i<els.length;i++) {
var num = parseInt(els[i].getAttribute('data-num'));
nums.push(num);
}
location = 'https://github.com/login/oauth/authorize' +
'?client_id={{oauth_client_id}}' +
'&scope=public_repo,admin:repo_hook' +
'&state=' + encodeURIComponent(JSON.stringify({
cmd: 'rollup',
repo_label: '{{repo_label}}',
nums: nums,
}));
};
document.getElementById('synch').onclick = function(ev) {
if (!confirm('Retrieve all pull requests?')) return;
location = 'https://github.com/login/oauth/authorize' +
'?client_id={{oauth_client_id}}' +
'&scope=public_repo,admin:repo_hook' +
'&state=' + encodeURIComponent(JSON.stringify({
cmd: 'synch',
repo_label: '{{repo_label}}',
}));
};
var handle_auto_reload = function() {
var timer_id = null;
return function() {
clearInterval(timer_id);
timer_id = null;
if (localStorage.homu_auto_reload == 'true') {
timer_id = setInterval(function() {
location.reload(true);
}, 1000 * 60 * 2);
}
};
}();
document.getElementById('auto_reload').onclick = function(ev) {
localStorage.homu_auto_reload = ev.target.checked;
handle_auto_reload();
};
document.getElementById('auto_reload').checked = localStorage.homu_auto_reload == 'true';
handle_auto_reload();
$(document).ready(function() {
var table = $('#queue').DataTable({
paging: false,
order: [],
autoWidth: false,
columnDefs: [
{targets: [1], orderable: false, searchable: false},
],
});
var search_el = document.getElementById('search');
search_el.oninput = function(ev) {
table.search(this.value).draw();
};
document.getElementById('reset').onclick = function(ev) {
search_el.value = '';
table.search('').draw();
table.order([0, 'asc']).draw();
};
});
document.querySelector('#queue thead input[type=checkbox]').onclick = function(ev) {
ev.stopPropagation();
var els = document.querySelectorAll('#queue tbody input[type=checkbox]');
for (var i=0;i<els.length;i++) {
els[i].checked = this.checked;
}
};
</script>
</body>
</html>