feat: replace setup screen with automatic settings modal for initial configuration

- Remove redirect to setup.html in favor of always serving main application
- Add automatic detection of placeholder configuration values on page load
- Automatically open settings modal when configuration needs setup
- Provide seamless unified interface for both initial setup and ongoing management
- Eliminate need for separate setup.html page while maintaining full functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
courtmanr@gmail.com
2025-05-30 15:10:27 +01:00
parent 5854ceada1
commit 839bfc2b59
2 changed files with 41 additions and 8 deletions
+1 -8
View File
@@ -125,14 +125,7 @@ app.use(express.static(publicDir, { index: false }));
// Route to serve the main HTML file for the root path
app.get('/', (req, res) => {
// Check if configuration is placeholder or missing using current state
const currentConfigStatus = stateManager.getState().isConfigPlaceholder;
if (currentConfigStatus) {
// Redirect to setup page
return res.redirect('/setup.html');
}
// Always serve the main application with settings modal for initial configuration
const indexPath = path.join(publicDir, 'index.html');
res.sendFile(indexPath, (err) => {
if (err) {
+40
View File
@@ -243,6 +243,9 @@ document.addEventListener('DOMContentLoaded', function() {
initializeModules();
// Check if configuration is missing or contains placeholders and automatically open settings modal
checkAndOpenSettingsIfNeeded();
// Fetch version immediately and retry after a short delay if needed
fetchVersion();
@@ -258,4 +261,41 @@ document.addEventListener('DOMContentLoaded', function() {
setInterval(() => {
fetchVersion();
}, 6 * 60 * 60 * 1000);
/**
* Check if configuration is missing or contains placeholder values and open settings modal
*/
async function checkAndOpenSettingsIfNeeded() {
try {
// Wait a moment for the socket connection to establish and initial data to arrive
setTimeout(async () => {
try {
const response = await fetch('/api/health');
if (response.ok) {
const health = await response.json();
// Check if configuration has placeholder values or no data is available
if (health.system && health.system.configPlaceholder) {
console.log('[Main] Configuration contains placeholder values, opening settings modal...');
// Wait for settings module to be fully initialized
setTimeout(() => {
if (PulseApp.ui.settings && typeof PulseApp.ui.settings.openModal === 'function') {
PulseApp.ui.settings.openModal();
} else {
console.warn('[Main] Settings module not available for auto-open');
}
}, 500);
} else {
console.log('[Main] Configuration appears valid, not opening settings modal');
}
}
} catch (error) {
console.error('[Main] Error checking configuration status:', error);
}
}, 2000); // Wait 2 seconds for everything to settle
} catch (error) {
console.error('[Main] Error in checkAndOpenSettingsIfNeeded:', error);
}
}
});