Skip to content

Commit

Permalink
Input-widgets: Label: Flag component as 'no variable element'
Browse files Browse the repository at this point in the history
Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
  • Loading branch information
ArturoManzoli authored and rafaellehmkuhl committed Jan 15, 2025
1 parent 72b3d8e commit 9db9628
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/components/InputElementConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
</template>
</ExpansiblePanel>
<ExpansiblePanel
v-if="currentElement"
v-if="currentElement && currentElement.options.variableType"
:key="currentElement.hash"
no-bottom-divider
no-top-divider
Expand Down
26 changes: 4 additions & 22 deletions src/components/custom-widget-elements/Label.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
margin: '1px',
}"
>
{{ miniWidget.options.text || 'Label' }}
{{ miniWidget.options.layout?.text || 'Label' }}
</div>
</div>
</template>

<script setup lang="ts">
import { onMounted, onUnmounted, toRefs, watch } from 'vue'
import { onMounted, toRefs, watch } from 'vue'
import { deleteDataLakeVariable, listenDataLakeVariable, unlistenDataLakeVariable } from '@/libs/actions/data-lake'
import { useWidgetManagerStore } from '@/stores/widgetManager'
import { CustomWidgetElementOptions, CustomWidgetElementType } from '@/types/widgets'
Expand All @@ -41,7 +40,6 @@ const props = defineProps<{
}>()
const miniWidget = toRefs(props).miniWidget
let listenerId: string | undefined
watch(
() => widgetStore.miniWidgetManagerVars(miniWidget.value.hash).configMenuOpen,
Expand All @@ -60,33 +58,17 @@ onMounted(() => {
if (!props.miniWidget.options || Object.keys(props.miniWidget.options).length === 0) {
miniWidget.value.isCustomElement = true
widgetStore.updateElementOptions(props.miniWidget.hash, {
text: 'Label',
layout: {
text: 'Label',
textSize: 20,
weight: 'normal',
decoration: 'none',
color: '#FFFFFF',
align: 'center',
},
variableType: 'string',
dataLakeVariable: undefined,
variableType: null,
})
}
if (props.miniWidget.options.dataLakeVariable) {
listenerId = listenDataLakeVariable(props.miniWidget.options.dataLakeVariable?.name, (value) => {
miniWidget.value.options.text = value as string
})
miniWidget.value.options.text = widgetStore.getMiniWidgetLastValue(miniWidget.value.hash) as string
}
})
onUnmounted(() => {
if (miniWidget.value.options.dataLakeVariable) {
deleteDataLakeVariable(miniWidget.value.options.dataLakeVariable.id)
if (listenerId) {
unlistenDataLakeVariable(miniWidget.value.options.dataLakeVariable.name, listenerId)
}
}
})
</script>

Expand Down
22 changes: 11 additions & 11 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,19 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable | null
/**
* Action parameter
*/
dataLakeVariable: DataLakeVariable
/**
* The label text
*/
text: string
/**
* Layout options
*/
layout: {
/**
* The label text
*/
text: string
/**
* The size of the label's font (in pixels)
*/
Expand Down Expand Up @@ -245,7 +245,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -304,7 +304,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -351,7 +351,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -414,7 +414,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -465,7 +465,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -536,7 +536,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down

0 comments on commit 9db9628

Please sign in to comment.