Skip to content

Commit 08b3f98

Browse files
committed
enable sort by tx.blockNumber or tx.value
1 parent c87a1a6 commit 08b3f98

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

public/js/controllers/AddressController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ angular.module('BlocksApp').controller('AddressController', function($stateParam
6363
"columnDefs": [
6464
{ "targets": [ 5 ], "visible": false, "searchable": false },
6565
{"type": "date", "targets": 6},
66-
{"orderable": false, "targets": [0,2,3]},
66+
{"orderable": false, "targets": [0,2,3,4]},
6767
{ "render": function(data, type, row) {
6868
if (data != $scope.addrHash)
6969
return '<a href="/addr/'+data+'">'+data+'</a>'

routes/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ var getAddr = function(req, res){
4848

4949
var addrFind = Transaction.find( { $or: [{"to": addr}, {"from": addr}] })
5050

51-
addrFind.lean(true).sort('-blockNumber').skip(start).limit(limit)
51+
var sortOrder = '-blockNumber';
52+
if (req.body.order && req.body.order[0] && req.body.order[0].column) {
53+
// date or blockNumber column
54+
if (req.body.order[0].column == 1 || req.body.order[0].column == 6) {
55+
if (req.body.order[0].dir == 'asc') {
56+
sortOrder = 'blockNumber';
57+
}
58+
}
59+
}
60+
61+
addrFind.lean(true).sort(sortOrder).skip(start).limit(limit)
5262
.exec("find", function (err, docs) {
5363
if (docs)
5464
data.data = filters.filterTX(docs, addr);

0 commit comments

Comments
 (0)