From b2af60ae73c08ad135c8e01a97f9ced5eb6d50a0 Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Tue, 15 Oct 2024 11:34:53 -0300 Subject: [PATCH] Components: Very-generic-input-widget: Add component Signed-off-by: Arturo Manzoli --- src/assets/defaults.ts | 94 +++ src/assets/widgets/CustomWidgetBase.png | Bin 0 -> 1129 bytes src/components/EditMenu.vue | 142 +++- src/components/ElementConfigPanel.vue | 490 ++++++++++++++ src/components/MiniWidgetContainer.vue | 4 +- src/components/MiniWidgetInstantiator.vue | 34 +- src/components/WidgetHugger.vue | 11 +- .../custom-widget-elements/Button.vue | 84 +++ .../custom-widget-elements/Checkbox.vue | 98 +++ .../custom-widget-elements/Dial.vue | 212 ++++++ .../custom-widget-elements/Dropdown.vue | 128 ++++ .../custom-widget-elements/Label.vue | 99 +++ .../custom-widget-elements/Slider.vue | 138 ++++ .../custom-widget-elements/Switch.vue | 86 +++ src/components/mini-widgets/ArmerButton.vue | 4 +- src/components/widgets/CustomWidgetBase.vue | 426 ++++++++++++ src/libs/actions/data-lake.ts | 20 +- src/stores/widgetManager.ts | 195 +++++- src/types/widgets.ts | 611 +++++++++++++++++- src/views/ConfigurationActionsView.vue | 3 +- 20 files changed, 2835 insertions(+), 44 deletions(-) create mode 100644 src/assets/widgets/CustomWidgetBase.png create mode 100644 src/components/ElementConfigPanel.vue create mode 100644 src/components/custom-widget-elements/Button.vue create mode 100644 src/components/custom-widget-elements/Checkbox.vue create mode 100644 src/components/custom-widget-elements/Dial.vue create mode 100644 src/components/custom-widget-elements/Dropdown.vue create mode 100644 src/components/custom-widget-elements/Label.vue create mode 100644 src/components/custom-widget-elements/Slider.vue create mode 100644 src/components/custom-widget-elements/Switch.vue create mode 100644 src/components/widgets/CustomWidgetBase.vue diff --git a/src/assets/defaults.ts b/src/assets/defaults.ts index 7800d23e9..6e69cad5a 100644 --- a/src/assets/defaults.ts +++ b/src/assets/defaults.ts @@ -4,6 +4,8 @@ import { DistanceDisplayUnit } from '@/libs/units' import { type MiniWidgetProfile, type Profile, + CustomWidgetManagerVars, + CustomWidgetType, MiniWidgetManagerVars, MiniWidgetType, WidgetManagerVars, @@ -29,6 +31,7 @@ export const defaultWidgetManagerVars: WidgetManagerVars = { lastNonMaximizedWidth: 0.2, lastNonMaximizedHeight: 0.36, highlighted: false, + disableResponsiveness: false, } export const defaultMiniWidgetManagerVars: MiniWidgetManagerVars = { @@ -37,6 +40,97 @@ export const defaultMiniWidgetManagerVars: MiniWidgetManagerVars = { highlighted: false, } +export const defaultCustomWidgetManagerVars: CustomWidgetManagerVars = { + everMounted: false, + configMenuOpen: false, + highlighted: false, + customWidgetVars: CustomWidgetType.Button, + cockpitActions: [], +} + +export const defaultCustomWidgetContainers = [ + { + name: '0-left', + elements: [], + }, + { + name: '1-left', + elements: [], + }, + { + name: '2-left', + elements: [], + }, + { + name: '3-left', + elements: [], + }, + { + name: '4-left', + elements: [], + }, + { + name: '5-left', + elements: [], + }, + { + name: '6-left', + elements: [], + }, + { + name: '7-left', + elements: [], + }, + { + name: '8-left', + elements: [], + }, + { + name: '9-left', + elements: [], + }, + { + name: '0-right', + elements: [], + }, + { + name: '1-right', + elements: [], + }, + { + name: '2-right', + elements: [], + }, + { + name: '3-right', + elements: [], + }, + { + name: '4-right', + elements: [], + }, + { + name: '5-right', + elements: [], + }, + { + name: '6-right', + elements: [], + }, + { + name: '7-right', + elements: [], + }, + { + name: '8-right', + elements: [], + }, + { + name: '9-right', + elements: [], + }, +] + const hostname = window.location.hostname export const defaultBlueOsAddress = 'http://blueos-avahi.local' export const defaultGlobalAddress = !hostname || hostname == 'localhost' ? defaultBlueOsAddress : hostname diff --git a/src/assets/widgets/CustomWidgetBase.png b/src/assets/widgets/CustomWidgetBase.png new file mode 100644 index 0000000000000000000000000000000000000000..032ac7f12db21a6ec7cf6edc83af1cd1ea8d64b1 GIT binary patch literal 1129 zcmeAS@N?(olHy`uVBq!ia0vp^FMzm#gAGVB@~Qd*$(BrK=KxP5mDwse2q#6!~Cgpz-XP>U~1pOZCEb&6w)jTQSRGS(epPZp;4A zbJ26QX3gFD{$#v_-V5#1G0RQ6M8r0-a4Lyh33L=Sd$i^Cl86%*DlZ+kfAmYWNb||6 zhKb3HrWq4r?SIJsdABxn&a5w!4tXy4ezef;Si`>91y>8^yiY!!IhWyJ`U9``KeBxj zzD@q(=H4yK*nIoI(Ng!|Zw;qq6MmeW;Cpjw)0UPb!3z7u`KOqjw>xBS-3T%8GOEq6uM1{7NUV9+(SX4w zxV_41F7w}8@f9zn-IJTk`AaYIpQ@Y`8(J$JmHqkR*04DS6Yt&Ic0b8}`?WCVNx%2~ z51vyXI`Q4FPh~Ie&y}=gSyuY*{qsDJO>dsconc+~NW_+XmqZWqy6Fy%3mU+fv9ZYk zf|;0D8=;tmi-{G2IYd~vAXq?yLj-~q0t7T5*kOS}00ct}0~tD44E#{fY^&y(otr9S zu=m=nP5*6pJnO!;Iy|&mbG*@RuKc!Z&(fGD&ztvIW&W>Ei7QssPCBl#Sw(u{p(TZR zzly>`kH3=MysvQI?|&YjB0|}do4eb0zM4PdbzOkmq@2~Swz}z`oph)F-Tni=Z>#={ z3tjIS^nXR=Md#Q)zmNw-eLp{^zYYHXq~^2qt*g1;{#=i~0!(oXp00i_>zopr0NvZg A-~a#s literal 0 HcmV?d00001 diff --git a/src/components/EditMenu.vue b/src/components/EditMenu.vue index 63aef0f46..194c39f1c 100644 --- a/src/components/EditMenu.vue +++ b/src/components/EditMenu.vue @@ -152,7 +152,7 @@

Widget type:

@@ -453,7 +453,7 @@ theme="dark" variant="filled" density="compact" - :items="['Regular', 'Mini']" + :items="['Regular', 'Mini', 'Input']" class="bg-[#27384255] 2xl:scale-100 scale-[80%]" hide-details @change="widgetMode = $event" @@ -463,17 +463,18 @@
To be placed on the main view area
-
- Click or drag to add -
+
(Drag card to add)
To be placed on the top and bottom bars
-
- (Drag card in place to add) +
(Drag card to add)
+
+ Add widget base +
@@ -491,7 +492,7 @@ @dragstart="onRegularWidgetDragStart" @dragend="onRegularWidgetDragEnd(widgetType)" > - + @@ -522,19 +522,47 @@ id="mini-widget-card" :ref="(el) => (miniWidgetContainers[miniWidget.component] = el as HTMLElement)" :key="miniWidget.hash" - class="flex flex-col items-center justify-between w-full rounded-md bg-[#273842] hover:brightness-125 h-[90%] aspect-square cursor-pointer elevation-4 overflow-clip pointer-events-none" + class="flex flex-col items-center w-full justify-between rounded-md bg-[#273842] hover:brightness-125 h-[90%] aspect-square cursor-pointer elevation-4 overflow-clip" :draggable="false" >
-
+
+ +
+
+
+ {{ + miniWidget.name.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (str) => str.toUpperCase()) + }} +
+
+
+
+
+
+
+
-
+
{{ - miniWidget.name.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (str) => str.toUpperCase()) || - 'Very Generic Indicator' + miniWidget.name.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (str) => str.toUpperCase()) }}
@@ -587,6 +615,21 @@ + +
+ +
+
+ + diff --git a/src/components/MiniWidgetContainer.vue b/src/components/MiniWidgetContainer.vue index ff481712c..dc099e915 100644 --- a/src/components/MiniWidgetContainer.vue +++ b/src/components/MiniWidgetContainer.vue @@ -25,7 +25,7 @@ @mouseover="widgetStore.miniWidgetManagerVars(miniWidget.hash).highlighted = allowEditing" @mouseleave="widgetStore.miniWidgetManagerVars(miniWidget.hash).highlighted = false" > -
+
@@ -51,7 +51,7 @@ @add="handleDeleteWidget" >
-
+
diff --git a/src/components/MiniWidgetInstantiator.vue b/src/components/MiniWidgetInstantiator.vue index 0b57d8274..c1aeeeb91 100644 --- a/src/components/MiniWidgetInstantiator.vue +++ b/src/components/MiniWidgetInstantiator.vue @@ -3,28 +3,40 @@ diff --git a/src/components/WidgetHugger.vue b/src/components/WidgetHugger.vue index a45a7246f..6b0186059 100644 --- a/src/components/WidgetHugger.vue +++ b/src/components/WidgetHugger.vue @@ -59,6 +59,10 @@ export interface Props { * To hide or not content that overflows the widget area */ hideOverflow?: boolean + /** + * To change the widget sizes according to window size + */ + disableResponsiveness?: boolean } const props = withDefaults(defineProps(), { @@ -75,6 +79,7 @@ const outerWidgetRef = ref() const innerWidgetRef = ref() const widgetView = computed(() => outerWidgetRef.value?.parentElement) const widgetResizeHandles = computed(() => outerWidgetRef.value?.getElementsByClassName('resize-handle')) +const disableResponsiveness = toRefs(props).disableResponsiveness const devStore = useDevelopmentStore() @@ -87,7 +92,7 @@ const hoveringWidgetOrOverlay = computed(() => hoveringOverlay.value || hovering // Put the widget into highlighted state when in edit-mode and hovering over it watch([hoveringWidgetOrOverlay, allowMoving], () => { - widgetStore.widgetManagerVars(widget.value.hash).highlighted = hoveringWidgetOrOverlay.value && allowMoving.value + widgetStore.widgetManagerVars(widget.value.hash).highlighted = hoveringWidgetOrOverlay.value }) const draggingWidget = ref(false) @@ -272,8 +277,8 @@ const temporaryPosition = computed(() => { }) const sizeStyle = computed(() => ({ - width: `${100 * size.value.width}%`, - height: `${100 * size.value.height}%`, + width: disableResponsiveness.value ? `${1000 * size.value.width}px` : `${100 * size.value.width}%`, + height: disableResponsiveness.value ? `${1000 * size.value.height}px` : `${100 * size.value.height}%`, })) const positionStyle = computed(() => ({ diff --git a/src/components/custom-widget-elements/Button.vue b/src/components/custom-widget-elements/Button.vue new file mode 100644 index 000000000..8c726c6c9 --- /dev/null +++ b/src/components/custom-widget-elements/Button.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/components/custom-widget-elements/Checkbox.vue b/src/components/custom-widget-elements/Checkbox.vue new file mode 100644 index 000000000..85bae9b24 --- /dev/null +++ b/src/components/custom-widget-elements/Checkbox.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/components/custom-widget-elements/Dial.vue b/src/components/custom-widget-elements/Dial.vue new file mode 100644 index 000000000..df22a3c91 --- /dev/null +++ b/src/components/custom-widget-elements/Dial.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/src/components/custom-widget-elements/Dropdown.vue b/src/components/custom-widget-elements/Dropdown.vue new file mode 100644 index 000000000..5cca1acbb --- /dev/null +++ b/src/components/custom-widget-elements/Dropdown.vue @@ -0,0 +1,128 @@ + + + + + diff --git a/src/components/custom-widget-elements/Label.vue b/src/components/custom-widget-elements/Label.vue new file mode 100644 index 000000000..fbb8e9afd --- /dev/null +++ b/src/components/custom-widget-elements/Label.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/components/custom-widget-elements/Slider.vue b/src/components/custom-widget-elements/Slider.vue new file mode 100644 index 000000000..b49991226 --- /dev/null +++ b/src/components/custom-widget-elements/Slider.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/src/components/custom-widget-elements/Switch.vue b/src/components/custom-widget-elements/Switch.vue new file mode 100644 index 000000000..b39f4490c --- /dev/null +++ b/src/components/custom-widget-elements/Switch.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/components/mini-widgets/ArmerButton.vue b/src/components/mini-widgets/ArmerButton.vue index 9de910457..8b69599ec 100644 --- a/src/components/mini-widgets/ArmerButton.vue +++ b/src/components/mini-widgets/ArmerButton.vue @@ -1,7 +1,7 @@