flosight-api/public/js/controllers/transactions.js
2014-01-20 13:31:37 -03:00

54 lines
1.2 KiB
JavaScript

'use strict';
angular.module('insight.transactions').controller('transactionsController',
['$scope',
'$rootScope',
'$routeParams',
'$location',
'Global',
'Transaction',
'TransactionsByBlock',
'TransactionsByAddress',
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) {
$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 = [];
}]);