fix conflics
This commit is contained in:
commit
cd71ce4421
25 changed files with 268 additions and 122 deletions
|
|
@ -1,32 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('BackupController',
|
||||
function($scope, $rootScope, $location, $window, $timeout, $modal, controllerUtils, walletFactory) {
|
||||
function($scope, $rootScope, $location, $window, $timeout, $modal, backupService, walletFactory, controllerUtils) {
|
||||
$scope.title = 'Backup';
|
||||
|
||||
var _getEncryptedWallet = function() {
|
||||
var wallet = $rootScope.wallet.toEncryptedObj();
|
||||
return wallet;
|
||||
};
|
||||
|
||||
$scope.download = function() {
|
||||
var timestamp = +(new Date);
|
||||
var walletName = ($rootScope.wallet.name ? $rootScope.wallet.name : '') + '-' + $rootScope.wallet.id;
|
||||
var filename = walletName + '-' + timestamp + '.json.aes';
|
||||
var wallet = _getEncryptedWallet();
|
||||
var blob = new Blob([wallet], {
|
||||
type: 'text/plain;charset=utf-8'
|
||||
});
|
||||
// show a native save dialog if we are in the shell
|
||||
// and pass the wallet to the shell to convert to node Buffer
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:download', {
|
||||
name: walletName,
|
||||
wallet: wallet
|
||||
});
|
||||
}
|
||||
// otherwise lean on the browser implementation
|
||||
saveAs(blob, filename);
|
||||
backupService.download($rootScope.wallet);
|
||||
};
|
||||
|
||||
$scope.openModal = function() {
|
||||
|
|
@ -35,7 +14,9 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
controller: ModalInstanceCtrl,
|
||||
});
|
||||
|
||||
modalInstance.result.then(sendEmail);
|
||||
modalInstance.result.then(function(email) {
|
||||
backupService.sendEmail(email, $rootScope.wallet);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
|
|
@ -46,23 +27,6 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
});
|
||||
};
|
||||
|
||||
var sendEmail = function(email) {
|
||||
var body = _getEncryptedWallet();
|
||||
var subject = ($rootScope.wallet.name ? $rootScope.wallet.name + ' - ' : '') + $rootScope.wallet.id;
|
||||
var href = 'mailto:' + email + '?' + 'subject=[Copay Backup] ' + subject + '&' + 'body=' + body;
|
||||
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:email', href);
|
||||
}
|
||||
|
||||
var newWin = $window.open(href, '_blank', 'scrollbars=yes,resizable=yes,width=10,height=10');
|
||||
|
||||
if (newWin) {
|
||||
$timeout(function() {
|
||||
newWin.close();
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HeaderController',
|
||||
function($scope, $rootScope, $location, $notification, $http, walletFactory, controllerUtils) {
|
||||
function($scope, $rootScope, $location, $notification, $http, controllerUtils) {
|
||||
$scope.menu = [
|
||||
{
|
||||
'title': 'Addresses',
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var valid_pairs = {
|
|||
};
|
||||
|
||||
angular.module('copayApp.controllers').controller('SetupController',
|
||||
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase) {
|
||||
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase, backupService) {
|
||||
|
||||
$rootScope.videoInfo = {};
|
||||
$scope.loading = false;
|
||||
|
|
@ -84,6 +84,7 @@ angular.module('copayApp.controllers').controller('SetupController',
|
|||
passphrase: passphrase,
|
||||
};
|
||||
var w = walletFactory.create(opts);
|
||||
backupService.download(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('SigninController',
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase) {
|
||||
var cmp = function(o1, o2){
|
||||
var v1 = o1.show.toLowerCase(), v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : ( v1 < v2 ) ? -1 : 0;
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, backupService) {
|
||||
var cmp = function(o1, o2) {
|
||||
var v1 = o1.show.toLowerCase(),
|
||||
v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : (v1 < v2) ? -1 : 0;
|
||||
};
|
||||
$rootScope.videoInfo = {};
|
||||
$scope.loading = false;
|
||||
|
|
@ -14,23 +15,31 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
$rootScope.$flashMessage = { message: 'Please, enter required fields', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Please, enter required fields',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$scope.loading = true;
|
||||
var password = form.openPassword.$modelValue;
|
||||
|
||||
Passphrase.getBase64Async(password, function(passphrase){
|
||||
Passphrase.getBase64Async(password, function(passphrase) {
|
||||
var w, errMsg;
|
||||
try{
|
||||
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
||||
} catch (e){
|
||||
try {
|
||||
var w = walletFactory.open($scope.selectedWalletId, {
|
||||
passphrase: passphrase
|
||||
});
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
};
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: errMsg || 'Wrong password', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: errMsg || 'Wrong password',
|
||||
type: 'error'
|
||||
};
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
|
|
@ -40,31 +49,48 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
|
||||
$scope.join = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
$rootScope.$flashMessage = { message: 'Please, enter required fields', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Please, enter required fields',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('badSecret', function() {
|
||||
});
|
||||
walletFactory.network.on('badSecret', function() {});
|
||||
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase){
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err,w) {
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err, w) {
|
||||
$scope.loading = false;
|
||||
if (err || !w) {
|
||||
if (err === 'joinError')
|
||||
$rootScope.$flashMessage = { message: 'Can not find peer'};
|
||||
if (err === 'joinError')
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Can\'t find peer'
|
||||
};
|
||||
else if (err === 'walletFull')
|
||||
$rootScope.$flashMessage = { message: 'The wallet is full', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'The wallet is full',
|
||||
type: 'error'
|
||||
};
|
||||
else if (err === 'badNetwork')
|
||||
$rootScope.$flashMessage = { message: 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.', type: 'error'};
|
||||
else if (err === 'badSecret')
|
||||
$rootScope.$flashMessage = { message: 'Bad secret secret string', type: 'error'};
|
||||
else
|
||||
$rootScope.$flashMessage = { message: 'Unknown error', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.',
|
||||
type: 'error'
|
||||
};
|
||||
else if (err === 'badSecret')
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Bad secret secret string',
|
||||
type: 'error'
|
||||
};
|
||||
else
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Unknown error',
|
||||
type: 'error'
|
||||
};
|
||||
controllerUtils.onErrorDigest();
|
||||
} else {
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
backupService.download(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue