Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 1 | (function() { |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 2 | 'use strict'; |
Matteo Scandolo | b585d38 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 3 | |
| 4 | /* eslint-disable angular/ng_module_name */ |
| 5 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 6 | 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 Scandolo | ba4c9aa | 2016-02-11 09:35:29 -0800 | [diff] [blame] | 16 | |
Matteo Scandolo | b585d38 | 2016-06-15 14:53:33 -0700 | [diff] [blame] | 17 | /* eslint-enable angular/ng_module_name */ |
| 18 | |
Matteo Scandolo | 57404dc | 2016-04-13 16:20:13 -0700 | [diff] [blame] | 19 | /** |
| 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 Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 25 | angular |
| 26 | .module('xos.helpers', [ |
| 27 | 'ngCookies', |
| 28 | 'ngResource', |
Matteo Scandolo | b028075 | 2016-04-25 10:31:22 -0700 | [diff] [blame] | 29 | 'ngAnimate', |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 30 | 'bugSnag', |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 31 | 'xos.uiComponents' |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 32 | ]) |
Matteo Scandolo | 7bc39c4 | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 33 | .config(config) |
Matteo Scandolo | 974c0e4 | 2016-05-25 16:02:16 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * @ngdoc service |
| 37 | * @name xos.helpers._ |
| 38 | * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service |
| 39 | **/ |
| 40 | |
Matteo Scandolo | 7bc39c4 | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 41 | .factory('_', $window => $window._ ); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 42 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 43 | function config($httpProvider, $interpolateProvider, $resourceProvider) { |
| 44 | $httpProvider.interceptors.push('SetCSRFToken'); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 45 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 46 | $interpolateProvider.startSymbol('{$'); |
| 47 | $interpolateProvider.endSymbol('$}'); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 48 | |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 49 | // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html |
| 50 | $resourceProvider.defaults.stripTrailingSlashes = false; |
| 51 | } |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 52 | })(); |