copay/js/controllers/homeWallet.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-10-31 07:49:52 -07:00
'use strict';
2015-01-18 13:48:16 -08:00
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) {
2014-12-09 09:27:09 -08:00
2014-12-09 10:13:17 -08:00
$scope.openTxModal = function(tx) {
2014-12-09 09:27:09 -08:00
var ModalInstanceCtrl = function($scope, $modalInstance) {
2014-12-11 16:14:56 -08:00
var w = $rootScope.wallet;
2014-12-09 10:13:17 -08:00
$scope.tx = tx;
2014-12-11 16:14:56 -08:00
$scope.loading = null;
2014-12-10 21:01:12 -08:00
$scope.sign = function(ntxid) {
2014-12-11 16:14:56 -08:00
$scope.loading = true;
$timeout(function() {
w.signAndSend(ntxid, function(err, id, status) {
$scope.loading = false;
if (err)
$scope.error = err;
else
$modalInstance.close(status);
});
}, 100);
2014-12-10 21:01:12 -08:00
};
2014-12-11 16:14:56 -08:00
2014-12-10 21:01:12 -08:00
$scope.reject = function(ntxid) {
2014-12-11 16:14:56 -08:00
$scope.loading = true;
$timeout(function() {
w.reject(ntxid, function(err, status) {
$scope.loading = false;
if (err)
$scope.error = err;
else
$modalInstance.close(status);
});
}, 100);
2014-12-09 09:27:09 -08:00
};
2014-12-11 16:14:56 -08:00
$scope.broadcast = function(ntxid) {
$scope.loading = true;
$timeout(function() {
w.issueTx(ntxid, function(err, txid, status) {
$scope.loading = false;
if (err)
$scope.error = err;
$modalInstance.close(status);
});
}, 100);
};
2014-12-09 09:27:09 -08:00
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
2014-12-11 16:14:56 -08:00
var modalInstance = $modal.open({
2014-12-09 10:13:17 -08:00
templateUrl: 'views/modals/txp-details.html',
windowClass: 'medium',
2014-12-09 09:27:09 -08:00
controller: ModalInstanceCtrl,
});
2014-12-11 16:14:56 -08:00
modalInstance.result.then(function(status) {
txStatus.notify(status);
});
2014-12-09 09:27:09 -08:00
};
2014-12-02 09:33:46 -08:00
});