Spaces:
Running
Running
refactor: dynamically resolve dashboard base path for API endpoints and UI navigation links
Browse files- health-server.js +9 -3
health-server.js
CHANGED
|
@@ -478,7 +478,7 @@ function renderDashboard() {
|
|
| 478 |
<span class="stat-label">Telegram</span>
|
| 479 |
<span id="tg-status">Loading...</span>
|
| 480 |
</div>
|
| 481 |
-
<a href="
|
| 482 |
</div>
|
| 483 |
|
| 484 |
<div class="stat-card" style="width: 100%;">
|
|
@@ -532,9 +532,14 @@ function renderDashboard() {
|
|
| 532 |
</div>
|
| 533 |
|
| 534 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
async function updateStats() {
|
| 536 |
try {
|
| 537 |
-
const res = await fetch('
|
| 538 |
const data = await res.json();
|
| 539 |
|
| 540 |
document.getElementById('model-id').textContent = data.model;
|
|
@@ -624,7 +629,7 @@ function renderDashboard() {
|
|
| 624 |
result.textContent = '';
|
| 625 |
|
| 626 |
try {
|
| 627 |
-
const res = await fetch('
|
| 628 |
method: 'POST',
|
| 629 |
headers: { 'Content-Type': 'application/json' },
|
| 630 |
body: JSON.stringify({ apiKey })
|
|
@@ -655,6 +660,7 @@ function renderDashboard() {
|
|
| 655 |
updateStats();
|
| 656 |
setInterval(updateStats, 10000);
|
| 657 |
restoreMonitorUiState();
|
|
|
|
| 658 |
document.getElementById('uptimerobot-btn').addEventListener('click', setupUptimeRobot);
|
| 659 |
document.getElementById('uptimerobot-toggle').addEventListener('click', toggleMonitorSetup);
|
| 660 |
</script>
|
|
|
|
| 478 |
<span class="stat-label">Telegram</span>
|
| 479 |
<span id="tg-status">Loading...</span>
|
| 480 |
</div>
|
| 481 |
+
<a href="#" id="control-ui-link" class="stat-btn">Open Control UI</a>
|
| 482 |
</div>
|
| 483 |
|
| 484 |
<div class="stat-card" style="width: 100%;">
|
|
|
|
| 532 |
</div>
|
| 533 |
|
| 534 |
<script>
|
| 535 |
+
function getDashboardBase() {
|
| 536 |
+
const pathname = window.location.pathname || '${DASHBOARD_BASE}';
|
| 537 |
+
return pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
async function updateStats() {
|
| 541 |
try {
|
| 542 |
+
const res = await fetch(getDashboardBase() + '/status');
|
| 543 |
const data = await res.json();
|
| 544 |
|
| 545 |
document.getElementById('model-id').textContent = data.model;
|
|
|
|
| 629 |
result.textContent = '';
|
| 630 |
|
| 631 |
try {
|
| 632 |
+
const res = await fetch(getDashboardBase() + '/uptimerobot/setup', {
|
| 633 |
method: 'POST',
|
| 634 |
headers: { 'Content-Type': 'application/json' },
|
| 635 |
body: JSON.stringify({ apiKey })
|
|
|
|
| 660 |
updateStats();
|
| 661 |
setInterval(updateStats, 10000);
|
| 662 |
restoreMonitorUiState();
|
| 663 |
+
document.getElementById('control-ui-link').setAttribute('href', getDashboardBase() + '/app/');
|
| 664 |
document.getElementById('uptimerobot-btn').addEventListener('click', setupUptimeRobot);
|
| 665 |
document.getElementById('uptimerobot-toggle').addEventListener('click', toggleMonitorSetup);
|
| 666 |
</script>
|