Merge pull request #1187 from TheSerapher/issue-1159-dashboardsplit

[IMPROVED]
This commit is contained in:
Sebastian Grewe 2013-12-31 07:19:11 -08:00
commit 4026eec570
4 changed files with 52 additions and 12 deletions

View File

@ -118,6 +118,13 @@ $aSettings['statistics'][] = array(
'name' => 'statistics_ajax_refresh_interval', 'value' => $setting->getValue('statistics_ajax_refresh_interval'),
'tooltip' => 'How often to refresh data via ajax in seconds.'
);
$aSettings['statistics'][] = array(
'display' => 'Ajax Long Refresh Interval', 'type' => 'select',
'options' => array('5' => '5', '10' => '10', '15' => '15', '30' => '30', '60' => '60', '600' => '600', '1800' => '1800', '3600' => '3600' ),
'default' => 10,
'name' => 'statistics_ajax_long_refresh_interval', 'value' => $setting->getValue('statistics_ajax_long_refresh_interval'),
'tooltip' => 'How often to refresh data via ajax in seconds. User for SQL costly queries like getBalance and getWorkers.'
);
$aSettings['statistics'][] = array(
'display' => 'Ajax Data Interval', 'type' => 'select',
'options' => array('60' => '1', '180' => '3', '300' => '5', '600' => '10'),

View File

@ -75,9 +75,6 @@ $dPersonalHashrateAdjusted = $dPersonalHashrate * $dPersonalHashrateModifier;
$dPoolHashrateAdjusted = $dPoolHashrate * $dPoolHashrateModifier;
$dNetworkHashrateAdjusted = $dNetworkHashrate / 1000 * $dNetworkHashrateModifier;
// Worker information
$aWorkers = $worker->getWorkers($user_id, $interval);
// Coin price
$aPrice = $setting->getValue('price');
@ -99,7 +96,7 @@ $data = array(
'personal' => array (
'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty,
'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ),
'balance' => $transaction->getBalance($user_id), 'estimates' => $aEstimates, 'workers' => $aWorkers ),
'estimates' => $aEstimates),
'pool' => array(
'info' => array(
'name' => $setting->getValue('website_name'),

View File

@ -46,6 +46,7 @@ if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActi
// Some settings to propagate to template
if (! $statistics_ajax_refresh_interval = $setting->getValue('statistics_ajax_refresh_interval')) $statistics_ajax_refresh_interval = 10;
if (! $statistics_ajax_long_refresh_interval = $setting->getValue('statistics_ajax_long_refresh_interval')) $statistics_ajax_long_refresh_interval = 10;
// Small helper array
$aHashunits = array( '1' => 'KH/s', '0.001' => 'MH/s', '0.000001' => 'GH/s' );
@ -76,6 +77,7 @@ $aGlobal = array(
'disable_notifications' => $setting->getValue('disable_notifications'),
'monitoring_uptimerobot_api_keys' => $setting->getValue('monitoring_uptimerobot_api_keys'),
'statistics_ajax_refresh_interval' => $statistics_ajax_refresh_interval,
'statistics_ajax_long_refresh_interval' => $statistics_ajax_long_refresh_interval,
'price' => array( 'currency' => $config['price']['currency'] ),
'targetdiff' => $config['difficulty'],
'currency' => $config['currency'],

View File

@ -17,7 +17,9 @@ $(document).ready(function(){
var g1, g2, g3, g4, g5;
// Ajax API URL
var url = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getdashboarddata&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
var url_dashboard = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getdashboarddata&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
var url_worker = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getuserworkers&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
var url_balance = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getuserbalance&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
// Enable all included plugins
// $.jqplot.config.enablePlugins = true;
@ -128,9 +130,15 @@ $(document).ready(function(){
if (typeof(plot2) != "undefined") plot2.replot(replotShareinfoOptions);
}
// Refresh balance information
function refreshBalanceData(data) {
balance = data.getuserbalance.data
$('#b-confirmed').html(balance.confirmed);
$('#b-unconfirmed').html(balance.unconfirmed);
}
// Refresh other static numbers on the template
function refreshStaticData(data) {
$('#b-confirmed').html(data.getdashboarddata.data.personal.balance.confirmed);
$('#b-unconfirmed').html(data.getdashboarddata.data.personal.balance.unconfirmed);
$('#b-price').html((parseFloat(data.getdashboarddata.data.pool.price).toFixed(8)));
$('#b-dworkers').html(data.getdashboarddata.data.pool.workers);
$('#b-hashrate').html((parseFloat(data.getdashboarddata.data.personal.hashrate).toFixed(2)));
@ -165,8 +173,7 @@ $(document).ready(function(){
// Refresh worker information
function refreshWorkerData(data) {
data = data.getdashboarddata.data;
workers = data.personal.workers;
workers = data.getuserworkers.data;
length = workers.length;
$('#b-workers').html('');
for (var i = j = 0; i < length; i++) {
@ -179,17 +186,44 @@ $(document).ready(function(){
}
// Our worker process to keep gauges and graph updated
(function worker() {
(function worker1() {
$.ajax({
url: url,
url: url_dashboard,
dataType: 'json',
success: function(data) {
refreshInformation(data);
refreshStaticData(data);
},
complete: function() {
setTimeout(worker1, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"10000"}{literal})
}
});
})();
// Our worker process to keep worker information updated
(function worker3() {
$.ajax({
url: url_balance,
dataType: 'json',
success: function(data) {
refreshBalanceData(data);
},
complete: function() {
setTimeout(worker3, {/literal}{($GLOBAL.config.statistics_ajax_long_refresh_interval * 1000)|default:"10000"}{literal})
}
});
})();
// Our worker process to keep gauges and graph updated
(function worker2() {
$.ajax({
url: url_worker,
dataType: 'json',
success: function(data) {
refreshWorkerData(data);
},
complete: function() {
setTimeout(worker, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"10000"}{literal})
setTimeout(worker2, {/literal}{($GLOBAL.config.statistics_ajax_long_refresh_interval * 1000)|default:"10000"}{literal})
}
});
})();