2015-07-19 15:16:31 +02:00

64 lines
2.1 KiB
JavaScript

/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
var accountantApp = angular.module("accountantApp", [
'ngResource', 'ngRoute',
"mgcrea.ngStrap",
"highcharts-ng"
])
.config(function($httpProvider, $routeProvider, $locationProvider) {
$httpProvider.interceptors.push(function($q) {
return {
"response": function(response) {
if(response.data.ok === false) {
return $q.reject(response);
}
// TODO Intercept validation error.
return response;
},
"responseError": function(response) {
// TODO Intercept Authentication Required error
new PNotify({
type: "error",
title: response.data.title,
text: response.data.text,
width: 300
});
return $q.reject(response);
}
};
});
$routeProvider.when('/account/:accountId/entries', {
templateUrl: 'static/templates/entries.html',
controller: 'EntryController'
}).when('/account/:accountId/scheduler', {
templateUrl: 'static/templates/scheduler.html',
controller: 'SchedulerController'
}).when('/accounts', {
templateUrl: 'static/templates/accounts.html',
controller: 'AccountController'
}).when('/', {
redirectTo: 'accounts'
});
$locationProvider.html5Mode(true);
})
;