From 639e6d5c1cb0ba1f2b40cbe2eac9287539dfb19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 2 Feb 2022 19:17:30 +0100 Subject: [PATCH] [ui] add thumbnail HIER view --- webui/src/components/AttributeView.svelte | 4 +- webui/src/components/widgets/Gallery.svelte | 126 ++++++++++++++++++ .../widgets/gallery/Thumbnail.svelte | 61 +++++++++ webui/src/lib/types.ts | 96 +++++++------ 4 files changed, 244 insertions(+), 43 deletions(-) create mode 100644 webui/src/components/widgets/Gallery.svelte create mode 100644 webui/src/components/widgets/gallery/Thumbnail.svelte diff --git a/webui/src/components/AttributeView.svelte b/webui/src/components/AttributeView.svelte index 18f1442..4053ee9 100644 --- a/webui/src/components/AttributeView.svelte +++ b/webui/src/components/AttributeView.svelte @@ -29,8 +29,8 @@ }, ]; - if (type?.widgetInfo) { - availableWidgets = [type.widgetInfo, ...availableWidgets]; + if (type?.widgetInfo.length > 0) { + availableWidgets = [...type.widgetInfo, ...availableWidgets]; } currentWidget = availableWidgets[0].name; } diff --git a/webui/src/components/widgets/Gallery.svelte b/webui/src/components/widgets/Gallery.svelte new file mode 100644 index 0000000..773704a --- /dev/null +++ b/webui/src/components/widgets/Gallery.svelte @@ -0,0 +1,126 @@ + + + + + diff --git a/webui/src/components/widgets/gallery/Thumbnail.svelte b/webui/src/components/widgets/gallery/Thumbnail.svelte new file mode 100644 index 0000000..2f64433 --- /dev/null +++ b/webui/src/components/widgets/gallery/Thumbnail.svelte @@ -0,0 +1,61 @@ + + + +
+
+ {#if handled && loaded != address} +
+ +
+ {/if} + {#if handled} + Thumbnail for {identity}... (loaded = address)} + on:error={() => (handled = false)} + /> + {:else} +
+ +
+ {/if} +
+
+ +
+
+
+ + diff --git a/webui/src/lib/types.ts b/webui/src/lib/types.ts index ebf050b..8340800 100644 --- a/webui/src/lib/types.ts +++ b/webui/src/lib/types.ts @@ -1,4 +1,5 @@ import Table from "../components/widgets/Table.svelte"; +import Gallery from "../components/widgets/Gallery.svelte"; export class UpType { address: string; @@ -14,8 +15,8 @@ export class UpType { return this.name ? TYPE_ICONS[this.name] : undefined; } - public get widgetInfo(): Widget | undefined { - return this.name ? TYPE_WIDGETS[this.name] : undefined; + public get widgetInfo(): Widget[] { + return TYPE_WIDGETS[this.name] || []; } } @@ -37,44 +38,57 @@ const TYPE_ICONS: { [key: string]: string } = { HIER: "folder", }; -const TYPE_WIDGETS: { [key: string]: Widget } = { - HIER: { - name: "hierarchical-listing", - icon: "folder", - components: [ - { - component: Table, - props: { - columns: "value", - header: false, +const TYPE_WIDGETS: { [key: string]: Widget[] } = { + HIER: [ + { + name: "hierarchical-listing", + icon: "folder", + components: [ + { + component: Table, + props: { + columns: "value", + header: false, + }, }, - }, - ], - }, - KSX_TRACK_MOODS: { - name: "ksx-track-compass", - icon: "plus-square", - components: [ - // { - // name: "Compass", - // id: "compass_tint_energy", - // props: { - // xAttrName: "KSX_TINT", - // yAttrName: "KSX_ENERGY", - // xLabel: "Lightsoft // Heavydark", - // yLabel: "Chill // Extreme", - // }, - // }, - // { - // name: "Compass", - // id: "compass_seriousness_materials", - // props: { - // xAttrName: "KSX_SERIOUSNESS", - // yAttrName: "KSX_MATERIALS", - // xLabel: "Dionysia // Apollonia", - // yLabel: "Natural // Reinforced", - // }, - // }, - ], - }, + ], + }, + { + name: "gallery-view", + icon: "image", + components: [ + { + component: Gallery, + }, + ], + }, + ], + KSX_TRACK_MOODS: [ + { + name: "ksx-track-compass", + icon: "plus-square", + components: [ + // { + // name: "Compass", + // id: "compass_tint_energy", + // props: { + // xAttrName: "KSX_TINT", + // yAttrName: "KSX_ENERGY", + // xLabel: "Lightsoft // Heavydark", + // yLabel: "Chill // Extreme", + // }, + // }, + // { + // name: "Compass", + // id: "compass_seriousness_materials", + // props: { + // xAttrName: "KSX_SERIOUSNESS", + // yAttrName: "KSX_MATERIALS", + // xLabel: "Dionysia // Apollonia", + // yLabel: "Natural // Reinforced", + // }, + // }, + ], + }, + ], };