Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for component settings and dashboard settings #1133

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3b68dd9
Add support for dashboard.json
hvangeffen Dec 11, 2024
2e875ff
Put topologyNodes in store
hvangeffen Dec 16, 2024
11b8bf9
Add icons to dashboard tabs and make more compact
hvangeffen Dec 11, 2024
f9fe142
Make most component settings types optional
hvangeffen Dec 12, 2024
a4ce883
Use component name for second record dashbaord
hvangeffen Dec 12, 2024
4b97e56
Pass settings to dashboard components
hvangeffen Dec 12, 2024
a975bd7
Add component type and use it for displaytabs
hvangeffen Dec 12, 2024
7893b48
Move component settings
hvangeffen Dec 12, 2024
3e2a4ae
Use component type in dashboard
hvangeffen Dec 12, 2024
3813ed8
Add component type map to componentSettings
hvangeffen Dec 12, 2024
a7d6759
Add component settings to spatialdisplay and spatialtimeseriesdisplay
hvangeffen Dec 16, 2024
cb1e63c
Add overlay control
hvangeffen Dec 17, 2024
e0789c8
Add support for overlayer layers based on locationSets
hvangeffen Dec 13, 2024
321de9c
Make overlay selection menu more compact
hvangeffen Dec 16, 2024
5b52d30
Use getLayer and getSource id to remain active on basemap change
hvangeffen Dec 16, 2024
61a4ee5
Use topologyNode name as dashboard tab title
hvangeffen Dec 17, 2024
eab95ec
Use topologyNode iconId if available for dasbboard tab
hvangeffen Dec 17, 2024
0702c0a
Add overlays to component settings store
hvangeffen Dec 17, 2024
0162300
Only fetch dashboards.json once
hvangeffen Dec 17, 2024
60b9af3
Make node dashboard check lowercase
hvangeffen Dec 17, 2024
c6c39e0
Add basemap control
hvangeffen Dec 17, 2024
6fcf0ad
Get dashboard after empty check
hvangeffen Dec 17, 2024
9501cab
Disable tasks as it breaks the topology tree
hvangeffen Dec 17, 2024
cc589ff
Linting
hvangeffen Dec 17, 2024
a39c840
Scope current colour scales to spatialdisplay instance
hvangeffen Dec 11, 2024
83bf913
Remove setting of declarations on each child component setting object
hvangeffen Dec 17, 2024
ae3f4d7
Disable download button instead of dialog for component setting
hvangeffen Dec 18, 2024
b66f9b4
Allow chart panel to be opened in dashboard
hvangeffen Dec 18, 2024
3ac091c
Linting
hvangeffen Dec 18, 2024
7dd7040
Make chartpanel fullscreen based on spatial display container size
hvangeffen Dec 18, 2024
1174aae
Hide instead of disable items based on component settings
hvangeffen Dec 18, 2024
d3c7352
Move overlay and basemap controls to informationpanel
hvangeffen Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/assets/DefaultBaseMaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"automatic": {
"id": "automatic",
"name": "Automatic",
"style": "automatic"
},
"light": {
"id": "carto-db-light",
"name": "CartoDB (light)",
"style": "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
},
"dark": {
"id": "carto-dark-matter",
"name": "CartoDB (dark)",
"style": "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
}
}
21 changes: 0 additions & 21 deletions src/assets/DefaultUserSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,6 @@
],
"group": "UI"
},
{
"id": "ui.map.theme",
"type": "oneOfMultiple",
"label": "Basemap",
"value": "carto-db-automatic",
"items": [
{
"value": "carto-db-automatic",
"icon": "mdi-theme-light-dark"
},
{
"value": "carto-db-light",
"icon": "mdi-weather-sunny"
},
{
"value": "carto-dark-matter",
"icon": "mdi-weather-night"
}
],
"group": "Map"
},
{
"id": "ui.map.showLocationNames",
"type": "boolean",
Expand Down
57 changes: 0 additions & 57 deletions src/assets/base-layers.json

This file was deleted.

55 changes: 14 additions & 41 deletions src/components/general/DashboardDisplay.vue
Original file line number Diff line number Diff line change
@@ -1,58 +1,31 @@
<template>
<div class="dashboard-container ga-3 pa-3">
<template v-for="panel in panelItems">
<v-card
v-if="panel.component"
:style="{ gridArea: panel.id }"
class="d-flex flex-column"
density="compact"
>
<component
class="overflow-auto"
:is="panel.component"
v-bind="panel.props"
:topologyNode="panel.node"
/>
</v-card>
<v-alert
v-else
:title="`${panel.id} not implemented`"
:style="{ gridArea: panel.id }"
class="ma-2"
/>
<template v-for="group in groups">
<template v-for="element in group.elements">
<v-card
:style="{ gridArea: element.gridTemplateArea }"
class="d-flex flex-column"
density="compact"
>
<DashboardItems :items="element.items" />
</v-card>
</template>
</template>
</div>
</template>

<script setup lang="ts">
import { getComponentWithPropsForNode } from '@/lib/topology/dashboard'
import type { TopologyNode } from '@deltares/fews-pi-requests'
import type { Dashboard } from '@/lib/dashboard/types'
import { computed, watch } from 'vue'

interface Dashboard {
id: string
css: string
panels: TopologyNode[]
}
import DashboardItems from '@/components/general/DashboardItems.vue'

interface Props {
dashboard: Dashboard
}

const props = defineProps<Props>()

const panelItems = computed(() => {
return props.dashboard.panels.map((panel) => {
const { component, props } = getComponentWithPropsForNode(panel)
return {
id: panel.id,
title: panel.name,
node: panel,
component,
props,
}
})
})
const groups = computed(() => props.dashboard.groups)

function loadCss(url: string) {
if (!document.querySelector(`link[href="${url}"]`)) {
Expand All @@ -71,7 +44,7 @@ function removeCss(url: string) {
}

watch(
() => props.dashboard.css,
() => props.dashboard.cssTemplate,
(newCss, oldCss) => {
if (oldCss) removeCss(oldCss)
loadCss(newCss)
Expand Down
87 changes: 87 additions & 0 deletions src/components/general/DashboardItems.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<v-tabs
v-model="tab"
v-if="items.length > 1"
bg-color="primary"
align-tabs="center"
class="flex-0-0 w-100"
density="compact"
>
<v-tab
v-for="item in componentItems"
:prepend-icon="item.icon"
class="text-none"
>
{{ item.title }}
</v-tab>
</v-tabs>

<template v-for="(item, i) in componentItems">
<component
v-if="tab === i"
class="overflow-auto flex-1-1"
:is="item.component"
v-bind="item.componentProps"
:topologyNode="item.topologyNode"
:settings="item.settings"
/>
</template>
</template>

<script setup lang="ts">
import type { DashboardItem } from '@/lib/dashboard/types'
import {
componentTypeToIconMap,
componentTypeToTitleMap,
} from '@/lib/topology/component'
import {
componentTypeToComponentMap,
getComponentPropsForNode,
} from '@/lib/topology/dashboard'
import { useComponentSettingsStore } from '@/stores/componentSettings'
import { useTopologyNodesStore } from '@/stores/topologyNodes'
import { computed, ref, watch } from 'vue'

interface Props {
items: DashboardItem[]
}

const props = defineProps<Props>()

const tab = ref(0)

const topologyNodesStore = useTopologyNodesStore()
const componentSettingsStore = useComponentSettingsStore()

function getComponentSettingsForItem(item: DashboardItem) {
const settings = componentSettingsStore.getSettingsById(
item.componentSettingsId,
)
return settings?.[item.component]
}

const componentItems = computed(() => {
return props.items.map((item) => {
const componentName = item.component
const topologyNode = topologyNodesStore.getNodeById(item.topologyNodeId)
const component = componentTypeToComponentMap[componentName]
const componentProps = getComponentPropsForNode(componentName, topologyNode)
const title = topologyNode?.name ?? componentTypeToTitleMap[componentName]
const icon = topologyNode?.iconId ?? componentTypeToIconMap[componentName]
const settings = getComponentSettingsForItem(item)
return {
title,
icon,
component,
componentProps,
componentName,
topologyNode,
settings,
}
})
})

watch(componentItems, () => {
tab.value = 0
})
</script>
37 changes: 16 additions & 21 deletions src/components/map/MapComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,37 @@ import { configManager } from '@/services/application-config'
import { authenticationManager } from '@/services/authentication/AuthenticationManager'
import {
MglAttributionControl,
MglDefaults,
MglMap,
MglScaleControl,
useMap,
} from '@indoorequal/vue-maplibre-gl'
import type { ResourceType, RequestParameters, LngLatBounds } from 'maplibre-gl'
import { useBaseLayers } from '@/services/useBaseLayers'
import { useUserSettingsStore } from '@/stores/userSettings'
import { useTemplateRef, watch } from 'vue'
import type {
ResourceType,
RequestParameters,
LngLatBounds,
Map,
} from 'maplibre-gl'
import { computed, useTemplateRef, watch } from 'vue'
import { transformStyle } from '@/lib/map'
import { useComponentSettingsStore } from '@/stores/componentSettings'

interface Props {
bounds?: LngLatBounds
baseMapId?: string
}

defineProps<Props>()

const settings = useUserSettingsStore()

MglDefaults.style =
'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'

const { baseLayerStyle } = useBaseLayers(
() => settings.get('ui.map.theme')?.value as string | undefined,
)

const initialStyle = baseLayerStyle.value

const mapRef = useTemplateRef('map')

watch(baseLayerStyle, (newBaseStyle) => {
const componentSettingsStore = useComponentSettingsStore()
const selectedStyle = computed(() => componentSettingsStore.selectedStyle)
const initialStyle = selectedStyle.value

watch(selectedStyle, (newBaseStyle) => {
if (!newBaseStyle) return

// NOTE: We have to get mapkey because useMap uses inject and we are not a child of MglMap
const mapKey = mapRef.value?.mapKey
const map = useMap(mapKey).map
// @ts-expect-error map is not exposed in the types
const map: Map | undefined = mapRef.value?.map
map?.setStyle(newBaseStyle, { transformStyle })
})

Expand Down
Loading
Loading