|
|
@ -1,59 +1,225 @@ |
|
|
|
function closeMainWindow() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
let _configCopy; |
|
|
|
|
|
|
|
window.createWindow('open'); |
|
|
|
window.hide(); |
|
|
|
} |
|
|
|
function initSettingsForm() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
let appConf = remote.getCurrentWindow().appConfig; |
|
|
|
let appConfSchema = remote.getCurrentWindow().appConfigSchema; |
|
|
|
_configCopy = Object.assign({}, appConf); |
|
|
|
|
|
|
|
function quitApp() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
let _htmlOut = '<table class="settings-table">'; |
|
|
|
for (let key in appConf) { |
|
|
|
if (appConfSchema[key] && |
|
|
|
appConfSchema[key].initDisplay) { |
|
|
|
_htmlOut = ` |
|
|
|
${_htmlOut} |
|
|
|
<tr> |
|
|
|
<td class="left"> |
|
|
|
${appConfSchema[key].displayName}`;
|
|
|
|
|
|
|
|
if (appConfSchema[key].info) { |
|
|
|
_htmlOut = ` |
|
|
|
${_htmlOut} |
|
|
|
<div |
|
|
|
class="settings-help" |
|
|
|
title="${appConfSchema[key].info}"> |
|
|
|
<img src="EasyDEX-GUI/assets/mainWindow/img/fa-question.png" /> |
|
|
|
</div>`; |
|
|
|
} |
|
|
|
|
|
|
|
window.forseCloseApp(); |
|
|
|
if (appConfSchema[key].type === 'number') { |
|
|
|
_htmlOut = ` |
|
|
|
${_htmlOut} |
|
|
|
</td> |
|
|
|
<td class="right"> |
|
|
|
<input |
|
|
|
type="number" |
|
|
|
id="${key}" |
|
|
|
pattern="[0-9]*" |
|
|
|
onKeyup="handleInput('${key}')" |
|
|
|
value="${_configCopy[key]}" /> |
|
|
|
</td> |
|
|
|
</tr>`; |
|
|
|
} else if (appConfSchema[key].type === 'string' || appConfSchema[key].type === 'folder') { |
|
|
|
_htmlOut = ` |
|
|
|
${_htmlOut} |
|
|
|
</td> |
|
|
|
<td class="right"> |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
id="${key}" |
|
|
|
onKeyup="handleInput('${key}')" |
|
|
|
value="${_configCopy[key]}" /> |
|
|
|
</td> |
|
|
|
</tr>`; |
|
|
|
} else if (appConfSchema[key].type === 'boolean') { |
|
|
|
_htmlOut = `${_htmlOut} |
|
|
|
</td> |
|
|
|
<td class="right"> |
|
|
|
<label |
|
|
|
class="switch" |
|
|
|
id="${key}" |
|
|
|
onClick="settingsToggle(\'${key}\')"> |
|
|
|
${(appConf[key] ? '<input type="checkbox" class="cb" checked />' : '<input type="checkbox" class="cb" />')} |
|
|
|
<div class="slider"></div> |
|
|
|
</label> |
|
|
|
</td> |
|
|
|
</tr>`; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function normalStart() { |
|
|
|
_htmlOut = ` |
|
|
|
${_htmlOut} |
|
|
|
</table>`; |
|
|
|
|
|
|
|
$('#agamaConfigBlock').html(_htmlOut); |
|
|
|
} |
|
|
|
|
|
|
|
function hideToastImmediate() { |
|
|
|
$('#toast-container').addClass('hide'); |
|
|
|
} |
|
|
|
|
|
|
|
function hideToast() { |
|
|
|
setTimeout(function() { |
|
|
|
$('#toast-container').addClass('hide'); |
|
|
|
}, 5000); |
|
|
|
} |
|
|
|
|
|
|
|
function showToast(type, message) { |
|
|
|
$('#toast-container .toast').removeClass('toast-success').removeClass('toast-error'); |
|
|
|
$('#toast-container .toast').addClass(`toast-${type}`); |
|
|
|
$('#toast-container .toast-message').html(message); |
|
|
|
$('#toast-container').removeClass('hide'); |
|
|
|
hideToast(); |
|
|
|
} |
|
|
|
|
|
|
|
function setDefaultAppSettings() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
|
|
|
|
remote.getCurrentWindow().setDefaultAppSettings(); |
|
|
|
remote.getCurrentWindow().appConfig = remote.getCurrentWindow().defaultAppSettings; |
|
|
|
initSettingsForm(); |
|
|
|
showToast('success', 'App settings are reset to default'); |
|
|
|
} |
|
|
|
|
|
|
|
function handleSaveSettings() { |
|
|
|
if (_configCopy.dataDir && |
|
|
|
_configCopy.dataDir.length) { |
|
|
|
const remote = require('electron').remote; |
|
|
|
let appConf = remote.getCurrentWindow().appConfig; |
|
|
|
appConf.iguanaLessMode = false; |
|
|
|
|
|
|
|
// run iguana-less mode with no daemons startup
|
|
|
|
if (appConf && appConf.iguanaLessMode) { |
|
|
|
// do something
|
|
|
|
} else { // run normal mode with 2 iguana instances started prior loading GUI
|
|
|
|
if (appConf && !appConf.manualIguanaStart) { |
|
|
|
StartIguana(); |
|
|
|
|
|
|
|
remote.getCurrentWindow().testLocation(_configCopy.dataDir) |
|
|
|
.then(function(res) { |
|
|
|
$('#debugOut').html(res + ' | ' + _configCopy.dataDir); |
|
|
|
if (res === -1) { |
|
|
|
showToast('error', 'Komodo datadir path is invalid'); |
|
|
|
} else if (res === false) { |
|
|
|
showToast('error', 'Komodo datadir path is not a directory'); |
|
|
|
} else { |
|
|
|
// save settings
|
|
|
|
remote.getCurrentWindow().updateAppSettings(_configCopy); |
|
|
|
remote.getCurrentWindow().appConfig = _configCopy; |
|
|
|
showToast('success', 'Settings saved'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// save settings
|
|
|
|
const remote = require('electron').remote; |
|
|
|
|
|
|
|
var portcheck; |
|
|
|
remote.getCurrentWindow().updateAppSettings(_configCopy); |
|
|
|
remote.getCurrentWindow().appConfig = _configCopy; |
|
|
|
showToast('success', 'Settings saved'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function startcheck() { |
|
|
|
portcheck = setInterval(function() { |
|
|
|
Iguana_activehandle(appConf).then(function(result){ |
|
|
|
console.log(result); |
|
|
|
function handleInput(key) { |
|
|
|
const _value = $(`#${key}`).val(); |
|
|
|
_configCopy[key] = _value; |
|
|
|
} |
|
|
|
|
|
|
|
if (result !== 'error') { |
|
|
|
stopcheck(); |
|
|
|
function settingsToggle(key) { |
|
|
|
const _value = $(`#${key} .cb`).prop('checked'); |
|
|
|
_configCopy[key] = _value; |
|
|
|
} |
|
|
|
|
|
|
|
if (appConf && appConf.useBasiliskInstance) { |
|
|
|
StartIguana_Cache(); |
|
|
|
} |
|
|
|
function closeSettingsWindow() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
|
|
|
|
$('#loading_status_text').text('Connecting to Basilisk Network...'); |
|
|
|
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf); |
|
|
|
window.destroyAppSettingsWindow(); |
|
|
|
} |
|
|
|
|
|
|
|
function reloadSettingsWindow() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
|
|
|
|
window.reloadSettingsWindow(); |
|
|
|
} |
|
|
|
|
|
|
|
function openSettingsWindow() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
|
|
|
|
window.createAppSettingsWindow(); |
|
|
|
} |
|
|
|
|
|
|
|
function closeMainWindow() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
|
|
|
|
window.createWindow('open'); |
|
|
|
window.hide(); |
|
|
|
} |
|
|
|
|
|
|
|
function quitApp() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
const window = remote.getCurrentWindow(); |
|
|
|
|
|
|
|
window.forseCloseApp(); |
|
|
|
} |
|
|
|
|
|
|
|
function normalStart() { |
|
|
|
const remote = require('electron').remote; |
|
|
|
let appConf = remote.getCurrentWindow().appConfig; |
|
|
|
appConf.iguanaLessMode = false; |
|
|
|
|
|
|
|
// run iguana-less mode with no daemons startup
|
|
|
|
if (appConf && |
|
|
|
appConf.iguanaLessMode) { |
|
|
|
// do something
|
|
|
|
} else { // run normal mode with 2 iguana instances started prior loading GUI
|
|
|
|
if (appConf && |
|
|
|
!appConf.manualIguanaStart) { |
|
|
|
StartIguana(); |
|
|
|
} |
|
|
|
|
|
|
|
var portcheck; |
|
|
|
|
|
|
|
function startcheck() { |
|
|
|
portcheck = setInterval(function() { |
|
|
|
Iguana_activehandle(appConf).then(function(result){ |
|
|
|
console.log(result); |
|
|
|
|
|
|
|
if (result !== 'error') { |
|
|
|
stopcheck(); |
|
|
|
|
|
|
|
if (appConf && appConf.useBasiliskInstance) { |
|
|
|
StartIguana_Cache(); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 2000); |
|
|
|
} |
|
|
|
|
|
|
|
function stopcheck() { |
|
|
|
clearInterval(portcheck); |
|
|
|
} |
|
|
|
$('#loading_status_text').text('Connecting to Basilisk Network...'); |
|
|
|
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 2000); |
|
|
|
} |
|
|
|
|
|
|
|
startcheck(); |
|
|
|
function stopcheck() { |
|
|
|
clearInterval(portcheck); |
|
|
|
} |
|
|
|
|
|
|
|
startcheck(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function IguanaAJAX(url, ajax_data, timeout) { |
|
|
|
return $.ajax({ |
|
|
|