1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 10:52: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';
var PgpBuilder = require('pgpbuilder');
var instance = new PgpBuilder();
var ngModule = angular.module('woEmail');
ngModule.factory('pgpbuilder', function() {
return instance;
return new PgpBuilder();
});

View File

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

View File

@ -1,23 +1,20 @@
'use strict';
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
ngModule.factory('appConfigStore', function(deviceStorage) {
ngModule.factory('appConfigStore', function(appConfigLawnchair) {
var deviceStorage = new DeviceStorage(appConfigLawnchair);
deviceStorage.init('app-config');
return deviceStorage;
});
// 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

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.
* @param {Object} restDao The REST Data Access Object abstraction
*/
function Invitation(restDao, appConfig) {
this._restDao = restDao;
this._restDao.setBaseUri(appConfig.config.cloudUrl);
function Invitation(invitationRestDao) {
this._restDao = invitationRestDao;
}
//

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,42 @@
'use strict';
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;
function RestDAO() {}

View File

@ -10,6 +10,13 @@ module.exports = Dialog;
function Dialog($q, axe) {
this._q = $q;
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}
*/
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) {
// log the error
if (options) {
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}
*/
Dialog.prototype.confirm = function(options) {
return this._handle(options, this.displayConfirm, 'displayConfirm');
return this._handle(options, this.displayConfirm.bind(this), 'displayConfirm');
};
/**