Skip to content

Commit dbbcb0f

Browse files
Merge pull request #1360 from giraffate/add_a_filter_to_the_triage_dashboard
Add a filter to the triage dashboard
2 parents 67f108c + 8d05684 commit dbbcb0f

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

templates/triage/pulls.html

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,61 @@
3838
border-radius:2;
3939
}
4040
</style>
41+
<script>
42+
function filter() {
43+
var input, filter, table, tr, i, txtValue;
44+
input = document.getElementById("filter-input");
45+
filter = input.value;
46+
table = document.getElementById("pr-table");
47+
tr = table.getElementsByTagName("tr");
48+
49+
filters = filter.split(' ').map(function(x) {
50+
return x.split(':');
51+
});
52+
53+
54+
for (i = 0; i < tr.length; i++) {
55+
filters.forEach(function(flt) {
56+
if (flt.length == 2) {
57+
var td;
58+
switch (flt[0]) {
59+
case 'label':
60+
case '-label':
61+
td = tr[i].getElementsByTagName("td")[6];
62+
break;
63+
case 'assignee':
64+
case '-assignee':
65+
td = tr[i].getElementsByTagName("td")[5];
66+
break;
67+
case 'author':
68+
case '-author':
69+
td = tr[i].getElementsByTagName("td")[4];
70+
break;
71+
}
72+
if (td) {
73+
txtValue = td.textContent || td.innerText;
74+
console.log(flt[0].charAt(0));
75+
if ((flt[0].charAt(0) != '-' && txtValue.indexOf(flt[1]) > -1)
76+
|| (flt[0].charAt(0) == '-' && txtValue.indexOf(flt[1]) <= -1)) {
77+
tr[i].style.display = "";
78+
} else {
79+
tr[i].style.display = "none";
80+
}
81+
}
82+
} else {
83+
tr[i].style.display = "";
84+
}
85+
});
86+
}
87+
}
88+
</script>
4189
</head>
4290

4391
<body>
4492
<h1>Triage dashboard - <a href="https://github.com/{{ owner }}/{{ repo }}">{{ owner }}/{{ repo }}</a></h1>
45-
<table>
93+
<input id="filter-input" type="search" style="width: 400px;">
94+
<input type="submit" value="filter" onclick="filter()">
95+
<table id="pr-table">
4696
<thead>
4797
<tr>
4898
<th>#</th>

0 commit comments

Comments
 (0)