blob: 3d534b931d6e2b818dddc3053c72790402621180 [file] [log] [blame]
Matteo Scandolo817386b2015-11-04 16:07:09 +01001(function() {
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -07002 'use strict';
Matteo Scandolob585d382016-06-15 14:53:33 -07003
4 /* eslint-disable angular/ng_module_name */
5
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -07006 angular.module('bugSnag', []).factory('$exceptionHandler', function () {
7 return function (exception, cause) {
8 if( window.Bugsnag ){
9 Bugsnag.notifyException(exception, {diagnostics: {cause: cause}});
10 }
11 else{
12 console.error(exception, cause, exception.stack);
13 }
14 };
15 });
Matteo Scandoloba4c9aa2016-02-11 09:35:29 -080016
Matteo Scandolob585d382016-06-15 14:53:33 -070017 /* eslint-enable angular/ng_module_name */
18
Matteo Scandolo57404dc2016-04-13 16:20:13 -070019 /**
20 * @ngdoc overview
21 * @name xos.helpers
22 * @description this is the module that group all the helpers service and components for XOS
23 **/
24
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070025 angular
26 .module('xos.helpers', [
27 'ngCookies',
28 'ngResource',
Matteo Scandolob0280752016-04-25 10:31:22 -070029 'ngAnimate',
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070030 'bugSnag',
Matteo Scandolob9fb6252016-05-26 15:09:55 -070031 'xos.uiComponents'
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070032 ])
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070033 .config(config)
Matteo Scandolo974c0e42016-05-25 16:02:16 -070034
35 /**
36 * @ngdoc service
37 * @name xos.helpers._
38 * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service
39 **/
40
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070041 .factory('_', $window => $window._ );
Matteo Scandolo817386b2015-11-04 16:07:09 +010042
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070043 function config($httpProvider, $interpolateProvider, $resourceProvider) {
44 $httpProvider.interceptors.push('SetCSRFToken');
Matteo Scandolo817386b2015-11-04 16:07:09 +010045
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070046 $interpolateProvider.startSymbol('{$');
47 $interpolateProvider.endSymbol('$}');
Matteo Scandolo817386b2015-11-04 16:07:09 +010048
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070049 // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
50 $resourceProvider.defaults.stripTrailingSlashes = false;
51 }
Matteo Scandolo817386b2015-11-04 16:07:09 +010052})();