copay/js/controllers/homeWallet.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

2014-10-31 07:49:52 -07:00
'use strict';
2014-12-09 10:13:17 -08:00
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) {
2014-12-09 06:52:01 -08:00
$scope.initHome = function() {
$rootScope.title = 'Home';
2014-12-10 13:18:28 -08:00
var w = $rootScope.wallet;
2014-12-09 06:52:01 -08:00
if (w.isShared())
$scope.copayers = w.getRegisteredPeerIds();
2014-12-04 13:12:29 -08:00
};
2014-12-10 13:18:28 -08:00
$scope.sign = function(ntxid) {
var w = $rootScope.wallet;
2014-12-10 13:18:28 -08:00
$scope.loading = true;
$scope.error = $scope.success = null;
w.signAndSend(ntxid, function(err, id, status) {
$scope.loading = false;
2014-12-10 13:18:28 -08:00
if (err)
$scope.error = err;
else
txStatus.notify(status);
});
2014-12-02 09:33:46 -08:00
};
2014-12-10 13:18:28 -08:00
$scope.reject = function(ntxid) {
var w = $rootScope.wallet;
2014-12-10 13:18:28 -08:00
w.reject(ntxid, function(err, status) {
if (err)
$scope.error = err;
else
txStatus.notify(status);
});
2014-12-10 13:18:28 -08:00
};
2014-12-04 13:12:29 -08:00
2014-12-10 13:18:28 -08:00
$scope.broadcast = function(ntxid) {
var w = $rootScope.wallet;
$scope.error = $scope.success = null;
2014-12-10 13:18:28 -08:00
$scope.loading = true;
w.issueTx(ntxid, function(err, txid, status) {
$scope.loading = false;
2014-12-10 13:18:28 -08:00
if (err)
$scope.error = err;
txStatus.notify(status);
});
};
2014-12-09 09:27:09 -08:00
2014-12-10 21:01:12 -08:00
var $outScope = $scope;
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-09 10:13:17 -08:00
$scope.tx = tx;
2014-12-10 21:01:12 -08:00
$scope.sign = function(ntxid) {
$outScope.sign(ntxid);
$modalInstance.dismiss('cancel');
};
$scope.reject = function(ntxid) {
$outScope.reject(ntxid);
$modalInstance.dismiss('cancel');
2014-12-09 09:27:09 -08:00
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
$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-02 09:33:46 -08:00
});