Browse Source

agama mode selector

all-modes
pbca26 8 years ago
parent
commit
14f244452a
  1. 20
      gui/index.html
  2. 8
      gui/init.js
  3. 78
      gui/loading.css
  4. 82
      gui/loading.js
  5. 5
      main.js
  6. 80
      routes/shepherd.js

20
gui/index.html

@ -13,14 +13,22 @@
<script type="text/javascript" src="jRoll.min.js"></script> <script type="text/javascript" src="jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script> <script>if (window.module) module = window.module;</script>
</head> </head>
<body> <body class="agamaMode">
<div class="text-center"> <div class="text-center">
<div class="loader-block"> <!--div id="normalStart">
<div id="loading_status_text">Starting Wallet. Please wait...</div> <div class="loader-block">
<div id="loading_sub_status_text"></div> <div id="loading_status_text">Starting Wallet. Please wait...</div>
<div id="loading_sub_status_output_text"></div> <div id="loading_sub_status_text"></div>
<div id="loading_sub_status_output_text"></div>
</div>
<div id="pulse" class="pulse-loader"></div>
</div-->
<div id="agamaMode">
<img src="agama-icon-small.png" class="agama-logo" alt="Agama Wallet" />
<div id="agamaModeStatus">Choose Agama mode</div>
<button onClick="closeMainWindow()" class="btn btn-primary">Native only</button>
<button onClick="normalStart()" class="btn btn-primary">Normal start</button>
</div> </div>
<div id="pulse" class="pulse-loader"></div>
</div> </div>
<script type="text/javascript" src="init.js"></script> <script type="text/javascript" src="init.js"></script>
</body> </body>

8
gui/init.js

@ -1,21 +1,21 @@
$(document).ready(function() { $(document).ready(function() {
const remote = require('electron').remote; const remote = require('electron').remote;
var window = remote.getCurrentWindow(); var window = remote.getCurrentWindow();
var appConf = remote.getCurrentWindow().appConfig;
$('#pulse').jRoll({ $('#pulse').jRoll({
radius: 100, radius: 100,
animation: 'pulse' animation: 'pulse'
}); });
GetAppConf(inititalWalletLoading); inititalWalletLoading();
$('#loading_status_text').text('Starting Wallet. Please wait...'); $('#loading_status_text').text('Starting Wallet. Please wait...');
function inititalWalletLoading(appConf) { function inititalWalletLoading() {
// run iguana-less mode with no daemons startup // run iguana-less mode with no daemons startup
if (appConf && appConf.iguanaLessMode) { if (appConf && appConf.iguanaLessMode) {
window.createWindow('open'); // do something
window.hide();
} else { // run normal mode with 2 iguana instances started prior loading GUI } else { // run normal mode with 2 iguana instances started prior loading GUI
if (appConf && !appConf.manualIguanaStart) { if (appConf && !appConf.manualIguanaStart) {
StartIguana(); StartIguana();

78
gui/loading.css

@ -25,4 +25,82 @@ body {
left: -100px; left: -100px;
margin: 80px 50px; margin: 80px 50px;
width: 400px !important; width: 400px !important;
}
body.agamaMode {
background-color: rgba(33, 33, 33, 0.85);
padding-top: 40px;
color: #fff;
}
.agama-logo {
padding-bottom: 20px;
}
#agamaModeStatus {
padding-bottom: 25px;
font-weight: bold;
font-size: 16px;
}
.btn-primary.focus,
.btn-primary:focus,
.btn-primary:hover {
background-color: #ffa726;
border-color: #ffa726;
}
.btn.active.focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn:active:focus,
.btn:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn {
padding: 6px 15px;
font-size: 14px;
line-height: 1.57142857;
border-radius: 3px;
-webkit-box-shadow: 0 1px 4px 0 rgba(0,0,0,.1);
box-shadow: 0 1px 4px 0 rgba(0,0,0,.1);
-webkit-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
-o-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear;
-webkit-font-smoothing: subpixel-antialiased;
font-weight: bold;
display: inline-block;
padding: 6px 15px;
margin-bottom: 0;
line-height: 1.57142857;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 3px;
}
.btn-primary {
color: #fff;
background-color: #FF6600;
border-color: #FF6600;
}
.btn:first-child {
margin-right: 20px;
}
.btn:last-child {
margin-left: 20px;
} }

82
gui/loading.js

@ -1,3 +1,53 @@
function closeMainWindow() {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
window.createWindow('open');
window.hide();
}
function normalStart() {
const remote = require('electron').remote;
var 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();
}
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf);
}
})
}, 2000);
}
function stopcheck() {
clearInterval(portcheck);
}
startcheck();
}
}
function IguanaAJAX(url, ajax_data, timeout) { function IguanaAJAX(url, ajax_data, timeout) {
return $.ajax({ return $.ajax({
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
@ -44,6 +94,8 @@ function StartIguana() {
var ajax_data = { 'herd': 'iguana'}; var ajax_data = { 'herd': 'iguana'};
console.log(ajax_data); console.log(ajax_data);
$('#agamaModeStatus').text('Starting main iguana instance...');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
@ -66,6 +118,8 @@ function StartIguana() {
} }
function StartIguana_Cache() { function StartIguana_Cache() {
$('#agamaModeStatus').text('Starting basilisk iguana instance...');
var ajax_data = { var ajax_data = {
'mode': 'basilisk', 'mode': 'basilisk',
'coin': 'all' 'coin': 'all'
@ -83,34 +137,6 @@ function StartIguana_Cache() {
}); });
} }
function GetAppConf(cb) { // get iguana app conf
var ajax_data = { 'herd': 'iguana' },
data = false;
console.log(ajax_data);
$.ajax({
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;
cb.call(this, data);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
cb.call(this, data);
});
return data;
}
function EDEX_DEXgetinfoAll(skip, minNotaries, appConf) { function EDEX_DEXgetinfoAll(skip, minNotaries, appConf) {
const remote = require('electron').remote; const remote = require('electron').remote;
var window = remote.getCurrentWindow(); var window = remote.getCurrentWindow();

5
main.js

@ -196,13 +196,14 @@ function createLoadingWindow() {
// initialise window // initialise window
loadingWindow = new BrowserWindow({ loadingWindow = new BrowserWindow({
width: appConfig.iguanaLessMode ? 1 : 500, width: 500,
height: appConfig.iguanaLessMode ? 1 : 300, height: 300,
frame: false, frame: false,
icon: iguanaIcon icon: iguanaIcon
}); });
loadingWindow.createWindow = createWindow; // expose createWindow to front-end scripts loadingWindow.createWindow = createWindow; // expose createWindow to front-end scripts
loadingWindow.appConfig = appConfig;
// load our index.html (i.e. easyDEX GUI) // load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/`); loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/`);

80
routes/shepherd.js

@ -827,26 +827,39 @@ shepherd.get('/InstantDEX/allcoins', function(req, res, next) {
// else query main iguana instance and return combined response // else query main iguana instance and return combined response
// http://localhost:7778/api/InstantDEX/allcoins?userpass=tmpIgRPCUser@1234 // http://localhost:7778/api/InstantDEX/allcoins?userpass=tmpIgRPCUser@1234
let successObj; let successObj;
let nativeCoindList = [];
for (let key in coindInstanceRegistry) {
nativeCoindList.push(key === 'komodod' ? 'KMD' : key);
}
if (Object.keys(iguanaInstanceRegistry).length) { if (Object.keys(iguanaInstanceRegistry).length) {
// call to iguana // call to iguana
} else { request({
let nativeCoindList = []; url: `http://localhost:${shepherd.appConfig.iguanaCorePort}/api/InstantDEX/allcoins?userpass=${req.query.userpass}`,
method: 'GET'
for (let key in coindInstanceRegistry) { }, function (error, response, body) {
nativeCoindList.push(key === 'komodod' ? 'KMD' : key); if (response &&
} response.statusCode &&
response.statusCode === 200) {
const _body = JSON.parse(body);
_body.native = nativeCoindList;
console.log(_body);
} else {
console.log('main iguana instance is not ready yet');
}
res.send(body);
});
} else {
successObj = { successObj = {
'native': nativeCoindList, 'native': nativeCoindList,
'basilisk': [], 'basilisk': [],
'full': [] 'full': []
}; };
}
console.log(successObj); res.end(JSON.stringify(successObj));
}
res.end(JSON.stringify(successObj));
}); });
/* /*
@ -857,15 +870,35 @@ shepherd.get('/SuperNET/activehandle', function(req, res, next) {
// TODO: if only native return obj // TODO: if only native return obj
// else query main iguana instance and return combined response // else query main iguana instance and return combined response
// http://localhost:7778/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234 // http://localhost:7778/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234
const successObj = { let successObj;
'pubkey': 'nativeonly',
'result': 'success',
'handle': '',
'status': Object.keys(coindInstanceRegistry).length ? 'unlocked' : 'locked',
'duration': 2507830
};
res.end(JSON.stringify(successObj)); if (Object.keys(iguanaInstanceRegistry).length) {
// call to iguana
request({
url: `http://localhost:${shepherd.appConfig.iguanaCorePort}/api/SuperNET/activehandle?userpass=${req.query.userpass}`,
method: 'GET'
}, function (error, response, body) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
console.log(body);
} else {
console.log('main iguana instance is not ready yet');
}
res.send(body);
});
} else {
successObj = {
'pubkey': 'nativeonly',
'result': 'success',
'handle': '',
'status': Object.keys(coindInstanceRegistry).length ? 'unlocked' : 'locked',
'duration': 2507830
};
res.end(JSON.stringify(successObj));
}
}); });
/* /*
@ -1374,7 +1407,8 @@ function herder(flock, data) {
'silent': '&', 'silent': '&',
'reindex': '-reindex', 'reindex': '-reindex',
'change': '-pubkey=', 'change': '-pubkey=',
'datadir': '-datadir=' 'datadir': '-datadir=',
'rescan': '-rescan'
}; };
let _customParam = ''; let _customParam = '';
@ -1404,6 +1438,14 @@ function herder(flock, data) {
if (error !== null) { if (error !== null) {
console.log(`exec error: ${error}`) console.log(`exec error: ${error}`)
shepherd.writeLog(`exec error: ${error}`); shepherd.writeLog(`exec error: ${error}`);
if (error.toString().indexOf('using -reindex') > -1) {
cache.io.emit('service', {
'komodod': {
'error': 'run -reindex'
}
});
}
} }
}); });
/*} else { /*} else {

Loading…
Cancel
Save