Simplification and fixes when getting transaction list (controller) from insight and look&feel of tx list
This commit is contained in:
parent
529ab11481
commit
8a40f169c0
4 changed files with 109 additions and 65 deletions
|
|
@ -305,12 +305,7 @@ hr { margin: 2.25rem 0;}
|
|||
|
||||
.tx-copayers {
|
||||
overflow: hidden;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.tx-copayers {
|
||||
overflow: hidden;
|
||||
padding: 0.5rem;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.box-copayers {
|
||||
|
|
|
|||
64
index.html
64
index.html
|
|
@ -517,15 +517,18 @@
|
|||
<pagination ng-show="!onlyPending" total-items="txs.length" items-per-page="txpItemsPerPage" page="txpCurrentPage" on-select-page="show()" class="pagination-small primary"></pagination>
|
||||
</div>
|
||||
<div class="large-12 columns">
|
||||
<h4>Last transactions</h4>
|
||||
<a ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-hide="lastShowed && !loading">Show</a>
|
||||
<a ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-show="lastShowed && !loading">Hide</a>
|
||||
<h4>Last transactions
|
||||
<small>
|
||||
<a ng-click="toogleLast()" ng-disabled="loading" loading="Loading" ng-hide="lastShowed && !loading">Show</a>
|
||||
<a ng-click="toogleLast()" ng-disabled="loading" loading="Loading" ng-show="lastShowed && !loading">Hide</a>
|
||||
</small>
|
||||
</h4>
|
||||
<div class="btransactions" ng-if="lastShowed">
|
||||
<div ng-if="!blockchain_txs[0].txid && !loading">
|
||||
No transactions yet.
|
||||
</div>
|
||||
<div class="panel radius" ng-repeat="btx in blockchain_txs | orderBy: 'firstSeenTs':true">
|
||||
<div class="m15">
|
||||
<div class="m10 size-12">
|
||||
<div class="row">
|
||||
<div class="large-8 columns">
|
||||
<a class="ellipsis" href="http://{{getShortNetworkName()}}.insight.is/tx/{{btx.txid}}" target="blank">
|
||||
|
|
@ -533,36 +536,37 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="large-4 columns text-right">
|
||||
{{btx.firstSeenTs * 1000 | amCalendar}} </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tx-copayers">
|
||||
<div class="large-5 small-5 columns">
|
||||
<div ng-repeat="vin in btx.vin track by $index | groupByAddress">
|
||||
<p class="small-8 ellipsis left text-gray size-12"> {{vin.addr}} </p>
|
||||
<small class="small-4 right">{{vin.value}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-1 small-1 columns text-center">
|
||||
<i class="fi-arrow-right"></i>
|
||||
</div>
|
||||
<div class="large-6 small-6 columns">
|
||||
<div ng-repeat="vout in btx.vout">
|
||||
<div class="row">
|
||||
<div class="large-10 small-8 columns">
|
||||
<div ng-repeat="addr in vout.scriptPubKey.addresses">
|
||||
<p class="ellipsis text-gray size-12"> {{addr}} </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-2 small-4 columns">
|
||||
<small>{{vout.value}}</small>
|
||||
</div>
|
||||
<div data-ng-show="btx.firstSeenTs">
|
||||
first seen at
|
||||
<time>{{btx.firstSeenTs * 1000 | amCalendar}}</time>
|
||||
</div>
|
||||
<div data-ng-show="btx.time && !btx.firstSeenTs">
|
||||
mined at
|
||||
<time>{{btx.time * 1000 | amCalendar}}</time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m15 size-12 text-gray">
|
||||
<div class="tx-copayers">
|
||||
<div class="row">
|
||||
<div class="large-5 medium-5 small-5 columns">
|
||||
<div ng-repeat="vin in btx.vinSimple">
|
||||
<small class="right m5t">{{vin.value}}</small>
|
||||
<p class="ellipsis text-gray size-12"> {{vin.addr}} </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-1 medium-1 small-1 columns text-center">
|
||||
<i class="fi-arrow-right"></i>
|
||||
</div>
|
||||
<div class="large-6 medium-6 small-6 columns">
|
||||
<div ng-repeat="vout in btx.voutSimple">
|
||||
<small class="right m5t">{{vout.value}}</small>
|
||||
<p class="ellipsis text-gray size-12"> {{vout.addr}} </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m10 size-12 text-gray">
|
||||
<div class="row">
|
||||
<div class="large-4 medium-4 small-4 columns">Fees: {{btx.fees}}</div>
|
||||
<div class="large-4 medium-4 small-4 columns text-center">Confirmations: {{btx.confirmations || 0}}</div>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
|
||||
$scope.txpCurrentPage = 1;
|
||||
$scope.txpItemsPerPage = 4;
|
||||
|
||||
var COIN = 100000000;
|
||||
$scope.blockchain_txs = [];
|
||||
|
||||
$scope.update = function () {
|
||||
$scope.loading = false;
|
||||
|
|
@ -30,22 +33,71 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
}, 10);
|
||||
};
|
||||
|
||||
var _aggregateItems = function(items) {
|
||||
if (!items) return [];
|
||||
|
||||
var l = items.length;
|
||||
|
||||
var ret = [];
|
||||
var tmp = {};
|
||||
var u = 0;
|
||||
|
||||
for(var i=0; i < l; i++) {
|
||||
|
||||
var notAddr = false;
|
||||
// non standard input
|
||||
if (items[i].scriptSig && !items[i].addr) {
|
||||
items[i].addr = 'Unparsed address [' + u++ + ']';
|
||||
items[i].notAddr = true;
|
||||
notAddr = true;
|
||||
}
|
||||
|
||||
// non standard output
|
||||
if (items[i].scriptPubKey && !items[i].scriptPubKey.addresses) {
|
||||
items[i].scriptPubKey.addresses = ['Unparsed address [' + u++ + ']'];
|
||||
items[i].notAddr = true;
|
||||
notAddr = true;
|
||||
}
|
||||
|
||||
// multiple addr at output
|
||||
if (items[i].scriptPubKey && items[i].scriptPubKey.addresses.length > 1) {
|
||||
items[i].addr = items[i].scriptPubKey.addresses.join(',');
|
||||
ret.push(items[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
var addr = items[i].addr || (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0]);
|
||||
|
||||
if (!tmp[addr]) {
|
||||
tmp[addr] = {};
|
||||
tmp[addr].valueSat = 0;
|
||||
tmp[addr].count = 0;
|
||||
tmp[addr].addr = addr;
|
||||
tmp[addr].items = [];
|
||||
}
|
||||
tmp[addr].isSpent = items[i].spentTxId;
|
||||
|
||||
tmp[addr].doubleSpentTxID = tmp[addr].doubleSpentTxID || items[i].doubleSpentTxID;
|
||||
tmp[addr].doubleSpentIndex = tmp[addr].doubleSpentIndex || items[i].doubleSpentIndex;
|
||||
tmp[addr].unconfirmedInput += items[i].unconfirmedInput;
|
||||
tmp[addr].dbError = tmp[addr].dbError || items[i].dbError;
|
||||
tmp[addr].valueSat += Math.round(items[i].value * COIN);
|
||||
tmp[addr].items.push(items[i]);
|
||||
tmp[addr].notAddr = notAddr;
|
||||
tmp[addr].count++;
|
||||
}
|
||||
|
||||
angular.forEach(tmp, function(v) {
|
||||
v.value = v.value || parseInt(v.valueSat) / COIN;
|
||||
ret.push(v);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
||||
$scope.toogleLast = function () {
|
||||
$scope.loading = true;
|
||||
$scope.lastShowed = !$scope.lastShowed;
|
||||
if ($scope.lastShowed) {
|
||||
$scope.getTransactions(function(txs){
|
||||
$timeout(function() {
|
||||
$scope.loading = false;
|
||||
$scope.blockchain_txs = txs;
|
||||
$scope.$digest();
|
||||
}, 10);
|
||||
});
|
||||
} else {
|
||||
$timeout(function(){
|
||||
$scope.loading = false;
|
||||
$rootScope.$digest();
|
||||
}, 10);
|
||||
$scope.getTransactions();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -87,16 +139,26 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.getTransactions = function(cb) {
|
||||
var w =$rootScope.wallet;
|
||||
$scope.getTransactions = function() {
|
||||
var w = $rootScope.wallet;
|
||||
$scope.loading = true;
|
||||
if (w) {
|
||||
console.log('### Querying last transactions...'); //TODO
|
||||
var addresses = w.getAddressesStr();
|
||||
if (addresses.length > 0) {
|
||||
return w.blockchain.getTransactions(addresses, cb);
|
||||
$scope.blockchain_txs = [];
|
||||
w.blockchain.getTransactions(addresses, function(txs) {
|
||||
$timeout(function() {
|
||||
for (var i=0; i<txs.length;i++) {
|
||||
txs[i].vinSimple = _aggregateItems(txs[i].vin);
|
||||
txs[i].voutSimple = _aggregateItems(txs[i].vout);
|
||||
$scope.blockchain_txs.push(txs[i]);
|
||||
}
|
||||
$scope.loading = false;
|
||||
}, 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
return cb();
|
||||
};
|
||||
|
||||
$scope.getShortNetworkName = function() {
|
||||
|
|
|
|||
|
|
@ -6,23 +6,6 @@ angular.module('copay.filters', [])
|
|||
return amMoment.preprocessDate(input).fromNow();
|
||||
};
|
||||
}])
|
||||
.filter('groupByAddress', function() {
|
||||
return function(inputs) {
|
||||
function reduce(dic, input) {
|
||||
if(!dic[input.addr]) dic[input.addr] = 0;
|
||||
dic[input.addr] += input.value;
|
||||
return dic;
|
||||
}
|
||||
|
||||
var dic;
|
||||
if (inputs) {
|
||||
dic = inputs.reduce(reduce, {});
|
||||
return Object.keys(dic).map(function(key) {
|
||||
return { addr: key, value: dic[key] };
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
.filter('paged', function() {
|
||||
return function(elements) {
|
||||
if (elements) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue