Skip to content

Commit

Permalink
Add an error page when the server is unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
ghickman committed Jul 11, 2023
1 parent 4fc0cd5 commit eb8dbef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
13 changes: 13 additions & 0 deletions sacro-app/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en" class="min-h-screen">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>SACRO Outputs Viewer</title>
</head>

<body>
<h2>ERROR!</h2>
</body>
</html>
21 changes: 14 additions & 7 deletions sacro-app/src/create-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function windowBuilder(options) {
let TEMPDIR = null;

const createWindow = async () => {
const error = windowBuilder({ file: "error.html", show: false });
const splash = windowBuilder({
file: "splash.html",
transparent: true,
Expand Down Expand Up @@ -99,13 +100,19 @@ const createWindow = async () => {
const url = `${serverUrl}?${qs}`;

const timeout = serverProcess === null ? 0 : 4000;
waitThenLoad(url, timeout).then(() => {
win.loadURL(url);

// swap the splash screen for the main window now it's loaded
splash.close();
win.show();
});
waitThenLoad(url, timeout)
.then(() => {
win.loadURL(url);

// swap the splash screen for the main window now it's loaded
splash.close();
win.show();
})
.catch(() => {
// swap the splash screen for the error screen on failure
splash.close();
error.show();
});
}

if (process.env.DEBUG) {
Expand Down

0 comments on commit eb8dbef

Please sign in to comment.