Merge pull request #1059 from yemel/feature/change-menu
Refactor menu, split transactions tab into send and history
This commit is contained in:
commit
fe53f1b87c
12 changed files with 235 additions and 209 deletions
|
|
@ -15,7 +15,7 @@ angular.module('copayApp.controllers').controller('CopayersController',
|
|||
}
|
||||
|
||||
$scope.goToWallet = function() {
|
||||
$location.path('/addresses');
|
||||
$location.path('/receive');
|
||||
};
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,25 @@
|
|||
var bitcore = require('bitcore');
|
||||
|
||||
angular.module('copayApp.controllers').controller('SendController',
|
||||
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification) {
|
||||
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils) {
|
||||
$scope.title = 'Send';
|
||||
$scope.loading = false;
|
||||
var satToUnit = 1 / config.unitToSatoshi;
|
||||
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
||||
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
|
||||
|
||||
$scope.loadTxs = function() {
|
||||
var opts = {
|
||||
pending: true,
|
||||
skip: null
|
||||
};
|
||||
controllerUtils.updateTxs(opts);
|
||||
setTimeout(function() {
|
||||
$scope.loading = false;
|
||||
$rootScope.$digest();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
$scope.showAddressBook = function() {
|
||||
var w = $rootScope.wallet;
|
||||
var flag;
|
||||
|
|
@ -54,7 +66,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
$scope.loading = false;
|
||||
var message = 'The transaction proposal has been created';
|
||||
notification.success('Success!', message);
|
||||
$rootScope.$digest();
|
||||
$scope.loadTxs();
|
||||
} else {
|
||||
w.sendTx(ntxid, function(txid) {
|
||||
if (txid) {
|
||||
|
|
@ -63,6 +75,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
notification.error('Error', 'There was an error sending the transaction.');
|
||||
}
|
||||
$scope.loading = false;
|
||||
$scope.loadTxs();
|
||||
});
|
||||
}
|
||||
$rootScope.pendingPayment = null;
|
||||
|
|
@ -280,4 +293,51 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
$scope.amount = $scope.getAvailableAmount();
|
||||
form.amount.$pristine = false;
|
||||
};
|
||||
|
||||
|
||||
$scope.send = function(ntxid, cb) {
|
||||
$scope.loading = true;
|
||||
$rootScope.txAlertCount = 0;
|
||||
var w = $rootScope.wallet;
|
||||
w.sendTx(ntxid, function(txid) {
|
||||
if (!txid) {
|
||||
notification.error('Error', 'There was an error sending the transaction');
|
||||
} else {
|
||||
notification.success('Transaction broadcast', 'Transaction id: '+txid);
|
||||
}
|
||||
|
||||
if (cb) return cb();
|
||||
else $scope.loadTxs();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.sign = function(ntxid) {
|
||||
$scope.loading = true;
|
||||
var w = $rootScope.wallet;
|
||||
w.sign(ntxid, function(ret) {
|
||||
if (!ret) {
|
||||
notification.error('Error', 'There was an error signing the transaction');
|
||||
$scope.loadTxs();
|
||||
} else {
|
||||
var p = w.txProposals.getTxProposal(ntxid);
|
||||
if (p.builder.isFullySigned()) {
|
||||
$scope.send(ntxid, function() {
|
||||
$scope.loadTxs();
|
||||
});
|
||||
} else
|
||||
$scope.loadTxs();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reject = function(ntxid) {
|
||||
$scope.loading = true;
|
||||
$rootScope.txAlertCount = 0;
|
||||
var w = $rootScope.wallet;
|
||||
w.reject(ntxid);
|
||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||
$scope.loading = false;
|
||||
$scope.loadTxs();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ angular.module('copayApp.controllers').controller('SidebarController',
|
|||
function($scope, $rootScope, $sce, $location, $http, notification, controllerUtils) {
|
||||
|
||||
$scope.menu = [{
|
||||
'title': 'Addresses',
|
||||
'icon': 'fi-address-book',
|
||||
'link': 'addresses'
|
||||
}, {
|
||||
'title': 'Transactions',
|
||||
'icon': 'fi-clipboard-pencil',
|
||||
'link': 'transactions'
|
||||
'title': 'Receive',
|
||||
'icon': 'fi-arrow-left',
|
||||
'link': 'receive'
|
||||
}, {
|
||||
'title': 'Send',
|
||||
'icon': 'fi-arrow-right',
|
||||
'link': 'send'
|
||||
}, {
|
||||
'title': 'History',
|
||||
'icon': 'fi-clipboard-pencil',
|
||||
'link': 'history'
|
||||
}, {
|
||||
'title': 'More',
|
||||
'icon': 'fi-download',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ angular.module('copayApp.controllers').controller('TransactionsController',
|
|||
|
||||
$scope.title = 'Transactions';
|
||||
$scope.loading = false;
|
||||
$scope.onlyPending = true;
|
||||
$scope.lastShowed = false;
|
||||
|
||||
$scope.txpCurrentPage = 1;
|
||||
|
|
@ -19,16 +18,17 @@ angular.module('copayApp.controllers').controller('TransactionsController',
|
|||
$scope.loading = false;
|
||||
var from = ($scope.txpCurrentPage - 1) * $scope.txpItemsPerPage;
|
||||
var opts = {
|
||||
onlyPending: $scope.onlyPending,
|
||||
skip: !$scope.onlyPending ? [from, from + $scope.txpItemsPerPage] : null
|
||||
pending: false,
|
||||
skip: [from, from + $scope.txpItemsPerPage]
|
||||
};
|
||||
controllerUtils.updateTxs(opts);
|
||||
$rootScope.$digest();
|
||||
setTimeout(function() {
|
||||
$rootScope.$digest();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
$scope.show = function(onlyPending) {
|
||||
$scope.show = function() {
|
||||
$scope.loading = true;
|
||||
$scope.onlyPending = onlyPending;
|
||||
setTimeout(function() {
|
||||
$scope.update();
|
||||
}, 10);
|
||||
|
|
@ -102,40 +102,6 @@ angular.module('copayApp.controllers').controller('TransactionsController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.send = function(ntxid, cb) {
|
||||
$scope.loading = true;
|
||||
$rootScope.txAlertCount = 0;
|
||||
var w = $rootScope.wallet;
|
||||
w.sendTx(ntxid, function(txid) {
|
||||
if (!txid) {
|
||||
notification.error('Error', 'There was an error sending the transaction');
|
||||
} else {
|
||||
notification.success('Transaction broadcast', 'Transaction id: '+txid);
|
||||
}
|
||||
if (cb) return cb();
|
||||
else $scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.sign = function(ntxid) {
|
||||
$scope.loading = true;
|
||||
var w = $rootScope.wallet;
|
||||
w.sign(ntxid, function(ret) {
|
||||
if (!ret) {
|
||||
notification.error('Error', 'There was an error signing the transaction');
|
||||
$scope.update();
|
||||
} else {
|
||||
var p = w.txProposals.getTxProposal(ntxid);
|
||||
if (p.builder.isFullySigned()) {
|
||||
$scope.send(ntxid, function() {
|
||||
$scope.update();
|
||||
});
|
||||
} else
|
||||
$scope.update();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getTransactions = function() {
|
||||
var w = $rootScope.wallet;
|
||||
$scope.loading = true;
|
||||
|
|
@ -174,15 +140,6 @@ angular.module('copayApp.controllers').controller('TransactionsController',
|
|||
return config.networkName.substring(0, 4);
|
||||
};
|
||||
|
||||
$scope.reject = function(ntxid) {
|
||||
$scope.loading = true;
|
||||
$rootScope.txAlertCount = 0;
|
||||
var w = $rootScope.wallet;
|
||||
w.reject(ntxid);
|
||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||
$scope.loading = false;
|
||||
};
|
||||
|
||||
// Autoload transactions on 1-of-1
|
||||
if ($rootScope.wallet && $rootScope.wallet.totalCopayers == 1) {
|
||||
$scope.lastShowed = true;
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ angular
|
|||
templateUrl: 'views/copayers.html',
|
||||
validate: true
|
||||
})
|
||||
.when('/addresses', {
|
||||
.when('/receive', {
|
||||
templateUrl: 'views/addresses.html',
|
||||
validate: true
|
||||
})
|
||||
.when('/transactions', {
|
||||
.when('/history', {
|
||||
templateUrl: 'views/transactions.html',
|
||||
validate: true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ angular.module('copayApp.services')
|
|||
});
|
||||
wallet.on('serverError', function(m) {
|
||||
var message = m || 'The PeerJS server is not responding, please try again';
|
||||
$location.path('addresses');
|
||||
$location.path('receive');
|
||||
root.onErrorDigest($scope, message);
|
||||
});
|
||||
wallet.on('ready', function() {
|
||||
|
|
@ -130,7 +130,7 @@ angular.module('copayApp.services')
|
|||
if ($rootScope.pendingPayment) {
|
||||
$location.path('send');
|
||||
} else {
|
||||
$location.path('addresses');
|
||||
$location.path('receive');
|
||||
}
|
||||
if (!config.disableVideo)
|
||||
video.setOwnPeer(myPeerID, w, handlePeerVideo);
|
||||
|
|
@ -143,9 +143,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
});
|
||||
w.on('txProposalsUpdated', function(dontDigest) {
|
||||
root.updateTxs({
|
||||
onlyPending: true
|
||||
});
|
||||
root.updateTxs();
|
||||
// give sometime to the tx to propagate.
|
||||
$timeout(function() {
|
||||
root.updateBalance(function() {
|
||||
|
|
@ -238,7 +236,7 @@ angular.module('copayApp.services')
|
|||
root.updateTxs = function(opts) {
|
||||
var w = $rootScope.wallet;
|
||||
if (!w) return;
|
||||
opts = opts || {};
|
||||
opts = opts || $rootScope.txsOpts || {};
|
||||
|
||||
var satToUnit = 1 / config.unitToSatoshi;
|
||||
var myCopayerId = w.getMyCopayerId();
|
||||
|
|
@ -259,7 +257,8 @@ angular.module('copayApp.services')
|
|||
if (!i.finallyRejected && !i.sentTs) {
|
||||
i.isPending = 1;
|
||||
}
|
||||
if (!opts.onlyPending || i.isPending) {
|
||||
|
||||
if (!!opts.pending == !!i.isPending) {
|
||||
var tx = i.builder.build();
|
||||
var outs = [];
|
||||
tx.outs.forEach(function(o) {
|
||||
|
|
@ -283,6 +282,7 @@ angular.module('copayApp.services')
|
|||
});
|
||||
|
||||
$rootScope.txs = txs;
|
||||
$rootScope.txsOpts = opts;
|
||||
if ($rootScope.pendingTxCount < pendingForUs) {
|
||||
$rootScope.txAlertCount = pendingForUs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue