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-04 10:06:17 -08:00
|
|
|
|
2014-12-10 13:18:28 -08:00
|
|
|
$scope.sign = function(ntxid) {
|
2014-12-04 10:06:17 -08:00
|
|
|
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-04 10:06:17 -08:00
|
|
|
|
2014-12-10 13:18:28 -08:00
|
|
|
if (err)
|
|
|
|
$scope.error = err;
|
|
|
|
else
|
|
|
|
txStatus.notify(status);
|
2014-12-04 10:06:17 -08:00
|
|
|
});
|
2014-12-02 09:33:46 -08:00
|
|
|
};
|
2014-12-04 10:06:17 -08:00
|
|
|
|
2014-12-10 13:18:28 -08:00
|
|
|
$scope.reject = function(ntxid) {
|
2014-12-04 10:06:17 -08:00
|
|
|
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-04 10:06:17 -08:00
|
|
|
});
|
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) {
|
2014-12-04 10:06:17 -08:00
|
|
|
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) {
|
2014-12-04 10:06:17 -08:00
|
|
|
$scope.loading = false;
|
|
|
|
|
2014-12-10 13:18:28 -08:00
|
|
|
if (err)
|
|
|
|
$scope.error = err;
|
|
|
|
|
|
|
|
txStatus.notify(status);
|
|
|
|
});
|
2014-12-04 10:06:17 -08:00
|
|
|
};
|
|
|
|
|
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',
|
2014-12-11 11:07:43 -08:00
|
|
|
windowClass: 'medium',
|
2014-12-09 09:27:09 -08:00
|
|
|
controller: ModalInstanceCtrl,
|
|
|
|
});
|
|
|
|
};
|
2014-12-02 09:33:46 -08:00
|
|
|
});
|