-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
248 lines (213 loc) · 5.08 KB
/
index.html
File metadata and controls
248 lines (213 loc) · 5.08 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
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
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>nixpkgs PRs</title>
<style>
* {
font-family: sans-serif;
}
.center {
margin-left: auto;
margin-right: auto;
width: fit-content;
}
h1 {
text-align: center;
}
html, body {
margin: 0;
padding: 0;
}
#categories {
padding-top: 0.5vw;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
}
.category {
width: 24vw;
border: 1px solid var(--category-border, black);
background-color: var(--category-background, #f4f6f8);
box-sizing: border-box;
}
.category > h2 {
padding: 8px 16px 4px;
}
.pr-list {
width: 100%;
display: flex;
flex-direction: column;
padding: 4px 8px;
box-sizing: border-box;
}
.pr {
border-radius: 6px;
border-width: 0px;
padding-top: 8px;
padding-bottom: 12px;
padding-left: 12px;
padding-right: 12px;
margin-bottom: 12px;
line-height: 1.3;
background-color: var(--overlay-bgColor,var(--color-canvas-overlay,#ffffff));
border-style: solid;
border-width: 1px;
border-color: var(--borderColor-default,var(--color-border-default,#d0d7de));
color: var(--fgColor-default,var(--color-fg-default,#1F2328));
box-shadow: var(--shadow-resting-medium,var(--color-shadow-medium,0 3px 6px rgba(140,149,159,0.15)));
}
.pr-header, .pr-date, .pr-label, .pr-hide {
font-size: 12px;
}
.pr-date, .pr-hide {
float: right;
}
.pr-date {
user-select: none;
}
.pr-title {
font-size: 14px;
word-wrap: break-word;
}
.pr-label {
padding: 0 7px;
text-decoration: dotted underline;
}
.pr-hide {
text-decoration: dotted underline;
background: none;
color: inherit;
border: none;
cursor: pointer;
padding-top: 3px;
}
.reserve {
border-radius: 0.375rem;
margin-left: auto;
margin-right: auto;
margin-bottom: 12px;
display: block;
padding: 12px;
font-size: 16px;
}
#error {
width: fit-content;
margin-left: auto;
margin-right: auto;
display: block;
border: 1px solid red;
padding: 12px;
margin-top: 0.5vw;
}
@media (prefers-color-scheme: dark) {
:root {
--fgColor-default: #fff;
--category-background: #111;
--category-border: #fff;
color: #fff;
--overlay-bgColor: #222;
background-color: #000;
}
a {
color: #aaf;
}
a:visited {
color: #faf;
}
}
</style>
<!--<h1>nixpkgs PRs</h1>-->
<form id="settings" class="center">
<fieldset>
<legend>Configuration</legend>
<label>Number of results: <input id="limit" name="limit" type="number" placeholder="50" value="$LIMIT"></label>
<label>Include filter: <input id="filter" name="filter" type="text" value="$FILTER"></label>
<label>Exclude filter: <input id="filter-exclude" name="exclude" type="text" value="$EXCLUDE_FILTER"></label>
<button type="submit">Update</button>
</fieldset>
</form>
<div id="error" style="display: none"><span id="error-message"></span></div>
<div id="categories">
<div class="category">
<h2>Awaiting changes ($C1)</h2>
<button class="reserve">Reserve and open one PR</button>
<div class="pr-list">
$PRS_1
</div>
</div>
<div class="category">
<h2>New ($C2)</h2>
<button class="reserve">Reserve and open one PR</button>
<div class="pr-list">
$PRS_2
</div>
</div>
<div class="category">
<h2>Needs reviewer ($C3)</h2>
<button class="reserve">Reserve and open one PR</button>
<div class="pr-list">
$PRS_3
</div>
</div>
<div class="category">
<h2>Needs merger ($C4)</h2>
<button class="reserve">Reserve and open one PR</button>
<div class="pr-list">
$PRS_4
</div>
</div>
</div>
<hr/>
<center><a href="https://github.com/FliegendeWurst/pr-dashboard">Source code</a> · Developer: @fliegendewurst:matrix.org</center>
<script>
"use strict";
function reserveAndOpen(category) {
fetch(`reserve-pr?category=${category}$RESERVE_FILTER`, { "method": "POST" })
.then(resp => resp.text())
.then(url => {
if (!url.startsWith("https")) {
if (url !== "") {
document.getElementById("error-message").innerText = url;
} else {
document.getElementById("error-message").innerText = "server returned no response";
}
document.getElementById("error").style.display = "block";
return;
}
window.open(url);
});
}
const buttons = document.querySelectorAll("button.reserve");
const categories = ["AwaitingChanges", "New", "NeedsReviewer", "NeedsMerger"];
let i = 0;
for (const button of buttons) {
const cat = categories[i];
i++;
button.addEventListener("click", e => {
reserveAndOpen(cat);
});
}
let hidden = localStorage.getItem("hiddenPRs");
if (!hidden) {
hidden = [];
} else {
hidden = JSON.parse(hidden);
}
const buttonsHide = document.querySelectorAll("button.pr-hide");
for (const button of buttonsHide) {
button.addEventListener("click", e => {
e.target.parentElement.style.visibility = "collapse"
const pr = e.target.parentElement.children[0].children[0].href.substring(38);
hidden.push(pr);
localStorage.setItem("hiddenPRs", JSON.stringify(hidden));
});
}
for (const pr of hidden) {
const target = document.querySelector(`a[href='https://github.com/NixOS/nixpkgs/pull/${pr}']`);
if (!target) {
continue;
}
target.parentElement.parentElement.style.visibility = "collapse";
}
</script>