-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·41 lines (35 loc) · 873 Bytes
/
script.js
File metadata and controls
executable file
·41 lines (35 loc) · 873 Bytes
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
const coreURL = "https://sagipinasv1.herokuapp.com";
const socket = io(coreURL);
function cancelReport(id) {
socket.emit("test_cancel", { id: id })
socket.on("cancel_report", () => {
renderTable()
})
}
const dataRow = (count, data) => {
return (`
<tr>
<th scope="row">${count + 1}</th>
<td>${data.type}</td>
<td>${data.details}</td>
<td>
<button class="btn btn-dark btn-sm" onclick="cancelReport('${data.uid}')">CANCEL</button>
</td>
</tr>
`);
}
const renderTable = () => {
document.getElementById('table-data').innerHTML = "";
axios.get(`${coreURL}/incidents`)
.then(res => {
res.data.forEach((item, index) => {
if (item.status === "unverified") {
document.getElementById('table-data').innerHTML += dataRow(index, item)
}
})
})
}
renderTable()
socket.on("report", () => {
renderTable()
})