-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
340 lines (281 loc) · 9.22 KB
/
index.html
File metadata and controls
340 lines (281 loc) · 9.22 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Rivanna Monitor</title>
</head>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
<header>
<h1>Rivanna Monitor: {{ hostname }}</h1>
<button style="float: right; margin-left: 10px;" onclick="ToggleDarkFn()">Toggle Dark Mode</button>
<button style="float: right;" onclick="updateAll()" id="updateButton">Update All</button>
<div id="updateStatus" style="float: right; margin-right: 20px; color: #666;"></div>
<script>
var dark_mode_enabled = localStorage.getItem('colorScheme') || "false";
if (!localStorage.getItem('colorScheme')) {
localStorage.setItem('colorScheme', dark_mode_enabled);
}
function applyThemeStyles() {
// 清除所有内联样式,让CSS规则正常工作
document.querySelectorAll('table tr, .progress').forEach(function(element) {
element.removeAttribute('style');
});
}
function checkColour(){
document.body.classList.toggle("dark", dark_mode_enabled === "true");
// 应用主题样式
setTimeout(applyThemeStyles, 100);
}
function ToggleDarkFn() {
document.body.classList.toggle("dark");
// 更新状态变量
dark_mode_enabled = dark_mode_enabled === "true" ? "false" : "true";
localStorage.setItem('colorScheme', dark_mode_enabled);
applyThemeStyles();
}
// 删除原来的darkMode函数,使用新的applyThemeStyles
</script>
<h3><div id="clock"></div></h3>
<hr>
</header>
<body onload="checkColour()">
<h2> Resource available:</h2>
<div id="resource"> </div>
<br>
<!-- <hr>
<h2> CPUs available:</h2>
<div id="cpu_resource"> </div>
<br> -->
<hr>
<details>
<summary style="cursor: pointer;font-size:1.5em;font-weight: bold;margin-block-start: 0.83em;margin-block-end: 0.83em;"> GPU Leaderboard</summary>
<pre class='terminal' id="leaderboard"> </pre>
</details>
<br>
<hr>
<details open>
<summary style="cursor: pointer;font-size:1.5em;font-weight: bold;margin-block-start: 0.83em;margin-block-end: 0.83em;"> Disk Quota</summary>
<div class='table_big' id='disk_quota'> </div>
</details>
<br>
<hr>
<details open>
<summary style="cursor: pointer;font-size:1.5em;font-weight: bold;margin-block-start: 0.83em;margin-block-end: 0.83em;"> Allocations for uva_cv_lab</summary>
<div class='table_big' id='allocations'> </div>
</details>
<br>
<hr>
<details open>
<summary style="cursor: pointer;font-size:1.5em;font-weight: bold;margin-block-start: 0.83em;margin-block-end: 0.83em;"> Waiting Queue</summary>
<pre class='terminal' id="queue"> </pre>
</details>
<br><br><br>
</body>
<footer>
<hr>
<p>Source code: <a href="https://github.com/UVA-Computer-Vision-Lab/rivanna_resource"
>https://github.com/UVA-Computer-Vision-Lab/rivanna_resource</a>
<p>Contact: Xuweiyi Chen (xuweic@email.virginia.edu) </p>
</footer>
</html>
<!-- Update content every {interval} ms -->
<script>
// Remove all setInterval calls and change to manual update
var clock = document.getElementById("clock");
var disk_quota = document.getElementById("disk_quota");
var resource = document.getElementById("resource");
var queue = document.getElementById("queue");
var leaderboard = document.getElementById("leaderboard");
var allocations = document.getElementById("allocations");
var updateButton = document.getElementById("updateButton");
var updateStatus = document.getElementById("updateStatus");
// 页面可见性变化时自动更新
document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'visible') updateAll();
});
// 页面加载时自动更新
window.onload = updateAll;
async function updateAll() {
// Disable update button
updateButton.disabled = true;
updateButton.textContent = "Updating...";
updateStatus.textContent = "Starting update...";
try {
// Update time
updateStatus.textContent = "Updating time...";
await fetch("{{ url_for('time_feed') }}")
.then(response => response.text())
.then(t => {clock.innerHTML = t;});
// Update resource information
updateStatus.textContent = "Updating resource info...";
await fetch("{{ url_for('resource') }}")
.then(response => response.text())
.then(t => {resource.innerHTML = t;});
// Update queue information
updateStatus.textContent = "Updating queue info...";
await fetch("{{ url_for('queue') }}")
.then(response => response.text())
.then(t => {queue.innerHTML = t;});
// Update leaderboard information
updateStatus.textContent = "Updating leaderboard...";
await fetch("{{ url_for('leaderboard') }}")
.then(response => response.text())
.then(t => {leaderboard.innerHTML = t;});
// Update allocation information
updateStatus.textContent = "Updating allocations...";
await fetch("{{ url_for('allocations') }}")
.then(response => response.text())
.then(t => {allocations.innerHTML = t;});
// Update disk quota information
updateStatus.textContent = "Updating disk quota...";
await fetch("{{ url_for('disk_quota') }}")
.then(response => response.text())
.then(t => {disk_quota.innerHTML = t;});
// Update completed
updateStatus.textContent = "Update completed!";
// 重新应用主题样式
setTimeout(applyThemeStyles, 50);
setTimeout(() => updateStatus.textContent = "", 2000);
} catch (error) {
updateStatus.textContent = "Update failed!";
console.error("Update error:", error);
} finally {
// Restore update button
updateButton.disabled = false;
updateButton.textContent = "Update All";
}
}
</script>
<!-- CSS -->
<style>
body {
font-family: 'Helvetica', 'Arial', sans-serif;
max-width: 1200px;
margin: auto;
zoom: 75%;
}
body.dark {
background-color: #222;
color: #e6e6e6;
}
body.dark a {
color: #4da6ff;
}
pre.terminal {
color: #222;
background-color: #fafafa;
}
body.dark pre.terminal {
color: #e6e6e6;
background-color: #333;
}
table {
border-collapse: collapse;
width: 100%;
}
.table_big table {
border-collapse: collapse;
width: 62%;
font-size: 18px;
}
th, td {
text-align: left;
padding: 8px;
}
/* 只对用户列应用文字溢出处理,其他列正常显示 */
td:last-child {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 400px;
}
tr:nth-child(even) {
background-color: #f5f5f5;
}
body.dark tr:nth-child(even) {
background-color: #333;
color: #e6e6e6;
}
body.dark progress {
background-color: #444;
border-color: #555;
}
body.dark progress::-webkit-progress-bar {
background-color: #444;
}
body.dark progress::-webkit-progress-value {
background-color: #4a90e2;
}
body.dark progress::-moz-progress-bar {
background-color: #4a90e2;
}
body.dark .progress {
color: #e6e6e6 !important;
}
progress {
border-width: 1px;
outline: none;
border-radius: 3px;
width: 100px;
height: 20px;
box-shadow: 1px 1px 4px rgba(128, 128, 128, 0.2);
margin-left: 5px;
background-color: rgb(216, 216, 216);
}
progress::-webkit-progress-bar {
background-color: rgb(216, 216, 216);
border-radius: 3px;
}
progress::-webkit-progress-value {
background-color: rgb(155, 224, 207);
border-radius: 3px;
}
progress::-moz-progress-bar {
background-color: rgb(155, 224, 207);
border-radius: 3px;
}
progress.long {
width: 200px;
}
.progress:before {
content:attr(data-text);
position:absolute;
left:0;
right:0;
top:1px;
}
.progress {
text-align:center;
display:inline-block;
position:relative;
}
pre {
font-size: large;
background-color: #f5f5f5;
}
footer {
text-align: right;
}
#updateButton {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
#updateButton:hover {
background-color: #45a049;
}
#updateButton:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
#updateStatus {
padding: 8px 0;
font-style: italic;
}
</style>