grocy/public/viewjs/uploadjson.js
Zeb Fross aa91418364 Add form to upload kroger receipt data
Add a new menu option to "Upload JSON" that will accept Kroger grocery
store json receipt data.
2020-04-01 19:33:57 -07:00

27 lines
739 B
JavaScript

$('#upload-json-button').on('click', function(e)
{
e.preventDefault();
var redirectDestination = U('/stockoverview');
var returnTo = GetUriParam('returnto');
if (returnTo !== undefined)
{
redirectDestination = U(returnTo);
}
var jsonData = $('#json-form').serializeJSON({ checkboxUncheckedValue: "0" });
Grocy.FrontendHelpers.BeginUiBusy("json-form");
Grocy.Api.Post('uploadjson', jsonData,
function(result)
{
window.location.href = redirectDestination
},
function (xhr)
{
Grocy.FrontendHelpers.EndUiBusy("json-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably an error in the json', xhr.response)
}
);
});