mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-25 02:10:32 -06:00
3be2986c7e
- fix crash reporter - fix typo - Add support to generate crash report - Add logic to store globally and return - PR review fixes - Add logic to validate file mime type
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
'use strict';
|
|
const { ipcRenderer, crashReporter } = require('electron');
|
|
|
|
renderDom();
|
|
|
|
/**
|
|
* Method that renders application data
|
|
*/
|
|
function renderDom() {
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
loadContent();
|
|
});
|
|
}
|
|
|
|
function loadContent() {
|
|
let basicAuth = document.getElementById('basicAuth');
|
|
let cancel = document.getElementById('cancel');
|
|
|
|
if (basicAuth) {
|
|
basicAuth.onsubmit = (e) => {
|
|
e.preventDefault();
|
|
submitForm();
|
|
};
|
|
}
|
|
|
|
if (cancel) {
|
|
cancel.addEventListener('click', () => {
|
|
ipcRenderer.send('close-basic-auth');
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Method that gets invoked on submitting the form
|
|
*/
|
|
function submitForm() {
|
|
let username = document.getElementById('username').value;
|
|
let password = document.getElementById('password').value;
|
|
|
|
if (username && password) {
|
|
ipcRenderer.send('login', { username, password });
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Updates the hosts name
|
|
*/
|
|
ipcRenderer.on('hostname', (event, host) => {
|
|
let hostname = document.getElementById('hostname');
|
|
|
|
if (hostname){
|
|
hostname.innerHTML = host || 'unknown';
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Triggered if user credentials are invalid
|
|
*/
|
|
ipcRenderer.on('isValidCredentials', (event, isValidCredentials) => {
|
|
let credentialsError = document.getElementById('credentialsError');
|
|
|
|
if (credentialsError){
|
|
credentialsError.style.display = isValidCredentials ? 'none' : 'block'
|
|
}
|
|
});
|
|
|
|
ipcRenderer.on('register-crash-reporter', (event, arg) => {
|
|
if (arg && typeof arg === 'object') {
|
|
crashReporter.start(arg);
|
|
}
|
|
}); |