1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -05:00

Multiple minor fixes

* Fix dialog service instance binding
* Fix service/factory handling
* Inject userStorage lawnchair adapter to keychain service
This commit is contained in:
Felix Hammerl 2014-11-25 17:46:33 +01:00
parent 2a2058c167
commit 2764c6e230
11 changed files with 71 additions and 38 deletions

View File

@ -1,9 +1,8 @@
'use strict'; 'use strict';
var PgpBuilder = require('pgpbuilder'); var PgpBuilder = require('pgpbuilder');
var instance = new PgpBuilder();
var ngModule = angular.module('woEmail'); var ngModule = angular.module('woEmail');
ngModule.factory('pgpbuilder', function() { ngModule.factory('pgpbuilder', function() {
return instance; return new PgpBuilder();
}); });

View File

@ -4,9 +4,8 @@ var ngModule = angular.module('woServices');
ngModule.service('admin', Admin); ngModule.service('admin', Admin);
module.exports = Admin; module.exports = Admin;
function Admin(restDao, appConfig) { function Admin(adminRestDao) {
this._restDao = restDao; this._restDao = adminRestDao;
this._restDao.setBaseUri(appConfig.config.adminUrl);
} }
/** /**

View File

@ -1,23 +1,20 @@
'use strict'; 'use strict';
var ngModule = angular.module('woServices'); var ngModule = angular.module('woServices');
ngModule.factory('deviceStorage', function(lawnchairDAO) {
return new DeviceStorage(lawnchairDAO);
});
module.exports = DeviceStorage;
//
// Export special device storage singletons
//
// expose an instance with the static dbName 'app-config' to store configuration data // expose an instance with the static dbName 'app-config' to store configuration data
ngModule.factory('appConfigStore', function(deviceStorage) { ngModule.factory('appConfigStore', function(appConfigLawnchair) {
var deviceStorage = new DeviceStorage(appConfigLawnchair);
deviceStorage.init('app-config'); deviceStorage.init('app-config');
return deviceStorage; return deviceStorage;
}); });
// expose a singleton instance of DeviceStorage called 'accountStore' to persist user data // expose a singleton instance of DeviceStorage called 'accountStore' to persist user data
ngModule.service('accountStore', DeviceStorage); ngModule.factory('accountStore', function(accountLawnchair) {
return new DeviceStorage(accountLawnchair);
});
module.exports = DeviceStorage;
// //
// Implementation // Implementation

View File

@ -8,9 +8,8 @@ module.exports = Invitation;
* The Invitation is a high level Data Access Object that access the invitation service REST endpoint. * The Invitation is a high level Data Access Object that access the invitation service REST endpoint.
* @param {Object} restDao The REST Data Access Object abstraction * @param {Object} restDao The REST Data Access Object abstraction
*/ */
function Invitation(restDao, appConfig) { function Invitation(invitationRestDao) {
this._restDao = restDao; this._restDao = invitationRestDao;
this._restDao.setBaseUri(appConfig.config.cloudUrl);
} }
// //

View File

@ -15,8 +15,8 @@ var DB_PUBLICKEY = 'publickey',
* A high-level Data-Access Api for handling Keypair synchronization * A high-level Data-Access Api for handling Keypair synchronization
* between the cloud service and the device's local storage * between the cloud service and the device's local storage
*/ */
function Keychain(lawnchairDAO, publicKey, privateKey, crypto, pgp, dialog, appConfig) { function Keychain(accountLawnchair, publicKey, privateKey, crypto, pgp, dialog, appConfig) {
this._lawnchairDAO = lawnchairDAO; this._lawnchairDAO = accountLawnchair;
this._publicKeyDao = publicKey; this._publicKeyDao = publicKey;
this._privateKeyDao = privateKey; this._privateKeyDao = privateKey;
this._crypto = crypto; this._crypto = crypto;

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
var ngModule = angular.module('woServices'); var ngModule = angular.module('woServices');
ngModule.factory('lawnchairDAO', function() { ngModule.service('appConfigLawnchair', LawnchairDAO);
return new LawnchairDAO(); ngModule.service('accountLawnchair', LawnchairDAO);
}); ngModule.service('keychainLawnchair', LawnchairDAO);
module.exports = LawnchairDAO; module.exports = LawnchairDAO;
/** /**

View File

@ -4,9 +4,8 @@ var ngModule = angular.module('woServices');
ngModule.service('oauth', OAuth); ngModule.service('oauth', OAuth);
module.exports = OAuth; module.exports = OAuth;
function OAuth(restDao) { function OAuth(oauthRestDao) {
this._googleApi = restDao; this._googleApi = oauthRestDao;
this._googleApi.setBaseUri('https://www.googleapis.com');
} }
/** /**

View File

@ -4,9 +4,8 @@ var ngModule = angular.module('woServices');
ngModule.service('privateKey', PrivateKey); ngModule.service('privateKey', PrivateKey);
module.exports = PrivateKey; module.exports = PrivateKey;
function PrivateKey(restDao, appConfig) { function PrivateKey(privateKeyRestDao) {
this._restDao = restDao; this._restDao = privateKeyRestDao;
this._restDao.setBaseUri(appConfig.config.privkeyServerUrl);
} }
// //

View File

@ -4,9 +4,8 @@ var ngModule = angular.module('woServices');
ngModule.service('publicKey', PublicKey); ngModule.service('publicKey', PublicKey);
module.exports = PublicKey; module.exports = PublicKey;
function PublicKey(restDao, appConfig) { function PublicKey(publicKeyRestDao) {
this._restDao = restDao; this._restDao = publicKeyRestDao;
this._restDao.setBaseUri(appConfig.config.cloudUrl);
} }
/** /**

View File

@ -1,9 +1,42 @@
'use strict'; 'use strict';
var ngModule = angular.module('woServices'); var ngModule = angular.module('woServices');
ngModule.factory('restDao', function() {
return new RestDAO(); // rest dao for use in the public key service
ngModule.factory('publicKeyRestDao', function(appConfig) {
var dao = new RestDAO();
dao.setBaseUri(appConfig.config.cloudUrl);
return dao;
}); });
// rest dao for use in the private key service
ngModule.factory('privateKeyRestDao', function(appConfig) {
var dao = new RestDAO();
dao.setBaseUri(appConfig.config.privkeyServerUrl);
return dao;
});
// rest dao for use in the invitation service
ngModule.factory('invitationRestDao', function(appConfig) {
var dao = new RestDAO();
dao.setBaseUri(appConfig.config.cloudUrl);
return dao;
});
// rest dao for use in the admin service
ngModule.factory('adminRestDao', function(appConfig) {
var dao = new RestDAO();
dao.setBaseUri(appConfig.config.adminUrl);
return dao;
});
// rest dao for use in the oauth service
ngModule.factory('oauthRestDao', function() {
var dao = new RestDAO();
dao.setBaseUri('https://www.googleapis.com');
return dao;
});
module.exports = RestDAO; module.exports = RestDAO;
function RestDAO() {} function RestDAO() {}

View File

@ -10,6 +10,13 @@ module.exports = Dialog;
function Dialog($q, axe) { function Dialog($q, axe) {
this._q = $q; this._q = $q;
this._axe = axe; this._axe = axe;
// binds the methods to the instance of the dialog service so that we can e.g.
// pass dialog.error as a callback to asynchronous functions without having to
// do dialog.error.bind(dialog) every time
this.info = this.info.bind(this);
this.error = this.error.bind(this);
this.confirm = this.confirm.bind(this);
} }
/** /**
@ -19,7 +26,7 @@ function Dialog($q, axe) {
* @return {Promise} * @return {Promise}
*/ */
Dialog.prototype.info = function(options) { Dialog.prototype.info = function(options) {
return this._handle(options, this.displayInfo, 'displayInfo'); return this._handle(options, this.displayInfo.bind(this), 'displayInfo');
}; };
/** /**
@ -30,8 +37,10 @@ Dialog.prototype.info = function(options) {
*/ */
Dialog.prototype.error = function(options) { Dialog.prototype.error = function(options) {
// log the error // log the error
if (options) {
this._axe.error((options.errMsg || options.message) + (options.stack ? ('\n' + options.stack) : '')); this._axe.error((options.errMsg || options.message) + (options.stack ? ('\n' + options.stack) : ''));
return this._handle(options, this.displayError, 'displayError'); }
return this._handle(options, this.displayError.bind(this), 'displayError');
}; };
/** /**
@ -42,7 +51,7 @@ Dialog.prototype.error = function(options) {
* @return {Promise} * @return {Promise}
*/ */
Dialog.prototype.confirm = function(options) { Dialog.prototype.confirm = function(options) {
return this._handle(options, this.displayConfirm, 'displayConfirm'); return this._handle(options, this.displayConfirm.bind(this), 'displayConfirm');
}; };
/** /**