angular supress unhandled rejection

This commit is contained in:
Mo Bitar
2016-12-18 00:09:57 -06:00
parent d527c8d34b
commit 3794d0496c
8 changed files with 95 additions and 86 deletions

1
.gitignore vendored
View File

@@ -24,6 +24,7 @@
/node_modules /node_modules
/vendor/assets/javascripts/app.js /vendor/assets/javascripts/app.js
/vendor/assets/javascripts/compiled.js /vendor/assets/javascripts/compiled.js
/vendor/assets/javascripts/transpiled.js
/vendor/assets/javascripts/compiled.min.js /vendor/assets/javascripts/compiled.min.js
/vendor/assets/javascripts/lib.js /vendor/assets/javascripts/lib.js
/vendor/assets/javascripts/templates.js /vendor/assets/javascripts/templates.js

View File

@@ -3,18 +3,16 @@
var Neeto = Neeto || {}; var Neeto = Neeto || {};
if(window.crypto.subtle) { if(window.crypto.subtle) {
console.log("using WebCrypto"); // console.log("using WebCrypto");
Neeto.crypto = new SNCryptoWeb(); Neeto.crypto = new SNCryptoWeb();
} else { } else {
console.log("using CryptoJS"); // console.log("using CryptoJS");
Neeto.crypto = new SNCryptoJS(); Neeto.crypto = new SNCryptoJS();
} }
angular.module('app.frontend', [ angular.module('app.frontend', [
'ui.router', 'ui.router',
'ng-token-auth',
'restangular', 'restangular',
'ipCookie',
'oc.lazyLoad', 'oc.lazyLoad',
'angularLazyImg', 'angularLazyImg',
'ngDialog' 'ngDialog'
@@ -40,3 +38,6 @@ angular.module('app.frontend', [
}; };
}); });
}) })
.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);

View File

@@ -17,7 +17,7 @@ angular.module('app.frontend')
} }
} }
}) })
.controller('HeaderCtrl', function ($auth, $state, apiController, modelManager, serverSideValidation, $timeout) { .controller('HeaderCtrl', function ($state, apiController, modelManager, serverSideValidation, $timeout) {
this.changePasswordPressed = function() { this.changePasswordPressed = function() {
this.showNewPasswordForm = !this.showNewPasswordForm; this.showNewPasswordForm = !this.showNewPasswordForm;
@@ -97,15 +97,15 @@ angular.module('app.frontend')
} }
this.forgotPasswordSubmit = function() { this.forgotPasswordSubmit = function() {
$auth.requestPasswordReset(this.resetData) // $auth.requestPasswordReset(this.resetData)
.then(function(resp) { // .then(function(resp) {
this.resetData.response = "Success"; // this.resetData.response = "Success";
// handle success response // // handle success response
}.bind(this)) // }.bind(this))
.catch(function(resp) { // .catch(function(resp) {
// handle error response // // handle error response
this.resetData.response = "Error"; // this.resetData.response = "Error";
}.bind(this)); // }.bind(this));
} }
this.encryptionStatusForNotes = function() { this.encryptionStatusForNotes = function() {

View File

@@ -19,36 +19,36 @@ angular.module('app.frontend')
}) })
// Auth routes // Auth routes
.state('auth', { // .state('auth', {
abstract: true, // abstract: true,
url: '/auth', // url: '/auth',
parent: 'base', // parent: 'base',
views: { // views: {
'content@' : { // 'content@' : {
templateUrl: 'frontend/auth/wrapper.html', // templateUrl: 'frontend/auth/wrapper.html',
} // }
} // }
}) // })
.state('auth.login', { // .state('auth.login', {
url: '/login', // url: '/login',
templateUrl: 'frontend/auth/login.html', // templateUrl: 'frontend/auth/login.html',
}) // })
.state('auth.forgot', { // .state('auth.forgot', {
url: '/forgot', // url: '/forgot',
templateUrl: 'frontend/auth/forgot.html', // templateUrl: 'frontend/auth/forgot.html',
}) // })
.state('auth.reset', { // .state('auth.reset', {
url: '/reset?reset_password_token&email', // url: '/reset?reset_password_token&email',
templateUrl: 'frontend/auth/reset.html', // templateUrl: 'frontend/auth/reset.html',
controller: function($rootScope, $stateParams) { // controller: function($rootScope, $stateParams) {
$rootScope.resetData = {reset_password_token: $stateParams.reset_password_token, email: $stateParams.email}; // $rootScope.resetData = {reset_password_token: $stateParams.reset_password_token, email: $stateParams.email};
//
// Clear reset_password_token on change state // // Clear reset_password_token on change state
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options) { // $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options) {
$rootScope.reset_password_token = null; // $rootScope.reset_password_token = null;
}); // });
}, // },
}) // })
// 404 Error // 404 Error

View File

@@ -29,7 +29,7 @@
<meta name="og:description" content="A private and secure personal notes/blogging system."/> <meta name="og:description" content="A private and secure personal notes/blogging system."/>
<% if Rails.env.development? %> <% if Rails.env.development? %>
<%= javascript_include_tag "compiled.js", debug: false %> <%= javascript_include_tag "compiled.js", debug: true %>
<% else %> <% else %>
<%= javascript_include_tag "compiled.min.js", debug: false %> <%= javascript_include_tag "compiled.min.js", debug: false %>

View File

@@ -10,10 +10,8 @@
"angular": "^1.6.0", "angular": "^1.6.0",
"angular-ui-router": "^0.2.18", "angular-ui-router": "^0.2.18",
"restangular": "^1.5.2", "restangular": "^1.5.2",
"ng-token-auth": "^0.0.29",
"oclazyload": "^1.0.9", "oclazyload": "^1.0.9",
"font-awesome": "^4.6.2", "font-awesome": "^4.6.2",
"angular-cookie": "4.1.0",
"marked": "0.3.4", "marked": "0.3.4",
"angular-lazy-img": "1.1.0", "angular-lazy-img": "1.1.0",
"ng-dialog" : "0.6.4" "ng-dialog" : "0.6.4"

View File

@@ -329,14 +329,14 @@ exports.SNCryptoWeb = SNCryptoWeb;
var Neeto = Neeto || {}; var Neeto = Neeto || {};
if (window.crypto.subtle) { if (window.crypto.subtle) {
console.log("using WebCrypto"); // console.log("using WebCrypto");
Neeto.crypto = new SNCryptoWeb(); Neeto.crypto = new SNCryptoWeb();
} else { } else {
console.log("using CryptoJS"); // console.log("using CryptoJS");
Neeto.crypto = new SNCryptoJS(); Neeto.crypto = new SNCryptoJS();
} }
angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ipCookie', 'oc.lazyLoad', 'angularLazyImg', 'ngDialog']).config(function (RestangularProvider, apiControllerProvider) { angular.module('app.frontend', ['ui.router', 'restangular', 'oc.lazyLoad', 'angularLazyImg', 'ngDialog']).config(function (RestangularProvider, apiControllerProvider) {
RestangularProvider.setDefaultHeaders({ "Content-Type": "application/json" }); RestangularProvider.setDefaultHeaders({ "Content-Type": "application/json" });
var url = apiControllerProvider.defaultServerURL(); var url = apiControllerProvider.defaultServerURL();
@@ -355,7 +355,10 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
httpConfig: httpConfig httpConfig: httpConfig
}; };
}); });
});angular.module('app.frontend').config(function ($stateProvider, $urlRouterProvider, $locationProvider) { }).config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);
;angular.module('app.frontend').config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$stateProvider.state('base', { $stateProvider.state('base', {
abstract: true abstract: true
@@ -374,33 +377,37 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
}) })
// Auth routes // Auth routes
.state('auth', { // .state('auth', {
abstract: true, // abstract: true,
url: '/auth', // url: '/auth',
parent: 'base', // parent: 'base',
views: { // views: {
'content@': { // 'content@' : {
templateUrl: 'frontend/auth/wrapper.html' // templateUrl: 'frontend/auth/wrapper.html',
} // }
} // }
}).state('auth.login', { // })
url: '/login', // .state('auth.login', {
templateUrl: 'frontend/auth/login.html' // url: '/login',
}).state('auth.forgot', { // templateUrl: 'frontend/auth/login.html',
url: '/forgot', // })
templateUrl: 'frontend/auth/forgot.html' // .state('auth.forgot', {
}).state('auth.reset', { // url: '/forgot',
url: '/reset?reset_password_token&email', // templateUrl: 'frontend/auth/forgot.html',
templateUrl: 'frontend/auth/reset.html', // })
controller: function controller($rootScope, $stateParams) { // .state('auth.reset', {
$rootScope.resetData = { reset_password_token: $stateParams.reset_password_token, email: $stateParams.email }; // url: '/reset?reset_password_token&email',
// templateUrl: 'frontend/auth/reset.html',
// controller: function($rootScope, $stateParams) {
// $rootScope.resetData = {reset_password_token: $stateParams.reset_password_token, email: $stateParams.email};
//
// // Clear reset_password_token on change state
// $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options) {
// $rootScope.reset_password_token = null;
// });
// },
// })
// Clear reset_password_token on change state
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams, options) {
$rootScope.reset_password_token = null;
});
}
})
// 404 Error // 404 Error
.state('404', { .state('404', {
@@ -737,7 +744,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
link: function link(scope, elem, attrs, ctrl) {} link: function link(scope, elem, attrs, ctrl) {}
}; };
}).controller('HeaderCtrl', function ($auth, $state, apiController, modelManager, serverSideValidation, $timeout) { }).controller('HeaderCtrl', function ($state, apiController, modelManager, serverSideValidation, $timeout) {
this.changePasswordPressed = function () { this.changePasswordPressed = function () {
this.showNewPasswordForm = !this.showNewPasswordForm; this.showNewPasswordForm = !this.showNewPasswordForm;
@@ -814,13 +821,15 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
}; };
this.forgotPasswordSubmit = function () { this.forgotPasswordSubmit = function () {
$auth.requestPasswordReset(this.resetData).then(function (resp) { // $auth.requestPasswordReset(this.resetData)
this.resetData.response = "Success"; // .then(function(resp) {
// handle success response // this.resetData.response = "Success";
}.bind(this)).catch(function (resp) { // // handle success response
// handle error response // }.bind(this))
this.resetData.response = "Error"; // .catch(function(resp) {
}.bind(this)); // // handle error response
// this.resetData.response = "Error";
// }.bind(this));
}; };
this.encryptionStatusForNotes = function () { this.encryptionStatusForNotes = function () {

File diff suppressed because one or more lines are too long