-
Notifications
You must be signed in to change notification settings - Fork 8
/
links.html
105 lines (104 loc) · 3.1 KB
/
links.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="TVHadmin">
<link rel="manifest" href="manifest.webmanifest" crossorigin="use-credentials">
<title>TVHadmin - Series Links</title>
<script src="include.js"></script>
<script>
function delete_link(r, uuid) {
event.preventDefault();
fetch("/api/idnode/delete?uuid=" + uuid).then(response => {
if (response.ok) {
var i = r.parentNode.parentNode.rowIndex;
document.getElementById("list").deleteRow(i);
}
});
}
</script>
</head>
<body>
<div id="container">
<div id="navigation">
<div class="logo">
<img src="images/logo.png" alt="TVHeadend Logo" width="150">
</div>
<div class="nav_bar">
</div>
</div>
<div id='layout'>
<div id='banner'>
<table>
<tr>
<td class='col_title'><div id='mobmenu'>☰</div> <h1>Series Links</h1></td>
</tr>
</table>
</div>
<div id='wrapper'>
<div id='content'>
<table class='list' id='list'>
<tr class='heading'>
<td class='col_value'><h2>Timers</h2></td>
<td class='col_value'><h2>Recs</h2></td>
<td class='col_channel'><h2>Channel</h2></td>
<td class='col_name'><h2>Name</h2></td>
<td class='wideonly col_channel'><h2>Next Timer</h2></td>
<td class='col_delete'></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<script>
async function main() {
const [ recordings, channels ] = await Promise.all([get_recordings(), get_channels(0)]);
var cname = [];
channels.forEach(function(c) {
cname[c.uuid] = c.name;
});
var rcnt = [];
var tcnt = [];
var tnext = [];
recordings.forEach(function(r) {
if (!r.enabled) return;
if (r.autorec === "") return;
let auto = r.autorec;
if (r.sched_status == "scheduled") {
if (tcnt[auto]) tcnt[auto]++;
else tcnt[auto] = 1;
if (tnext[auto]) {
tnext[auto] = Math.min(tnext[auto], r.start);
}
else tnext[auto] = r.start;
}
else if (r.sched_status == "completed" || r.sched_status == "recording") {
if (rcnt[auto]) rcnt[auto]++;
else rcnt[auto] = 1;
}
});
var links = await get_links();
var table = document.getElementById("list");
links.forEach(function(link) {
var recs = 0;
var timers = 0;
var next = '';
if (rcnt[link.uuid]) recs = rcnt[link.uuid];
if (tcnt[link.uuid]) timers = tcnt[link.uuid];
if (tnext[link.uuid]) next = strftime("%a %e/%n %H:%M", tnext[link.uuid]);
var row = table.insertRow(-1);
row.className = "row_alt";
row.innerHTML = `<td class='col_value'>${timers}</td>` +
`<td class='col_value'>${recs}</td>` +
`<td class='col_channel'>${cname[link.channel]}</td>` +
`<td class='col_name'>${link.name}</td>` +
`<td class='wideonly col_channel'>${next}</td>` +
`<td class='col_delete'><a href='links.html' onclick='delete_link(this, "${link.uuid}")'><img src='images/delete.png'></a></td>`;
});
}
main();
</script>
</body>
</html>