Browse Source

added app config (wip)

ca333-dev
pbca26 8 years ago
parent
commit
12adf4e5e1
  1. 6
      config.json
  2. 51
      gui/index.html
  3. 35
      gui/loading.js
  4. 70
      gui/main.html
  5. 15
      main.js
  6. 0
      pull-gui.sh
  7. 4
      routes/shepherd.js

6
config.json

@ -0,0 +1,6 @@
{
"edexGuiOnly": true,
"iguanaGuiOnly": false,
"manualIguanaStart": false,
"skipBasiliskNetworkCheck": false
}

51
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);
});
</script>
</body>

35
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)

70
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(); };
});
</script>
</head>
<body>
<div class="page-main">
<div class="col-xs-6 text-center" style="height: 100%; background: url(bg.jpg) no-repeat fixed; background-color: #c7c7c7; vertical-align: middle;"><h1 style="color: white;">Iguana Wallet<h1><a type="button" class="btn btn-default btn-lg" href="Iguana-GUI/index.html">Open Iguana Wallet</a></div>
<div class="col-xs-6 text-center" style="height: 100%; background: url(bg2.jpg) no-repeat fixed; background-color: #d8d8d8; vertical-align: middle;"><h1 style="color: white;">EasyDEX</h1><a type="button" class="btn btn-default btn-lg" href="EasyDEX-GUI/index.html">Open EasyDEX</a></div>
</div>
</body>
<body>
<div class="page-main">
<div class="col-xs-6 text-center" style="height: 100%; background: url(bg.jpg) no-repeat fixed; background-color: #c7c7c7; vertical-align: middle;" id="iguanaGuiStart">
<h1 style="color: white;">Iguana Wallet<h1>
<a type="button" class="btn btn-default btn-lg" href="Iguana-GUI/index.html">Open Iguana Wallet</a><br/><br/>
<a type="button" class="btn btn-default btn-lg" href="#" onclick="StartCorsproxy()">Launch proxy server</a><br/><br/>
<a type="button" class="btn btn-default btn-lg" href="#" onclick="StartIguana()">Start Iguana Core</a>
</div>
<div class="col-xs-6 text-center" style="height: 100%; background: url(bg2.jpg) no-repeat fixed; background-color: #d8d8d8; vertical-align: middle;" id="edexGuiStart">
<h1 style="color: white;">EasyDEX</h1>
<a type="button" class="btn btn-default btn-lg" href="EasyDEX-GUI/index.html">Open EasyDEX</a>
</div>
</div>
</body>
</html>

15
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)

0
pull-gui.sh

4
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 =======');

Loading…
Cancel
Save