adding account balance to new dashboard via Ajax

This commit is contained in:
Sebastian Grewe 2013-09-17 14:27:46 +02:00
parent 59b82c72e1
commit cdf71cbfba
6 changed files with 32 additions and 12 deletions

View File

@ -251,19 +251,19 @@ class Transaction extends Base {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT
ROUND((
IFNULL(ROUND((
SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) -
SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
), 8) AS confirmed,
ROUND((
), 8), 0) AS confirmed,
IFNULL(ROUND((
SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) -
SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) )
), 8) AS unconfirmed,
ROUND((
), 8), 0) AS unconfirmed,
IFNULL(ROUND((
SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations = -1, t.amount, 0) ) -
SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations = -1, t.amount, 0) )
), 8) AS orphaned
), 8), 0) AS orphaned
FROM $this->table AS t
LEFT JOIN " . $this->block->getTableName() . " AS b
ON t.block_id = b.id

View File

@ -46,7 +46,7 @@ $dNetworkHashrateAdjusted = $dNetworkHashrate / 1000 * $dNetworkHashrateModifier
// Output JSON format
$data = array(
'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000 ) ),
'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'shares' => $aUserRoundShares),
'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'shares' => $aUserRoundShares, 'balance' => $transaction->getBalance($user_id)),
'pool' => array( 'hashrate' => $dPoolHashrateAdjusted, 'shares' => $aRoundShares ),
'network' => array( 'hashrate' => $dNetworkHashrateAdjusted, 'difficulty' => $dDifficulty, 'block' => $iBlock ),
);

View File

@ -0,0 +1,16 @@
<article class="module width_quarter">
<header><h3>Account Information</h3></header>
<div class="module_content">
<table width="100%">
<caption style="text-align: left;">{$GLOBAL.config.currency} Account Balance</caption>
<tr>
<th align="left">Confirmed</th>
<td id="b-confirmed" align="right"></td>
</tr>
<tr>
<th align="left">Unconfirmed</th>
<td id="b-unconfirmed" align="right"></td>
</tr>
</table>
</div>
</article>

View File

@ -2,6 +2,7 @@
{assign var=payout_system value=$GLOBAL.config.payout_system}
{include file="dashboard/overview.tpl"}
{include file="dashboard/round_data.tpl"}
{include file="dashboard/account_data.tpl"}
{include file="dashboard/default_$payout_system.tpl"}
{include file="dashboard/js.tpl"}
{/if}

View File

@ -46,9 +46,6 @@
<td class="right">{$GLOBAL.userdata.est_payout|number_format:"8"}</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2"><b><u>{$GLOBAL.config.currency} Account Balance</u></b></td></tr>
<tr><td>Confirmed</td><td class="right"><b>{$GLOBAL.userdata.balance.confirmed|default:"0"}</td></tr>
<tr><td>Unconfirmed</td><td class="right"><b>{$GLOBAL.userdata.balance.unconfirmed|default:"0"}</td></tr>
</tbody>
</table>
</div>

View File

@ -77,8 +77,8 @@ $(document).ready(function(){
],
legend: { show: true, location: 'ne', renderer: $.jqplot.EnhancedLegendRenderer, rendererOptions: { seriesToggleReplot: { resetAxes: true } } },
axes: {
yaxis: { tickOptions: { angle: -90 }, ticks: [ 'invalid', 'valid' ], renderer: $.jqplot.CategoryAxisRenderer },
xaxis: { tickOptions: { angle: -15 }, pointLabels: { show: true } }
yaxis: { tickOptions: { angle: -90 }, ticks: [ 'valid', 'invalid' ], renderer: $.jqplot.CategoryAxisRenderer },
xaxis: { tickOptions: { angle: -17 }, pointLabels: { show: true } }
}
};
@ -132,6 +132,11 @@ $(document).ready(function(){
success: function (data) { initGauges(data); }
});
function refreshStaticData(data) {
$('#b-confirmed').html(data.getdashboarddata.data.personal.balance.confirmed);
$('#b-unconfirmed').html(data.getdashboarddata.data.personal.balance.unconfirmed);
}
// Our worker process to keep gauges and graph updated
(function worker() {
$.ajax({
@ -139,6 +144,7 @@ $(document).ready(function(){
dataType: 'json',
success: function(data) {
refreshInformation(data);
refreshStaticData(data);
},
complete: function() {
setTimeout(worker, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"10000"}{literal})