Merge pull request #529 from gordonwritescode/feature/copay-shell
WIP: Copay Shell Integration 2
This commit is contained in:
commit
30c6dcae6f
4 changed files with 76 additions and 11 deletions
|
|
@ -15,10 +15,18 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
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);
|
||||
};
|
||||
|
||||
|
||||
$scope.openModal = function () {
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'backupModal.html',
|
||||
|
|
@ -35,6 +43,10 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
+ '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) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,17 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.openFileDialog = function() {
|
||||
if (window.cshell) {
|
||||
return cshell.send('backup:import');
|
||||
}
|
||||
$scope.choosefile = !$scope.choosefile;
|
||||
};
|
||||
|
||||
$scope.openPasteArea = function() {
|
||||
$scope.pastetext = !$scope.pastetext;
|
||||
};
|
||||
|
||||
$scope.getFile = function() {
|
||||
// If we use onloadend, we need to check the readyState.
|
||||
reader.onloadend = function(evt) {
|
||||
|
|
@ -53,7 +64,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
}
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
|
||||
if (backupFile) {
|
||||
reader.readAsBinaryString(backupFile);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue