mirror of https://github.com/BTCPrivate/copay.git
merged email modal and wired up copay shell integration for it
This commit is contained in:
commit
47f9ade884
11
index.html
11
index.html
|
@ -669,7 +669,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-6 medium-6 columns">
|
<div class="large-6 medium-6 columns">
|
||||||
<a class="panel radius box-backup" ng-click="email()">
|
<a class="panel radius box-backup" ng-click="openModal()">
|
||||||
<i class="fi-mail size-72"></i>
|
<i class="fi-mail size-72"></i>
|
||||||
<p> Backup to email </p>
|
<p> Backup to email </p>
|
||||||
</a>
|
</a>
|
||||||
|
@ -678,6 +678,15 @@
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/ng-template" id="backupModal.html">
|
||||||
|
<h3>Insert your email</h3>
|
||||||
|
<form name="emailForm" ng-submit="submit(emailForm)">
|
||||||
|
<p><input type="email" ng-model="$parent.email" placeholder="your@email.com" required/></p>
|
||||||
|
<input type="submit" class="button" value="Send" ng-disabled="emailForm.$invalid"/>
|
||||||
|
</form>
|
||||||
|
<a class="close-reveal-modal" ng-click="cancel()">×</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- CONFIG -->
|
<!-- CONFIG -->
|
||||||
<script type="text/ng-template" id="settings.html">
|
<script type="text/ng-template" id="settings.html">
|
||||||
<div class="settings" ng-controller="SettingsController">
|
<div class="settings" ng-controller="SettingsController">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copay.backup').controller('BackupController',
|
angular.module('copay.backup').controller('BackupController',
|
||||||
function($scope, $rootScope, $location, $window, $timeout) {
|
function($scope, $rootScope, $location, $window, $timeout, $modal) {
|
||||||
$scope.title = 'Backup';
|
$scope.title = 'Backup';
|
||||||
|
|
||||||
var _getEncryptedWallet = function() {
|
var _getEncryptedWallet = function() {
|
||||||
|
@ -27,29 +27,43 @@ angular.module('copay.backup').controller('BackupController',
|
||||||
saveAs(blob, filename);
|
saveAs(blob, filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.email = function() {
|
$scope.openModal = function () {
|
||||||
var email = prompt('Please enter your email addres.');
|
var modalInstance = $modal.open({
|
||||||
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
|
templateUrl: 'backupModal.html',
|
||||||
|
controller: ModalInstanceCtrl,
|
||||||
|
});
|
||||||
|
|
||||||
if (email && email !== '') {
|
modalInstance.result.then(sendEmail);
|
||||||
if (!email.match(mailformat)) {
|
};
|
||||||
alert('Enter a valid email address');
|
|
||||||
} else {
|
|
||||||
var body = _getEncryptedWallet();
|
|
||||||
var subject = ($rootScope.wallet.name ? $rootScope.wallet.name + ' - ' : '') + $rootScope.wallet.id;
|
|
||||||
var href = 'mailto:' + email + '?'
|
|
||||||
+ 'subject=[Copay Backup] ' + subject + '&'
|
|
||||||
+ 'body=' + body;
|
|
||||||
|
|
||||||
var newWin = $window.open(href, '_blank', 'scrollbars=yes,resizable=yes,width=10,height=10');
|
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 (newWin) {
|
if (window.cshell) {
|
||||||
$timeout(function() {
|
return window.cshell.send('backup:email', href);
|
||||||
newWin.close();
|
}
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
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) {
|
||||||
|
|
||||||
|
$scope.submit = function (form) {
|
||||||
|
$modalInstance.close($scope.email);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.cancel = function () {
|
||||||
|
$modalInstance.dismiss('cancel');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
@ -75,10 +75,10 @@
|
||||||
location.href = '#/backup';
|
location.href = '#/backup';
|
||||||
var ctrl = controller('BackupController');
|
var ctrl = controller('BackupController');
|
||||||
if (!ctrl) return needsWalletLogin(ipc);
|
if (!ctrl) return needsWalletLogin(ipc);
|
||||||
ctrl.email();
|
ctrl.openModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.on('backup:import', function(data) {
|
ipc.on('backup:import:data', function(data) {
|
||||||
location.href = '#/import';
|
location.href = '#/import';
|
||||||
var ctrl = controller('ImportController');
|
var ctrl = controller('ImportController');
|
||||||
if (!ctrl) return;
|
if (!ctrl) return;
|
||||||
|
@ -87,6 +87,10 @@
|
||||||
ctrl.$apply();
|
ctrl.$apply();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipc.on('backup:import', function(data) {
|
||||||
|
location.href = '#/import';
|
||||||
|
});
|
||||||
|
|
||||||
// let the shell know when an error occurs
|
// let the shell know when an error occurs
|
||||||
window.onerror = function(err) {
|
window.onerror = function(err) {
|
||||||
ipc.send('error', err);
|
ipc.send('error', err);
|
||||||
|
|
Loading…
Reference in New Issue