flocore-node/public/js/controllers/transactions.js
Manuel Araoz b7d3666249 Merge branch 'master' of github.com:bitpay/insight into feature/address-socket-api
Conflicts:
	app/controllers/socket.js
	app/models/Transaction.js
	lib/PeerSync.js
	public/js/controllers/address.js
	public/js/controllers/index.js
	public/js/controllers/transactions.js
	public/views/transaction.html
2014-01-20 11:47:22 -03:00

54 lines
1.2 KiB
JavaScript

'use strict';
angular.module('insight.transactions').controller('transactionsController',
['$scope',
'$routeParams',
'$location',
'Global',
'Transaction',
'TransactionsByBlock',
'TransactionsByAddress',
'socket',
function ($scope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress, socket) {
$scope.global = Global;
$scope.findThis = function() {
$scope.findTx($routeParams.txId);
};
$scope.findTx = function(txid) {
Transaction.get({
txId: txid
}, function(tx) {
$scope.tx = tx;
$scope.txs.push(tx);
}, function() {
$rootScope.flashMessage = 'Transaction Not Found';
$location.path('/');
});
};
$scope.byBlock = function(bId) {
TransactionsByBlock.query({
block: bId
}, function(txs) {
$scope.txs = txs;
});
};
$scope.byAddress = function(aId) {
TransactionsByAddress.query({
address: aId
}, function(txs) {
$scope.txs = txs;
});
};
socket.on('tx', function(tx) {
console.log('Incoming message for new transaction!', tx);
$scope.findTx(tx.txid);
});
$scope.txs = [];
}]);