blob: 3d534b931d6e2b818dddc3053c72790402621180 [file] [log] [blame]
Matteo Scandolo889ced32015-11-04 16:07:09 +01001(function() {
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -07002 'use strict';
Matteo Scandolob2a1a182016-06-15 14:53:33 -07003
4 /* eslint-disable angular/ng_module_name */
5
Matteo Scandolo2ef0cd72016-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 Scandolo32f83922016-02-11 09:35:29 -080016
Matteo Scandolob2a1a182016-06-15 14:53:33 -070017 /* eslint-enable angular/ng_module_name */
18
Matteo Scandolo45a5c562016-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 Scandolo2ef0cd72016-04-12 11:59:29 -070025 angular
26 .module('xos.helpers', [
27 'ngCookies',
28 'ngResource',
Matteo Scandoloc88bb9f2016-04-25 10:31:22 -070029 'ngAnimate',
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070030 'bugSnag',
Matteo Scandolo2aca9ab2016-05-26 15:09:55 -070031 'xos.uiComponents'
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070032 ])
Matteo Scandoloc49f53c2016-04-20 11:38:42 -070033 .config(config)
Matteo Scandolo741d6b42016-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 Scandoloc49f53c2016-04-20 11:38:42 -070041 .factory('_', $window => $window._ );
Matteo Scandolo889ced32015-11-04 16:07:09 +010042
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070043 function config($httpProvider, $interpolateProvider, $resourceProvider) {
44 $httpProvider.interceptors.push('SetCSRFToken');
Matteo Scandolo889ced32015-11-04 16:07:09 +010045
Matteo Scandolo2ef0cd72016-04-12 11:59:29 -070046 $interpolateProvider.startSymbol('{$');
47 $interpolateProvider.endSymbol('$}');
Matteo Scandolo889ced32015-11-04 16:07:09 +010048
Matteo Scandolo2ef0cd72016-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 Scandolo889ced32015-11-04 16:07:09 +010052})();