InvenTree icon indicating copy to clipboard operation
InvenTree copied to clipboard

[BUG] Machine Printing Plugin does not show/open options for selecting Machine (especially in App not functioning)

Open thehe opened this issue 9 months ago • 13 comments

When selecting the "InvenTreeLabelMaschine"-Printing Plugin with label printing, I find some strange behaviour (on the master branch).

The Options for the Mschine-Plugin does not show the selection of the maschine. The machine itself is not configured to be bound to a specific location (location filter).

Stock-Locations: From WEB-UI from "stock/locations/X/sublocations" view, via Print-Icon --> no options, no errors (no errors at nginx, no errors at supervisor/gunicorn, no errors in JS-console) from "stock/locations/X/details" view, vie Print-Icon --> works only some times! only if you go back and forth all the time, sometimes it works Image

Parts: From WEB-UI works from everywhere Image

thought it could be a cache problem in the reverse-proxy and set it to "no-cache" for /api, but that does not solve the issue.

ANY LABEL From APP does not work, no options shown to select the right printer.

Anybody who has any idea what's going wrong there? Is it a regression-bug or never worked in the app?

thehe avatar Mar 17 '25 16:03 thehe

Update: the call to "/api/label/print/?plugin=inventreelabelmachine" is correctly made, even when options not shown.

thehe avatar Mar 17 '25 16:03 thehe

What specific version of InvenTree are you running?

SchrodingersGat avatar Mar 18 '25 00:03 SchrodingersGat

What specific version of InvenTree are you running?

tried with current master branch and the 0.17.9... could not figure out any difference

thehe avatar Mar 18 '25 09:03 thehe

Can you also open the devtools and go to the network tab. Are you seeing OPTIONS requests being made when switching between the available printing drivers? Is there any difference between the working form and the for you non working form in requests there?

wolflu05 avatar Mar 18 '25 09:03 wolflu05

Can you also open the devtools and go to the network tab. Are you seeing OPTIONS requests being made when switching between the available printing drivers? Is there any difference between the working form and the for you non working form in requests there?

As I pointed already out, yes - the OPTIONS request is sent.

Interestingly a chrome-update now shows the reason (I guess):

"Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden. Element with focus: button Ancestor with aria-hidden:"

this is shown in dev-tools (now! not yesterday or the days before), when it should be displayed

thehe avatar Mar 18 '25 10:03 thehe

update: works in firefox

thehe avatar Mar 18 '25 10:03 thehe

I initially thought that this complex (problems) come together with the app-problem, where the options selection is not available in any way... :-(

thehe avatar Mar 18 '25 10:03 thehe

@thehe are you saying that the issue is related to a particular browser?

SchrodingersGat avatar Mar 18 '25 22:03 SchrodingersGat

@thehe are you saying that the issue is related to a particular browser?

seems to be -- screenshots underneath....

the aria-message appears a bit randomly but seems to be related to the problem, because it does not show up, when the options-loading worked.

For better understanding: How it's called internally - the "second load" of options after selection of a machine?

Image Image

thehe avatar Mar 19 '25 01:03 thehe

In the "network" tab can you show the results of both the OPTIONS requests? Both the payload and the actual response from the server

SchrodingersGat avatar Mar 19 '25 01:03 SchrodingersGat

Request-Headers:

OPTIONS /api/label/print/?plugin=inventreelabelmachine HTTP/1.1
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en, en-us
Authorization: Token inv-b43387c7d1ebc249b4b61c8c1a570ff50e26ccb1-20240617
Connection: keep-alive
Cookie: sessionid=mn58r08ucr5n4zk2p82um5gug9noh4sx; csrftoken=5K41N4TXRf8B6pZ7qNzQ2lW6DYnTuHGU
DNT: 1
Host: xx.yy.de
Origin: https://xx.yy.de
Referer: https:/xx.yy.de/platform/stock/location/2/sublocations
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
X-CSRFToken: 5K41N4TXRf8B6pZ7qNzQ2lW6DYnTuHGU
sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"

Payload:

plugin=inventreelabelmachine

Response-Headers:

HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Wed, 19 Mar 2025 04:32:07 GMT
Content-Type: application/json
Content-Length: 1409
Connection: keep-alive
Vary: Accept, origin, Accept-Language, Cookie
Allow: POST, OPTIONS
X-Frame-Options: DENY
access-control-allow-origin: https://xx.yy.de
access-control-allow-credentials: true
access-control-allow-headers: accept, authorization, content-type, user-agent, x-csrftoken, x-requested-with
access-control-allow-methods: DELETE, GET, OPTIONS, PATCH, POST, PUT
access-control-max-age: 86400
Content-Language: en
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin

Response-Payload:

{
    "name": "Label Print",
    "description": "API endpoint for printing labels.",
    "renders": [
        "application/json",
        "text/html"
    ],
    "parses": [
        "application/json",
        "application/x-www-form-urlencoded",
        "multipart/form-data"
    ],
    "actions": {
        "POST": {
            "template": {
                "type": "related field",
                "required": true,
                "read_only": false,
                "label": "Template",
                "help_text": "Select label template",
                "model": "labeltemplate",
                "api_url": "/api/label/template/",
                "pk_field": "pk"
            },
            "plugin": {
                "type": "related field",
                "required": false,
                "read_only": false,
                "label": "Printing Plugin",
                "help_text": "Select plugin to use for label printing",
                "model": "pluginconfig",
                "api_url": "/api/plugins/",
                "pk_field": "key"
            },
            "items": {
                "type": "list",
                "required": true,
                "read_only": false,
                "label": "Items",
                "help_text": "List of item primary keys to include in the report",
                "child": {
                    "type": "integer",
                    "required": true,
                    "read_only": false
                }
            },
            "machine": {
                "type": "choice",
                "required": true,
                "read_only": false,
                "label": "Machine",
                "choices": [
                    {
                        "value": "da4e9ab4-157b-41ad-bca6-2600936c1fd7",
                        "display_name": "BrotherPortable"
                    }
                ],
                "default": "da4e9ab4-157b-41ad-bca6-2600936c1fd7"
            },
            "driver_options": {
                "type": "dependent field",
                "required": false,
                "read_only": false,
                "label": "Options",
                "child": {
                    "type": "nested object",
                    "required": true,
                    "read_only": false,
                    "children": {
                        "copies": {
                            "type": "integer",
                            "required": false,
                            "read_only": false,
                            "label": "Copies",
                            "help_text": "Number of copies to print for each label",
                            "default": 1
                        }
                    }
                },
                "depends_on": [
                    "machine"
                ]
            }
        }
    }
}

thehe avatar Mar 19 '25 04:03 thehe

The response looks OK.

Can you please clarify - your original comment mentions the app - the app does not yet support machine printing

SchrodingersGat avatar Mar 19 '25 04:03 SchrodingersGat

The response looks OK.

Can you please clarify - your original comment mentions the app - the app does not yet support machine printing

I thought that the problem results in both - not working in browser (as stated in previous comments), AND not working in the app. Only after the discussions in the issues it got clear, that the app does not support machine-printing which I could not have been thinking about before. For me it's a "must-have" to print labels while sorting/moving things around...

So...

  1. "no bug in app" -- ticket closed in the repo
  2. "bug in browser" -- as shown above

thehe avatar Mar 20 '25 17:03 thehe