mirror of
https://github.com/moparisthebest/mail
synced 2024-11-23 01:12:19 -05:00
[WO-52] export encrypted key file
This commit is contained in:
parent
1d44993d8b
commit
34547f7bb6
@ -3,6 +3,7 @@ window.name = 'NG_DEFER_BOOTSTRAP!';
|
||||
|
||||
require([
|
||||
'angular',
|
||||
'js/controller/account',
|
||||
'js/controller/login',
|
||||
'js/controller/login-initial',
|
||||
'js/controller/login-new-device',
|
||||
@ -13,7 +14,7 @@ require([
|
||||
'js/controller/navigation',
|
||||
'angularRoute',
|
||||
'angularTouch'
|
||||
], function(angular, LoginCtrl, LoginInitialCtrl, LoginNewDeviceCtrl, LoginExistingCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
||||
], function(angular, AccountCtrl, LoginCtrl, LoginInitialCtrl, LoginNewDeviceCtrl, LoginExistingCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'mail-list', 'write', 'read']);
|
||||
@ -49,6 +50,7 @@ require([
|
||||
app.controller('ReadCtrl', ReadCtrl);
|
||||
app.controller('WriteCtrl', WriteCtrl);
|
||||
app.controller('MailListCtrl', MailListCtrl);
|
||||
app.controller('AccountCtrl', AccountCtrl);
|
||||
|
||||
// manually bootstrap angular due to require.js
|
||||
angular.element().ready(function() {
|
||||
|
52
src/js/controller/account.js
Normal file
52
src/js/controller/account.js
Normal file
@ -0,0 +1,52 @@
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var appController = require('js/app-controller'),
|
||||
emailDao;
|
||||
|
||||
//
|
||||
// Controller
|
||||
//
|
||||
|
||||
var AccountCtrl = function($scope) {
|
||||
emailDao = appController._emailDao;
|
||||
|
||||
//
|
||||
// scope functions
|
||||
//
|
||||
|
||||
$scope.hideAccountView = function() {
|
||||
$scope.$parent.$parent.accountOpen = false;
|
||||
};
|
||||
|
||||
$scope.exportKeyFile = function() {
|
||||
var userId = emailDao._account.emailAddress;
|
||||
emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
download(keypair.privateKey.encryptedKey, 'key_' + userId + '.asc', 'text/plain');
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// helper functions
|
||||
//
|
||||
|
||||
function download(content, filename, contentType) {
|
||||
contentType = contentType || 'application/octet-stream';
|
||||
var a = document.createElement('a');
|
||||
var blob = new Blob([content], {
|
||||
'type': contentType
|
||||
});
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.download = filename;
|
||||
a.click();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return AccountCtrl;
|
||||
});
|
@ -13,6 +13,7 @@ define(function(require) {
|
||||
var NavigationCtrl = function($scope) {
|
||||
$scope.navOpen = false;
|
||||
$scope.writerOpen = false;
|
||||
$scope.accountOpen = false;
|
||||
|
||||
emailDao = appController._emailDao;
|
||||
|
||||
@ -42,6 +43,10 @@ define(function(require) {
|
||||
$scope.closeNav();
|
||||
};
|
||||
|
||||
$scope.showAccountView = function() {
|
||||
$scope.accountOpen = true;
|
||||
};
|
||||
|
||||
$scope.remove = function(email) {
|
||||
var trashFolder = _.findWhere($scope.folders, {
|
||||
type: 'Trash'
|
||||
|
10
src/tpl/account.html
Normal file
10
src/tpl/account.html
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="lightbox-body" ng-controller="AccountCtrl">
|
||||
<header>
|
||||
<h2>Account</h2>
|
||||
<button class="close" ng-click="hideAccountView()" data-action="lightbox-close"></button>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
<button ng-click="exportKeyFile()" class="btn" >Download encrypted key file</button>
|
||||
</div>
|
||||
</div>
|
@ -21,4 +21,8 @@
|
||||
<!-- lightbox -->
|
||||
<div class="lightbox-overlay" ng-class="{'show': writerOpen}">
|
||||
<div class="lightbox lightbox-effect" ng-include="'tpl/write.html'"></div>
|
||||
</div><!--/.lightbox-overlay-->
|
||||
</div>
|
||||
<div class="lightbox-overlay" ng-class="{'show': accountOpen}">
|
||||
<div class="lightbox lightbox-effect" ng-include="'tpl/account.html'"></div>
|
||||
</div>
|
||||
<!--/.lightbox-overlay-->
|
@ -13,7 +13,7 @@
|
||||
</ul>
|
||||
|
||||
<ul class="nav-secondary">
|
||||
<li><a href="#">Account</a></li>
|
||||
<li><a href="#" ng-click="showAccountView(); $event.preventDefault()">Account</a></li>
|
||||
<li><a href="#">About whiteout.io</a></li>
|
||||
<li><a href="#">Help</a></li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user