Change API paths.

This commit is contained in:
Alexis Lahouze
2016-01-13 12:29:12 +01:00
parent 880a57de96
commit b9c9199c78
8 changed files with 43 additions and 32 deletions

View File

@ -20,7 +20,7 @@ accountantApp
.factory("Account", ["$resource", function($resource) {
return $resource(
"/api/accounts/:id", {
"/api/account/:id", {
id: "@id"
}
);

View File

@ -123,7 +123,7 @@ var accountantApp = angular.module("accountantApp", [
var email = $('#email').val();
var password = $('#password').val();
$http.post(
"/api/users/login",
"/api/user/login",
{
"email": email,
"password": password

View File

@ -19,19 +19,37 @@ accountantApp
.factory("Operation", [ "$resource", function($resource) {
return $resource(
"/api/operations/:id", {
"/api/operation/:id", {
id: "@id"
}
);
}])
.factory("OHLC", [ "$resource", "$routeParams",
function($resource, $routeParams) {
return $resource(
"/api/account/:account_id/ohlc", {
account_id: $routeParams.accountId
}
);
}])
.factory("Category", [ "$resource", "$routeParams",
function($resource, $routeParams) {
return $resource(
"/api/account/:account_id/category", {
account_id: $routeParams.accountId
}
);
}])
/*
* Controller for category chart.
*/
.controller(
"CategoryChartController", [
"$rootScope", "$scope", "$http", "$routeParams",
function($rootScope, $scope, $http, $routeParams) {
"$rootScope", "$scope", "$http", "$routeParams", "Category",
function($rootScope, $scope, $http, $routeParams, Category) {
var colors = Highcharts.getOptions().colors;
$scope.revenueColor = colors[2];
@ -101,13 +119,10 @@ accountantApp
$scope.load = function(begin, end) {
$scope.config.loading = true;
$http.get("/api/categories", {
params: {
account: $routeParams.accountId,
Category.query({
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
}
}).success(function(data) {
}, function(data) {
var expenses = [], revenues = [];
var expenseColor = $scope.brightenColor($scope.expenseColor);
@ -138,7 +153,7 @@ accountantApp
* Get account status.
*/
$scope.getAccountStatus = function(begin, end) {
$http.get("/api/accounts/" + $routeParams.accountId, {
$http.get("/api/account/" + $routeParams.accountId, {
params: {
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
@ -176,8 +191,8 @@ accountantApp
*/
.controller(
"SoldChartController", [
"$rootScope", "$scope", "$http", "$routeParams",
function($rootScope, $scope, $http, $routeParams) {
"$rootScope", "$scope", "$http", "OHLC",
function($rootScope, $scope, $http, OHLC) {
// Configure chart for operations.
$scope.config = {
options: {
@ -271,11 +286,7 @@ accountantApp
$scope.loadSolds = function() {
$scope.config.loading = true;
$http.get("/api/solds", {
params: {
account: $routeParams.accountId,
}
}).success(function(data) {
OHLC.query({}, function(data) {
$scope.config.series[0].data = [];
angular.forEach(data, function(operation) {

View File

@ -18,7 +18,7 @@ accountantApp
.factory("ScheduledOperation", ["$resource", function($resource) {
return $resource(
"/api/scheduled_operations/:id", {
"/api/scheduled_operation/:id", {
id: "@id"
}
);