@collabdt/core 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
- package/dist/core/components/AppSidebarContent.js +2 -7
- package/dist/core/components/AppSidebarContent.js.map +1 -1
- package/dist/core/components/ConfirmDialog.d.ts +2 -1
- package/dist/core/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/core/components/ConfirmDialog.js +8 -0
- package/dist/core/components/ConfirmDialog.js.map +1 -1
- package/dist/core/components/authentication/AuthPage.d.ts.map +1 -1
- package/dist/core/components/authentication/AuthPage.js +1 -2
- package/dist/core/components/authentication/AuthPage.js.map +1 -1
- package/dist/core/components/authentication/auth.css +4 -1
- package/dist/core/components/organizationConfig/src/CountrySubdivisionFields.d.ts +2 -0
- package/dist/core/components/organizationConfig/src/CountrySubdivisionFields.d.ts.map +1 -0
- package/dist/core/components/organizationConfig/src/CountrySubdivisionFields.js +180 -0
- package/dist/core/components/organizationConfig/src/CountrySubdivisionFields.js.map +1 -0
- package/dist/core/components/organizationConfig/src/organizationConfigContent.d.ts.map +1 -1
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js +13 -0
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js.map +1 -1
- package/dist/core/components/settings/index.js +1 -1
- package/dist/core/components/settings/index.js.map +1 -1
- package/dist/core/components/settings/src/AccountSettingsPanel.d.ts.map +1 -1
- package/dist/core/components/settings/src/AccountSettingsPanel.js +6 -7
- package/dist/core/components/settings/src/AccountSettingsPanel.js.map +1 -1
- package/dist/core/components/ui/AnimatedBackground.d.ts +2 -2
- package/dist/core/components/ui/AnimatedBackground.d.ts.map +1 -1
- package/dist/core/components/ui/AnimatedBackground.js +7 -8
- package/dist/core/components/ui/AnimatedBackground.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js.map +1 -1
- package/dist/core/components/ui/LegendCard.d.ts +8 -3
- package/dist/core/components/ui/LegendCard.d.ts.map +1 -1
- package/dist/core/components/ui/LegendCard.js +37 -19
- package/dist/core/components/ui/LegendCard.js.map +1 -1
- package/dist/core/components/ui/Progress.js +2 -2
- package/dist/core/components/ui/Progress.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorDetailDialog.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorDetailDialog.js +56 -19
- package/dist/core/components/ui/Sensors/SensorDetailDialog.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorLegend.d.ts +6 -3
- package/dist/core/components/ui/Sensors/SensorLegend.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorLegend.js +95 -27
- package/dist/core/components/ui/Sensors/SensorLegend.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.d.ts +10 -4
- package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.js +60 -9
- package/dist/core/components/ui/Sensors/SensorMultiSeriesChart.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.d.ts +1 -2
- package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.js +36 -6
- package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
- package/dist/core/components/ui/Sensors/buildingSensorColours.d.ts +49 -0
- package/dist/core/components/ui/Sensors/buildingSensorColours.d.ts.map +1 -0
- package/dist/core/components/ui/Sensors/buildingSensorColours.js +68 -0
- package/dist/core/components/ui/Sensors/buildingSensorColours.js.map +1 -0
- package/dist/core/components/ui/Sensors/sensorScope.js +1 -1
- package/dist/core/components/ui/Sensors/sensorScope.js.map +1 -1
- package/dist/core/components/ui/Sensors/sensorVisibility.d.ts +47 -0
- package/dist/core/components/ui/Sensors/sensorVisibility.d.ts.map +1 -0
- package/dist/core/components/ui/Sensors/sensorVisibility.js +29 -0
- package/dist/core/components/ui/Sensors/sensorVisibility.js.map +1 -0
- package/dist/core/components/ui/Sensors/useBuildingSensorColours.d.ts +30 -0
- package/dist/core/components/ui/Sensors/useBuildingSensorColours.d.ts.map +1 -0
- package/dist/core/components/ui/Sensors/useBuildingSensorColours.js +92 -0
- package/dist/core/components/ui/Sensors/useBuildingSensorColours.js.map +1 -0
- package/dist/core/components/ui/Sensors/useSensorSeriesMulti.d.ts +1 -1
- package/dist/core/components/ui/Sensors/useSensorSeriesMulti.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/useSensorSeriesMulti.js.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.js +10 -6
- package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.d.ts +161 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.js +382 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/BimMeasurementManager.js.map +1 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/measurementSettings.d.ts +80 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/measurementSettings.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/measurementSettings.js +48 -0
- package/dist/core/components/viewers/bim/src/BimMeasurements/measurementSettings.js.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.js +3 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/MeasurementSettings.d.ts +11 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/MeasurementSettings.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/MeasurementSettings.js +186 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/MeasurementSettings.js.map +1 -0
- package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts +10 -0
- package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Highlighter/index.js +28 -6
- package/dist/core/components/viewers/bim/src/Highlighter/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/LoadModels.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/LoadModels.js +5 -2
- package/dist/core/components/viewers/bim/src/LoadModels.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.d.ts +5 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.js +26 -14
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useFilePlacement.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useFilePlacement.js +4 -2
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useFilePlacement.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.js +21 -18
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useSensorMarkers.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js +15 -10
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.js +52 -60
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +1 -1
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js +27 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.d.ts +36 -0
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.js +95 -0
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingSensorDetails.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js +55 -42
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js +5 -5
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js +9 -6
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts +32 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js +56 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +61 -39
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.d.ts +18 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.js +82 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/BuildingSensorMarkers.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js +3 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.js +22 -2
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js +39 -22
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.d.ts +22 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.js +36 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/sensorClusterColour.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.d.ts +5 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.js +6 -2
- package/dist/core/components/viewers/map/src/MapLayers/src/mapLayersUtils.js.map +1 -1
- package/dist/core/components/viewers/map/src/SimpleMap.d.ts +1 -1
- package/dist/core/components/viewers/map/src/SimpleMap.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/SimpleMap.js +4 -10
- package/dist/core/components/viewers/map/src/SimpleMap.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js +4 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudLoadingState/index.d.ts.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudLoadingState/index.js +16 -3
- package/dist/core/components/viewers/pointcloud/src/PointCloudLoadingState/index.js.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/src/PointCloudSection.d.ts.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/src/PointCloudSection.js +105 -26
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/src/PointCloudSection.js.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/src/PerformanceSettings.js +6 -6
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/src/PerformanceSettings.js.map +1 -1
- package/dist/core/i18n/messages/en.json +29 -2
- package/dist/core/i18n/messages/es.json +29 -2
- package/dist/core/i18n/messages/fr.json +29 -2
- package/dist/core/store/Menus/context.d.ts.map +1 -1
- package/dist/core/store/Menus/context.js +4 -2
- package/dist/core/store/Menus/context.js.map +1 -1
- package/dist/core/store/Menus/reducer.d.ts +15 -26
- package/dist/core/store/Menus/reducer.d.ts.map +1 -1
- package/dist/core/store/Menus/reducer.js +38 -4
- package/dist/core/store/Menus/reducer.js.map +1 -1
- package/dist/core/store/PointCloud/reducer.js +1 -1
- package/dist/core/store/PointCloud/reducer.js.map +1 -1
- package/dist/core/utils/appContent.d.ts +15 -0
- package/dist/core/utils/appContent.d.ts.map +1 -0
- package/dist/core/utils/appContent.js +24 -0
- package/dist/core/utils/appContent.js.map +1 -0
- package/dist/core/utils/colourUtils.d.ts +9 -0
- package/dist/core/utils/colourUtils.d.ts.map +1 -1
- package/dist/core/utils/colourUtils.js +16 -0
- package/dist/core/utils/colourUtils.js.map +1 -1
- package/dist/core/utils/markerUtils.d.ts +11 -0
- package/dist/core/utils/markerUtils.d.ts.map +1 -1
- package/dist/core/utils/markerUtils.js +2 -0
- package/dist/core/utils/markerUtils.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/components/viewers/bim/src/BimMeasurements/LenghtMeasurement.d.ts +0 -21
- package/dist/core/components/viewers/bim/src/BimMeasurements/LenghtMeasurement.d.ts.map +0 -1
- package/dist/core/components/viewers/bim/src/BimMeasurements/LenghtMeasurement.js +0 -92
- package/dist/core/components/viewers/bim/src/BimMeasurements/LenghtMeasurement.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorLegend.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport { useSensors } from '../../../hooks/sensors/sensors'\r\nimport { useSensorTypes } from '../../../hooks/sensorTypes/sensorTypes'\r\nimport { MenusContext } from '../../../store'\r\nimport { LegendCard } from '../LegendCard'\r\n\r\nimport { observedDomain, rampStops, resolveDomain, resolveRamp, valueOffset } from './sensorColour'\r\nimport { useSensorSeries } from './useSensorSeries'\r\n\r\nimport type { ViewerNames } from '../../../types/dbTypes'\r\n\r\nconst format = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\n/** `Air_Quality` reads as `Air Quality`, matching how the cards title a type. */\r\nconst typeLabel = (name: string): string => name.replace(/_/g, ' ')\r\n\r\n/**\r\n * Colour legend for the focused sensor's type, shown in a viewer's bottom-left card stack.\r\n *\r\n * This is what makes the value ramp readable: it puts the domain's numbers next to the colours\r\n * used by the marker halos and the chart fill, so nothing in the scene is encoded by colour\r\n * alone. Renders nothing unless a sensor is focused and its type has a usable colour domain, so\r\n * an unconfigured type shows no legend rather than a meaningless gradient.\r\n */\r\nexport function SensorLegend(): React.ReactElement | null {\r\n const t = useTranslations('SensorLegend')\r\n const { state } = React.useContext(MenusContext)\r\n const { focusedSensorId, currentSensorId, currentViewer } = state.menus\r\n\r\n const { sensors } = useSensors()\r\n const { sensorTypes } = useSensorTypes()\r\n\r\n // A click-focused sensor wins; hover is the fallback so the legend still explains the colours\r\n // while the pointer sweeps the scene.\r\n const activeId = focusedSensorId ?? currentSensorId\r\n const sensor = activeId == null ? undefined : sensors.find(s => s.id === activeId)\r\n const sensorType = sensor ? sensorTypes.find(ty => ty.id === sensor.typeId) : undefined\r\n\r\n const { points, unit, valueLabels } = useSensorSeries(\r\n sensor?.url ?? '',\r\n sensor?.dataFormat ?? 'Json',\r\n sensor?.updateFrequency ?? 0,\r\n { enabled: !!sensor?.url },\r\n )\r\n\r\n const ramp = resolveRamp(sensorType)\r\n const domain = resolveDomain(sensorType, observedDomain(points))\r\n\r\n const sameType = sensors.filter(\r\n s => s.typeId != null && s.typeId === sensor?.typeId && s.viewer === (currentViewer as ViewerNames),\r\n )\r\n\r\n if (!sensor || !sensorType || !domain) return null\r\n\r\n const latest = points[points.length - 1]?.value\r\n const hasReading = typeof latest === 'number' && Number.isFinite(latest)\r\n const gradient = `linear-gradient(to right, ${rampStops(ramp)\r\n .map(s => `${s.colour} ${s.offset * 100}%`)\r\n .join(', ')})`\r\n const [low, mid, high] = [domain.min, (domain.min + domain.max) / 2, domain.max]\r\n\r\n const readingText = hasReading\r\n ? valueLabels?.[latest] ?? `${format.format(latest)}${unit ? ` ${unit}` : ''}`\r\n : t('noReading')\r\n\r\n return (\r\n <LegendCard\r\n title={typeLabel(String(sensorType.name))}\r\n count={sameType.length}\r\n testId=\"sensor-legend-card\"\r\n countTestId=\"sensor-legend-count\"\r\n >\r\n <div className=\"px-3 py-2\">\r\n <div className=\"mb-2 flex items-baseline justify-between gap-2\">\r\n <span className=\"truncate text-xs text-muted-foreground\">{sensor.name}</span>\r\n <span className=\"shrink-0 text-xs font-medium tabular-nums\">{readingText}</span>\r\n </div>\r\n\r\n <div className=\"relative\">\r\n {/* Caret sits above the ramp at the current value. */}\r\n <div className=\"relative h-2\">\r\n {hasReading && (\r\n <div\r\n data-testid=\"sensor-legend-caret\"\r\n className=\"absolute top-0 -translate-x-1/2\"\r\n style={{ left: `${valueOffset(latest, domain) * 100}%` }}\r\n >\r\n <div className=\"h-2 w-0.5 rounded-full bg-foreground\" />\r\n </div>\r\n )}\r\n </div>\r\n <div\r\n data-testid=\"sensor-legend-ramp\"\r\n aria-hidden=\"true\"\r\n className=\"h-2.5 w-full rounded-full\"\r\n style={{ background: gradient }}\r\n />\r\n <div className=\"mt-1 flex justify-between text-[10px] tabular-nums text-muted-foreground\">\r\n <span>{format.format(low)}</span>\r\n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AAO,EAAE,YAAY,SAAS;AAAA;AAAA,UAChC;AAAA,UACA,qBAAC,SAAI,WAAU,4EACb;AAAA,gCAAC,UAAM,iBAAO,OAAO,GAAG,GAAE;AAAA,YAC1B,oBAAC,UAAM,iBAAO,OAAO,GAAG,GAAE;AAAA,YAC1B,oBAAC,UAAM,iBAAO,OAAO,IAAI,GAAE;AAAA,aAC7B;AAAA,WACF;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorLegend.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport { useSensors } from '../../../hooks/sensors/sensors'\r\nimport { useSensorTypes } from '../../../hooks/sensorTypes/sensorTypes'\r\nimport { MenusContext } from '../../../store'\r\nimport { Button } from '../Button'\r\nimport {\r\n DropdownMenu,\r\n DropdownMenuTrigger,\r\n DropdownMenuContent,\r\n DropdownMenuRadioGroup,\r\n DropdownMenuRadioItem,\r\n} from '../DropdownMenu'\r\nimport { LegendCard } from '../LegendCard'\r\n\r\nimport { observedDomain, rampStops, resolveDomain, resolveRamp, valueOffset } from './sensorColour'\r\nimport { activeSensorTypeId, legendScopeSensors } from './sensorVisibility'\r\nimport { latestValues, useSensorSeriesMulti } from './useSensorSeriesMulti'\r\n\r\nimport type { ViewerNames } from '../../../types/dbTypes'\r\n\r\nconst format = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\n/** `Air_Quality` reads as `Air Quality`, matching how the cards title a type. */\r\nconst typeLabel = (name: string): string => name.replace(/_/g, ' ')\r\n\r\n/**\r\n * Colour legend for the viewer's active sensor type, shown in the bottom-left card stack.\r\n *\r\n * This is what makes the value ramp readable: it puts the domain's numbers next to the colours\r\n * used by the marker halos and the chart fill, so nothing in the scene is encoded by colour\r\n * alone. Its title doubles as the type picker, which also retargets the halos and the map's\r\n * building colours.\r\n *\r\n * It exists only while it has something to explain: dismissed by its own close button, or with\r\n * no visible sensor of the active type, it renders nothing.\r\n */\r\nexport function SensorLegend(): React.ReactElement | null {\r\n const t = useTranslations('SensorLegend')\r\n const { state, dispatch } = React.useContext(MenusContext)\r\n const {\r\n focusedSensorId,\r\n currentSensorId,\r\n currentViewer,\r\n visibleSensorTypes,\r\n visibleSensorTags,\r\n sensorLegendVisible,\r\n sensorLegendTypeId,\r\n } = state.menus\r\n const viewer = currentViewer as ViewerNames\r\n\r\n const { sensors } = useSensors()\r\n const { sensorTypes } = useSensorTypes()\r\n\r\n // A click-focused sensor wins; hover is the fallback so the legend still explains the colours\r\n // while the pointer sweeps the scene.\r\n const activeId = focusedSensorId ?? currentSensorId\r\n const activeSensor = activeId == null ? undefined : sensors.find(s => s.id === activeId)\r\n const activeTypeId = activeSensorTypeId(sensors, {\r\n legendTypeId: sensorLegendTypeId?.[viewer],\r\n activeSensorId: activeId,\r\n })\r\n const sensorType = sensorTypes.find(ty => ty.id === activeTypeId)\r\n\r\n // After the type is changed from the dropdown the focused sensor belongs to another type, so\r\n // there is no reading to mark: the card shows the ramp alone until a sensor is picked.\r\n const caretSensor = activeSensor?.typeId === activeTypeId ? activeSensor : undefined\r\n\r\n const inScope = legendScopeSensors(\r\n sensors,\r\n {\r\n viewer,\r\n visibleTypeIds: visibleSensorTypes?.[viewer] ?? [],\r\n visibleTags: visibleSensorTags?.[viewer] ?? [],\r\n },\r\n activeTypeId,\r\n )\r\n\r\n // Polls the whole type, not just the focused sensor. Two reasons: the ramp has to be drawable\r\n // with nothing focused, and a type whose configured range is unusable can only get a domain\r\n // from what its sensors are actually reporting. It also makes the legend's domain identical to\r\n // the one the marker halos use, which is resolved across the same set.\r\n const { seriesById } = useSensorSeriesMulti(inScope, { enabled: inScope.length > 0 })\r\n\r\n // Types worth offering: every type placed in this viewer, visible or not. Picking a hidden\r\n // one turns it on below, so the list does not have to be pre-filtered by visibility.\r\n const selectableTypes = sensorTypes.filter(\r\n ty => sensors.some(s => s.viewer === viewer && s.typeId === ty.id),\r\n )\r\n\r\n const selectType = React.useCallback((sensorTypeId: number) => {\r\n dispatch({ type: 'SET_SENSOR_LEGEND_TYPE_ID', payload: { viewer, sensorTypeId } })\r\n // Without this the legend would hide itself the moment it retargets to a hidden type.\r\n dispatch({ type: 'TOGGLE_SENSOR_TYPE_VISIBILITY', payload: { viewer, sensorTypeId, force: true } })\r\n // Drops the caret, since the focused sensor is no longer of the displayed type. A null\r\n // payload deliberately leaves the pin above intact.\r\n dispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: null } })\r\n }, [dispatch, viewer])\r\n\r\n const closeLegend = React.useCallback(() => {\r\n dispatch({ type: 'TOGGLE_SENSOR_LEGEND', payload: { viewer, visible: false } })\r\n }, [dispatch, viewer])\r\n\r\n if (sensorLegendVisible?.[viewer] === false) return null\r\n if (!sensorType) return null\r\n // The one rule tying the card to the scene: no visible sensors of this type, no legend. Covers\r\n // the type switch, the tag switch and hide-all in a single condition.\r\n if (inScope.length === 0) return null\r\n\r\n const ramp = resolveRamp(sensorType)\r\n const typePoints = [...seriesById.values()].flatMap(series => series.points)\r\n const domain = resolveDomain(sensorType, observedDomain(typePoints))\r\n\r\n const caretSeries = caretSensor ? seriesById.get(caretSensor.id) : undefined\r\n const unit = caretSeries?.unit ?? [...seriesById.values()].find(s => s.unit)?.unit\r\n const valueLabels = caretSeries?.valueLabels\r\n const latest = caretSensor ? latestValues(seriesById).get(caretSensor.id) : undefined\r\n const hasReading = latest !== undefined\r\n const gradient = `linear-gradient(to right, ${rampStops(ramp)\r\n .map(s => `${s.colour} ${s.offset * 100}%`)\r\n .join(', ')})`\r\n\r\n const readingText = hasReading\r\n ? valueLabels?.[latest] ?? `${format.format(latest)}${unit ? ` ${unit}` : ''}`\r\n : t('noReading')\r\n\r\n const title = (\r\n <DropdownMenu>\r\n <DropdownMenuTrigger asChild>\r\n <Button\r\n variant=\"ghost\"\r\n size=\"sm\"\r\n title={t('selectType')}\r\n className=\"-ml-2 h-7 gap-1 px-2 text-sm font-medium\"\r\n data-testid=\"sensor-legend-type-trigger\"\r\n >\r\n {typeLabel(String(sensorType.name))}\r\n <LR.ChevronDown size={14} className=\"opacity-70\" />\r\n </Button>\r\n </DropdownMenuTrigger>\r\n <DropdownMenuContent align=\"start\">\r\n <DropdownMenuRadioGroup\r\n value={String(sensorType.id)}\r\n onValueChange={value => selectType(Number(value))}\r\n >\r\n {selectableTypes.map(ty => (\r\n <DropdownMenuRadioItem key={ty.id} value={String(ty.id)}>\r\n {typeLabel(String(ty.name))}\r\n </DropdownMenuRadioItem>\r\n ))}\r\n </DropdownMenuRadioGroup>\r\n </DropdownMenuContent>\r\n </DropdownMenu>\r\n )\r\n\r\n return (\r\n <LegendCard\r\n title={title}\r\n titleLabel={typeLabel(String(sensorType.name))}\r\n count={inScope.length}\r\n onClose={closeLegend}\r\n closeLabel={t('close')}\r\n testId=\"sensor-legend-card\"\r\n countTestId=\"sensor-legend-count\"\r\n >\r\n <div className=\"px-3 py-2\">\r\n <div className=\"mb-2 flex items-baseline justify-between gap-2\">\r\n <span className=\"truncate text-xs text-muted-foreground\">{caretSensor?.name ?? ''}</span>\r\n {caretSensor && (\r\n <span className=\"shrink-0 text-xs font-medium tabular-nums\">{readingText}</span>\r\n )}\r\n </div>\r\n\r\n {/* An unconfigured type still gets a card, so the picker that reached it stays reachable. */}\r\n {domain == null ? (\r\n <p className=\"text-xs text-muted-foreground\">{t('noRange')}</p>\r\n ) : (\r\n <div className=\"relative\">\r\n {/* Caret sits above the ramp at the current value. */}\r\n <div className=\"relative h-2\">\r\n {hasReading && (\r\n <div\r\n data-testid=\"sensor-legend-caret\"\r\n className=\"absolute top-0 -translate-x-1/2\"\r\n style={{ left: `${valueOffset(latest, domain) * 100}%` }}\r\n >\r\n <div className=\"h-2 w-0.5 rounded-full bg-foreground\" />\r\n </div>\r\n )}\r\n </div>\r\n <div\r\n data-testid=\"sensor-legend-ramp\"\r\n aria-hidden=\"true\"\r\n className=\"h-2.5 w-full rounded-full\"\r\n style={{ background: gradient }}\r\n />\r\n <div className=\"mt-1 flex justify-between text-[10px] tabular-nums text-muted-foreground\">\r\n <span>{format.format(domain.min)}</span>\r\n <span>{format.format((domain.min + domain.max) / 2)}</span>\r\n <span>{format.format(domain.max)}</span>\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n </LegendCard>\r\n )\r\n}\r\n"],"mappings":";AAwIQ,SAQE,KARF;AAnIR,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB,WAAW,eAAe,aAAa,mBAAmB;AACnF,SAAS,oBAAoB,0BAA0B;AACvD,SAAS,cAAc,4BAA4B;AAInD,MAAM,SAAS,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,EAAE,CAAC;AAG5E,MAAM,YAAY,CAAC,SAAyB,KAAK,QAAQ,MAAM,GAAG;AAa3D,SAAS,eAA0C;AA5C1D;AA6CE,QAAM,IAAI,gBAAgB,cAAc;AACxC,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,YAAY;AACzD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,MAAM;AACV,QAAM,SAAS;AAEf,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,EAAE,YAAY,IAAI,eAAe;AAIvC,QAAM,WAAW,4CAAmB;AACpC,QAAM,eAAe,YAAY,OAAO,SAAY,QAAQ,KAAK,OAAK,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
|
|
2
|
+
import { type RangeBounds } from './sensorRange';
|
|
2
3
|
import type { SensorSeries } from './sensorData';
|
|
3
4
|
export interface MultiSeriesEntry {
|
|
4
5
|
id: number;
|
|
@@ -10,17 +11,22 @@ interface SensorMultiSeriesChartProps {
|
|
|
10
11
|
focusedId: number;
|
|
11
12
|
/** Click a line or a legend row to focus that sensor everywhere. */
|
|
12
13
|
onFocus: (sensorId: number) => void;
|
|
13
|
-
/** Colour for the focused line. Siblings are
|
|
14
|
-
|
|
14
|
+
/** Colour for the focused line, carrying its current value. Siblings are not coloured. */
|
|
15
|
+
focusColour: string;
|
|
15
16
|
unit?: string;
|
|
16
17
|
valueLabels?: Record<number, string>;
|
|
17
18
|
timeZone: string;
|
|
18
19
|
emptyText: string;
|
|
19
20
|
othersLabel: (count: number) => string;
|
|
21
|
+
/** Window to show. `null` spans everything. Ignored unless `onBoundsChange` is supplied. */
|
|
22
|
+
bounds?: RangeBounds | null;
|
|
23
|
+
/** Supplying this renders the brush. Dragging it reports the new window in milliseconds. */
|
|
24
|
+
onBoundsChange?: (bounds: RangeBounds) => void;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Every sensor in scope over time, using the emphasis pattern: the focused sensor is the only
|
|
23
|
-
* coloured line and the rest are recessive hairlines.
|
|
28
|
+
* coloured line and the rest are recessive hairlines. That one colour is the focused sensor's
|
|
29
|
+
* own value ramp colour, so the line matches its bar, its halo and the legend caret.
|
|
24
30
|
*
|
|
25
31
|
* Why not a colour per sensor: a type can hold dozens of sensors, and past a handful of hues
|
|
26
32
|
* adjacent series stop being distinguishable (especially under colour-vision deficiency). Here
|
|
@@ -28,6 +34,6 @@ interface SensorMultiSeriesChartProps {
|
|
|
28
34
|
* colour, so it holds at any series count. Clicking a line or a legend row re-focuses, which
|
|
29
35
|
* also moves the marker halos and the viewer legend.
|
|
30
36
|
*/
|
|
31
|
-
export declare function SensorMultiSeriesChart({ sensors, seriesById, focusedId, onFocus,
|
|
37
|
+
export declare function SensorMultiSeriesChart({ sensors, seriesById, focusedId, onFocus, focusColour, unit, valueLabels, timeZone, emptyText, othersLabel, bounds, onBoundsChange, }: SensorMultiSeriesChartProps): React.ReactElement;
|
|
32
38
|
export {};
|
|
33
39
|
//# sourceMappingURL=SensorMultiSeriesChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorMultiSeriesChart.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorMultiSeriesChart.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SensorMultiSeriesChart.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorMultiSeriesChart.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAGlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAOhD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAuED,UAAU,2BAA2B;IACnC,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACtC,4FAA4F;IAC5F,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,4FAA4F;IAC5F,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;CAC/C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,MAAa,EACb,cAAc,GACf,EAAE,2BAA2B,GAAG,KAAK,CAAC,YAAY,CAgLlD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { CartesianGrid, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts";
|
|
4
|
+
import { Brush, CartesianGrid, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts";
|
|
5
5
|
import { formatInZone } from "../../../utils/timeUtils";
|
|
6
6
|
import { ChartContainer } from "../chart";
|
|
7
|
+
import { indicesForBounds } from "./sensorRange";
|
|
7
8
|
import { mergeSeriesRows, rowsValueDomain } from "./sensorSeriesRows";
|
|
8
9
|
const TOOLTIP_LIMIT = 8;
|
|
9
10
|
const valueNumber = new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 });
|
|
@@ -18,7 +19,13 @@ function SeriesTooltip({
|
|
|
18
19
|
othersLabel
|
|
19
20
|
}) {
|
|
20
21
|
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
21
|
-
const
|
|
22
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23
|
+
const entries = payload.filter((p) => typeof p.value === "number").filter((p) => {
|
|
24
|
+
const key = String(p.dataKey);
|
|
25
|
+
if (seen.has(key)) return false;
|
|
26
|
+
seen.add(key);
|
|
27
|
+
return true;
|
|
28
|
+
}).sort((a, b) => Number(b.value) - Number(a.value));
|
|
22
29
|
const shown = entries.slice(0, TOOLTIP_LIMIT);
|
|
23
30
|
const hidden = entries.length - shown.length;
|
|
24
31
|
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-md", children: [
|
|
@@ -45,12 +52,14 @@ function SensorMultiSeriesChart({
|
|
|
45
52
|
seriesById,
|
|
46
53
|
focusedId,
|
|
47
54
|
onFocus,
|
|
48
|
-
|
|
55
|
+
focusColour,
|
|
49
56
|
unit,
|
|
50
57
|
valueLabels,
|
|
51
58
|
timeZone,
|
|
52
59
|
emptyText,
|
|
53
|
-
othersLabel
|
|
60
|
+
othersLabel,
|
|
61
|
+
bounds = null,
|
|
62
|
+
onBoundsChange
|
|
54
63
|
}) {
|
|
55
64
|
const [hoveredId, setHoveredId] = React.useState(null);
|
|
56
65
|
const ids = sensors.map((s) => s.id);
|
|
@@ -64,6 +73,7 @@ function SensorMultiSeriesChart({
|
|
|
64
73
|
var _a;
|
|
65
74
|
return (_a = valueLabels == null ? void 0 : valueLabels[value]) != null ? _a : `${valueNumber.format(value)}${unit ? ` ${unit}` : ""}`;
|
|
66
75
|
};
|
|
76
|
+
const formatAxis = (value) => formatInZone(Number(value), timeZone, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
|
|
67
77
|
const renderTooltip = /* @__PURE__ */ jsx(
|
|
68
78
|
SeriesTooltip,
|
|
69
79
|
{
|
|
@@ -78,8 +88,17 @@ function SensorMultiSeriesChart({
|
|
|
78
88
|
return /* @__PURE__ */ jsx("div", { className: "flex h-[260px] items-center justify-center text-sm text-muted-foreground", children: emptyText });
|
|
79
89
|
}
|
|
80
90
|
const yDomain = valueDomain ? valueDomain.max > valueDomain.min ? [valueDomain.min, valueDomain.max] : [valueDomain.min - 1, valueDomain.max + 1] : void 0;
|
|
91
|
+
const showBrush = onBoundsChange != null && rows.length > 1;
|
|
92
|
+
const brushRange = showBrush ? indicesForBounds(rows, bounds) : null;
|
|
93
|
+
const reportBounds = (range) => {
|
|
94
|
+
var _a, _b, _c, _d;
|
|
95
|
+
const from = (_b = rows[(_a = range.startIndex) != null ? _a : 0]) == null ? void 0 : _b.t;
|
|
96
|
+
const to = (_d = rows[(_c = range.endIndex) != null ? _c : rows.length - 1]) == null ? void 0 : _d.t;
|
|
97
|
+
if (from == null || to == null) return;
|
|
98
|
+
onBoundsChange == null ? void 0 : onBoundsChange({ from, to });
|
|
99
|
+
};
|
|
81
100
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row", children: [
|
|
82
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[
|
|
101
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: `w-full ${showBrush ? "h-[300px]" : "h-[260px]"}`, children: /* @__PURE__ */ jsxs(LineChart, { data: rows, margin: { left: 0, right: 12, top: 10 }, children: [
|
|
83
102
|
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, opacity: 0.4 }),
|
|
84
103
|
/* @__PURE__ */ jsx(
|
|
85
104
|
YAxis,
|
|
@@ -108,10 +127,30 @@ function SensorMultiSeriesChart({
|
|
|
108
127
|
tickMargin: 8,
|
|
109
128
|
interval: "preserveStartEnd",
|
|
110
129
|
tick: { fontSize: 11 },
|
|
111
|
-
tickFormatter:
|
|
130
|
+
tickFormatter: formatAxis
|
|
112
131
|
}
|
|
113
132
|
),
|
|
114
133
|
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
|
|
134
|
+
sensors.map((sensor) => /* @__PURE__ */ jsx(
|
|
135
|
+
Line,
|
|
136
|
+
{
|
|
137
|
+
dataKey: String(sensor.id),
|
|
138
|
+
type: "monotone",
|
|
139
|
+
stroke: "transparent",
|
|
140
|
+
strokeWidth: 12,
|
|
141
|
+
dot: false,
|
|
142
|
+
activeDot: false,
|
|
143
|
+
connectNulls: true,
|
|
144
|
+
isAnimationActive: false,
|
|
145
|
+
legendType: "none",
|
|
146
|
+
tooltipType: "none",
|
|
147
|
+
onClick: () => onFocus(sensor.id),
|
|
148
|
+
onMouseEnter: () => setHoveredId(sensor.id),
|
|
149
|
+
onMouseLeave: () => setHoveredId(null),
|
|
150
|
+
style: { pointerEvents: "stroke", cursor: "pointer" }
|
|
151
|
+
},
|
|
152
|
+
`hit-${sensor.id}`
|
|
153
|
+
)),
|
|
115
154
|
sensors.map((sensor) => {
|
|
116
155
|
const isFocused = sensor.id === focusedId;
|
|
117
156
|
const isHovered = sensor.id === hoveredId;
|
|
@@ -121,7 +160,7 @@ function SensorMultiSeriesChart({
|
|
|
121
160
|
dataKey: String(sensor.id),
|
|
122
161
|
name: sensor.name,
|
|
123
162
|
type: "monotone",
|
|
124
|
-
stroke: isFocused ?
|
|
163
|
+
stroke: isFocused ? focusColour : "hsl(var(--muted-foreground))",
|
|
125
164
|
strokeWidth: isFocused ? 2 : isHovered ? 2 : 1,
|
|
126
165
|
strokeOpacity: isFocused ? 1 : isHovered ? 0.9 : 0.35,
|
|
127
166
|
strokeLinecap: "round",
|
|
@@ -135,7 +174,19 @@ function SensorMultiSeriesChart({
|
|
|
135
174
|
},
|
|
136
175
|
sensor.id
|
|
137
176
|
);
|
|
138
|
-
})
|
|
177
|
+
}),
|
|
178
|
+
showBrush && brushRange && /* @__PURE__ */ jsx(
|
|
179
|
+
Brush,
|
|
180
|
+
{
|
|
181
|
+
dataKey: "t",
|
|
182
|
+
height: 22,
|
|
183
|
+
travellerWidth: 8,
|
|
184
|
+
startIndex: brushRange.startIndex,
|
|
185
|
+
endIndex: brushRange.endIndex,
|
|
186
|
+
tickFormatter: (value) => formatAxis(Number(value)),
|
|
187
|
+
onChange: (range) => reportBounds(range)
|
|
188
|
+
}
|
|
189
|
+
)
|
|
139
190
|
] }) }) }),
|
|
140
191
|
/* @__PURE__ */ jsx("ul", { className: "max-h-[260px] shrink-0 overflow-y-auto sm:w-44", children: sensors.map((sensor) => {
|
|
141
192
|
const isFocused = sensor.id === focusedId;
|
|
@@ -155,7 +206,7 @@ function SensorMultiSeriesChart({
|
|
|
155
206
|
"aria-hidden": "true",
|
|
156
207
|
className: "h-0.5 w-3 shrink-0 rounded-full",
|
|
157
208
|
style: {
|
|
158
|
-
backgroundColor: isFocused ?
|
|
209
|
+
backgroundColor: isFocused ? focusColour : "hsl(var(--muted-foreground))",
|
|
159
210
|
opacity: isFocused ? 1 : 0.5
|
|
160
211
|
}
|
|
161
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorMultiSeriesChart.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\nimport { CartesianGrid, Line, LineChart, Tooltip, XAxis, YAxis } from 'recharts'\r\n\r\nimport { formatInZone } from '../../../utils/timeUtils'\r\nimport { ChartContainer, type ChartConfig } from '../chart'\r\n\r\nimport { mergeSeriesRows, rowsValueDomain } from './sensorSeriesRows'\r\n\r\nimport type { SensorSeries } from './sensorData'\r\n\r\n/** How many series the tooltip lists before collapsing the tail into a count. */\r\nconst TOOLTIP_LIMIT = 8\r\n\r\nconst valueNumber = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\nexport interface MultiSeriesEntry {\r\n id: number\r\n name: string\r\n}\r\n\r\ninterface TooltipPayloadEntry {\r\n dataKey?: string | number | ((obj: unknown) => unknown)\r\n value?: unknown\r\n}\r\n\r\ninterface SeriesTooltipProps {\r\n active?: boolean\r\n payload?: TooltipPayloadEntry[]\r\n label?: unknown\r\n nameById: Map<number, string>\r\n focusedId: number\r\n timeZone: string\r\n formatValue: (value: number) => string\r\n othersLabel: (count: number) => string\r\n}\r\n\r\n/**\r\n * Declared at module scope, not inline in the chart: a component defined during render is a new\r\n * type on every pass, so React would tear down and rebuild the tooltip subtree each time.\r\n */\r\nfunction SeriesTooltip({\r\n active,\r\n payload,\r\n label,\r\n nameById,\r\n focusedId,\r\n timeZone,\r\n formatValue,\r\n othersLabel,\r\n}: SeriesTooltipProps): React.ReactElement | null {\r\n if (!active || !payload?.length) return null\r\n const entries = payload\r\n .filter(p => typeof p.value === 'number')\r\n .sort((a, b) => Number(b.value) - Number(a.value))\r\n const shown = entries.slice(0, TOOLTIP_LIMIT)\r\n const hidden = entries.length - shown.length\r\n\r\n return (\r\n <div className=\"rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-md\">\r\n <div className=\"mb-1 font-medium\">\r\n {formatInZone(Number(label), timeZone, {\r\n month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23',\r\n })}\r\n </div>\r\n {shown.map(p => {\r\n const id = Number(p.dataKey)\r\n return (\r\n <div key={String(p.dataKey)} className=\"flex items-baseline justify-between gap-3\">\r\n <span className={id === focusedId ? 'font-medium' : 'text-muted-foreground'}>\r\n {nameById.get(id) ?? String(p.dataKey)}\r\n </span>\r\n <span className=\"tabular-nums\">{formatValue(Number(p.value))}</span>\r\n </div>\r\n )\r\n })}\r\n {hidden > 0 && <div className=\"mt-1 text-muted-foreground\">{othersLabel(hidden)}</div>}\r\n </div>\r\n )\r\n}\r\n\r\ninterface SensorMultiSeriesChartProps {\r\n sensors: MultiSeriesEntry[]\r\n seriesById: Map<number, SensorSeries>\r\n focusedId: number\r\n /** Click a line or a legend row to focus that sensor everywhere. */\r\n onFocus: (sensorId: number) => void\r\n /** Colour for the focused line. Siblings are deliberately not coloured. */\r\n accentColour: string\r\n unit?: string\r\n valueLabels?: Record<number, string>\r\n timeZone: string\r\n emptyText: string\r\n othersLabel: (count: number) => string\r\n}\r\n\r\n/**\r\n * Every sensor in scope over time, using the emphasis pattern: the focused sensor is the only\r\n * coloured line and the rest are recessive hairlines.\r\n *\r\n * Why not a colour per sensor: a type can hold dozens of sensors, and past a handful of hues\r\n * adjacent series stop being distinguishable (especially under colour-vision deficiency). Here\r\n * identity comes from the legend list, the hover lift and the shared tooltip rather than from\r\n * colour, so it holds at any series count. Clicking a line or a legend row re-focuses, which\r\n * also moves the marker halos and the viewer legend.\r\n */\r\nexport function SensorMultiSeriesChart({\r\n sensors,\r\n seriesById,\r\n focusedId,\r\n onFocus,\r\n accentColour,\r\n unit,\r\n valueLabels,\r\n timeZone,\r\n emptyText,\r\n othersLabel,\r\n}: SensorMultiSeriesChartProps): React.ReactElement {\r\n const [hoveredId, setHoveredId] = React.useState<number | null>(null)\r\n\r\n const ids = sensors.map(s => s.id)\r\n const rows = React.useMemo(() => mergeSeriesRows(seriesById, ids), [seriesById, ids.join(',')])\r\n const valueDomain = rowsValueDomain(rows, ids)\r\n const nameById = new Map(sensors.map(s => [s.id, s.name]))\r\n\r\n // ChartContainer needs a config entry per key to size its CSS vars; colours come from the\r\n // Line props instead, since they depend on focus rather than identity.\r\n const chartConfig: ChartConfig = Object.fromEntries(\r\n sensors.map(s => [String(s.id), { label: s.name }]),\r\n )\r\n\r\n const formatValue = (value: number): string =>\r\n valueLabels?.[value] ?? `${valueNumber.format(value)}${unit ? ` ${unit}` : ''}`\r\n\r\n // Recharts renders `content` itself, so pass an element carrying the extra props; it merges\r\n // its own active/payload/label in.\r\n const renderTooltip = (\r\n <SeriesTooltip\r\n nameById={nameById}\r\n focusedId={focusedId}\r\n timeZone={timeZone}\r\n formatValue={formatValue}\r\n othersLabel={othersLabel}\r\n />\r\n )\r\n\r\n if (rows.length === 0) {\r\n return <div className=\"flex h-[260px] items-center justify-center text-sm text-muted-foreground\">{emptyText}</div>\r\n }\r\n\r\n const yDomain: [number, number] | undefined = valueDomain\r\n ? valueDomain.max > valueDomain.min\r\n ? [valueDomain.min, valueDomain.max]\r\n : [valueDomain.min - 1, valueDomain.max + 1]\r\n : undefined\r\n\r\n return (\r\n <div className=\"flex flex-col gap-3 sm:flex-row\">\r\n <div className=\"min-w-0 flex-1\">\r\n <ChartContainer config={chartConfig} className=\"h-[260px] w-full\">\r\n <LineChart data={rows} margin={{ left: 0, right: 12, top: 10 }}>\r\n <CartesianGrid vertical={false} opacity={0.4} />\r\n <YAxis\r\n domain={yDomain}\r\n tickLine={false}\r\n axisLine={false}\r\n width={44}\r\n tickMargin={4}\r\n tick={{ fontSize: 11 }}\r\n tickFormatter={(value: number) => valueLabels?.[value] ?? valueNumber.format(value)}\r\n />\r\n <XAxis\r\n dataKey=\"t\"\r\n type=\"number\"\r\n scale=\"time\"\r\n domain={['dataMin', 'dataMax']}\r\n tickLine={false}\r\n axisLine={false}\r\n tickMargin={8}\r\n interval=\"preserveStartEnd\"\r\n tick={{ fontSize: 11 }}\r\n tickFormatter={(value: number) =>\r\n formatInZone(Number(value), timeZone, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })}\r\n />\r\n {/* One crosshair readout listing every series, so the pointer never has to land on\r\n a specific 1px line to read a value. */}\r\n <Tooltip content={renderTooltip} />\r\n {sensors.map(sensor => {\r\n const isFocused = sensor.id === focusedId\r\n const isHovered = sensor.id === hoveredId\r\n return (\r\n <Line\r\n key={sensor.id}\r\n dataKey={String(sensor.id)}\r\n name={sensor.name}\r\n type=\"monotone\"\r\n // Colour marks focus, never identity: see the component doc.\r\n stroke={isFocused ? accentColour : 'hsl(var(--muted-foreground))'}\r\n strokeWidth={isFocused ? 2 : isHovered ? 2 : 1}\r\n strokeOpacity={isFocused ? 1 : isHovered ? 0.9 : 0.35}\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n dot={false}\r\n activeDot={{ r: 4 }}\r\n connectNulls\r\n isAnimationActive={false}\r\n onClick={() => onFocus(sensor.id)}\r\n style={{ cursor: 'pointer' }}\r\n />\r\n )\r\n })}\r\n </LineChart>\r\n </ChartContainer>\r\n </div>\r\n\r\n {/* The dependable identity channel: names, not colours. */}\r\n <ul className=\"max-h-[260px] shrink-0 overflow-y-auto sm:w-44\">\r\n {sensors.map(sensor => {\r\n const isFocused = sensor.id === focusedId\r\n return (\r\n <li key={sensor.id}>\r\n <button\r\n type=\"button\"\r\n onClick={() => onFocus(sensor.id)}\r\n onMouseEnter={() => setHoveredId(sensor.id)}\r\n onMouseLeave={() => setHoveredId(null)}\r\n aria-current={isFocused}\r\n className={`flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-accent ${\r\n isFocused ? 'font-medium' : 'text-muted-foreground'\r\n }`}\r\n >\r\n <span\r\n aria-hidden=\"true\"\r\n className=\"h-0.5 w-3 shrink-0 rounded-full\"\r\n style={{\r\n backgroundColor: isFocused ? accentColour : 'hsl(var(--muted-foreground))',\r\n opacity: isFocused ? 1 : 0.5,\r\n }}\r\n />\r\n <span className=\"truncate\">{sensor.name}</span>\r\n </button>\r\n </li>\r\n )\r\n })}\r\n </ul>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AAgEM,cAQI,YARJ;AA3DN,YAAY,WAAW;AACvB,SAAS,eAAe,MAAM,WAAW,SAAS,OAAO,aAAa;AAEtE,SAAS,oBAAoB;AAC7B,SAAS,sBAAwC;AAEjD,SAAS,iBAAiB,uBAAuB;AAKjD,MAAM,gBAAgB;AAEtB,MAAM,cAAc,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,EAAE,CAAC;AA2BjF,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,CAAC,UAAU,EAAC,mCAAS,QAAQ,QAAO;AACxC,QAAM,UAAU,QACb,OAAO,OAAK,OAAO,EAAE,UAAU,QAAQ,EACvC,KAAK,CAAC,GAAG,MAAM,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,KAAK,CAAC;AACnD,QAAM,QAAQ,QAAQ,MAAM,GAAG,aAAa;AAC5C,QAAM,SAAS,QAAQ,SAAS,MAAM;AAEtC,SACE,qBAAC,SAAI,WAAU,mEACb;AAAA,wBAAC,SAA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AA;AAAA,YACF;AAAA,YACA,oBAAC,UAAK,WAAU,YAAY,iBAAO,MAAK;AAAA;AAAA;AAAA,MAC1C,KApBO,OAAO,EAqBhB;AAAA,IAEJ,CAAC,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorMultiSeriesChart.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\nimport { Brush, CartesianGrid, Line, LineChart, Tooltip, XAxis, YAxis } from 'recharts'\r\n\r\nimport { formatInZone } from '../../../utils/timeUtils'\r\nimport { ChartContainer, type ChartConfig } from '../chart'\r\n\r\nimport { indicesForBounds, type RangeBounds } from './sensorRange'\r\nimport { mergeSeriesRows, rowsValueDomain } from './sensorSeriesRows'\r\n\r\nimport type { SensorSeries } from './sensorData'\r\n\r\n/** How many series the tooltip lists before collapsing the tail into a count. */\r\nconst TOOLTIP_LIMIT = 8\r\n\r\nconst valueNumber = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\nexport interface MultiSeriesEntry {\r\n id: number\r\n name: string\r\n}\r\n\r\ninterface TooltipPayloadEntry {\r\n dataKey?: string | number | ((obj: unknown) => unknown)\r\n value?: unknown\r\n}\r\n\r\ninterface SeriesTooltipProps {\r\n active?: boolean\r\n payload?: TooltipPayloadEntry[]\r\n label?: unknown\r\n nameById: Map<number, string>\r\n focusedId: number\r\n timeZone: string\r\n formatValue: (value: number) => string\r\n othersLabel: (count: number) => string\r\n}\r\n\r\n/**\r\n * Declared at module scope, not inline in the chart: a component defined during render is a new\r\n * type on every pass, so React would tear down and rebuild the tooltip subtree each time.\r\n */\r\nfunction SeriesTooltip({\r\n active,\r\n payload,\r\n label,\r\n nameById,\r\n focusedId,\r\n timeZone,\r\n formatValue,\r\n othersLabel,\r\n}: SeriesTooltipProps): React.ReactElement | null {\r\n if (!active || !payload?.length) return null\r\n // Each series is drawn twice, once as an invisible wide hit target, so recharts hands us two\r\n // payload entries per sensor. Keep the first of each dataKey.\r\n const seen = new Set<string>()\r\n const entries = payload\r\n .filter(p => typeof p.value === 'number')\r\n .filter(p => {\r\n const key = String(p.dataKey)\r\n if (seen.has(key)) return false\r\n seen.add(key)\r\n return true\r\n })\r\n .sort((a, b) => Number(b.value) - Number(a.value))\r\n const shown = entries.slice(0, TOOLTIP_LIMIT)\r\n const hidden = entries.length - shown.length\r\n\r\n return (\r\n <div className=\"rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-md\">\r\n <div className=\"mb-1 font-medium\">\r\n {formatInZone(Number(label), timeZone, {\r\n month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23',\r\n })}\r\n </div>\r\n {shown.map(p => {\r\n const id = Number(p.dataKey)\r\n return (\r\n <div key={String(p.dataKey)} className=\"flex items-baseline justify-between gap-3\">\r\n <span className={id === focusedId ? 'font-medium' : 'text-muted-foreground'}>\r\n {nameById.get(id) ?? String(p.dataKey)}\r\n </span>\r\n <span className=\"tabular-nums\">{formatValue(Number(p.value))}</span>\r\n </div>\r\n )\r\n })}\r\n {hidden > 0 && <div className=\"mt-1 text-muted-foreground\">{othersLabel(hidden)}</div>}\r\n </div>\r\n )\r\n}\r\n\r\ninterface SensorMultiSeriesChartProps {\r\n sensors: MultiSeriesEntry[]\r\n seriesById: Map<number, SensorSeries>\r\n focusedId: number\r\n /** Click a line or a legend row to focus that sensor everywhere. */\r\n onFocus: (sensorId: number) => void\r\n /** Colour for the focused line, carrying its current value. Siblings are not coloured. */\r\n focusColour: string\r\n unit?: string\r\n valueLabels?: Record<number, string>\r\n timeZone: string\r\n emptyText: string\r\n othersLabel: (count: number) => string\r\n /** Window to show. `null` spans everything. Ignored unless `onBoundsChange` is supplied. */\r\n bounds?: RangeBounds | null\r\n /** Supplying this renders the brush. Dragging it reports the new window in milliseconds. */\r\n onBoundsChange?: (bounds: RangeBounds) => void\r\n}\r\n\r\n/**\r\n * Every sensor in scope over time, using the emphasis pattern: the focused sensor is the only\r\n * coloured line and the rest are recessive hairlines. That one colour is the focused sensor's\r\n * own value ramp colour, so the line matches its bar, its halo and the legend caret.\r\n *\r\n * Why not a colour per sensor: a type can hold dozens of sensors, and past a handful of hues\r\n * adjacent series stop being distinguishable (especially under colour-vision deficiency). Here\r\n * identity comes from the legend list, the hover lift and the shared tooltip rather than from\r\n * colour, so it holds at any series count. Clicking a line or a legend row re-focuses, which\r\n * also moves the marker halos and the viewer legend.\r\n */\r\nexport function SensorMultiSeriesChart({\r\n sensors,\r\n seriesById,\r\n focusedId,\r\n onFocus,\r\n focusColour,\r\n unit,\r\n valueLabels,\r\n timeZone,\r\n emptyText,\r\n othersLabel,\r\n bounds = null,\r\n onBoundsChange,\r\n}: SensorMultiSeriesChartProps): React.ReactElement {\r\n const [hoveredId, setHoveredId] = React.useState<number | null>(null)\r\n\r\n const ids = sensors.map(s => s.id)\r\n const rows = React.useMemo(() => mergeSeriesRows(seriesById, ids), [seriesById, ids.join(',')])\r\n const valueDomain = rowsValueDomain(rows, ids)\r\n const nameById = new Map(sensors.map(s => [s.id, s.name]))\r\n\r\n // ChartContainer needs a config entry per key to size its CSS vars; colours come from the\r\n // Line props instead, since they depend on focus rather than identity.\r\n const chartConfig: ChartConfig = Object.fromEntries(\r\n sensors.map(s => [String(s.id), { label: s.name }]),\r\n )\r\n\r\n const formatValue = (value: number): string =>\r\n valueLabels?.[value] ?? `${valueNumber.format(value)}${unit ? ` ${unit}` : ''}`\r\n\r\n const formatAxis = (value: number): string =>\r\n formatInZone(Number(value), timeZone, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })\r\n\r\n // Recharts renders `content` itself, so pass an element carrying the extra props; it merges\r\n // its own active/payload/label in.\r\n const renderTooltip = (\r\n <SeriesTooltip\r\n nameById={nameById}\r\n focusedId={focusedId}\r\n timeZone={timeZone}\r\n formatValue={formatValue}\r\n othersLabel={othersLabel}\r\n />\r\n )\r\n\r\n if (rows.length === 0) {\r\n return <div className=\"flex h-[260px] items-center justify-center text-sm text-muted-foreground\">{emptyText}</div>\r\n }\r\n\r\n const yDomain: [number, number] | undefined = valueDomain\r\n ? valueDomain.max > valueDomain.min\r\n ? [valueDomain.min, valueDomain.max]\r\n : [valueDomain.min - 1, valueDomain.max + 1]\r\n : undefined\r\n\r\n // The brush windows the merged rows, so a preset picked upstream and a drag down here are the\r\n // same operation expressed in two units: the caller works in times, recharts in row indices.\r\n const showBrush = onBoundsChange != null && rows.length > 1\r\n const brushRange = showBrush ? indicesForBounds(rows, bounds) : null\r\n const reportBounds = (range: { startIndex?: number; endIndex?: number }) => {\r\n const from = rows[range.startIndex ?? 0]?.t\r\n const to = rows[range.endIndex ?? rows.length - 1]?.t\r\n if (from == null || to == null) return\r\n onBoundsChange?.({ from, to })\r\n }\r\n\r\n return (\r\n <div className=\"flex flex-col gap-3 sm:flex-row\">\r\n <div className=\"min-w-0 flex-1\">\r\n <ChartContainer config={chartConfig} className={`w-full ${showBrush ? 'h-[300px]' : 'h-[260px]'}`}>\r\n <LineChart data={rows} margin={{ left: 0, right: 12, top: 10 }}>\r\n <CartesianGrid vertical={false} opacity={0.4} />\r\n <YAxis\r\n domain={yDomain}\r\n tickLine={false}\r\n axisLine={false}\r\n width={44}\r\n tickMargin={4}\r\n tick={{ fontSize: 11 }}\r\n tickFormatter={(value: number) => valueLabels?.[value] ?? valueNumber.format(value)}\r\n />\r\n <XAxis\r\n dataKey=\"t\"\r\n type=\"number\"\r\n scale=\"time\"\r\n domain={['dataMin', 'dataMax']}\r\n tickLine={false}\r\n axisLine={false}\r\n tickMargin={8}\r\n interval=\"preserveStartEnd\"\r\n tick={{ fontSize: 11 }}\r\n tickFormatter={formatAxis}\r\n />\r\n {/* One crosshair readout listing every series, so the pointer never has to land on\r\n a specific 1px line to read a value. */}\r\n <Tooltip content={renderTooltip} />\r\n {/* Transparent fat copies of every series, drawn under the real ones: a recessive\r\n line is a 1px path and all but unclickable, so this is what actually catches the\r\n pointer. `pointerEvents: stroke` hit-tests the widened stroke, not the fill. */}\r\n {sensors.map(sensor => (\r\n <Line\r\n key={`hit-${sensor.id}`}\r\n dataKey={String(sensor.id)}\r\n type=\"monotone\"\r\n stroke=\"transparent\"\r\n strokeWidth={12}\r\n dot={false}\r\n activeDot={false}\r\n connectNulls\r\n isAnimationActive={false}\r\n legendType=\"none\"\r\n tooltipType=\"none\"\r\n onClick={() => onFocus(sensor.id)}\r\n onMouseEnter={() => setHoveredId(sensor.id)}\r\n onMouseLeave={() => setHoveredId(null)}\r\n style={{ pointerEvents: 'stroke', cursor: 'pointer' }}\r\n />\r\n ))}\r\n {sensors.map(sensor => {\r\n const isFocused = sensor.id === focusedId\r\n const isHovered = sensor.id === hoveredId\r\n return (\r\n <Line\r\n key={sensor.id}\r\n dataKey={String(sensor.id)}\r\n name={sensor.name}\r\n type=\"monotone\"\r\n // Colour marks focus, never identity: see the component doc.\r\n stroke={isFocused ? focusColour : 'hsl(var(--muted-foreground))'}\r\n strokeWidth={isFocused ? 2 : isHovered ? 2 : 1}\r\n strokeOpacity={isFocused ? 1 : isHovered ? 0.9 : 0.35}\r\n strokeLinecap=\"round\"\r\n strokeLinejoin=\"round\"\r\n dot={false}\r\n activeDot={{ r: 4 }}\r\n connectNulls\r\n isAnimationActive={false}\r\n onClick={() => onFocus(sensor.id)}\r\n style={{ cursor: 'pointer' }}\r\n />\r\n )\r\n })}\r\n {showBrush && brushRange && (\r\n <Brush\r\n dataKey=\"t\"\r\n height={22}\r\n travellerWidth={8}\r\n startIndex={brushRange.startIndex}\r\n endIndex={brushRange.endIndex}\r\n tickFormatter={(value) => formatAxis(Number(value))}\r\n onChange={(range) => reportBounds(range as { startIndex?: number; endIndex?: number })}\r\n />\r\n )}\r\n </LineChart>\r\n </ChartContainer>\r\n </div>\r\n\r\n {/* The dependable identity channel: names, not colours. */}\r\n <ul className=\"max-h-[260px] shrink-0 overflow-y-auto sm:w-44\">\r\n {sensors.map(sensor => {\r\n const isFocused = sensor.id === focusedId\r\n return (\r\n <li key={sensor.id}>\r\n <button\r\n type=\"button\"\r\n onClick={() => onFocus(sensor.id)}\r\n onMouseEnter={() => setHoveredId(sensor.id)}\r\n onMouseLeave={() => setHoveredId(null)}\r\n aria-current={isFocused}\r\n className={`flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-accent ${\r\n isFocused ? 'font-medium' : 'text-muted-foreground'\r\n }`}\r\n >\r\n <span\r\n aria-hidden=\"true\"\r\n className=\"h-0.5 w-3 shrink-0 rounded-full\"\r\n style={{\r\n backgroundColor: isFocused ? focusColour : 'hsl(var(--muted-foreground))',\r\n opacity: isFocused ? 1 : 0.5,\r\n }}\r\n />\r\n <span className=\"truncate\">{sensor.name}</span>\r\n </button>\r\n </li>\r\n )\r\n })}\r\n </ul>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AA0EM,cAQI,YARJ;AArEN,YAAY,WAAW;AACvB,SAAS,OAAO,eAAe,MAAM,WAAW,SAAS,OAAO,aAAa;AAE7E,SAAS,oBAAoB;AAC7B,SAAS,sBAAwC;AAEjD,SAAS,wBAA0C;AACnD,SAAS,iBAAiB,uBAAuB;AAKjD,MAAM,gBAAgB;AAEtB,MAAM,cAAc,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,EAAE,CAAC;AA2BjF,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,CAAC,UAAU,EAAC,mCAAS,QAAQ,QAAO;AAGxC,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,UAAU,QACb,OAAO,OAAK,OAAO,EAAE,UAAU,QAAQ,EACvC,OAAO,OAAK;AACX,UAAM,MAAM,OAAO,EAAE,OAAO;AAC5B,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO;AAC1B,SAAK,IAAI,GAAG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,uBAC9B;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,eAAY;AAAA,gBACZ,WAAU;AAAA,gBACV,OAAO;AAAA,kBACL,iBAAiB,YAAY,cAAc;AAAA,kBAC3C,SAAS,YAAY,IAAI;AAAA,gBAC3B;AAAA;AAAA,YACF;AAAA,YACA,oBAAC,UAAK,WAAU,YAAY,iBAAO,MAAK;AAAA;AAAA;AAAA,MAC1C,KApBO,OAAO,EAqBhB;AAAA,IAEJ,CAAC,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export declare const UNTAGGED_TAG = "__untagged__";
|
|
2
|
+
export { UNTAGGED_TAG } from './sensorVisibility';
|
|
4
3
|
export declare function SensorsSection(): React.JSX.Element;
|
|
5
4
|
//# sourceMappingURL=SensorsSection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SensorsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAuC9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,wBAAgB,cAAc,sBAwW7B"}
|
|
@@ -26,15 +26,16 @@ import { SensorInput } from "./SensorInput";
|
|
|
26
26
|
import { SensorsSectionSkeleton } from "./SensorsSectionSkeleton";
|
|
27
27
|
import { resolveLucideIcon } from "./sensorUtils";
|
|
28
28
|
import { valueColoursBySensor } from "./sensorValueColours";
|
|
29
|
+
import { activeSensorTypeId, legendScopeSensors, UNTAGGED_TAG } from "./sensorVisibility";
|
|
29
30
|
import { useSensorSeriesMulti } from "./useSensorSeriesMulti";
|
|
30
31
|
const readingNumber = new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 });
|
|
31
|
-
|
|
32
|
+
import { UNTAGGED_TAG as UNTAGGED_TAG2 } from "./sensorVisibility";
|
|
32
33
|
function SensorsSection() {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
34
35
|
const t = useTranslations("SensorsSection");
|
|
35
36
|
const { dispatch: toolsDispatch } = React.useContext(ToolsContext);
|
|
36
37
|
const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext);
|
|
37
|
-
const { currentViewer, visibleSensorTypes, visibleSensorTags, focusedSensorId } = menusState.menus;
|
|
38
|
+
const { currentViewer, visibleSensorTypes, visibleSensorTags, focusedSensorId, sensorLegendVisible, sensorLegendTypeId } = menusState.menus;
|
|
38
39
|
const { sensors: allSensors } = useSensors();
|
|
39
40
|
const { sensorTypes, isLoading } = useSensorTypes();
|
|
40
41
|
const { state: buildingsState } = React.useContext(BuildingsContext);
|
|
@@ -132,6 +133,22 @@ function SensorsSection() {
|
|
|
132
133
|
menusDispatch({ type: "HIDE_ALL_SENSOR_TAGS_IN_VIEWER", payload: { viewer: currentViewer } });
|
|
133
134
|
}
|
|
134
135
|
}, [currentViewer, menusDispatch]);
|
|
136
|
+
const legendHasContent = legendScopeSensors(
|
|
137
|
+
allSensors,
|
|
138
|
+
{
|
|
139
|
+
viewer: currentViewer,
|
|
140
|
+
visibleTypeIds: (_h = visibleSensorTypes == null ? void 0 : visibleSensorTypes[currentViewer]) != null ? _h : [],
|
|
141
|
+
visibleTags: (_i = visibleSensorTags == null ? void 0 : visibleSensorTags[currentViewer]) != null ? _i : []
|
|
142
|
+
},
|
|
143
|
+
activeSensorTypeId(allSensors, {
|
|
144
|
+
legendTypeId: sensorLegendTypeId == null ? void 0 : sensorLegendTypeId[currentViewer],
|
|
145
|
+
activeSensorId: focusedSensorId
|
|
146
|
+
})
|
|
147
|
+
).length > 0;
|
|
148
|
+
const legendVisible = legendHasContent && (sensorLegendVisible == null ? void 0 : sensorLegendVisible[currentViewer]) !== false;
|
|
149
|
+
const toggleLegend = React.useCallback(() => {
|
|
150
|
+
menusDispatch({ type: "TOGGLE_SENSOR_LEGEND", payload: { viewer: currentViewer } });
|
|
151
|
+
}, [currentViewer, menusDispatch]);
|
|
135
152
|
const toggleSensorTagVisibility = React.useCallback((tag) => {
|
|
136
153
|
menusDispatch({
|
|
137
154
|
type: "TOGGLE_SENSOR_TAG_VISIBILITY",
|
|
@@ -183,6 +200,19 @@ function SensorsSection() {
|
|
|
183
200
|
onChange: (e) => setSearchQuery(e.target.value)
|
|
184
201
|
}
|
|
185
202
|
),
|
|
203
|
+
/* @__PURE__ */ jsx(
|
|
204
|
+
Button,
|
|
205
|
+
{
|
|
206
|
+
variant: legendVisible ? "default" : "outline",
|
|
207
|
+
size: "icon",
|
|
208
|
+
title: t("toggleLegend"),
|
|
209
|
+
"aria-pressed": legendVisible,
|
|
210
|
+
disabled: !legendHasContent,
|
|
211
|
+
className: "flex-shrink-0",
|
|
212
|
+
onClick: toggleLegend,
|
|
213
|
+
children: /* @__PURE__ */ jsx(LR.Palette, { size: 16 })
|
|
214
|
+
}
|
|
215
|
+
),
|
|
186
216
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
187
217
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", title: t("filters"), className: "flex-shrink-0", children: /* @__PURE__ */ jsx(LR.Funnel, { size: 16 }) }) }),
|
|
188
218
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
|
|
@@ -233,7 +263,7 @@ function SensorsSection() {
|
|
|
233
263
|
checked: isTypeVisible,
|
|
234
264
|
onCheckedChange: () => toggleSensorTypeVisibility(typeId)
|
|
235
265
|
},
|
|
236
|
-
children: /* @__PURE__ */ jsx("div", { className: "space-y-2 mx-2 pr-2", children: sensorsOfType.map((sensor) => {
|
|
266
|
+
children: /* @__PURE__ */ jsx("div", { className: "space-y-2 mx-2 pr-2 py-1", children: sensorsOfType.map((sensor) => {
|
|
237
267
|
var _a3;
|
|
238
268
|
return /* @__PURE__ */ jsx(
|
|
239
269
|
CollapsibleSensorItem,
|
|
@@ -271,7 +301,7 @@ function SensorsSection() {
|
|
|
271
301
|
checked: isTagVisible,
|
|
272
302
|
onCheckedChange: () => toggleSensorTagVisibility(tag)
|
|
273
303
|
},
|
|
274
|
-
children: /* @__PURE__ */ jsx("div", { className: "space-y-2 mx-2 pr-2", children: sensorsOfTag.map((sensor) => {
|
|
304
|
+
children: /* @__PURE__ */ jsx("div", { className: "space-y-2 mx-2 pr-2 py-1", children: sensorsOfTag.map((sensor) => {
|
|
275
305
|
var _a3;
|
|
276
306
|
const type = sensorTypes.find((tp) => tp.id === sensor.typeId);
|
|
277
307
|
return /* @__PURE__ */ jsx(
|
|
@@ -310,6 +340,6 @@ function SensorsSection() {
|
|
|
310
340
|
}
|
|
311
341
|
export {
|
|
312
342
|
SensorsSection,
|
|
313
|
-
UNTAGGED_TAG
|
|
343
|
+
UNTAGGED_TAG2 as UNTAGGED_TAG
|
|
314
344
|
};
|
|
315
345
|
//# sourceMappingURL=SensorsSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\nimport { toast } from 'sonner'\r\n\r\nimport { useSensor, useSensors } from '../../../hooks/sensors/sensors'\r\nimport { useSensorTypes } from '../../../hooks/sensorTypes/sensorTypes'\r\nimport { AppConfigContext, BuildingsContext, MenusContext, ToolsContext } from '../../../store'\r\nimport { resolveDefaultTimeZone } from '../../../utils/timeUtils'\r\nimport { stringToColour } from '../../viewers/map/utils/stringToColour'\r\nimport { Button } from '../Button'\r\nimport { CollapsibleSection } from '../CollapsibleSection'\r\nimport { DropdownMenu } from '../DropdownMenu'\r\nimport {\r\n DropdownMenuTrigger,\r\n DropdownMenuContent,\r\n DropdownMenuLabel,\r\n DropdownMenuSeparator,\r\n DropdownMenuRadioGroup,\r\n DropdownMenuRadioItem,\r\n} from '../DropdownMenu'\r\nimport { SearchInput } from '../SearchInput'\r\n\r\nimport { CollapsibleSensorItem } from './CollapsibleSensorItem'\r\nimport { SensorInput } from './SensorInput'\r\nimport { SensorsSectionSkeleton } from './SensorsSectionSkeleton'\r\nimport { resolveLucideIcon } from './sensorUtils'\r\nimport { valueColoursBySensor } from './sensorValueColours'\r\nimport { useSensorSeriesMulti } from './useSensorSeriesMulti'\r\n\r\nimport type { Sensor } from '../../../types/dbTypes';\r\n\r\n/** Sidebar readings: compact, at most one decimal, so a row stays on one line. */\r\nconst readingNumber = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\n\r\ntype SensorAction = 'view' | 'edit' | 'delete'\r\n\r\n/** Stable key used in state for sensors with no tags — locale-independent */\r\nexport const UNTAGGED_TAG = '__untagged__'\r\n\r\nexport function SensorsSection() {\r\n // Translation\r\n const t = useTranslations('SensorsSection')\r\n\r\n const { dispatch: toolsDispatch } = React.useContext(ToolsContext)\r\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { currentViewer, visibleSensorTypes, visibleSensorTags, focusedSensorId } = menusState.menus\r\n\r\n const { sensors: allSensors }: { sensors: Sensor[] } = useSensors()\r\n const { sensorTypes, isLoading } = useSensorTypes()\r\n\r\n const {state: buildingsState} = React.useContext(BuildingsContext)\r\n const buildingId = buildingsState?.buildings?.building?.id || -1\r\n\r\n const { state: appConfigState, dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\r\n\r\n const [sensorToDelete, setSensorToDelete] = React.useState<number | null>(null)\r\n const [editSensorId, setEditSensorId] = React.useState<number | null>(null)\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n const [groupBy, setGroupBy] = React.useState<'type' | 'tag'>('type')\r\n const { deleteSensor } = useSensor(sensorToDelete)\r\n\r\n const handleAddSensor = React.useCallback((currentSensorTypeId?: number) => {\r\n if (!currentViewer) return\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: {\r\n currentToolId:\r\n currentViewer === 'bim'\r\n ? 'bim-add-sensor'\r\n : currentViewer === 'map'\r\n ? 'map-add-sensor'\r\n : undefined,\r\n },\r\n })\r\n if (currentSensorTypeId) {\r\n menusDispatch({\r\n type: 'SET_CURRENT_SENSOR_TYPE_ID',\r\n payload: { currentSensorTypeId },\r\n })\r\n }\r\n }, [toolsDispatch, currentViewer])\r\n\r\n const handleSensorAction = React.useCallback((action: SensorAction, id: number) => {\r\n switch (action) {\r\n case 'view':\r\n // ⚠️ View sensor action not implemented\r\n break\r\n case 'edit':\r\n setEditSensorId(id)\r\n break\r\n case 'delete':\r\n toast.success(t('sensorDeleted'))\r\n setSensorToDelete(id)\r\n break\r\n default:\r\n break\r\n }\r\n }, [t])\r\n\r\n // Trigger deletion when sensorToDelete changes\r\n React.useEffect(() => {\r\n if (sensorToDelete !== null) {\r\n void deleteSensor()\r\n setSensorToDelete(null)\r\n }\r\n }, [sensorToDelete, deleteSensor])\r\n\r\n const currentSensors: Sensor[] = allSensors.filter((sensor) => currentViewer === sensor.viewer && (!sensor.buildingId || sensor.buildingId === buildingId))\r\n\r\n // Readings for every listed sensor, so each row can be ringed by its current value. This is the\r\n // only place that polls across types; the viewers poll the focused type alone. Bounded by\r\n // useSensorSeriesMulti's concurrency cap and only active while this panel is mounted.\r\n const { seriesById } = useSensorSeriesMulti(currentSensors, { enabled: currentSensors.length > 0 })\r\n const readings = React.useMemo(\r\n () => valueColoursBySensor(currentSensors, sensorTypes, seriesById),\r\n [seriesById, sensorTypes, currentSensors.map(s => s.id).join(',')],\r\n )\r\n const readingText = (sensorId: number): string | undefined => {\r\n const reading = readings.get(sensorId)\r\n if (!reading) return undefined\r\n const unit = seriesById.get(sensorId)?.unit\r\n const labels = seriesById.get(sensorId)?.valueLabels\r\n return labels?.[reading.value] ?? `${readingNumber.format(reading.value)}${unit ? ` ${unit}` : ''}`\r\n }\r\n\r\n // Default the display zone from the building's (else a sensor's) longitude, until the user overrides.\r\n // Depends on primitive longitudes (not the re-created currentSensors array) so it only runs on real change.\r\n const buildingLongitude = buildingsState?.buildings?.building?.buildingLongitude ?? null\r\n const firstSensorLongitude = currentSensors.find(s => typeof s.longitude === 'number')?.longitude ?? null\r\n const { displayTimeZone, displayTimeZoneUserSet } = appConfigState.appConfig\r\n React.useEffect(() => {\r\n if (displayTimeZoneUserSet) return\r\n // BIM sensors live in a building (use its longitude); map sensors carry their own.\r\n const candidates = currentViewer === 'bim'\r\n ? [buildingLongitude, firstSensorLongitude]\r\n : [firstSensorLongitude, buildingLongitude]\r\n const zone = resolveDefaultTimeZone(candidates)\r\n if (zone !== displayTimeZone) {\r\n appConfigDispatch({ type: 'SET_DEFAULT_TIME_ZONE', payload: { displayTimeZone: zone } })\r\n }\r\n }, [currentViewer, buildingLongitude, firstSensorLongitude, displayTimeZone, displayTimeZoneUserSet, appConfigDispatch])\r\n\r\n // Filter sensors based on search query\r\n const filteredSensors = React.useMemo(() => {\r\n if (!searchQuery.trim()) return currentSensors\r\n\r\n const query = searchQuery.toLowerCase()\r\n return currentSensors.filter((sensor) => {\r\n const sensorTypeName =\r\n sensorTypes.find(type => type.id === sensor.typeId)?.name ?? ''\r\n return (\r\n sensor.name?.toLowerCase().includes(query) ||\r\n sensorTypeName.toLowerCase().includes(query)\r\n )\r\n })\r\n }, [currentSensors, searchQuery])\r\n\r\n const toggleSensorTypeVisibility = React.useCallback((sensorTypeId: number) => {\r\n menusDispatch({\r\n type: 'TOGGLE_SENSOR_TYPE_VISIBILITY',\r\n payload: {\r\n viewer: currentViewer,\r\n sensorTypeId: sensorTypeId,\r\n },\r\n })\r\n }, [currentViewer, menusDispatch])\r\n\r\n const handleGroupByChange = React.useCallback((newGroupBy: 'type' | 'tag') => {\r\n setGroupBy(newGroupBy)\r\n // Clear the opposing visibility state so markers from the old filter don't bleed through\r\n if (newGroupBy === 'tag') {\r\n menusDispatch({ type: 'HIDE_ALL_SENSORS_IN_VIEWER', payload: { viewer: currentViewer } })\r\n } else {\r\n menusDispatch({ type: 'HIDE_ALL_SENSOR_TAGS_IN_VIEWER', payload: { viewer: currentViewer } })\r\n }\r\n }, [currentViewer, menusDispatch])\r\n\r\n const toggleSensorTagVisibility = React.useCallback((tag: string) => {\r\n menusDispatch({\r\n type: 'TOGGLE_SENSOR_TAG_VISIBILITY',\r\n payload: {\r\n viewer: currentViewer,\r\n sensorTag: tag,\r\n },\r\n })\r\n }, [currentViewer, menusDispatch])\r\n\r\n // Group sensors by type, using sensorTypes as the source of truth for types\r\n const sensorsByType = React.useMemo(() => {\r\n const grouped: Record<string, Sensor[]> = {}\r\n sensorTypes.forEach(type => {\r\n grouped[type.name] = []\r\n })\r\n filteredSensors.forEach(sensor => {\r\n const type = sensorTypes.find(t => t.id === sensor.typeId)\r\n const typeName = type?.name ?? 'Other'\r\n if (!grouped[typeName]) {\r\n grouped[typeName] = []\r\n }\r\n grouped[typeName].push(sensor)\r\n })\r\n // Remove empty groups\r\n Object.keys(grouped).forEach(key => {\r\n if (grouped[key].length === 0) {\r\n delete grouped[key]\r\n }\r\n })\r\n return grouped\r\n }, [filteredSensors, sensorTypes])\r\n\r\n // Group sensors by tag\r\n const sensorsByTag = React.useMemo(() => {\r\n const grouped: Record<string, Sensor[]> = {}\r\n filteredSensors.forEach(sensor => {\r\n const tags = sensor.tags && sensor.tags.length > 0 ? sensor.tags : [UNTAGGED_TAG]\r\n tags.forEach(tag => {\r\n if (!grouped[tag]) grouped[tag] = []\r\n grouped[tag].push(sensor)\r\n })\r\n })\r\n return grouped\r\n }, [filteredSensors])\r\n\r\n return (\r\n <div className=\"flex-1 flex flex-col space-y-4 overflow-hidden\">\r\n <div className=\"px-4 flex items-center gap-2\">\r\n <SearchInput\r\n placeholder={t('searchSensors')}\r\n value={searchQuery}\r\n onChange={e => setSearchQuery(e.target.value)}\r\n />\r\n <DropdownMenu>\r\n <DropdownMenuTrigger asChild>\r\n <Button variant=\"outline\" size=\"icon\" title={t('filters')} className=\"flex-shrink-0\">\r\n <LR.Funnel size={16} />\r\n </Button>\r\n </DropdownMenuTrigger>\r\n <DropdownMenuContent align=\"end\">\r\n <DropdownMenuLabel>{t('groupBy')}</DropdownMenuLabel>\r\n <DropdownMenuSeparator />\r\n <DropdownMenuRadioGroup value={groupBy} onValueChange={v => handleGroupByChange(v as 'type' | 'tag')}>\r\n <DropdownMenuRadioItem value=\"type\">\r\n <LR.Layers className=\"mr-2 h-4 w-4\" />\r\n {t('groupByType')}\r\n </DropdownMenuRadioItem>\r\n <DropdownMenuRadioItem value=\"tag\">\r\n <LR.Tag className=\"mr-2 h-4 w-4\" />\r\n {t('groupByTag')}\r\n </DropdownMenuRadioItem>\r\n </DropdownMenuRadioGroup>\r\n </DropdownMenuContent>\r\n </DropdownMenu>\r\n </div>\r\n {isLoading ? (\r\n <SensorsSectionSkeleton />\r\n ) :\r\n filteredSensors.length === 0 ? (\r\n <div className=\"p-4 text-muted-foreground text-sm flex flex-col items-center\">\r\n <div>{t('noSensorsFound')}</div>\r\n <Button\r\n className=\"mt-2 px-4 \"\r\n variant='outline'\r\n onClick={() => handleAddSensor()}\r\n >\r\n {t('addSensorTitle')}\r\n </Button>\r\n </div>\r\n ) : groupBy === 'type' ? (\r\n Object.entries(sensorsByType).map(([typeName, sensorsOfType]) => {\r\n const type = sensorTypes.find(t => t.name === typeName)\r\n const typeId = type?.id ?? -1\r\n\r\n const viewerTypes = visibleSensorTypes?.[currentViewer]\r\n const isTypeVisible = viewerTypes?.length > 0 && viewerTypes.includes(typeId)\r\n\r\n const sensorIcon = resolveLucideIcon(type?.icon)\r\n\r\n return (\r\n <CollapsibleSection\r\n key={typeName}\r\n title={typeName.replace(/_/g, ' ')}\r\n icon={sensorIcon}\r\n className=\"overflow-y-auto\"\r\n itemCount={sensorsOfType.length}\r\n onAddItem={() => handleAddSensor(typeId)}\r\n addItemTitle={t('addSensorTitle')}\r\n defaultOpen={false}\r\n switchVariant={{\r\n checked: isTypeVisible,\r\n onCheckedChange: () => toggleSensorTypeVisibility(typeId),\r\n }}\r\n >\r\n <div className=\"space-y-2 mx-2 pr-2\">\r\n {sensorsOfType.map((sensor) => (\r\n <CollapsibleSensorItem\r\n key={sensor.id}\r\n sensor={sensor}\r\n sensorType={type}\r\n onAction={handleSensorAction}\r\n isVisible={isTypeVisible}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: sensor.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: null } })}\r\n onSelect={() => menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: sensor.id } })}\r\n isFocused={focusedSensorId === sensor.id}\r\n valueColour={readings.get(sensor.id)?.colour}\r\n valueText={readingText(sensor.id)}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n )\r\n })\r\n ) : (\r\n Object.entries(sensorsByTag).map(([tag, sensorsOfTag]) => {\r\n const isTagVisible = visibleSensorTags?.[currentViewer]?.includes(tag) ?? false\r\n return (\r\n <CollapsibleSection\r\n key={tag}\r\n title={tag === UNTAGGED_TAG ? t('untagged') : tag}\r\n icon={LR.Tag}\r\n colour={stringToColour(tag, 'max')}\r\n className=\"overflow-y-auto\"\r\n itemCount={sensorsOfTag.length}\r\n defaultOpen={false}\r\n switchVariant={{\r\n checked: isTagVisible,\r\n onCheckedChange: () => toggleSensorTagVisibility(tag),\r\n }}\r\n >\r\n <div className=\"space-y-2 mx-2 pr-2\">\r\n {sensorsOfTag.map((sensor) => {\r\n const type = sensorTypes.find(tp => tp.id === sensor.typeId)\r\n return (\r\n <CollapsibleSensorItem\r\n key={sensor.id}\r\n sensor={sensor}\r\n sensorType={type}\r\n onAction={handleSensorAction}\r\n isVisible={isTagVisible}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: sensor.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: null } })}\r\n onSelect={() => menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: sensor.id } })}\r\n isFocused={focusedSensorId === sensor.id}\r\n valueColour={readings.get(sensor.id)?.colour}\r\n valueText={readingText(sensor.id)}\r\n />\r\n )\r\n })}\r\n </div>\r\n </CollapsibleSection>\r\n )\r\n })\r\n )}\r\n\r\n {editSensorId != null && allSensors.some(s => s.id === editSensorId) && (\r\n <SensorInput\r\n viewer={currentViewer}\r\n layout=\"dialog\"\r\n isOpen={editSensorId != null}\r\n editSensor={allSensors.find(s => s.id === editSensorId)}\r\n onCancel={() => setEditSensorId(null)}\r\n onSaved={() => setEditSensorId(null)}\r\n />\r\n )}\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AAyOQ,cAeM,YAfN;AApOR,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB,kBAAkB,cAAc,oBAAoB;AAC/E,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,4B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AE,MAAM,yBAAyB,SAAS,EAAE,UAAU,OAAO,GAAG,EAAE,CAAC;AAAA,gBACjG,WAAW,oBAAoB,OAAO;AAAA,gBACtC,cAAaA,MAAA,SAAS,IAAI,OAAO,EAAE,MAAtB,gBAAAA,IAAyB;AAAA,gBACtC,WAAW,YAAY,OAAO,EAAE;AAAA;AAAA,cAV3B,OAAO;AAAA,YAWd;AAAA,UAEJ,CAAC,GACH;AAAA;AAAA,QA/BK;AAAA,MAgCP;AAAA,IAEF,CAAC;AAAA,IAGF,gBAAgB,QAAQ,WAAW,KAAK,OAAK,EAAE,OAAO,YAAY,KACjE;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,QAAO;AAAA,QACP,QAAQ,gBAAgB;AAAA,QACxB,YAAY,WAAW,KAAK,OAAK,EAAE,OAAO,YAAY;AAAA,QACtD,UAAU,MAAM,gBAAgB,IAAI;AAAA,QACpC,SAAS,MAAM,gBAAgB,IAAI;AAAA;AAAA,IACrC;AAAA,KAEJ;AAEJ;","names":["_a","_b","_c","t"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\nimport { toast } from 'sonner'\r\n\r\nimport { useSensor, useSensors } from '../../../hooks/sensors/sensors'\r\nimport { useSensorTypes } from '../../../hooks/sensorTypes/sensorTypes'\r\nimport { AppConfigContext, BuildingsContext, MenusContext, ToolsContext } from '../../../store'\r\nimport { resolveDefaultTimeZone } from '../../../utils/timeUtils'\r\nimport { stringToColour } from '../../viewers/map/utils/stringToColour'\r\nimport { Button } from '../Button'\r\nimport { CollapsibleSection } from '../CollapsibleSection'\r\nimport { DropdownMenu } from '../DropdownMenu'\r\nimport {\r\n DropdownMenuTrigger,\r\n DropdownMenuContent,\r\n DropdownMenuLabel,\r\n DropdownMenuSeparator,\r\n DropdownMenuRadioGroup,\r\n DropdownMenuRadioItem,\r\n} from '../DropdownMenu'\r\nimport { SearchInput } from '../SearchInput'\r\n\r\nimport { CollapsibleSensorItem } from './CollapsibleSensorItem'\r\nimport { SensorInput } from './SensorInput'\r\nimport { SensorsSectionSkeleton } from './SensorsSectionSkeleton'\r\nimport { resolveLucideIcon } from './sensorUtils'\r\nimport { valueColoursBySensor } from './sensorValueColours'\r\nimport { activeSensorTypeId, legendScopeSensors, UNTAGGED_TAG } from './sensorVisibility'\r\nimport { useSensorSeriesMulti } from './useSensorSeriesMulti'\r\n\r\nimport type { Sensor } from '../../../types/dbTypes';\r\n\r\n/** Sidebar readings: compact, at most one decimal, so a row stays on one line. */\r\nconst readingNumber = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 })\r\n\r\n\r\ntype SensorAction = 'view' | 'edit' | 'delete'\r\n\r\n// Re-exported from its own module so the pure helpers and the viewer layers can use it without\r\n// pulling this component in. Kept here because every existing import points at this path.\r\nexport { UNTAGGED_TAG } from './sensorVisibility'\r\n\r\nexport function SensorsSection() {\r\n // Translation\r\n const t = useTranslations('SensorsSection')\r\n\r\n const { dispatch: toolsDispatch } = React.useContext(ToolsContext)\r\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { currentViewer, visibleSensorTypes, visibleSensorTags, focusedSensorId, sensorLegendVisible, sensorLegendTypeId } = menusState.menus\r\n\r\n const { sensors: allSensors }: { sensors: Sensor[] } = useSensors()\r\n const { sensorTypes, isLoading } = useSensorTypes()\r\n\r\n const {state: buildingsState} = React.useContext(BuildingsContext)\r\n const buildingId = buildingsState?.buildings?.building?.id || -1\r\n\r\n const { state: appConfigState, dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\r\n\r\n const [sensorToDelete, setSensorToDelete] = React.useState<number | null>(null)\r\n const [editSensorId, setEditSensorId] = React.useState<number | null>(null)\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n const [groupBy, setGroupBy] = React.useState<'type' | 'tag'>('type')\r\n const { deleteSensor } = useSensor(sensorToDelete)\r\n\r\n const handleAddSensor = React.useCallback((currentSensorTypeId?: number) => {\r\n if (!currentViewer) return\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: {\r\n currentToolId:\r\n currentViewer === 'bim'\r\n ? 'bim-add-sensor'\r\n : currentViewer === 'map'\r\n ? 'map-add-sensor'\r\n : undefined,\r\n },\r\n })\r\n if (currentSensorTypeId) {\r\n menusDispatch({\r\n type: 'SET_CURRENT_SENSOR_TYPE_ID',\r\n payload: { currentSensorTypeId },\r\n })\r\n }\r\n }, [toolsDispatch, currentViewer])\r\n\r\n const handleSensorAction = React.useCallback((action: SensorAction, id: number) => {\r\n switch (action) {\r\n case 'view':\r\n // ⚠️ View sensor action not implemented\r\n break\r\n case 'edit':\r\n setEditSensorId(id)\r\n break\r\n case 'delete':\r\n toast.success(t('sensorDeleted'))\r\n setSensorToDelete(id)\r\n break\r\n default:\r\n break\r\n }\r\n }, [t])\r\n\r\n // Trigger deletion when sensorToDelete changes\r\n React.useEffect(() => {\r\n if (sensorToDelete !== null) {\r\n void deleteSensor()\r\n setSensorToDelete(null)\r\n }\r\n }, [sensorToDelete, deleteSensor])\r\n\r\n const currentSensors: Sensor[] = allSensors.filter((sensor) => currentViewer === sensor.viewer && (!sensor.buildingId || sensor.buildingId === buildingId))\r\n\r\n // Readings for every listed sensor, so each row can be ringed by its current value. This is the\r\n // only place that polls across types; the viewers poll the focused type alone. Bounded by\r\n // useSensorSeriesMulti's concurrency cap and only active while this panel is mounted.\r\n const { seriesById } = useSensorSeriesMulti(currentSensors, { enabled: currentSensors.length > 0 })\r\n const readings = React.useMemo(\r\n () => valueColoursBySensor(currentSensors, sensorTypes, seriesById),\r\n [seriesById, sensorTypes, currentSensors.map(s => s.id).join(',')],\r\n )\r\n const readingText = (sensorId: number): string | undefined => {\r\n const reading = readings.get(sensorId)\r\n if (!reading) return undefined\r\n const unit = seriesById.get(sensorId)?.unit\r\n const labels = seriesById.get(sensorId)?.valueLabels\r\n return labels?.[reading.value] ?? `${readingNumber.format(reading.value)}${unit ? ` ${unit}` : ''}`\r\n }\r\n\r\n // Default the display zone from the building's (else a sensor's) longitude, until the user overrides.\r\n // Depends on primitive longitudes (not the re-created currentSensors array) so it only runs on real change.\r\n const buildingLongitude = buildingsState?.buildings?.building?.buildingLongitude ?? null\r\n const firstSensorLongitude = currentSensors.find(s => typeof s.longitude === 'number')?.longitude ?? null\r\n const { displayTimeZone, displayTimeZoneUserSet } = appConfigState.appConfig\r\n React.useEffect(() => {\r\n if (displayTimeZoneUserSet) return\r\n // BIM sensors live in a building (use its longitude); map sensors carry their own.\r\n const candidates = currentViewer === 'bim'\r\n ? [buildingLongitude, firstSensorLongitude]\r\n : [firstSensorLongitude, buildingLongitude]\r\n const zone = resolveDefaultTimeZone(candidates)\r\n if (zone !== displayTimeZone) {\r\n appConfigDispatch({ type: 'SET_DEFAULT_TIME_ZONE', payload: { displayTimeZone: zone } })\r\n }\r\n }, [currentViewer, buildingLongitude, firstSensorLongitude, displayTimeZone, displayTimeZoneUserSet, appConfigDispatch])\r\n\r\n // Filter sensors based on search query\r\n const filteredSensors = React.useMemo(() => {\r\n if (!searchQuery.trim()) return currentSensors\r\n\r\n const query = searchQuery.toLowerCase()\r\n return currentSensors.filter((sensor) => {\r\n const sensorTypeName =\r\n sensorTypes.find(type => type.id === sensor.typeId)?.name ?? ''\r\n return (\r\n sensor.name?.toLowerCase().includes(query) ||\r\n sensorTypeName.toLowerCase().includes(query)\r\n )\r\n })\r\n }, [currentSensors, searchQuery])\r\n\r\n const toggleSensorTypeVisibility = React.useCallback((sensorTypeId: number) => {\r\n menusDispatch({\r\n type: 'TOGGLE_SENSOR_TYPE_VISIBILITY',\r\n payload: {\r\n viewer: currentViewer,\r\n sensorTypeId: sensorTypeId,\r\n },\r\n })\r\n }, [currentViewer, menusDispatch])\r\n\r\n const handleGroupByChange = React.useCallback((newGroupBy: 'type' | 'tag') => {\r\n setGroupBy(newGroupBy)\r\n // Clear the opposing visibility state so markers from the old filter don't bleed through\r\n if (newGroupBy === 'tag') {\r\n menusDispatch({ type: 'HIDE_ALL_SENSORS_IN_VIEWER', payload: { viewer: currentViewer } })\r\n } else {\r\n menusDispatch({ type: 'HIDE_ALL_SENSOR_TAGS_IN_VIEWER', payload: { viewer: currentViewer } })\r\n }\r\n }, [currentViewer, menusDispatch])\r\n\r\n // Mirrors what the legend itself decides, so the button never claims the card is on while the\r\n // viewer is showing nothing. With no sensors of the active type there is nothing to toggle.\r\n const legendHasContent = legendScopeSensors(\r\n allSensors,\r\n {\r\n viewer: currentViewer,\r\n visibleTypeIds: visibleSensorTypes?.[currentViewer] ?? [],\r\n visibleTags: visibleSensorTags?.[currentViewer] ?? [],\r\n },\r\n activeSensorTypeId(allSensors, {\r\n legendTypeId: sensorLegendTypeId?.[currentViewer],\r\n activeSensorId: focusedSensorId,\r\n }),\r\n ).length > 0\r\n const legendVisible = legendHasContent && sensorLegendVisible?.[currentViewer] !== false\r\n\r\n const toggleLegend = React.useCallback(() => {\r\n menusDispatch({ type: 'TOGGLE_SENSOR_LEGEND', payload: { viewer: currentViewer } })\r\n }, [currentViewer, menusDispatch])\r\n\r\n const toggleSensorTagVisibility = React.useCallback((tag: string) => {\r\n menusDispatch({\r\n type: 'TOGGLE_SENSOR_TAG_VISIBILITY',\r\n payload: {\r\n viewer: currentViewer,\r\n sensorTag: tag,\r\n },\r\n })\r\n }, [currentViewer, menusDispatch])\r\n\r\n // Group sensors by type, using sensorTypes as the source of truth for types\r\n const sensorsByType = React.useMemo(() => {\r\n const grouped: Record<string, Sensor[]> = {}\r\n sensorTypes.forEach(type => {\r\n grouped[type.name] = []\r\n })\r\n filteredSensors.forEach(sensor => {\r\n const type = sensorTypes.find(t => t.id === sensor.typeId)\r\n const typeName = type?.name ?? 'Other'\r\n if (!grouped[typeName]) {\r\n grouped[typeName] = []\r\n }\r\n grouped[typeName].push(sensor)\r\n })\r\n // Remove empty groups\r\n Object.keys(grouped).forEach(key => {\r\n if (grouped[key].length === 0) {\r\n delete grouped[key]\r\n }\r\n })\r\n return grouped\r\n }, [filteredSensors, sensorTypes])\r\n\r\n // Group sensors by tag\r\n const sensorsByTag = React.useMemo(() => {\r\n const grouped: Record<string, Sensor[]> = {}\r\n filteredSensors.forEach(sensor => {\r\n const tags = sensor.tags && sensor.tags.length > 0 ? sensor.tags : [UNTAGGED_TAG]\r\n tags.forEach(tag => {\r\n if (!grouped[tag]) grouped[tag] = []\r\n grouped[tag].push(sensor)\r\n })\r\n })\r\n return grouped\r\n }, [filteredSensors])\r\n\r\n return (\r\n <div className=\"flex-1 flex flex-col space-y-4 overflow-hidden\">\r\n <div className=\"px-4 flex items-center gap-2\">\r\n <SearchInput\r\n placeholder={t('searchSensors')}\r\n value={searchQuery}\r\n onChange={e => setSearchQuery(e.target.value)}\r\n />\r\n <Button\r\n variant={legendVisible ? 'default' : 'outline'}\r\n size=\"icon\"\r\n title={t('toggleLegend')}\r\n aria-pressed={legendVisible}\r\n disabled={!legendHasContent}\r\n className=\"flex-shrink-0\"\r\n onClick={toggleLegend}\r\n >\r\n <LR.Palette size={16} />\r\n </Button>\r\n <DropdownMenu>\r\n <DropdownMenuTrigger asChild>\r\n <Button variant=\"outline\" size=\"icon\" title={t('filters')} className=\"flex-shrink-0\">\r\n <LR.Funnel size={16} />\r\n </Button>\r\n </DropdownMenuTrigger>\r\n <DropdownMenuContent align=\"end\">\r\n <DropdownMenuLabel>{t('groupBy')}</DropdownMenuLabel>\r\n <DropdownMenuSeparator />\r\n <DropdownMenuRadioGroup value={groupBy} onValueChange={v => handleGroupByChange(v as 'type' | 'tag')}>\r\n <DropdownMenuRadioItem value=\"type\">\r\n <LR.Layers className=\"mr-2 h-4 w-4\" />\r\n {t('groupByType')}\r\n </DropdownMenuRadioItem>\r\n <DropdownMenuRadioItem value=\"tag\">\r\n <LR.Tag className=\"mr-2 h-4 w-4\" />\r\n {t('groupByTag')}\r\n </DropdownMenuRadioItem>\r\n </DropdownMenuRadioGroup>\r\n </DropdownMenuContent>\r\n </DropdownMenu>\r\n </div>\r\n {isLoading ? (\r\n <SensorsSectionSkeleton />\r\n ) :\r\n filteredSensors.length === 0 ? (\r\n <div className=\"p-4 text-muted-foreground text-sm flex flex-col items-center\">\r\n <div>{t('noSensorsFound')}</div>\r\n <Button\r\n className=\"mt-2 px-4 \"\r\n variant='outline'\r\n onClick={() => handleAddSensor()}\r\n >\r\n {t('addSensorTitle')}\r\n </Button>\r\n </div>\r\n ) : groupBy === 'type' ? (\r\n Object.entries(sensorsByType).map(([typeName, sensorsOfType]) => {\r\n const type = sensorTypes.find(t => t.name === typeName)\r\n const typeId = type?.id ?? -1\r\n\r\n const viewerTypes = visibleSensorTypes?.[currentViewer]\r\n const isTypeVisible = viewerTypes?.length > 0 && viewerTypes.includes(typeId)\r\n\r\n const sensorIcon = resolveLucideIcon(type?.icon)\r\n\r\n return (\r\n <CollapsibleSection\r\n key={typeName}\r\n title={typeName.replace(/_/g, ' ')}\r\n icon={sensorIcon}\r\n className=\"overflow-y-auto\"\r\n itemCount={sensorsOfType.length}\r\n onAddItem={() => handleAddSensor(typeId)}\r\n addItemTitle={t('addSensorTitle')}\r\n defaultOpen={false}\r\n switchVariant={{\r\n checked: isTypeVisible,\r\n onCheckedChange: () => toggleSensorTypeVisibility(typeId),\r\n }}\r\n >\r\n {/* py-1 so the focused row's 2px ring, which is painted outside its border box,\r\n is not clipped by this section's scroll boundary on the first and last rows. */}\r\n <div className=\"space-y-2 mx-2 pr-2 py-1\">\r\n {sensorsOfType.map((sensor) => (\r\n <CollapsibleSensorItem\r\n key={sensor.id}\r\n sensor={sensor}\r\n sensorType={type}\r\n onAction={handleSensorAction}\r\n isVisible={isTypeVisible}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: sensor.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: null } })}\r\n onSelect={() => menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: sensor.id } })}\r\n isFocused={focusedSensorId === sensor.id}\r\n valueColour={readings.get(sensor.id)?.colour}\r\n valueText={readingText(sensor.id)}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n )\r\n })\r\n ) : (\r\n Object.entries(sensorsByTag).map(([tag, sensorsOfTag]) => {\r\n const isTagVisible = visibleSensorTags?.[currentViewer]?.includes(tag) ?? false\r\n return (\r\n <CollapsibleSection\r\n key={tag}\r\n title={tag === UNTAGGED_TAG ? t('untagged') : tag}\r\n icon={LR.Tag}\r\n colour={stringToColour(tag, 'max')}\r\n className=\"overflow-y-auto\"\r\n itemCount={sensorsOfTag.length}\r\n defaultOpen={false}\r\n switchVariant={{\r\n checked: isTagVisible,\r\n onCheckedChange: () => toggleSensorTagVisibility(tag),\r\n }}\r\n >\r\n <div className=\"space-y-2 mx-2 pr-2 py-1\">\r\n {sensorsOfTag.map((sensor) => {\r\n const type = sensorTypes.find(tp => tp.id === sensor.typeId)\r\n return (\r\n <CollapsibleSensorItem\r\n key={sensor.id}\r\n sensor={sensor}\r\n sensorType={type}\r\n onAction={handleSensorAction}\r\n isVisible={isTagVisible}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: sensor.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_SENSOR_ID', payload: { currentSensorId: null } })}\r\n onSelect={() => menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: sensor.id } })}\r\n isFocused={focusedSensorId === sensor.id}\r\n valueColour={readings.get(sensor.id)?.colour}\r\n valueText={readingText(sensor.id)}\r\n />\r\n )\r\n })}\r\n </div>\r\n </CollapsibleSection>\r\n )\r\n })\r\n )}\r\n\r\n {editSensorId != null && allSensors.some(s => s.id === editSensorId) && (\r\n <SensorInput\r\n viewer={currentViewer}\r\n layout=\"dialog\"\r\n isOpen={editSensorId != null}\r\n editSensor={allSensors.find(s => s.id === editSensorId)}\r\n onCancel={() => setEditSensorId(null)}\r\n onSaved={() => setEditSensorId(null)}\r\n />\r\n )}\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AA+PQ,cA0BM,YA1BN;AA1PR,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB,kBAAkB,cAAc,oBAAoB;AAC/E,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,oBAAoB,oBAAoB;AACrE,SAAS,4BAA4B;AAKrC,MAAM,gBAAgB,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,EAAE,CAAC;AAOnF,SAAS,gBAAAA,qBAAoB;AAEtB,SAAS,iBAAiB;AAhDjC;AAkDE,QAAM,IAAI,gBAAgB,gBAAgB;AAE1C,QAAM,EAAE,UAAU,cAAc,IAAI,MAAM,WAAW,YAAY;AACjE,QAAM,EAAE,OAAO,YAAY,UAAU,cAAc,IAAI,MAAM,WAAW,YAAY;AACpF,QAAM,EAAE,eAAe,oBAAoB,mBAAmB,iBAAiB,qBAAqB,mBAAmB,IAAI,WAAW;AAEtI,QAAM,EAAE,SAAS,WAAW,IAA2B,WAAW;AAClE,QAAM,EAAE,aAAa,UAAU,IAAI,eAAe;AAElD,QAAM,EA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Y;AAAA,gBACZ,UAAU;AAAA,gBACV,WAAW;AAAA,gBACX,cAAc,MAAM,cAAc,EAAE,MAAM,yBAAyB,SAAS,EAAE,iBAAiB,OAAO,GAAG,EAAE,CAAC;AAAA,gBAC5G,cAAc,MAAM,cAAc,EAAE,MAAM,yBAAyB,SAAS,EAAE,iBAAiB,KAAK,EAAE,CAAC;AAAA,gBACvG,UAAU,MAAM,cAAc,EAAE,MAAM,yBAAyB,SAAS,EAAE,UAAU,OAAO,GAAG,EAAE,CAAC;AAAA,gBACjG,WAAW,oBAAoB,OAAO;AAAA,gBACtC,cAAaA,MAAA,SAAS,IAAI,OAAO,EAAE,MAAtB,gBAAAA,IAAyB;AAAA,gBACtC,WAAW,YAAY,OAAO,EAAE;AAAA;AAAA,cAV3B,OAAO;AAAA,YAWd;AAAA,UAEJ,CAAC,GACH;AAAA;AAAA,QA/BK;AAAA,MAgCP;AAAA,IAEF,CAAC;AAAA,IAGF,gBAAgB,QAAQ,WAAW,KAAK,OAAK,EAAE,OAAO,YAAY,KACjE;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,QAAO;AAAA,QACP,QAAQ,gBAAgB;AAAA,QACxB,YAAY,WAAW,KAAK,OAAK,EAAE,OAAO,YAAY;AAAA,QACtD,UAAU,MAAM,gBAAgB,IAAI;AAAA,QACpC,SAAS,MAAM,gBAAgB,IAAI;AAAA;AAAA,IACrC;AAAA,KAEJ;AAEJ;","names":["UNTAGGED_TAG","_a","_b","_c","t"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ColourDomain } from './sensorColour';
|
|
2
|
+
import type { SensorSeries } from './sensorData';
|
|
3
|
+
import type { Sensor, SensorType } from '../../../types/dbTypes';
|
|
4
|
+
/** One building's sensors of a single type, reduced to a colourable number. */
|
|
5
|
+
export interface BuildingSensorAverage {
|
|
6
|
+
buildingId: number;
|
|
7
|
+
/** Mean of the contributing sensors' latest readings. */
|
|
8
|
+
average: number;
|
|
9
|
+
/** How many sensors reported a finite reading. Never zero: those buildings are omitted. */
|
|
10
|
+
sensorCount: number;
|
|
11
|
+
colour: string;
|
|
12
|
+
}
|
|
13
|
+
/** Enough of a sensor to aggregate it onto a building. */
|
|
14
|
+
export type AggregateSensor = Pick<Sensor, 'id' | 'typeId' | 'buildingId'>;
|
|
15
|
+
/**
|
|
16
|
+
* The type's colour domain, resolved the way the legend and the charts resolve it: the
|
|
17
|
+
* configured `minValue..maxValue`, else the range observed across the polled sensors.
|
|
18
|
+
*
|
|
19
|
+
* `null` means the type has no usable domain, which callers must read as "no colours
|
|
20
|
+
* configured" and answer by keeping their pre-colour appearance.
|
|
21
|
+
*/
|
|
22
|
+
export declare function typeDomain(sensorType: SensorType | null | undefined, seriesById: ReadonlyMap<number, SensorSeries>): ColourDomain | null;
|
|
23
|
+
/**
|
|
24
|
+
* Mean latest reading and ramp colour per building, for one sensor type.
|
|
25
|
+
*
|
|
26
|
+
* Deliberately blind to `sensor.viewer`: a building's temperature is its temperature whether the
|
|
27
|
+
* sensor was placed on the map or inside the BIM model, so both feed the average. Every other
|
|
28
|
+
* consumer of sensors filters by viewer, so do not "fix" this to match them.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildingSensorAverages(sensors: readonly AggregateSensor[], sensorType: SensorType | null | undefined, seriesById: ReadonlyMap<number, SensorSeries>): Map<number, BuildingSensorAverage>;
|
|
31
|
+
/**
|
|
32
|
+
* Most recent reading time per building, epoch ms.
|
|
33
|
+
*
|
|
34
|
+
* Separate from the averages because a building can have a stale reading and still average
|
|
35
|
+
* cleanly; showing when the number is from is what makes a dead feed visible.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildingLatestTimes(sensors: readonly AggregateSensor[], seriesById: ReadonlyMap<number, SensorSeries>): Map<number, number>;
|
|
38
|
+
/**
|
|
39
|
+
* The type the map should colour buildings by: pinned in the legend *and* switched on for the
|
|
40
|
+
* viewer. The single gate for whether this feature polls and paints at all, so toggling the type
|
|
41
|
+
* off both stops the requests and returns the footprints to their default colour.
|
|
42
|
+
*/
|
|
43
|
+
export declare function activeLegendTypeId(legendTypeId: number | null | undefined, visibleTypeIds: readonly number[] | undefined): number | null;
|
|
44
|
+
/**
|
|
45
|
+
* Stable key over the resolved colours, for effect deps that must not fire on equal polls.
|
|
46
|
+
* Sorted, so a reordered sensor list does not read as a change.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildingColoursKey(averages: ReadonlyMap<number, BuildingSensorAverage>): string;
|
|
49
|
+
//# sourceMappingURL=buildingSensorColours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildingSensorColours.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/buildingSensorColours.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEhE,+EAA+E;AAC/E,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAA;IACf,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,0DAA0D;AAC1D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAA;AAE1E;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACzC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC5C,YAAY,GAAG,IAAI,CAIrB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,UAAU,EAAE,UAAU,GAAG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