fix(dashboard): display dashboard images configured via external URL link - #313
Merged
deaflynx merged 10 commits intoSep 8, 2026
Merged
Conversation
…t-client Feat/migrate new dart client
…-back-button fix(dashboard): make system back mirror the AppBar back arrow
…url-link' into fix/dashboard-image-external-url-link
Address review feedback on PR thingsboard#249: - use the prefix-stripped url consistently and rename it to resolvedImageUrl, matching ImageService.resolveImageUrl on the web - anchor the tb-image prefix strip so an occurrence inside a link is kept - replace _isValidUrl, which accepted almost any string, with _resolveNetworkImageLink: absolute http/https links are fetched as they are, platform-relative links such as an image public link are resolved against the active endpoint the way a browser resolves them against its origin, and anything else renders the missing image
…url-link' into fix/dashboard-image-external-url-link Conflict in lib/utils/utils.dart resolved by keeping the PE whitelabel login logo branch and taking the rename to resolvedImageUrl, which also brings the image resource check onto the prefix-stripped value.
…url-link' into fix/dashboard-image-external-url-link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merges the CE fix (thingsboard/flutter_thingsboard_app#249) from
ce-origin/fix/dashboard-image-external-url-link, plus one PE-side resolution noted below.Dashboard cards on the Home grid showed an empty white box instead of the thumbnail when the dashboard image was configured via the "Image link" field. Images uploaded to the Image Gallery displayed fine.
Fixes PROD-8502.
Two distinct inputs produced the same empty box, and both are fixed here:
https://example.com/pic.png/api/images/public/{key}, found while reviewing (1) and reproduced on a deviceRoot cause
The platform stores every dashboard image value with a
tb-image;prefix, external URLs included (prependTbImagePrefixingallery-image-input.component.ts).Utils.imageFromTbImagecomputed the prefix-stripped URL but only used it in the gallery-resource branch, while the base64 and external-URL branches checked and loaded the raw prefixed string.Uri.tryParse('tb-image;https://…')returnsnull, so external links fell through to the error placeholder — a transparent 1×1 GIF stretched by the card'sFittedBox, which renders as the empty white box.The public-link case has a separate cause.
TbResourceInfo.getPublicLink()returns a relative path, the "Embed image" dialog hands users exactly that string, and the "Image link" field has no validators.IMAGES_URL_REGEXPmatches onlytenant|system, so a public link is classified as external, and_isValidUrl— which was justUri.tryParse(url) != nulland therefore true for almost any string — let the relative path reachImage.network, where it cannot be fetched at all (ArgumentError: No host specified in URI).Changes
resolvedImageUrlto matchImageService.resolveImageUrlon the web side.tb-image;strip withstartsWith/substringinstead ofreplaceFirst, so an occurrence inside a link is no longer removed._isValidUrlwith_resolveNetworkImageLink, which classifies and resolves in one step: absolutehttp/httpslinks are fetched as they are, platform-relative links resolve against the active endpoint the way a browser resolves them against its origin, and anything without a meaningful target renders the missing image. Resolved relative links carry no auth header, matching the platform —/api/images/public/{key}is anoauthendpoint and a browser<img src>does not send the JWT either.Since
imageFromTbImagealso backs device and device-profile images, this repairs image links there too, not only the dashboard grid.Behaviour
https://example.com/pic.pngtb-image;https://example.com/pic.png/api/images/tenant/pic.png/api/images/public/pic.pngdata:image/png;base64,…ftp://…, or text that is not a linkTest plan
PE-specific note
The merge conflicted in
lib/utils/utils.dart, in the image-resource branch that PE rewrote for the whitelabel login logo. Resolved by keeping the PEloginLogostructure and taking the rename toresolvedImageUrl.That resolution also brings PE's
_isImageResourceUrlcheck onto the prefix-stripped value, where it was previously testing the still-prefixed string. Behaviour is unchanged today, because_imagesUrlRegexpis unanchored and matches with or without the prefix — but it puts PE in line with CE and is a prerequisite for anchoring that pattern, which would otherwise classify every gallery image as external in PE.