mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-967 (Handle network state and implement retry logic) (#600)
* ELECTRON-967 - Display Error content when there is no active network connection * ELECTRON-967 - Fix css issue for Windows * ELECTRON-967 - Optimize code
This commit is contained in:
committed by
Vishwas Shashidhar
parent
a074126537
commit
c3bbadb955
44
js/networkError/index.js
Normal file
44
js/networkError/index.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
const apiEnums = require('../enums/api.js');
|
||||
const apiCmds = apiEnums.cmds;
|
||||
const apiName = apiEnums.apiName;
|
||||
const htmlContents = require('./contents');
|
||||
|
||||
class NetworkError {
|
||||
|
||||
constructor() {
|
||||
this.domParser = new DOMParser();
|
||||
}
|
||||
|
||||
showError(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
const { message, error } = data;
|
||||
const errorContent = this.domParser.parseFromString(htmlContents.errorContent(message), 'text/html');
|
||||
errorContent.getElementById('error-code').innerText = error || "UNKNOWN_ERROR";
|
||||
|
||||
// Add event listeners for buttons
|
||||
const cancelRetryButton = errorContent.getElementById('cancel-retry-button');
|
||||
cancelRetryButton.addEventListener('click', () => {
|
||||
ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.cancelNetworkStatusCheck
|
||||
});
|
||||
});
|
||||
|
||||
const quitButton = errorContent.getElementById('quit-button');
|
||||
quitButton.addEventListener('click', () => {
|
||||
ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.quitWindow
|
||||
})
|
||||
});
|
||||
|
||||
const mainFrame = errorContent.getElementById('main-frame');
|
||||
document.body.appendChild(mainFrame);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NetworkError,
|
||||
};
|
||||
Reference in New Issue
Block a user