Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
165 lines (150 loc) · 3.82 KB
/
Copy pathindex.html
File metadata and controls
165 lines (150 loc) · 3.82 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
<!DOCTYPE html>
<html>
<head>
<title>RPi - Python API</title>
<link rel="icon" href="/icon.jpg" sizes="32x32">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
.common-styles {
font-weight: 400;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
font-size: 70%;
}
.button {
box-sizing: border-box;
margin-top: 3px;
padding: 6px 12px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 67%;
border-radius: 4px;
margin-left: 6px;
border: 1px solid #000;
background-color: inherit;
color: #000;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5);
}
.button:hover {
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.75);
}
table {
width: 100%;
}
td, th {
border: 1px solid #ddd;
text-align: left;
padding: 8px;
}
tr:nth-child(odd) {
background-color: #ddd;
}
.column {
padding: 10px;
}
.left {
float: left;
width: 200px;
}
.right {
float: right;
width: 530px;
}
.row {
margin: auto;
width: 730px;
}
a:link {
text-decoration: none;
color: black;
}
a:visited {
text-decoration: none;
color: black;
}
a:hover {
color: red;
}
a:active {
text-decoration: none;
color: blue;
}
</style>
<body>
<div style="text-align: center;">
<!--- Top menu --->
<b>Transmission:</b>
<a class="button common-styles" href="http://piz2:9091/transmission/web/" rel="nofollow" target="_blank">WebUI</a>
<a class="button common-styles" href="javascript:void(0);" onclick="Start();">Start</a>
<a class="button common-styles" href="javascript:void(0);" onclick="Stop();">Stop</a>
<b>VPN:</b>
<a class="button common-styles" href="javascript:void(0);" onclick="Connect();">Connect</a>
<a class="button common-styles" href="javascript:void(0);" onclick="Disconnect();">Disconnect</a>
<b>System:</b>
<a class="button common-styles" href="/reboot" rel="nofollow">Reboot</a>
<a class="button common-styles" href="/halt" rel="nofollow">Halt</a>
</div>
<div class="row" style="background-color:#111;">
<div class="column left">
<!--- Left table --->
<center><b>Metrics</b></center>
<table class="common-styles" id="metrics">
<tr><td>Loading...<td></tr>
</table>
</div>
<div class="column right">
<!--- Right table --->
<center><b>Files</b></center>
<table class="common-styles" id="files">
<tr><td>Loading...<td></tr>
</table>
</div>
</div>
</body>
<script>
async function Metrics(){
const request = await fetch("/status");
const metrics = await request.json();
var table = document.getElementById("metrics");
document.getElementById("metrics").innerHTML = `<td><b>Key</b></td><td><b>Value</b></td>`;
for (const [key, value] of Object.entries(metrics)) {
document.getElementById("metrics").insertRow().innerHTML = `<td>${key}</td><td>${value}</td>`;
}
}
async function Files(){
const request = await fetch("/files");
const files = await request.json();
var table = document.getElementById("files");
var download_url = "http://" + window.location.hostname + ":8080";
document.getElementById("files").innerHTML = `<td><b>Name</b></td><td width="100"><b>Size</b></td>`;
for (const [key, value] of Object.entries(files)) {
document.getElementById("files").insertRow().innerHTML = `<td><a target="_blank" href="${download_url}/${key}">${key}</a></td><td>${value}</td>`;
}
}
async function Start() {
await fetch("/start");
Metrics();
}
async function Stop() {
await fetch("/stop");
Metrics();
}
async function Connect() {
await fetch("/connect");
Metrics();
}
async function Disconnect() {
await fetch("/disconnect");
Metrics();
}
window.onload = function () {
Files();
Metrics();
}
setInterval(Files, 2000);
setInterval(Metrics, 60000);
</script>
</html>