blob: 4ffc99da5364b57181a836fee01c69a256207e83 [file] [log] [blame]
Matteo Scandolo817386b2015-11-04 16:07:09 +01001(function() {
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -07002 'use strict';
Matteo Scandolo57404dc2016-04-13 16:20:13 -07003
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -07004 angular.module('bugSnag', []).factory('$exceptionHandler', function () {
5 return function (exception, cause) {
6 if( window.Bugsnag ){
7 Bugsnag.notifyException(exception, {diagnostics: {cause: cause}});
8 }
9 else{
10 console.error(exception, cause, exception.stack);
11 }
12 };
13 });
Matteo Scandoloba4c9aa2016-02-11 09:35:29 -080014
Matteo Scandolo57404dc2016-04-13 16:20:13 -070015 /**
16 * @ngdoc overview
17 * @name xos.helpers
18 * @description this is the module that group all the helpers service and components for XOS
19 **/
20
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070021 angular
22 .module('xos.helpers', [
23 'ngCookies',
24 'ngResource',
Matteo Scandolob0280752016-04-25 10:31:22 -070025 'ngAnimate',
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070026 'bugSnag',
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070027 'xos.uiComponents',
Matteo Scandolo03d8b8e2016-05-25 17:37:37 -070028 'RecursionHelper'
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070029 ])
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070030 .config(config)
Matteo Scandolo974c0e42016-05-25 16:02:16 -070031
32 /**
33 * @ngdoc service
34 * @name xos.helpers._
35 * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service
36 **/
37
Matteo Scandolo7bc39c42016-04-20 11:38:42 -070038 .factory('_', $window => $window._ );
Matteo Scandolo817386b2015-11-04 16:07:09 +010039
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070040 function config($httpProvider, $interpolateProvider, $resourceProvider) {
41 $httpProvider.interceptors.push('SetCSRFToken');
Matteo Scandolo817386b2015-11-04 16:07:09 +010042
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070043 $interpolateProvider.startSymbol('{$');
44 $interpolateProvider.endSymbol('$}');
Matteo Scandolo817386b2015-11-04 16:07:09 +010045
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070046 // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
47 $resourceProvider.defaults.stripTrailingSlashes = false;
48 }
Matteo Scandolo817386b2015-11-04 16:07:09 +010049})();