2015-03-06 12:00:10 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('copayersController',
|
|
|
|
|
function($scope, $rootScope, $timeout, $log, $modal, profileService, go, notification, isCordova) {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.init = function() {
|
|
|
|
|
var fc = profileService.focusedClient;
|
|
|
|
|
if (fc.isComplete()) {
|
|
|
|
|
$log.debug('Wallet Complete...redirecting')
|
|
|
|
|
go.walletHome();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.loading = false;
|
|
|
|
|
self.isCordova = isCordova;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var _modalDeleteWallet = function() {
|
|
|
|
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
|
|
|
|
$scope.title = 'Are you sure you want to delete this wallet?';
|
|
|
|
|
$scope.loading = false;
|
|
|
|
|
|
|
|
|
|
$scope.ok = function() {
|
|
|
|
|
$scope.loading = true;
|
|
|
|
|
$modalInstance.close('ok');
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
$scope.cancel = function() {
|
|
|
|
|
$modalInstance.dismiss('cancel');
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var modalInstance = $modal.open({
|
|
|
|
|
templateUrl: 'views/modals/confirmation.html',
|
|
|
|
|
windowClass: 'full',
|
|
|
|
|
controller: ModalInstanceCtrl
|
|
|
|
|
});
|
|
|
|
|
modalInstance.result.then(function(ok) {
|
|
|
|
|
if (ok) {
|
|
|
|
|
_deleteWallet();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var _deleteWallet = function() {
|
|
|
|
|
var fc = profileService.focusedClient;
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
var fc = profileService.focusedClient;
|
|
|
|
|
var walletName = fc.credentials.walletName;
|
|
|
|
|
|
|
|
|
|
profileService.deleteWalletFC({}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
this.error = err.message || err;
|
|
|
|
|
console.log(err);
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
go.walletHome();
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
notification.success('Success', 'The wallet "' + walletName + '" was deleted');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 100);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.deleteWallet = function() {
|
|
|
|
|
var fc = profileService.focusedClient;
|
|
|
|
|
if (isCordova) {
|
|
|
|
|
navigator.notification.confirm(
|
|
|
|
|
'Are you sure you want to delete this wallet?',
|
|
|
|
|
function(buttonIndex) {
|
|
|
|
|
if (buttonIndex == 2) {
|
|
|
|
|
_deleteWallet();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'Confirm', ['Cancel', 'OK']
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
_modalDeleteWallet();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.copySecret = function(secret) {
|
|
|
|
|
if (isCordova) {
|
|
|
|
|
window.cordova.plugins.clipboard.copy(secret);
|
|
|
|
|
window.plugins.toast.showShortCenter('Copied to clipboard');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.shareSecret = function(secret) {
|
|
|
|
|
if (isCordova) {
|
|
|
|
|
if (isMobile.Android() || isMobile.Windows()) {
|
|
|
|
|
window.ignoreMobilePause = true;
|
|
|
|
|
}
|
2015-04-26 17:44:54 -03:00
|
|
|
var message = 'Join my Copay wallet. Here is the invitation code: ' + secret + ' You can download Copay for your phone or desktop at https://copay.io';
|
|
|
|
|
window.plugins.socialsharing.share(message, 'Invitation to share a Copay Wallet', null, null);
|
2015-03-06 12:00:10 -03:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|