Skip to content

Commit ed54bf6

Browse files
authored
Canvas Interactive SVG: Prevent image caching & Add id in config dialog (#2881)
prevent url caching in edit mode, add svg element id to dialog title Signed-off-by: Stefan Höhn <[email protected]>
1 parent d5a0748 commit ed54bf6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-embedded-svg-mixin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export default {
1717
* @returns {Promise<void>}
1818
*/
1919
embedSvg () {
20-
// Load the real SVG content
21-
return fetch(this.config.imageUrl)
20+
// Load the real SVG content, in editmode we add a random number to the URL to prevent caching
21+
const svgUrl = (this.context.editmode) ? this.config.imageUrl + `?rnd=${Math.random()}` : this.config.imageUrl
22+
return fetch(svgUrl)
2223
.then(response => response.text())
2324
.then(svgCode => {
2425
this.$refs.canvasBackground.innerHTML = svgCode
@@ -46,7 +47,7 @@ export default {
4647
const that = this
4748
this.$f7router.navigate({ url: 'on-svg-click-settings', route: { path: 'on-svg-click-settings', popup } }, {
4849
props: {
49-
widget: new WidgetDefinition('onSvgClickSettings', 'SVG onClick Action', '')
50+
widget: new WidgetDefinition('onSvgClickSettings', `SVG onClick Action for ${id}`, '')
5051
.paramGroup(pg('state', 'State', 'Defines if and how the state is represented in the SVG'), [
5152
pi('stateItems', 'State Item(s)', 'Item(s) that should be used to determine the state').m().a(),
5253
pb('useProxyElementForState', 'Use State Proxy Element', 'Use "flash" element to highlight the active state. The element is marked with the attribute flash: true and must be part of the elements group').a(),

0 commit comments

Comments
 (0)