blob: e43e477689af980f8398ce1b53c2d424c447fdb7 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001[define title]Spam Moderation Queue[end]
2[define category_css]css/ph_list.css[end]
3[define page_css]css/ph_detail.css[end][# needed for infopeek]
4
5[if-any projectname]
6 [include "../framework/header.ezt" "showtabs"]
7[else]
8 [include "../framework/header.ezt" "hidetabs"]
9[end]
10[include "../framework/js-placeholders.ezt" "showtabs"]
11
12<h2>Spam Moderation Queue: Automatic Classifier Close Calls</h2>
13[include "../framework/artifact-list-pagination-part.ezt"]
14
15<button type="submit" vaue="mark_spam" disabled="true">Mark as Spam</button>
16<button type="submit" value="mark_ham" disabled="true">Mark as Ham</button>
17
18<span style="margin:0 .7em">Select:
19 <a id="selectall" href="#">All</a>
20 <a id="selectnone" href="#">None</a>
21</span>
22
23<table id='resultstable'>
24<tr>
25 <td>
26 </td>
27 <td>ID</td>
28 <td>Author</td>
29 <td>Summary</td>
30 <td>Snippet</td>
31 <td>Opened at</td>
32 <td>Spam?</td>
33 <td>Verdict reason</td>
34 <td>Confidence</td>
35 <td>Verdict at</td>
36 <td>Flag count</td>
37</tr>
38[for issue_queue]
39<tr>
40 <td><input type='checkbox' name='issue_local_id' value='[issue_queue.issue.local_id]'/></td>
41 <td><a href='/p/[projectname]/issues/detail?id=[issue_queue.issue.local_id]'>[issue_queue.issue.local_id]</a></td>
42 <td><a href='/u/[issue_queue.reporter.email]'>[issue_queue.reporter.email]</a></td>
43 <td><a href='/p/[projectname]/issues/detail?id=[issue_queue.issue.local_id]'>[issue_queue.summary]</a></td>
44 <td>
45 [issue_queue.comment_text]
46 </td>
47 <td>[issue_queue.issue.opened_timestamp]</td>
48 <td>[issue_queue.issue.is_spam]</td>
49
50 <td>[issue_queue.reason]</td>
51 <td>[issue_queue.classifier_confidence]</td>
52 <td>[issue_queue.verdict_time]</td>
53 <td>[issue_queue.flag_count]</td>
54</tr>
55[end]
56</table>
57
58[include "../framework/artifact-list-pagination-part.ezt"]
59<button type="submit" vaue="mark_spam" disabled="true">Mark as Spam</button>
60<button type="submit" value="mark_ham" disabled="true">Mark as Ham</button>
61
62</form>
63
64<script type="text/javascript" nonce="[nonce]">
65runOnLoad(function() {
66 if ($("selectall")) {
67 $("selectall").addEventListener("click", function() {
68 _selectAllIssues();
69 setDisabled(false);
70 });
71 }
72 if ($("selectnone")) {
73 $("selectnone").addEventListener("click", function() {
74 _selectNoneIssues();
75 setDisabled(true);
76 });
77 }
78
79 const checkboxes = Array.from(
80 document.querySelectorAll('input[type=checkbox]'));
81 checkboxes.forEach(checkbox => {
82 checkbox.addEventListener('change', updateEnabled);
83 });
84
85 const buttons = Array.from(
86 document.querySelectorAll('button[type=submit]'));
87 buttons.forEach(button => {
88 button.addEventListener('click', function(event) {
89 const markSpam = (button.value === 'mark_spam');
90 const issueRefs = [];
91 checkboxes.forEach(checkbox => {
92 if (checkbox.checked) {
93 issueRefs.push({
94 projectName: window.CS_env.projectName,
95 localId: checkbox.value,
96 });
97 const rowElement = checkbox.parentElement.parentElement;
98 rowElement.parentElement.removeChild(rowElement);
99 }
100 });
101 window.prpcClient.call('monorail.Issues', 'FlagIssues', {
102 issueRefs: issueRefs,
103 flag: markSpam,
104 });
105 });
106 });
107
108 function updateEnabled() {
109 const anySelected = checkboxes.some(checkbox => checkbox.checked);
110 setDisabled(!anySelected);
111 }
112
113 function setDisabled(disabled) {
114 buttons.forEach(button => {
115 button.disabled = disabled;
116 });
117 }
118});
119</script>
120
121[include "../framework/footer.ezt"]