Browse Source

added app config (wip)

ca333-dev
pbca26 8 years ago
parent
commit
12adf4e5e1
  1. 6
      config.json
  2. 9
      gui/index.html
  3. 23
      gui/loading.js
  4. 62
      gui/main.html
  5. 7
      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
}

9
gui/index.html

@ -29,8 +29,13 @@
const remote = require('electron').remote; const remote = require('electron').remote;
var window = remote.getCurrentWindow(); var window = remote.getCurrentWindow();
$('#loading_status_text').text('Starting Iguana daemon...') $('#loading_status_text').text('Starting Iguana daemon...')
var appConf = GetAppConf();
if (appConf && !appConf.manualIguanaStart) {
StartIguana(); StartIguana();
}
if (appConf && !appConf.skipBasiliskNetworkCheck) {
var portcheck; var portcheck;
function sartcheck() { function sartcheck() {
portcheck = setInterval(function(){ portcheck = setInterval(function(){
@ -53,6 +58,10 @@
} }
sartcheck(); sartcheck();
//setTimeout(function(){ window.close(); }, 15000); //setTimeout(function(){ window.close(); }, 15000);
} else {
$('#loading_status_text').text(appConf)
//window.close();
}
}); });
</script> </script>
</body> </body>

23
gui/loading.js

@ -63,6 +63,29 @@ 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() { function EDEX_DEXnotarychains() {
return new Promise((resolve) =>{ return new Promise((resolve) =>{
var ajax_data = {"agent":"dpow","method":"notarychains"} var ajax_data = {"agent":"dpow","method":"notarychains"}

62
gui/main.html

@ -13,6 +13,54 @@
$(".page-main").outerHeight(mapH); $(".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() { jQuery(document).ready(function() {
resizeMainWindow(); resizeMainWindow();
window.onresize = function(event) { resizeMainWindow(); }; window.onresize = function(event) { resizeMainWindow(); };
@ -20,11 +68,17 @@
</script> </script>
</head> </head>
<body> <body>
<div class="page-main"> <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(bg.jpg) no-repeat fixed; background-color: #c7c7c7; vertical-align: middle;" id="iguanaGuiStart">
<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> <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> </div>
</body> </body>
</html> </html>

7
main.js

@ -17,6 +17,8 @@ var mkdirp = require('mkdirp');
var pm2 = require('pm2'); var pm2 = require('pm2');
Promise = require('bluebird'); Promise = require('bluebird');
var appConfig = JSON.parse(fs.readFileSync('config.json', 'utf8'));
app.setName('Iguana'); app.setName('Iguana');
if (os.platform() === 'linux') { if (os.platform() === 'linux') {
@ -164,7 +166,12 @@ function createWindow (status) {
mainWindow = new BrowserWindow({width: 1280, height: 800, icon: iguanaIcon}) mainWindow = new BrowserWindow({width: 1280, height: 800, icon: iguanaIcon})
// load our index.html (i.e. easyDEX GUI) // load our index.html (i.e. 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/'); 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 // DEVTOOLS - only for dev purposes - ca333
//mainWindow.webContents.openDevTools() //mainWindow.webContents.openDevTools()

0
pull-gui.sh

4
routes/shepherd.js

@ -63,6 +63,10 @@ shepherd.get('/', function(req, res, next) {
res.send('Hello World!') 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) { shepherd.post('/herd', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');

Loading…
Cancel
Save