Change app and controller declaration.

This commit is contained in:
Alexis Lahouze 2015-06-13 19:54:17 +02:00
parent 65718acb5b
commit 6edf83a382
6 changed files with 64 additions and 67 deletions

View File

@ -25,7 +25,8 @@ function account() {
}; };
// The AccountController. // The AccountController.
var AccountController = function($scope, $http, $rootScope, $window) { accountantApp.controller(
"AccountController", function($scope, $http, $rootScope, $window) {
// Account store and selection // Account store and selection
$scope.account = null; $scope.account = null;
$scope.accounts = []; $scope.accounts = [];
@ -193,5 +194,4 @@ var AccountController = function($scope, $http, $rootScope, $window) {
$rootScope.$on("operationRemovedEvent", $scope.loadAccounts); $rootScope.$on("operationRemovedEvent", $scope.loadAccounts);
$scope.loadAccounts(); $scope.loadAccounts();
}; });

View File

@ -0,0 +1,49 @@
/*
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", [
"mgcrea.ngStrap"
])
.config(function($interpolateProvider, $httpProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
$httpProvider.interceptors.push(function($q) {
return {
"response": function(response) {
console.debug(response)
if(response.data.ok == false) {
return $q.reject(response)
}
// TODO Intercept validation error.
return response;
},
"responseError": function(response) {
// TODO Intercept Authentication Required error
$.pnotify({
type: "error",
title: response.data.title,
text: response.data.text,
width: 300
})
return $q.reject(response);
}
};
});
});

View File

@ -14,7 +14,8 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>. along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/ */
var EntryController = function($scope, $http, $rootScope, $filter) { accountantApp.controller(
"EntryController", function($scope, $http, $rootScope, $filter) {
// Entry store and selection // Entry store and selection
$scope.entries = []; $scope.entries = [];
$scope.categories = []; $scope.categories = [];
@ -463,5 +464,4 @@ var EntryController = function($scope, $http, $rootScope, $filter) {
$scope.$on("entriesLoadedEvent", function(event, args) { $scope.$on("entriesLoadedEvent", function(event, args) {
$scope.entriesLoaded(args.entries); $scope.entriesLoaded(args.entries);
}); });
}; });

View File

@ -21,7 +21,8 @@ function month() {
} }
var MonthController = function($scope, $http, $rootScope) { accountantApp.controller(
"MonthController", function($scope, $http, $rootScope) {
// Month store and selection // Month store and selection
$scope.months = null; $scope.months = null;
$scope.month = null; $scope.month = null;
@ -112,5 +113,4 @@ var MonthController = function($scope, $http, $rootScope) {
$rootScope.$on("accountsLoadedEvent", function(event, args) { $rootScope.$on("accountsLoadedEvent", function(event, args) {
$scope.loadMonths(args.account); $scope.loadMonths(args.account);
}); });
}; });

View File

@ -14,7 +14,8 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>. along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/ */
var SchedulerController = function($scope, $http, $rootScope, $filter) { accountantApp.controller(
"SchedulerController", function($scope, $http, $rootScope, $filter) {
// Operations store and selection // Operations store and selection
$scope.operations = []; $scope.operations = [];
$scope.selectedOperation = null; $scope.selectedOperation = null;
@ -194,4 +195,4 @@ var SchedulerController = function($scope, $http, $rootScope, $filter) {
$rootScope.$on("accountsLoadedEvent", function(event, args){ $rootScope.$on("accountsLoadedEvent", function(event, args){
$scope.loadOperations(args.account); $scope.loadOperations(args.account);
}); });
} });

View File

@ -15,7 +15,7 @@
along with Accountant. If not, see <http://www.gnu.org/licenses/>. along with Accountant. If not, see <http://www.gnu.org/licenses/>.
#} #}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr" ng-app="$strap"> <html lang="fr" ng-app="accountantApp">
<head> <head>
<!-- Title --> <!-- Title -->
<title>Entries</title> <title>Entries</title>
@ -83,65 +83,12 @@
</div> </div>
{% block footer %}{% endblock %} {% block footer %}{% endblock %}
<script type="text/javascript" src="https://raw.githubusercontent.com/moment/moment/develop/min/moment.min.js"></script> <script type="text/javascript" src="{{ url_for('frontend.static', filename="build/js/vendor.js") }}"></script>
<!-- JQuery Javascript library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<!-- Bootstrap Javascript library -->
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<!-- Bootstrap datepicker module -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.0.2/js/bootstrap-datepicker.min.js"></script>
<!-- Angular Javascript library -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.3/angular.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-strap/0.7.4/angular-strap.js"></script>
<!-- D3 Plotting framework -->
<script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script>
<!-- NVD3 framework -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.13-beta/nv.d3.js"></script>
<!-- Pines Notify JQuery plugin -->
<script type="text/javascript" src="{{ url_for('frontend.static', filename='third-party/pines-notify/jquery.pnotify.min.js') }}"></script>
<!-- Custom Javascript library for entries --> <!-- Custom Javascript library for entries -->
{% block js %}{% endblock %} <script type="text/javascript" src="{{ url_for('frontend.static', filename='build/js/app.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
angular.module('$strap').config(function($interpolateProvider, $httpProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
$httpProvider.responseInterceptors.push(['$rootScope', '$q', function(scope, $q) {
function success(response) {
console.debug(response)
if(response.data.ok == false) {
return $q.reject(response)
}
// TODO Intercept validation error.
return response;
}
function error(response) {
// TODO Intercept Authentication Required error
$.pnotify({
type: "error",
title: response.data.title,
text: response.data.text,
width: 300
})
return $q.reject(response);
}
return function(promise) {
return promise.then(success, error);
}
}]);
});
</script> </script>
</body> </body>
</html> </html>