Change API paths.
This commit is contained in:
parent
880a57de96
commit
b9c9199c78
@ -143,8 +143,8 @@ class AccountResource(Resource):
|
||||
return None, 204
|
||||
|
||||
|
||||
api.add_resource(AccountListResource, '/accounts')
|
||||
api.add_resource(AccountResource, '/accounts/<int:id>')
|
||||
api.add_resource(AccountListResource, '/account')
|
||||
api.add_resource(AccountResource, '/account/<int:id>')
|
||||
|
||||
|
||||
range_parser = reqparse.RequestParser()
|
||||
@ -163,10 +163,10 @@ category_model = {
|
||||
class CategoryResource(Resource):
|
||||
@requires_auth
|
||||
@marshal_with_field(fields.List(Object(category_model)))
|
||||
def get(self):
|
||||
def get(self, id):
|
||||
data = range_parser.parse_args()
|
||||
|
||||
return Operation.get_categories_for_range(**data).all(), 200
|
||||
return Operation.get_categories_for_range(id, **data).all()
|
||||
|
||||
|
||||
ohlc_model = {
|
||||
@ -181,11 +181,11 @@ ohlc_model = {
|
||||
class OHLCResource(Resource):
|
||||
@requires_auth
|
||||
@marshal_with_field(fields.List(Object(ohlc_model)))
|
||||
def get(self):
|
||||
def get(self, id):
|
||||
data = range_parser.parse_args()
|
||||
|
||||
return Operation.get_ohlc_per_day_for_range(**data).all(), 200
|
||||
return Operation.get_ohlc_per_day_for_range(id, **data).all()
|
||||
|
||||
|
||||
api.add_resource(CategoryResource, "/categories")
|
||||
api.add_resource(OHLCResource, "/solds")
|
||||
api.add_resource(CategoryResource, "/account/<int:id>/categories")
|
||||
api.add_resource(OHLCResource, "/account/<int:id>/solds")
|
||||
|
@ -136,5 +136,5 @@ class OperationResource(Resource):
|
||||
return None, 204
|
||||
|
||||
|
||||
api.add_resource(OperationListResource, "/operations")
|
||||
api.add_resource(OperationResource, "/operations/<int:id>")
|
||||
api.add_resource(OperationListResource, "/operation")
|
||||
api.add_resource(OperationResource, "/operation/<int:id>")
|
||||
|
@ -168,6 +168,6 @@ class ScheduledOperationResource(Resource):
|
||||
return None, 204
|
||||
|
||||
|
||||
api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
|
||||
api.add_resource(ScheduledOperationListResource, "/scheduled_operation")
|
||||
api.add_resource(ScheduledOperationResource,
|
||||
"/scheduled_operations/<int:id>")
|
||||
"/scheduled_operation/<int:id>")
|
||||
|
@ -126,4 +126,4 @@ class LoginResource(Resource):
|
||||
return g.user
|
||||
|
||||
|
||||
api.add_resource(LoginResource, "/users/login")
|
||||
api.add_resource(LoginResource, "/user/login")
|
||||
|
@ -20,7 +20,7 @@ accountantApp
|
||||
|
||||
.factory("Account", ["$resource", function($resource) {
|
||||
return $resource(
|
||||
"/api/accounts/:id", {
|
||||
"/api/account/:id", {
|
||||
id: "@id"
|
||||
}
|
||||
);
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -18,7 +18,7 @@ accountantApp
|
||||
|
||||
.factory("ScheduledOperation", ["$resource", function($resource) {
|
||||
return $resource(
|
||||
"/api/scheduled_operations/:id", {
|
||||
"/api/scheduled_operation/:id", {
|
||||
id: "@id"
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user