Add error page on connection error
This commit is contained in:
parent
05acd44e98
commit
ae1c343560
@ -3,6 +3,7 @@
|
||||
"files": "ts/files.ts",
|
||||
"layout": "sass/layout.scss",
|
||||
"index": "sass/index.scss",
|
||||
"error": "sass/error.scss",
|
||||
"service-settings": "sass/service-settings.scss"
|
||||
}
|
||||
}
|
22
frontend/error.html
Normal file
22
frontend/error.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>An error occured</title>
|
||||
<meta http-equiv="Content-Security-Policy"
|
||||
content="style-src 'self' 'unsafe-inline' https://use.fontawesome.com; font-src 'self' https://use.fontawesome.com; script-src 'self'">
|
||||
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
|
||||
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
|
||||
|
||||
<link rel="stylesheet" href="css/layout.css">
|
||||
<link rel="stylesheet" href="css/error.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Oops</h1>
|
||||
<p>An error has occurred while loading this document.</p>
|
||||
<p>Please check your internet connection and this service's URL.</p>
|
||||
<p>If you can load the actual URL in your favorite web browser, please file us a bug report.</p>
|
||||
</body>
|
||||
</html>
|
9
frontend/sass/error.scss
Normal file
9
frontend/sass/error.scss
Normal file
@ -0,0 +1,9 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-self: center;
|
||||
}
|
@ -26,7 +26,7 @@ let securityButton: HTMLElement | null,
|
||||
backButton: HTMLElement | null,
|
||||
refreshButton: HTMLElement | null;
|
||||
let addButton, settingsButton;
|
||||
let emptyPage: string;
|
||||
let emptyPage: string, errorPage: string;
|
||||
let urlPreview: HTMLElement | null;
|
||||
let serviceSelector: HTMLElement | null;
|
||||
|
||||
@ -128,7 +128,7 @@ function openServiceContextMenu(event: Event, serviceId: number) {
|
||||
}
|
||||
|
||||
|
||||
ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUrl, config) => {
|
||||
ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUrl, errorUrl, config) => {
|
||||
// App info
|
||||
appInfo.title = appData.title;
|
||||
|
||||
@ -179,6 +179,7 @@ ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUr
|
||||
|
||||
// Empty
|
||||
emptyPage = emptyUrl;
|
||||
errorPage = errorUrl;
|
||||
|
||||
// Url preview element
|
||||
urlPreview = document.getElementById("url-preview");
|
||||
@ -477,6 +478,11 @@ function loadService(serviceId: number, service: any) {
|
||||
// eventual future human mistakes.
|
||||
service.view.setAttribute('webpreferences', 'contextIsolation=yes');
|
||||
|
||||
// Error handling
|
||||
service.view.addEventListener('did-fail-load', (e: Event) => {
|
||||
service.view.setAttribute('src', errorPage);
|
||||
});
|
||||
|
||||
// Append element to DOM
|
||||
document.querySelector('#services')?.appendChild(service.view);
|
||||
|
||||
|
@ -147,6 +147,7 @@ export default class MainWindow extends Window {
|
||||
Meta.ICON_SETS,
|
||||
this.activeService,
|
||||
path.resolve(Meta.RESOURCES_PATH, 'empty.html'),
|
||||
path.resolve(Meta.RESOURCES_PATH, 'error.html'),
|
||||
this.config
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user