485485 class =" flex items-center justify-between w-full h-full gap-3 overflow-x-auto text-white -mb-1 pr-2 cursor-pointer"
486486 >
487487 <div
488- v-for =" widgetType in availableWidgetTypes "
489- :key =" widgetType "
488+ v-for =" widget in allAvailableWidgets "
489+ :key =" widget.name "
490490 class =" flex flex-col items-center justify-between rounded-md bg-[#273842] hover:brightness-125 h-[90%] aspect-square cursor-pointer elevation-4"
491491 draggable =" true"
492492 @dragstart =" onRegularWidgetDragStart"
493- @dragend =" onRegularWidgetDragEnd(widgetType )"
493+ @dragend =" onRegularWidgetDragEnd(widget )"
494494 >
495495 <v-tooltip text =" Drag to add" location =" top" theme =" light" >
496496 <template #activator =" { props: tooltipProps } " >
497497 <div />
498- <img
499- v-bind =" tooltipProps"
500- :src =" widgetImages[widgetType]"
501- alt =" widget-icon"
502- class =" p-4 max-h-[75%] max-w-[95%]"
503- />
498+ <img v-bind =" tooltipProps" :src =" widget.icon" alt =" widget-icon" class =" p-4 max-h-[75%] max-w-[95%]" />
504499 <div
505500 class =" flex items-center justify-center w-full p-1 transition-all bg-[#3B78A8] rounded-b-md text-white"
506501 >
507502 <span class =" whitespace-normal text-center" >{{
508- widgetType .replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (str) => str.toUpperCase())
503+ widget.name .replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (str) => str.toUpperCase())
509504 }}</span >
510505 </div >
511506 </template >
@@ -659,6 +654,7 @@ import URLVideoPlayerImg from '@/assets/widgets/URLVideoPlayer.png'
659654import VideoPlayerImg from ' @/assets/widgets/VideoPlayer.png'
660655import VirtualHorizonImg from ' @/assets/widgets/VirtualHorizon.png'
661656import { useInteractionDialog } from ' @/composables/interactionDialog'
657+ import { getWidgetsFromBlueOS } from ' @/libs/blueos'
662658import { MavType } from ' @/libs/connection/m2r/messages/mavlink2rest-enum'
663659import { isHorizontalScroll } from ' @/libs/utils'
664660import { useAppInterfaceStore } from ' @/stores/appInterface'
@@ -668,6 +664,8 @@ import {
668664 type View ,
669665 type Widget ,
670666 CustomWidgetElementType ,
667+ ExternalWidgetSetupInfo ,
668+ InternalWidgetSetupInfo ,
671669 MiniWidgetType ,
672670 WidgetType ,
673671} from ' @/types/widgets'
@@ -695,6 +693,8 @@ const toggleDial = (): void => {
695693
696694const forceUpdate = ref (0 )
697695
696+ const ExternalWidgetSetupInfos = ref <ExternalWidgetSetupInfo []>([])
697+
698698watch (
699699 () => store .currentView .widgets ,
700700 () => {
@@ -714,7 +714,31 @@ const emit = defineEmits<{
714714 (e : ' update:editMode' , editMode : boolean ): void
715715}>()
716716
717- const availableWidgetTypes = computed (() => Object .values (WidgetType ))
717+ const availableWidgetTypes = computed (() =>
718+ Object .values (WidgetType ).map ((widgetType ) => {
719+ return {
720+ component: widgetType ,
721+ name: widgetType ,
722+ icon: widgetImages [widgetType ] as string ,
723+ options: {},
724+ }
725+ })
726+ )
727+
728+ const allAvailableWidgets = computed (() => {
729+ return [
730+ ... ExternalWidgetSetupInfos .value .map ((widget ) => ({
731+ component: WidgetType .IFrame ,
732+ icon: widget .iframe_icon ,
733+ name: widget .name ,
734+ options: {
735+ source: widget .iframe_url ,
736+ },
737+ })),
738+ ... availableInternalWidgets .value ,
739+ ]
740+ })
741+
718742const availableMiniWidgetTypes = computed (() =>
719743 Object .values (MiniWidgetType ).map ((widgetType ) => ({
720744 component: widgetType ,
@@ -927,6 +951,10 @@ const miniWidgetsContainerOptions = ref<UseDraggableOptions>({
927951})
928952useDraggable (availableMiniWidgetsContainer , availableMiniWidgetTypes , miniWidgetsContainerOptions )
929953
954+ const getExternalWidgetSetupInfos = async (): Promise <void > => {
955+ ExternalWidgetSetupInfos .value = await getWidgetsFromBlueOS ()
956+ }
957+
930958// @ts-ignore: Documentation is not clear on what generic should be passed to 'UseDraggableOptions'
931959const customWidgetElementContainerOptions = ref <UseDraggableOptions >({
932960 animation: ' 150' ,
@@ -940,6 +968,7 @@ useDraggable(
940968)
941969
942970onMounted (() => {
971+ getExternalWidgetSetupInfos ()
943972 const widgetContainers = [
944973 availableWidgetsContainer .value ,
945974 availableMiniWidgetsContainer .value ,
@@ -991,7 +1020,7 @@ const onRegularWidgetDragStart = (event: DragEvent): void => {
9911020 }
9921021}
9931022
994- const onRegularWidgetDragEnd = (widgetType : WidgetType ): void => {
1023+ const onRegularWidgetDragEnd = (widgetType : ExtendedWidget ): void => {
9951024 store .addWidget (widgetType , store .currentView )
9961025
9971026 const widgetCards = document .querySelectorAll (' [draggable="true"]' )
0 commit comments