diff --git a/config.json b/config.json new file mode 100644 index 0000000..2fe8b6c --- /dev/null +++ b/config.json @@ -0,0 +1,6 @@ +{ + "edexGuiOnly": true, + "iguanaGuiOnly": false, + "manualIguanaStart": false, + "skipBasiliskNetworkCheck": false +} \ No newline at end of file diff --git a/gui/index.html b/gui/index.html index c84f06e..d49283e 100644 --- a/gui/index.html +++ b/gui/index.html @@ -29,30 +29,39 @@ const remote = require('electron').remote; var window = remote.getCurrentWindow(); $('#loading_status_text').text('Starting Iguana daemon...') - StartIguana(); - - var portcheck; - function sartcheck() { - portcheck = setInterval(function(){ - Iguana_activehandle().then(function(result){ - console.log(result) - if (result !== 'error') { - stopcheck(); - $('#loading_status_text').text('Connecting to Basilisk Network...') - EDEX_DEXgetinfoAll() - //window.close(); - } - }) - //var check = Iguana_activehandle(); - //console.log(check[0]) - },2000); + var appConf = GetAppConf(); + + if (appConf && !appConf.manualIguanaStart) { + StartIguana(); } - function stopcheck() { - clearInterval(portcheck); + if (appConf && !appConf.skipBasiliskNetworkCheck) { + var portcheck; + function sartcheck() { + portcheck = setInterval(function(){ + Iguana_activehandle().then(function(result){ + console.log(result) + if (result !== 'error') { + stopcheck(); + $('#loading_status_text').text('Connecting to Basilisk Network...') + EDEX_DEXgetinfoAll() + //window.close(); + } + }) + //var check = Iguana_activehandle(); + //console.log(check[0]) + },2000); + } + + function stopcheck() { + clearInterval(portcheck); + } + sartcheck(); + //setTimeout(function(){ window.close(); }, 15000); + } else { + $('#loading_status_text').text(appConf) + //window.close(); } - sartcheck(); - //setTimeout(function(){ window.close(); }, 15000); }); diff --git a/gui/loading.js b/gui/loading.js index 6f75bd7..9c8a360 100644 --- a/gui/loading.js +++ b/gui/loading.js @@ -13,9 +13,9 @@ function IguanaAJAX(url,ajax_data) { } -function Iguana_activehandle(callback) { - return new Promise((resolve) =>{ - +function Iguana_activehandle(callback) { + return new Promise((resolve) =>{ + var ajax_data = {"agent":"SuperNET","method":"activehandle"}; var AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) { //console.log(AjaxOutputData.responseText); @@ -63,8 +63,31 @@ function StartIguana() { }); } +function GetAppConf() { // get iguana app conf + var ajax_data = {"herd":"iguana"}; + console.log(ajax_data); + $.ajax({ + 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); + return data; + }).fail(function(xhr, textStatus, error) { + // handle request failures + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + } + console.log(textStatus); + console.log(error); + + return false; + }); +} + function EDEX_DEXnotarychains() { - return new Promise((resolve) =>{ + 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); @@ -90,13 +113,13 @@ function EDEX_DEXgetinfoAll() { //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 ) { console.log(coin_index + ': ' + coin_value); var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getinfo","symbol":coin_value} 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) diff --git a/gui/main.html b/gui/main.html index 913810d..13e2eac 100644 --- a/gui/main.html +++ b/gui/main.html @@ -13,18 +13,72 @@ $(".page-main").outerHeight(mapH); } + function StartIguana() { + var ajax_data = {"herd":"iguana"}; + console.log(ajax_data); + $.ajax({ + //async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:17777/shepherd/herd', + dataType: "xml/html/script/json", // expected format for response + contentType: "application/json", // send as JSON + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + console.log('== ActiveHandle Data OutPut =='); + console.log(AjaxOutputData); + }, + error: function(xhr, textStatus, error) { + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + } + console.log(textStatus); + console.log(error); + } + }); + } + function StartCorsproxy() { + var ajax_data = {"herd":"corsproxy"}; + console.log(ajax_data); + $.ajax({ + //async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:17777/shepherd/herd', + dataType: "xml/html/script/json", // expected format for response + contentType: "application/json", // send as JSON + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); + console.log('== ActiveHandle Data OutPut =='); + console.log(AjaxOutputData); + }, + error: function(xhr, textStatus, error) { + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + } + console.log(textStatus); + console.log(error); + } + }); + } jQuery(document).ready(function() { resizeMainWindow(); window.onresize = function(event) { resizeMainWindow(); }; }); - - -
-

Iguana Wallet

Open Iguana Wallet

-

EasyDEX

Open EasyDEX
-
- - + +
+
+

Iguana Wallet

+ Open Iguana Wallet

+ Launch proxy server

+ Start Iguana Core +

+
+

EasyDEX

+ Open EasyDEX +
+
+ \ No newline at end of file diff --git a/main.js b/main.js index 9a7ad92..2108d59 100644 --- a/main.js +++ b/main.js @@ -17,6 +17,8 @@ var mkdirp = require('mkdirp'); var pm2 = require('pm2'); Promise = require('bluebird'); +var appConfig = JSON.parse(fs.readFileSync('config.json', 'utf8')); + app.setName('Iguana'); if (os.platform() === 'linux') { @@ -164,7 +166,12 @@ function createWindow (status) { mainWindow = new BrowserWindow({width: 1280, height: 800, icon: iguanaIcon}) // load our index.html (i.e. easyDEX GUI) - mainWindow.loadURL('http://127.0.0.1:17777/gui/EasyDEX-GUI/'); + //mainWindow.loadURL('http://127.0.0.1:17777/gui/EasyDEX-GUI/'); + if (appConfig.edexGuiOnly) { + mainWindow.loadURL('http://127.0.0.1:17777/gui/EasyDEX-GUI/'); + } else { + mainWindow.loadURL('http://127.0.0.1:17777/gui/main.html'); + } // DEVTOOLS - only for dev purposes - ca333 //mainWindow.webContents.openDevTools() @@ -175,7 +182,7 @@ function createWindow (status) { return new Promise(function(resolve, reject) { console.log('Closing Main Window...'); - + pm2.connect(true,function(err) { console.log('connecting to pm2...'); if (err) { @@ -194,7 +201,7 @@ function createWindow (status) { return new Promise(function(resolve, reject) { console.log('killing to pm2...'); - + pm2.killDaemon(function(err) { pm2.disconnect(); console.log('killed to pm2...'); @@ -233,7 +240,7 @@ function createWindow (status) { } ConnectToPm2() - .then(function(result) { + .then(function(result) { return KillPm2(); }) .then(HideMainWindow) diff --git a/pull-gui.sh b/pull-gui.sh old mode 100644 new mode 100755 diff --git a/routes/shepherd.js b/routes/shepherd.js index 0e9c4b4..74ccecc 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -63,6 +63,10 @@ shepherd.get('/', function(req, res, next) { res.send('Hello World!') }) +shepherd.get('/appconf', function(req, res, next) { + var obj = JSON.parse(fs.readFileSync('config.json', 'utf8')); + res.send(obj); +}) shepherd.post('/herd', function(req, res) { console.log('======= req.body =======');