Spaces:
Sleeping
Sleeping
ichieh commited on
Commit ·
7db85a7
1
Parent(s): b959f55
增加休眠喚醒
Browse files- templates/admin.html +87 -1
- templates/index.html +86 -0
templates/admin.html
CHANGED
|
@@ -7,8 +7,52 @@
|
|
| 7 |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.css" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</head>
|
| 11 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
<div class="container mt-4">
|
| 13 |
<h2>管理員後台</h2>
|
| 14 |
|
|
@@ -557,10 +601,52 @@
|
|
| 557 |
}
|
| 558 |
}
|
| 559 |
|
| 560 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
document.addEventListener('DOMContentLoaded', () => {
|
| 562 |
loadCurrentSettings();
|
| 563 |
loadParticipants();
|
|
|
|
| 564 |
});
|
| 565 |
</script>
|
| 566 |
</body>
|
|
|
|
| 7 |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.css" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
|
| 10 |
+
<style>
|
| 11 |
+
#restartContainer {
|
| 12 |
+
display: none;
|
| 13 |
+
position: fixed;
|
| 14 |
+
top: 50%;
|
| 15 |
+
left: 50%;
|
| 16 |
+
transform: translate(-50%, -50%);
|
| 17 |
+
z-index: 9999;
|
| 18 |
+
text-align: center;
|
| 19 |
+
background: rgba(0, 0, 0, 0.9);
|
| 20 |
+
padding: 2rem;
|
| 21 |
+
border-radius: 10px;
|
| 22 |
+
color: white;
|
| 23 |
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
|
| 24 |
+
}
|
| 25 |
+
#restartContainer h3 {
|
| 26 |
+
margin-bottom: 1rem;
|
| 27 |
+
}
|
| 28 |
+
#restartContainer p {
|
| 29 |
+
margin-bottom: 1.5rem;
|
| 30 |
+
}
|
| 31 |
+
.sleeping-overlay {
|
| 32 |
+
position: fixed;
|
| 33 |
+
top: 0;
|
| 34 |
+
left: 0;
|
| 35 |
+
right: 0;
|
| 36 |
+
bottom: 0;
|
| 37 |
+
background: rgba(0, 0, 0, 0.5);
|
| 38 |
+
z-index: 9998;
|
| 39 |
+
display: none;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
</head>
|
| 43 |
<body>
|
| 44 |
+
<!-- 重啟系統對話框 -->
|
| 45 |
+
<div id="restartContainer">
|
| 46 |
+
<h3><i class="bi bi-moon-stars"></i> 系統休眠中</h3>
|
| 47 |
+
<p>由於一段時間沒有活動,系統進入了休眠狀態。<br>請點擊下方按鈕重新啟動。</p>
|
| 48 |
+
<button onclick="restartSpace()" class="btn btn-primary">
|
| 49 |
+
<i class="bi bi-arrow-clockwise"></i> 重新啟動系統
|
| 50 |
+
</button>
|
| 51 |
+
</div>
|
| 52 |
+
|
| 53 |
+
<!-- 遮罩層 -->
|
| 54 |
+
<div id="sleepingOverlay" class="sleeping-overlay"></div>
|
| 55 |
+
|
| 56 |
<div class="container mt-4">
|
| 57 |
<h2>管理員後台</h2>
|
| 58 |
|
|
|
|
| 601 |
}
|
| 602 |
}
|
| 603 |
|
| 604 |
+
// 檢查系統狀態的函數
|
| 605 |
+
async function checkSystemStatus() {
|
| 606 |
+
try {
|
| 607 |
+
const response = await fetch('/api/admin/participants');
|
| 608 |
+
if (!response.ok) {
|
| 609 |
+
showRestartButton();
|
| 610 |
+
} else {
|
| 611 |
+
hideRestartButton();
|
| 612 |
+
}
|
| 613 |
+
} catch (error) {
|
| 614 |
+
console.error('Error checking system status:', error);
|
| 615 |
+
showRestartButton();
|
| 616 |
+
}
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
// 顯示重啟按鈕
|
| 620 |
+
function showRestartButton() {
|
| 621 |
+
document.getElementById('restartContainer').style.display = 'block';
|
| 622 |
+
document.getElementById('sleepingOverlay').style.display = 'block';
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
// 隱藏重啟按鈕
|
| 626 |
+
function hideRestartButton() {
|
| 627 |
+
document.getElementById('restartContainer').style.display = 'none';
|
| 628 |
+
document.getElementById('sleepingOverlay').style.display = 'none';
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
// 重啟系統
|
| 632 |
+
async function restartSpace() {
|
| 633 |
+
const button = document.querySelector('#restartContainer button');
|
| 634 |
+
const originalText = button.innerHTML;
|
| 635 |
+
button.disabled = true;
|
| 636 |
+
button.innerHTML = '<i class="bi bi-arrow-clockwise"></i> 正在重新啟動...';
|
| 637 |
+
|
| 638 |
+
// 重新載入頁面
|
| 639 |
+
window.location.reload();
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
+
// 定期檢查系統狀態
|
| 643 |
+
setInterval(checkSystemStatus, 30000); // 每30秒檢查一次
|
| 644 |
+
|
| 645 |
+
// 初始化頁面時也檢查一次
|
| 646 |
document.addEventListener('DOMContentLoaded', () => {
|
| 647 |
loadCurrentSettings();
|
| 648 |
loadParticipants();
|
| 649 |
+
checkSystemStatus();
|
| 650 |
});
|
| 651 |
</script>
|
| 652 |
</body>
|
templates/index.html
CHANGED
|
@@ -8,8 +8,52 @@
|
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.0/dist/sweetalert2.min.css" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
|
| 10 |
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
</head>
|
| 12 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
<div class="container">
|
| 14 |
<h1 class="text-center my-4">蛇來蛇去 - 辦桌春酒大亂鬥暨天公生慶生祝願
|
| 15 |
<a href="https://fb.me/1LHAts3TlfxyvhM" target="_blank" class="btn btn-outline-primary btn-sm">
|
|
@@ -167,9 +211,51 @@
|
|
| 167 |
}
|
| 168 |
}
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
// 初始化頁面
|
| 171 |
document.addEventListener('DOMContentLoaded', () => {
|
| 172 |
loadTables();
|
|
|
|
| 173 |
});
|
| 174 |
|
| 175 |
// 字數計數器
|
|
|
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.0/dist/sweetalert2.min.css" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
|
| 10 |
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
| 11 |
+
<style>
|
| 12 |
+
#restartContainer {
|
| 13 |
+
display: none;
|
| 14 |
+
position: fixed;
|
| 15 |
+
top: 50%;
|
| 16 |
+
left: 50%;
|
| 17 |
+
transform: translate(-50%, -50%);
|
| 18 |
+
z-index: 9999;
|
| 19 |
+
text-align: center;
|
| 20 |
+
background: rgba(0, 0, 0, 0.9);
|
| 21 |
+
padding: 2rem;
|
| 22 |
+
border-radius: 10px;
|
| 23 |
+
color: white;
|
| 24 |
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
|
| 25 |
+
}
|
| 26 |
+
#restartContainer h3 {
|
| 27 |
+
margin-bottom: 1rem;
|
| 28 |
+
}
|
| 29 |
+
#restartContainer p {
|
| 30 |
+
margin-bottom: 1.5rem;
|
| 31 |
+
}
|
| 32 |
+
.sleeping-overlay {
|
| 33 |
+
position: fixed;
|
| 34 |
+
top: 0;
|
| 35 |
+
left: 0;
|
| 36 |
+
right: 0;
|
| 37 |
+
bottom: 0;
|
| 38 |
+
background: rgba(0, 0, 0, 0.5);
|
| 39 |
+
z-index: 9998;
|
| 40 |
+
display: none;
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
</head>
|
| 44 |
<body>
|
| 45 |
+
<!-- 重啟系統對話框 -->
|
| 46 |
+
<div id="restartContainer">
|
| 47 |
+
<h3><i class="bi bi-moon-stars"></i> 系統休眠中</h3>
|
| 48 |
+
<p>由於一段時間沒有活動,系統進入了休眠狀態。<br>請點擊下方按鈕重新啟動。</p>
|
| 49 |
+
<button onclick="restartSpace()" class="btn btn-primary">
|
| 50 |
+
<i class="bi bi-arrow-clockwise"></i> 重新啟動系統
|
| 51 |
+
</button>
|
| 52 |
+
</div>
|
| 53 |
+
|
| 54 |
+
<!-- 遮罩層 -->
|
| 55 |
+
<div id="sleepingOverlay" class="sleeping-overlay"></div>
|
| 56 |
+
|
| 57 |
<div class="container">
|
| 58 |
<h1 class="text-center my-4">蛇來蛇去 - 辦桌春酒大亂鬥暨天公生慶生祝願
|
| 59 |
<a href="https://fb.me/1LHAts3TlfxyvhM" target="_blank" class="btn btn-outline-primary btn-sm">
|
|
|
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
| 214 |
+
// 檢查系統狀態的函數
|
| 215 |
+
async function checkSystemStatus() {
|
| 216 |
+
try {
|
| 217 |
+
const response = await fetch('/api/tables');
|
| 218 |
+
if (!response.ok) {
|
| 219 |
+
showRestartButton();
|
| 220 |
+
} else {
|
| 221 |
+
hideRestartButton();
|
| 222 |
+
}
|
| 223 |
+
} catch (error) {
|
| 224 |
+
console.error('Error checking system status:', error);
|
| 225 |
+
showRestartButton();
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// 顯示重啟按鈕
|
| 230 |
+
function showRestartButton() {
|
| 231 |
+
document.getElementById('restartContainer').style.display = 'block';
|
| 232 |
+
document.getElementById('sleepingOverlay').style.display = 'block';
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
// 隱藏重啟按鈕
|
| 236 |
+
function hideRestartButton() {
|
| 237 |
+
document.getElementById('restartContainer').style.display = 'none';
|
| 238 |
+
document.getElementById('sleepingOverlay').style.display = 'none';
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
// 重啟系統
|
| 242 |
+
async function restartSpace() {
|
| 243 |
+
const button = document.querySelector('#restartContainer button');
|
| 244 |
+
const originalText = button.innerHTML;
|
| 245 |
+
button.disabled = true;
|
| 246 |
+
button.innerHTML = '<i class="bi bi-arrow-clockwise"></i> 正在重新啟動...';
|
| 247 |
+
|
| 248 |
+
// 重新載入頁面
|
| 249 |
+
window.location.reload();
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
// 定期檢查系統狀態
|
| 253 |
+
setInterval(checkSystemStatus, 30000); // 每30秒檢查一次
|
| 254 |
+
|
| 255 |
// 初始化頁面
|
| 256 |
document.addEventListener('DOMContentLoaded', () => {
|
| 257 |
loadTables();
|
| 258 |
+
checkSystemStatus();
|
| 259 |
});
|
| 260 |
|
| 261 |
// 字數計數器
|