Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/web/frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function App() {
const [bgLoaded, setBgLoaded] = useState(false)
const [fadingOut, setFadingOut] = useState(false)
const [authDisabled, setAuthDisabled] = useState(false)
const [loadError, setLoadError] = useState(null)

useEffect(() => {
Promise.all([
Expand All @@ -26,14 +27,26 @@ export default function App() {
} else {
setView('login')
}
}).catch((e) => {
// A server hiccup during startup used to leave the page blank
// forever: the view never left its initial null state.
setLoadError(e?.message || 'failed to reach the server')
setView('error')
})
fetchBackgroundArt().then((artUrl) => {
if (artUrl) setBgUrl(artUrl)
})
}, [])

async function handleLoginSuccess({ fromLogin = false } = {}) {
const { values, sources } = await fetchConfig()
let values, sources
try {
({ values, sources } = await fetchConfig())
} catch (e) {
setLoadError(e?.message || 'failed to load configuration')
setView('error')
return
}
setConfig(values)
setEnvSources(sources || {})
const nextView = values.WIZARD_COMPLETE === 'true' ? 'settings' : 'wizard'
Expand All @@ -48,6 +61,23 @@ export default function App() {
}
}

if (view === 'error') {
return (
<div className="min-h-screen bg-bg flex items-center justify-center p-6">
<div className="max-w-md text-center">
<h1 className="text-xl font-semibold mb-2">Couldn&apos;t load Explo</h1>
<p className="text-sm text-muted mb-4">{loadError}</p>
<button
className="px-4 py-2 rounded bg-accent text-white"
onClick={() => window.location.reload()}
>
Retry
</button>
</div>
</div>
)
}

if (view === null) return <div className="min-h-screen bg-bg" />

if (view === 'login') {
Expand Down
1 change: 1 addition & 0 deletions src/web/frontend/src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function login(username, password) {

export async function fetchConfig() {
const res = await apiFetch('/api/ui/config')
if (!res.ok) throw new Error(`config load failed (${res.status}): ${await res.text()}`)
return res.json()
}

Expand Down
Loading