mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Fixed LABEL_PRINTER_HOOK_JSON check was missing when running label printer WebHooks client side (fixes #1978)
This commit is contained in:
parent
c396c2a84c
commit
d883474f03
@ -57,6 +57,7 @@
|
||||
|
||||
### General
|
||||
|
||||
- Fixed that when running label printer WebHooks client side (so when `LABEL_PRINTER_RUN_SERVER` = `false`), the setting `LABEL_PRINTER_HOOK_JSON` was ignored (the WebHook data was always sent as form data)
|
||||
- New translations: (thanks all the translators)
|
||||
- Lithuanian (demo available at <https://lt.demo.grocy.info>)
|
||||
|
||||
|
@ -505,14 +505,28 @@ Grocy.FrontendHelpers.RunWebhook = function(webhook, data, repetitions = 1)
|
||||
|
||||
for (i = 0; i < repetitions; i++)
|
||||
{
|
||||
$.post(webhook.hook, data).fail(function(req, status, errorThrown)
|
||||
if (webhook.json)
|
||||
{
|
||||
if (!hasAlreadyFailed)
|
||||
$.ajax(webhook.hook, { "data": JSON.stringify(data), "contentType": "application/json", "type": "POST" }).fail(function(req, status, errorThrown)
|
||||
{
|
||||
hasAlreadyFailed = true;
|
||||
Grocy.FrontendHelpers.ShowGenericError(__t("Error while executing WebHook", { "status": status, "errorThrown": errorThrown }));
|
||||
}
|
||||
});
|
||||
if (!hasAlreadyFailed)
|
||||
{
|
||||
hasAlreadyFailed = true;
|
||||
Grocy.FrontendHelpers.ShowGenericError(__t("Error while executing WebHook", { "status": status, "errorThrown": errorThrown }));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$.post(webhook.hook, data).fail(function(req, status, errorThrown)
|
||||
{
|
||||
if (!hasAlreadyFailed)
|
||||
{
|
||||
hasAlreadyFailed = true;
|
||||
Grocy.FrontendHelpers.ShowGenericError(__t("Error while executing WebHook", { "status": status, "errorThrown": errorThrown }));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,9 @@
|
||||
Grocy.Webhooks = {
|
||||
@if(GROCY_FEATURE_FLAG_LABEL_PRINTER && !GROCY_LABEL_PRINTER_RUN_SERVER)
|
||||
"labelprinter" : {
|
||||
"hook" : "{{ GROCY_LABEL_PRINTER_WEBHOOK}}",
|
||||
"extra_data" : {!! json_encode(GROCY_LABEL_PRINTER_PARAMS) !!}
|
||||
"hook": "{{ GROCY_LABEL_PRINTER_WEBHOOK }}",
|
||||
"extra_data": {!! json_encode(GROCY_LABEL_PRINTER_PARAMS) !!},
|
||||
"json": {{ BoolToString(GROCY_LABEL_PRINTER_HOOK_JSON) }}
|
||||
}
|
||||
@endif
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user