From d16fe3ac60d1fc4ec27a6dd31a581672310d25c8 Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Fri, 10 Jan 2025 04:24:04 +1000 Subject: [PATCH] Thing details: Make link in Thing status description clickable (#2996) Resolve #2994 Signed-off-by: Jimmy Tanagra --- .../src/components/thing/thing-status-mixin.js | 17 +++++++++++++++++ .../src/pages/settings/things/thing-details.vue | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/thing/thing-status-mixin.js b/bundles/org.openhab.ui/web/src/components/thing/thing-status-mixin.js index ffc827d5fd..47a533bba2 100644 --- a/bundles/org.openhab.ui/web/src/components/thing/thing-status-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/thing/thing-status-mixin.js @@ -1,5 +1,9 @@ import ThingStatusLabels from '@/assets/i18n/thing-status/en' +// Applies to Thing statusInfo.description containing a pattern of +// http(s)://[YOUROPENHAB]:[YOURPORT]/path +const linkRegex = /^(?.*)http[^:]*:\/\/[^/]?YOUROPENHAB[^/]?:[^/]?YOURPORT[^/]?\/(?\S+)(?.*)$/ + export default { methods: { thingStatusBadgeColor (statusInfo) { @@ -12,6 +16,19 @@ export default { thingStatusBadgeText (statusInfo) { if (statusInfo.statusDetail !== 'NONE') return ThingStatusLabels[statusInfo.statusDetail] return statusInfo.status + }, + thingStatusDescription (statusInfo) { + const description = statusInfo.description + if (statusInfo.statusDetail === 'CONFIGURATION_PENDING' && description) { + const result = linkRegex.exec(description) + if (result) { + const { pretext, path, posttext } = result.groups + if (!path) return description + const root = location.protocol + '//' + location.host + return `${pretext}${root}/${path}${posttext}` + } + } + return description } } } diff --git a/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue b/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue index 9861d4a34c..178cc15351 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue @@ -35,9 +35,7 @@
{{ (thing.statusInfo.statusDetail !== 'NONE') ? thing.statusInfo.statusDetail : ' ' }}
-
- {{ thing.statusInfo.description }} -
+