Browse Source

Merge pull request #24 from pbca26/master

fixed window.hide when min notaries are connected
all-modes
Satinder Grewal 8 years ago
committed by GitHub
parent
commit
1f19b95c08
  1. 4
      gui/index.html
  2. 2
      gui/init.js
  3. 151
      gui/loading.js
  4. 41
      main.js
  5. 68
      routes/shepherd.js

4
gui/index.html

@ -10,6 +10,10 @@
<script type="text/javascript" src="loading.js"></script>
<script type="text/javascript" src="jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script>
<script type="text/javascript">
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
</script>>
</head>
<body style="overflow:hidden;">
<div style="text-align: center;">

2
gui/init.js

@ -5,8 +5,6 @@ $(document).ready(function() {
});
var appConf = GetAppConf();
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
$('#loading_status_text').text('Starting Iguana daemon...');

151
gui/loading.js

@ -11,10 +11,12 @@ function IguanaAJAX(url, ajax_data) {
});
}
function Iguana_activehandle(callback) {
return new Promise((resolve) => {
var ajax_data = { 'agent': 'SuperNET', 'method': 'activehandle' },
var ajax_data = {
'agent': 'SuperNET',
'method': 'activehandle'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
@ -60,88 +62,107 @@ function StartIguana() {
}
function GetAppConf() { // get iguana app conf
var ajax_data = { 'herd': 'iguana' };
var ajax_data = { 'herd': 'iguana' },
data = false;
console.log(ajax_data);
$.ajax({
async: false,
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
async: false,
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
}).done(function(_data) {
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
return data;
}
function EDEX_DEXnotarychains() {
return new Promise((resolve) =>{
var ajax_data = {"agent":"dpow","method":"notarychains"}
var AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
})
return new Promise((resolve) => {
var ajax_data = {
'agent': 'dpow',
'method': 'notarychains'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText);
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
});
}
function EDEX_DEXgetinfoAll() {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dpow","method":"notarychains"}
var get_dex_notarychains = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
//console.log(get_dex_notarychains.responseText);
get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText)
//console.log(get_dex_notarychains)
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'dpow',
'method': 'notarychains'
},
tmp_index = 0,
get_dex_notarychains = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//console.log(get_dex_notarychains.responseText);
get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText);
//console.log(get_dex_notarychains)
$.each(get_dex_notarychains, function( coin_index, coin_value ) {
$.each(get_dex_notarychains, function( coin_index, coin_value ) {
console.log(coin_index + ': ' + coin_value);
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getinfo","symbol":coin_value}
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'dex',
'method': 'getinfo',
'symbol': coin_value
},
basiliskMinNotariesConnected = 10;
console.log(ajax_data);
if (coin_value !== 'MESH') {
var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText)
console.log(getinfo_each_chain)
var tmp_index = parseInt(coin_index) + 1
$('#loading_sub_status_text').text('Connection status... ' + tmp_index + '/' + get_dex_notarychains.length + ': ' + coin_value)
if (getinfo_each_chain.error === 'less than required responses') {
$('#loading_sub_status_output_text').text('Output: ' + getinfo_each_chain.error)
} else {
$('#loading_sub_status_output_text').text('Output: Connected')
}
if ( tmp_index == 10 ) {
window.hide();
}
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
})
if (coin_value !== 'MESH' || coin_value !== 'CEAL') {
var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText);
console.log(getinfo_each_chain);
tmp_index = parseInt(coin_index) + 1;
$('#loading_sub_status_text').text('Connection status... ' + tmp_index + '/' + get_dex_notarychains.length + ': ' + coin_value);
if (getinfo_each_chain.error === 'less than required responses') {
$('#loading_sub_status_output_text').text('Output: ' + getinfo_each_chain.error);
} else {
$('#loading_sub_status_output_text').text('Output: Connected');
}
if ( tmp_index == 10 ) {
console.log('min notaries connected');
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
window.hide();
}
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
}
});
});
});
}
}

41
main.js

@ -9,11 +9,11 @@ var express = require('express'),
const path = require('path'),
url = require('url'),
os = require('os'),
spawn = require('child_process').spawn
spawn = require('child_process').spawn,
exec = require('child_process').exec;
var fs = require('fs'),
fs = require('fs-extra'),
mkdirp = require('mkdirp')
mkdirp = require('mkdirp'),
pm2 = require('pm2');
var iguanaAppPort = 17777;
@ -33,8 +33,8 @@ if (os.platform() === 'linux') {
const _setImmediate = setImmediate,
_clearImmediate = clearImmediate;
process.once('loaded', () => {
global.setImmediate = _setImmediate
global.clearImmediate = _clearImmediate
global.setImmediate = _setImmediate;
global.clearImmediate = _clearImmediate;
if (os.platform() === 'darwin') {
process.setFdLimit(90000);
@ -42,7 +42,7 @@ process.once('loaded', () => {
if (os.platform() === 'linux') {
process.setFdLimit(1000000);
}
})
});
// GUI APP settings and starting gui on address http://120.0.0.1:17777
var shepherd = require('./routes/shepherd'),
@ -52,16 +52,16 @@ guiapp.use(bodyParser.json()); // support json encoded bodies
guiapp.use(bodyParser.urlencoded({ extended: false })); // support encoded bodies
guiapp.get('/', function (req, res) {
res.send('Iguana app server')
res.send('Iguana app server');
})
var guipath = path.join(__dirname, '/gui')
guiapp.use('/gui', express.static(guipath))
var guipath = path.join(__dirname, '/gui');
guiapp.use('/gui', express.static(guipath));
guiapp.use('/shepherd', shepherd);
var rungui = guiapp.listen(iguanaAppPort, function () {
console.log('guiapp listening on port ' + iguanaAppPort + '!')
console.log('guiapp listening on port ' + iguanaAppPort + '!');
})
module.exports = guiapp;
@ -96,10 +96,10 @@ if (os.platform() === 'win32') {
*/
if (os.platform() === 'linux') {
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon_png/128x128.png')
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon_png/128x128.png');
}
if (os.platform() === 'win32') {
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico')
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico');
}
//console.log(iguanaDir);
@ -123,8 +123,8 @@ fs.copy(iguanaConfsDirSrc, iguanaConfsDir, function (err) {
})
*/
let mainWindow
let loadingWindow
let mainWindow;
let loadingWindow;
function createLoadingWindow() {
mainWindow = null;
@ -223,7 +223,8 @@ function createWindow (status) {
pm2.killDaemon(function(err) {
pm2.disconnect();
console.log('killed to pm2...');
if (err) throw err;
if (err)
throw err;
});
var result = 'Killing Pm2: done';
@ -285,26 +286,26 @@ app.on('window-all-closed', function () {
app.on('before-quit', function (event) {
if (mainWindow === null && loadingWindow != null) { //mainWindow not intitialised and loadingWindow not dereferenced
//loading window is still open
console.log("before-quit prevented");
console.log('before-quit prevented');
event.preventDefault();
}
})
});
//Emitted when all windows have been closed and the application will quit.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('will-quit', function (event) {
if (mainWindow === null && loadingWindow != null) {
//loading window is still open
console.log("will-quit while loading window active");
console.log('will-quit while loading window active');
event.preventDefault();
}
})
});
//Emitted when the application is quitting.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('quit', function (event) {
if (mainWindow === null && loadingWindow != null) {
console.log("quit while loading window active");
console.log('quit while loading window active');
event.preventDefault();
}
})
@ -313,4 +314,4 @@ app.on('activate', function () {
if (mainWindow === null) {
//createWindow('open');
}
})
});

68
routes/shepherd.js

@ -46,10 +46,13 @@ if (os.platform() === 'linux') {
}
if (os.platform() === 'win32') {
var iguanaBin = path.join(__dirname, '../assets/bin/win64/iguana.exe'); iguanaBin = path.normalize(iguanaBin),
iguanaDir = process.env.APPDATA + '/iguana'; iguanaDir = path.normalize(iguanaDir),
iguanaConfsDir = process.env.APPDATA + '/iguana/confs'; iguanaConfsDir = path.normalize(iguanaConfsDir),
iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico'),
var iguanaBin = path.join(__dirname, '../assets/bin/win64/iguana.exe');
iguanaBin = path.normalize(iguanaBin);
var iguanaDir = process.env.APPDATA + '/iguana';
iguanaDir = path.normalize(iguanaDir);
var iguanaConfsDir = process.env.APPDATA + '/iguana/confs';
iguanaConfsDir = path.normalize(iguanaConfsDir);
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico'),
iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc);
}
@ -192,20 +195,20 @@ function herder(flock, data) {
});
pm2.connect(true,function(err) { //start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: iguanaBin, // path to binary
name: 'IGUANA',
exec_mode : 'fork',
cwd: iguanaDir, //set correct iguana directory
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err
pm2.start({
script: iguanaBin, // path to binary
name: 'IGUANA',
exec_mode : 'fork',
cwd: iguanaDir, //set correct iguana directory
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err
});
});
}
@ -215,22 +218,22 @@ function herder(flock, data) {
console.log('selected data: ' + data);
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options,
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
pm2.start({
script: komododBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: komodoDir,
args: data.ac_options,
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
@ -483,7 +486,6 @@ function setConf(flock) {
.then(MakeConfReadOnly);
}
function getConf(flock) {
console.log(flock);

Loading…
Cancel
Save