added new controller

This commit is contained in:
Mario Colque 2014-02-07 13:57:55 -03:00
parent ad8392380d
commit 398babaa8f
9 changed files with 97 additions and 96 deletions

View File

@ -48,19 +48,13 @@ exports.index = function(req, res) {
res.jsonp({
status: 200,
data: {
bitstamp: bitstampRate,
delay: delay
}
data: { bitstamp: bitstampRate }
});
});
} else {
res.jsonp({
status: 200,
data: {
bitstamp: bitstampRate,
delay: delay
}
data: { bitstamp: bitstampRate }
});
}
};

View File

@ -35,11 +35,12 @@ script(type='text/javascript', src='/js/services/currency.js')
//Application Controllers
script(type='text/javascript', src='/js/controllers/index.js')
script(type='text/javascript', src='/js/controllers/header.js')
script(type='text/javascript', src='/js/controllers/search.js')
script(type='text/javascript', src='/js/controllers/blocks.js')
script(type='text/javascript', src='/js/controllers/transactions.js')
script(type='text/javascript', src='/js/controllers/address.js')
script(type='text/javascript', src='/js/controllers/search.js')
script(type='text/javascript', src='/js/controllers/status.js')
script(type='text/javascript', src='/js/controllers/footer.js')
script(type='text/javascript', src='/js/controllers/connection.js')
script(type='text/javascript', src='/js/controllers/currency.js')
script(type='text/javascript', src='/js/init.js')

View File

@ -0,0 +1,57 @@
'use strict';
angular.module('insight.currency').controller('CurrencyController',
function($scope, $rootScope, Currency) {
$rootScope.currency = {
factor: 1,
bitstamp: 0,
symbol: 'BTC'
};
var _roundFloat = function(x, n) {
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
};
$scope.setCurrency = function(currency) {
$rootScope.currency.symbol = currency;
if (currency === 'USD') {
Currency.get({}, function(res) {
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
});
} else if (currency === 'mBTC') {
$rootScope.currency.factor = 1000;
} else {
$rootScope.currency.factor = 1;
}
};
$scope.getConvertion = function(value) {
if (typeof value !== 'undefined' && value !== null) {
var response;
if ($rootScope.currency.symbol === 'USD') {
response = _roundFloat((value * $rootScope.currency.factor), 2);
} else if ($rootScope.currency.symbol === 'mBTC') {
$rootScope.currency.factor = 1000;
response = _roundFloat((value * $rootScope.currency.factor), 5);
} else {
$rootScope.currency.factor = 1;
response = value;
}
return response + ' ' + $rootScope.currency.symbol;
}
return 'value error';
};
// Get initial value
Currency.get({}, function(res) {
$rootScope.currency.bitstamp = res.data.bitstamp;
});
});

View File

@ -1,52 +1,7 @@
'use strict';
angular.module('insight.system').controller('FooterController',
function($rootScope, $scope, Version, Currency) {
var _roundFloat = function(x, n) {
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
};
$rootScope.currency = {
factor: 1,
symbol: 'BTC',
bitstamp: 0,
getConversion: function(value) {
if (value !== 'undefined' && value !== null) {
var response;
if (this.symbol === 'USD') {
response = _roundFloat((value * this.factor), 2);
} else if (this.symbol === 'mBTC') {
this.factor = 1000;
response = _roundFloat((value * this.factor), 5);
} else {
this.factor = 1;
response = value;
}
return response + ' ' + this.symbol;
}
return null;
}
};
$scope.setCurrency = function(currency) {
if (currency === 'USD') {
Currency.get({}, function(res) {
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
});
} else if (currency === 'mBTC') {
$rootScope.currency.factor = 1000;
} else {
$rootScope.currency.factor = 1;
}
$rootScope.currency.symbol = currency;
};
function($scope, Version) {
var _getVersion = function() {
Version.get({},

View File

@ -1,13 +1,9 @@
'use strict';
angular.module('insight.system').controller('HeaderController',
function($scope, $rootScope, getSocket, Global, Block, Currency) {
function($scope, $rootScope, getSocket, Global, Block) {
$scope.global = Global;
Currency.get({}, function(res) {
$rootScope.currency.bitstamp = res.data.bitstamp;
});
$scope.menu = [
{
'title': 'Blocks',

View File

@ -12,19 +12,19 @@
</div>
<div class="m20v">
<h4>Summary</h4>
<table class="table">
<table class="table" data-ng-controller="CurrencyController">
<tbody>
<tr>
<td class="small">Total Received</td>
<td class="address ellipsis text-right">{{$root.currency.getConversion(address.totalReceived)}}</td>
<td class="address ellipsis text-right">{{getConvertion(address.totalReceived)}}</td>
</tr>
<tr>
<td class="small">Total Sent</td>
<td class="address ellipsis text-right">{{$root.currency.getConversion(address.totalSent)}}</td>
<td class="address ellipsis text-right">{{getConvertion(address.totalSent)}}</td>
</tr>
<tr>
<td class="small">Final Balance</td>
<td class="address ellipsis text-right">{{$root.currency.getConversion(address.balance)}}</td>
<td class="address ellipsis text-right">{{getConvertion(address.balance)}}</td>
</tr>
<tr>
<td class="small">No. Transactions</td>

View File

@ -1,8 +1,8 @@
<div class="currency text-center m10t" data-ng-controller="FooterController">
<div class="currency text-center m10t" data-ng-controller="CurrencyController">
<small>
Currency:
<a href="#" data-ng-click="setCurrency('USD')" data-ng-class="{active: $root.currency.symbol == 'USD'}" tooltip="Change to USD: Bitstamp ${{$root.currency.bitstamp}}">USD</a> ·
<a href="#" data-ng-click="setCurrency('BTC')" data-ng-class="{active: $root.currency.symbol == 'BTC'}" tooltip="Change to BTC">BTC</a> ·
<a href="#" data-ng-click="setCurrency('mBTC')" data-ng-class="{active: $root.currency.symbol == 'mBTC'}" tooltip="Change to mBTC">mBTC</a>
<a href="#" data-ng-click="setCurrency('USD')" data-ng-class="{active: currency.symbol == 'USD'}" tooltip="Change to USD: Bitstamp ${{currency.bitstamp}}">USD</a> ·
<a href="#" data-ng-click="setCurrency('BTC')" data-ng-class="{active: currency.symbol == 'BTC'}" tooltip="Change to BTC">BTC</a> ·
<a href="#" data-ng-click="setCurrency('mBTC')" data-ng-class="{active: currency.symbol == 'mBTC'}" tooltip="Change to mBTC">mBTC</a>
</small>
</div>

View File

@ -27,36 +27,32 @@
</table>
<div data-ng-include src="'/views/includes/currency.html'"></div>
</div>
<div class="col-xs-12 col-md-9 col-md-offset-3">
<h2>
Details
Details
<small>View information about a bitcoin transaction</small>
</h2>
<div class="block-tx">
<div data-ng-include src="'/views/transaction/tx.html'"></div>
</div>
<div data-ng-show="!tx.isCoinBase">
<h2>Inputs and Outputs</h2>
<table class="table">
<table class="table" data-ng-controller="CurrencyController">
<tbody>
<tr>
<td><strong>Total Input</strong></td>
<td class="text-muted text-right">{{$root.currency.getConversion(tx.valueIn)}}</td>
<td class="text-muted text-right">{{getConvertion(tx.valueIn)}}</td>
</tr>
<tr>
<td><strong>Total Output</strong></td>
<td class="text-muted text-right">{{$root.currency.getConversion(tx.valueOut)}}</td>
<td class="text-muted text-right">{{getConvertion(tx.valueOut)}}</td>
</tr>
<tr>
<td><strong>Fees</strong></td>
<td class="text-muted text-right">{{$root.currency.getConversion(tx.fees)}}</td>
<td class="text-muted text-right">{{getConvertion(tx.fees)}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>

View File

@ -1,20 +1,21 @@
<div class="line-bot row">
<div class="col-xs-12 col-md-6">
<button class="btn-expand pull-left" data-ng-click="itemsExpanded = !itemsExpanded"><span class="glyphicon glyphicon-plus" data-ng-class="{'glyphicon-minus': itemsExpanded}" tooltip="Show/Hide items details" tooltip-placement="right"></span></button>
<button class="btn-copy pull-right" clip-copy="tx.txid"></button>
<div class="ellipsis">
<a class="txid" href="/tx/{{tx.txid}}">{{tx.txid}}</a>
<div data-ng-controller="CurrencyController">
<div class="line-bot row">
<div class="col-xs-12 col-md-6">
<button class="btn-expand pull-left" data-ng-click="itemsExpanded = !itemsExpanded"><span class="glyphicon glyphicon-plus" data-ng-class="{'glyphicon-minus': itemsExpanded}" tooltip="Show/Hide items details" tooltip-placement="right"></span></button>
<button class="btn-copy pull-right" clip-copy="tx.txid"></button>
<div class="ellipsis">
<a class="txid" href="/tx/{{tx.txid}}">{{tx.txid}}</a>
</div>
</div>
<div class="col-xs-12 col-md-6 text-right">
<time>{{tx.time * 1000 | date:'medium'}}</time>
</div>
</div>
<div class="col-xs-12 col-md-6 text-right">
<time>{{tx.time * 1000 | date:'medium'}}</time>
</div>
</div>
<div class="row line-mid">
<div class="row line-mid">
<div class="col-md-5">
<div class="row" data-ng-show="tx.isCoinBase">
<div class="col-md-12 transaction-vin-vout" data-ng-repeat="vin in tx.vin">
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConversion(vin.reward)}}</small></div>
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vin.reward)}}</small></div>
<div class="ellipsis">
<span>No Inputs (Newly Generated Coins)</span>
</div>
@ -23,7 +24,7 @@
<div class="row" data-ng-show="!tx.isCoinBase">
<div data-ng-repeat="vin in tx.vinSimple" data-ng-show="!itemsExpanded">
<div class="col-md-12 transaction-vin-vout">
<div class="text-muted pull-right btc-value" data-ng-class="{'text-danger': $root.currentAddr == vin.addr}"><small>{{$root.currency.getConversion(vin.value)}}</small></div>
<div class="text-muted pull-right btc-value" data-ng-class="{'text-danger': $root.currentAddr == vin.addr}"><small>{{getConvertion(vin.value)}}</small></div>
<div class="ellipsis">
<span data-ng-show="vin.notAddr">{{vin.addr}}</span>
<span class="text-muted" title="Current Bitcoin Address" data-ng-show="vin.addr == $root.currentAddr">{{vin.addr}}</span>
@ -33,7 +34,7 @@
</div>
<div data-ng-repeat="vin in tx.vin" data-ng-show="itemsExpanded">
<div class="col-md-12 transaction-vin-vout">
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConversion(vin.value)}}</small></div>
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vin.value)}}</small></div>
<div class="ellipsis">
<a class="glyphicon glyphicon-chevron-right" href="/#!/tx/{{vin.txid}}" title="Outpoint: {{vin.txid}},{{vin.vout}}"></a>&nbsp;&nbsp;
<span data-ng-show="vin.notAddr">{{vin.addr}}</span>
@ -63,7 +64,7 @@
<div class="row">
<div data-ng-repeat="vout in tx.voutSimple" data-ng-show="!itemsExpanded">
<div class="col-md-12 transaction-vin-vout">
<div class="text-muted pull-right btc-value" data-ng-class="{'text-success': $root.currentAddr == vout.addr}"><small>{{$root.currency.getConversion(vout.value)}}</small></div>
<div class="text-muted pull-right btc-value" data-ng-class="{'text-success': $root.currentAddr == vout.addr}"><small>{{getConvertion(vout.value)}}</small></div>
<div class="ellipsis">
<span data-ng-show="vout.notAddr">{{vout.addr}}</span>
<span class="text-muted" title="Current Bitcoin Address" data-ng-show="address == $root.currentAddr" data-ng-repeat="address in vout.addr.split(',')">{{vout.addr}}</span>
@ -73,7 +74,7 @@
</div>
<div data-ng-repeat="vout in tx.vout" data-ng-show="itemsExpanded">
<div class="col-md-12 transaction-vin-vout">
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConversion(vout.value)}}</small></div>
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vout.value)}}</small></div>
<div class="ellipsis">
<a href="/address/{{address}}" data-ng-repeat="address in vout.scriptPubKey.addresses">{{address}}</a>
</div>
@ -101,7 +102,7 @@
<div class="panel panel-default" data-ng-show="itemsExpanded">
<div class="panel-body" style="word-wrap:break-word">
<small>
<strong>BlockHash</strong>
<strong>BlockHash</strong>
<a href="/block/{{tx.blockhash}}">{{tx.blockhash}}</a>
<button class="btn-copy" clip-copy="tx.blockhash"></button>
</small>
@ -109,11 +110,12 @@
</div>
<div class="line-top row">
<div class="col-xs-4 col-md-6">
<button data-ng-show="!tx.isCoinBase" class="btn btn-default">Fees: {{$root.currency.getConversion(tx.fees)}}</button>
<button data-ng-show="!tx.isCoinBase" class="btn btn-default">Fees: {{getConvertion(tx.fees)}}</button>
</div>
<div class="col-xs-8 col-md-6 text-right">
<button data-ng-show="tx.confirmations" class="btn btn-success">{{tx.confirmations}} Confirmations</button>
<button data-ng-show="!tx.confirmations" class="btn btn-danger">Unconfirmed Transaction!</button>
<button class="btn btn-primary">{{$root.currency.getConversion(tx.valueOut)}}</button>
<button class="btn btn-primary">{{getConvertion(tx.valueOut)}}</button>
</div>
</div>
</div>