Rework API to be more RESTful (references #139)

This commit is contained in:
Bernd Bestel
2019-01-19 14:51:51 +01:00
parent 0ce8d706a6
commit bfa59dd29c
52 changed files with 1110 additions and 1143 deletions

View File

@@ -5,10 +5,14 @@
var jsonForm = $('#inventory-form').serializeJSON();
Grocy.FrontendHelpers.BeginUiBusy("inventory-form");
Grocy.Api.Get('stock/' + jsonForm.product_id,
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
function (productDetails)
{
Grocy.Api.Post('stock/' + jsonForm.product_id + '/inventory/' + jsonForm.new_amount + '?bestbeforedate=' + Grocy.Components.DateTimePicker.GetValue(),
var jsonData = { };
jsonData.new_amount = jsonForm.new_amount;
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
Grocy.Api.Post('stock/products/' + jsonForm.product_id + '/inventory', jsonData,
function(result)
{
var addBarcode = GetUriParam('addbarcodetoselection');
@@ -24,7 +28,7 @@
productDetails.product.barcode += ',' + addBarcode;
}
Grocy.Api.Put('object/products/' + productDetails.product.id, productDetails.product,
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
function (result) { },
function(xhr)
{
@@ -73,7 +77,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
Grocy.Components.ProductCard.Refresh(productId);
Grocy.Api.Get('stock/' + productId,
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
$('#new_amount').attr('not-equal', productDetails.stock_amount);
@@ -157,7 +161,7 @@ $('#new_amount').on('keyup', function(e)
if (productId)
{
Grocy.Api.Get('stock/' + productId,
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
var productStockAmount = parseInt(productDetails.stock_amount || '0');