mirror of
https://github.com/moparisthebest/mail
synced 2025-03-03 10:11:47 -05:00
[WO-116] Integrate error handler into all conrtollers
This commit is contained in:
parent
5be2d89fab
commit
4b8f4ee7df
@ -1,9 +1,15 @@
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var appController = require('js/app-controller');
|
||||
var appController = require('js/app-controller'),
|
||||
errorUtil = require('js/util/error');
|
||||
|
||||
var LoginExistingCtrl = function($scope, $location) {
|
||||
// global state... inherited to all child scopes
|
||||
$scope.$root.state = {};
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
var emailDao = appController._emailDao;
|
||||
|
||||
$scope.buttonEnabled = true;
|
||||
@ -48,8 +54,8 @@ define(function(require) {
|
||||
function handleError(err) {
|
||||
$scope.incorrect = true;
|
||||
$scope.buttonEnabled = true;
|
||||
$scope.onError(err);
|
||||
$scope.$apply();
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@ define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var appController = require('js/app-controller'),
|
||||
errorUtil = require('js/util/error'),
|
||||
dl = require('js/util/download');
|
||||
|
||||
var LoginInitialCtrl = function($scope, $location) {
|
||||
@ -10,6 +11,8 @@ define(function(require) {
|
||||
|
||||
// global state... inherited to all child scopes
|
||||
$scope.$root.state = {};
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
states = {
|
||||
IDLE: 1,
|
||||
@ -35,7 +38,7 @@ define(function(require) {
|
||||
setTimeout(function() {
|
||||
emailDao.unlock({}, passphrase, function(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.onError(err);
|
||||
$scope.setState(states.IDLE, true);
|
||||
return;
|
||||
}
|
||||
@ -49,7 +52,7 @@ define(function(require) {
|
||||
// export keys from keychain
|
||||
emailDao._crypto.exportKeys(function(err, keys) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -63,7 +66,7 @@ define(function(require) {
|
||||
|
||||
function onSave(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.onError(err);
|
||||
return;
|
||||
}
|
||||
$scope.proceed();
|
||||
|
@ -2,9 +2,15 @@ define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var angular = require('angular'),
|
||||
errorUtil = require('js/util/error'),
|
||||
appController = require('js/app-controller');
|
||||
|
||||
var LoginExistingCtrl = function($scope, $location) {
|
||||
// global state... inherited to all child scopes
|
||||
$scope.$root.state = {};
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
var emailDao = appController._emailDao;
|
||||
|
||||
$scope.incorrect = false;
|
||||
@ -23,7 +29,7 @@ define(function(require) {
|
||||
var userId = emailDao._account.emailAddress;
|
||||
emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,8 +42,8 @@ define(function(require) {
|
||||
emailDao.unlock(keypair, $scope.passphrase, function(err) {
|
||||
if (err) {
|
||||
$scope.incorrect = true;
|
||||
$scope.onError(err);
|
||||
$scope.$apply();
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,7 +54,7 @@ define(function(require) {
|
||||
|
||||
function onUnlock(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
$scope.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,19 @@
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var appController = require('js/app-controller');
|
||||
var appController = require('js/app-controller'),
|
||||
errorUtil = require('js/util/error');
|
||||
|
||||
var LoginCtrl = function($scope, $location) {
|
||||
// global state... inherited to all child scopes
|
||||
$scope.$root.state = {};
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
$scope.$root.onError = function(options) {
|
||||
console.error(options);
|
||||
$scope.state.dialog = {
|
||||
open: true,
|
||||
title: options.title || 'Error',
|
||||
message: options.message || options.errMsg
|
||||
};
|
||||
};
|
||||
// check for app update
|
||||
appController.checkForUpdate();
|
||||
|
||||
// start main application controller
|
||||
appController.start(function(err) {
|
||||
if (err) {
|
||||
$scope.onError(err);
|
||||
@ -28,9 +26,6 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check for app update
|
||||
appController.checkForUpdate();
|
||||
|
||||
// login to imap
|
||||
initializeUser();
|
||||
});
|
||||
|
@ -3,6 +3,7 @@ define(function(require) {
|
||||
|
||||
var angular = require('angular'),
|
||||
appController = require('js/app-controller'),
|
||||
errorUtil = require('js/util/error'),
|
||||
_ = require('underscore'),
|
||||
config = require('js/app-config').config,
|
||||
emailDao, senderIntervalId,
|
||||
@ -15,6 +16,8 @@ define(function(require) {
|
||||
var NavigationCtrl = function($scope) {
|
||||
// global state... inherited to all child scopes
|
||||
$scope.$root.state = {};
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
emailDao = appController._emailDao;
|
||||
|
||||
@ -22,19 +25,6 @@ define(function(require) {
|
||||
// scope functions
|
||||
//
|
||||
|
||||
$scope.$root.onError = function(options) {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(options);
|
||||
$scope.state.dialog = {
|
||||
open: true,
|
||||
title: options.title || 'Error',
|
||||
message: options.message || options.errMsg
|
||||
};
|
||||
};
|
||||
|
||||
$scope.state.nav = {
|
||||
open: false,
|
||||
toggle: function(to) {
|
||||
|
23
src/js/util/error.js
Normal file
23
src/js/util/error.js
Normal file
@ -0,0 +1,23 @@
|
||||
define(function() {
|
||||
'use strict';
|
||||
|
||||
var er = {};
|
||||
|
||||
er.attachHandler = function(scope) {
|
||||
scope.$root.onError = function(options) {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(options);
|
||||
|
||||
scope.state.dialog = {
|
||||
open: true,
|
||||
title: options.title || 'Error',
|
||||
message: options.errMsg || options.message
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
return er;
|
||||
});
|
@ -28,4 +28,3 @@
|
||||
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||
</div>
|
||||
<!--/.lightbox-overlay-->
|
@ -1,5 +1,4 @@
|
||||
<div class="view-login view-login-existing">
|
||||
|
||||
<div class="logo-wrapper">
|
||||
<div class="logo"></div>
|
||||
</div><!--/logo-->
|
||||
@ -18,5 +17,9 @@
|
||||
</div>
|
||||
</form>
|
||||
</div><!--/content-->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- lightbox -->
|
||||
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||
</div>
|
@ -1,5 +1,4 @@
|
||||
<div class="view-login" ng-class="{'waiting-cursor': state.ui === 2}">
|
||||
|
||||
<div class="logo-wrapper">
|
||||
<div class="logo"></div>
|
||||
</div><!--/logo-->
|
||||
@ -34,3 +33,8 @@
|
||||
|
||||
</div><!--/content-->
|
||||
</div>
|
||||
|
||||
<!-- lightbox -->
|
||||
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||
</div>
|
@ -1,5 +1,4 @@
|
||||
<div class="view-login">
|
||||
|
||||
<div class="logo-wrapper">
|
||||
<div class="logo"></div>
|
||||
</div><!--/logo-->
|
||||
@ -11,8 +10,13 @@
|
||||
|
||||
<form>
|
||||
<div><input type="file" file-reader tabindex="1"></div>
|
||||
<div><input type="password" ng-model="passphrase" ng-class="{error:incorrect}" placeholder="Passphrase" tabindex="2"></div>
|
||||
<div><input type="password" ng-model="passphrase" ng-class="{error:incorrect}" placeholder="Passphrase" tabindex="2" focus-me="true"></div>
|
||||
<div><button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!key" tabindex="3">Import</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- lightbox -->
|
||||
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||
</div>
|
@ -15,4 +15,3 @@
|
||||
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||
</div>
|
||||
<!--/.lightbox-overlay-->
|
Loading…
x
Reference in New Issue
Block a user