Spaces:
Running
Running
refactor: replace static sign check with async network validation for private space detection
Browse files- health-server.js +26 -11
health-server.js
CHANGED
|
@@ -436,10 +436,6 @@ function renderDashboard(initialData) {
|
|
| 436 |
display: none;
|
| 437 |
}
|
| 438 |
|
| 439 |
-
.helper-intro.hidden {
|
| 440 |
-
display: none;
|
| 441 |
-
}
|
| 442 |
-
|
| 443 |
.helper-summary {
|
| 444 |
margin-top: 14px;
|
| 445 |
padding: 12px 14px;
|
|
@@ -660,9 +656,23 @@ function renderDashboard(initialData) {
|
|
| 660 |
|
| 661 |
const monitorStateKey = 'huggingclaw_uptimerobot_setup_v1';
|
| 662 |
|
| 663 |
-
function
|
| 664 |
const params = new URLSearchParams(window.location.search || '');
|
| 665 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 666 |
}
|
| 667 |
|
| 668 |
function setMonitorUiState(isConfigured) {
|
|
@@ -746,13 +756,18 @@ function renderDashboard(initialData) {
|
|
| 746 |
setInterval(updateStats, 10000);
|
| 747 |
restoreMonitorUiState();
|
| 748 |
document.getElementById('control-ui-link').setAttribute('href', getDashboardBase() + '/app/' + getCurrentSearch());
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 753 |
document.getElementById('uptimerobot-btn').addEventListener('click', setupUptimeRobot);
|
| 754 |
document.getElementById('uptimerobot-toggle').addEventListener('click', toggleMonitorSetup);
|
| 755 |
-
}
|
| 756 |
</script>
|
| 757 |
</body>
|
| 758 |
</html>
|
|
|
|
| 436 |
display: none;
|
| 437 |
}
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
.helper-summary {
|
| 440 |
margin-top: 14px;
|
| 441 |
padding: 12px 14px;
|
|
|
|
| 656 |
|
| 657 |
const monitorStateKey = 'huggingclaw_uptimerobot_setup_v1';
|
| 658 |
|
| 659 |
+
async function detectPrivateSpace() {
|
| 660 |
const params = new URLSearchParams(window.location.search || '');
|
| 661 |
+
|
| 662 |
+
if (!params.has('__sign')) {
|
| 663 |
+
return false;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
try {
|
| 667 |
+
const res = await fetch(getDashboardBase(), {
|
| 668 |
+
method: 'GET',
|
| 669 |
+
cache: 'no-store',
|
| 670 |
+
credentials: 'same-origin'
|
| 671 |
+
});
|
| 672 |
+
return !res.ok;
|
| 673 |
+
} catch {
|
| 674 |
+
return true;
|
| 675 |
+
}
|
| 676 |
}
|
| 677 |
|
| 678 |
function setMonitorUiState(isConfigured) {
|
|
|
|
| 756 |
setInterval(updateStats, 10000);
|
| 757 |
restoreMonitorUiState();
|
| 758 |
document.getElementById('control-ui-link').setAttribute('href', getDashboardBase() + '/app/' + getCurrentSearch());
|
| 759 |
+
detectPrivateSpace().then((isPrivate) => {
|
| 760 |
+
if (isPrivate) {
|
| 761 |
+
document.getElementById('uptimerobot-public-flow').classList.add('hidden');
|
| 762 |
+
document.getElementById('uptimerobot-private-note').classList.remove('hidden');
|
| 763 |
+
document.getElementById('uptimerobot-result').className = 'helper-result';
|
| 764 |
+
document.getElementById('uptimerobot-result').textContent = '';
|
| 765 |
+
return;
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
document.getElementById('uptimerobot-btn').addEventListener('click', setupUptimeRobot);
|
| 769 |
document.getElementById('uptimerobot-toggle').addEventListener('click', toggleMonitorSetup);
|
| 770 |
+
});
|
| 771 |
</script>
|
| 772 |
</body>
|
| 773 |
</html>
|