@sjvair/monitor-map 3.2.0 → 3.2.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { MonitorsMeta
|
|
2
|
+
import type { MonitorsMeta } from "@sjvair/sdk";
|
|
3
3
|
import DisplayOption from "../../components/DisplayOption.svelte";
|
|
4
4
|
import SegmentedControl from "../../components/SegmentedControl.svelte";
|
|
5
5
|
import ToggleSwitch from "../../components/ToggleSwitch.svelte";
|
|
@@ -22,17 +22,28 @@
|
|
|
22
22
|
}
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
// "inside" is a location filter (indoor vs outdoor), not tied to a monitor type or
|
|
26
|
+
// pollutant, so it's always shown, like "inactive".
|
|
27
|
+
const uiOnlyDisplayOptions = new Set(["inactive", "inside"]);
|
|
28
|
+
|
|
29
|
+
// "sjvair" (SJVAir non-FEM) isn't its own backend monitor type — it groups is_sjvair-flagged
|
|
30
|
+
// purpleair devices with airgradient devices (see monitorsMapIntegration.filters/featuresByType),
|
|
31
|
+
// so its visibility follows whichever of those two types supports the current pollutant.
|
|
32
|
+
const sjvairUnderlyingTypes = ["purpleair", "airgradient"];
|
|
33
|
+
|
|
34
|
+
function pollutantSupportedByType(type: string): boolean {
|
|
35
|
+
const deviceMeta = monitorsManager.meta?.monitors[type];
|
|
36
|
+
return (
|
|
37
|
+
!!deviceMeta && !!monitorsManager.pollutant && monitorsManager.pollutant in deviceMeta.entries
|
|
35
38
|
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const monitorDisplayOptions = $derived.by(() => {
|
|
42
|
+
return Object.entries(monitorsMapIntegration.displayOptions).filter(([key]) => {
|
|
43
|
+
if (uiOnlyDisplayOptions.has(key)) return true;
|
|
44
|
+
if (key === "sjvair") return sjvairUnderlyingTypes.some(pollutantSupportedByType);
|
|
45
|
+
return pollutantSupportedByType(key);
|
|
46
|
+
});
|
|
36
47
|
});
|
|
37
48
|
|
|
38
49
|
$effect(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onDestroy } from "svelte";
|
|
3
3
|
import { Marker } from "@maptiler/sdk";
|
|
4
|
-
import { SearchIcon } from "@lucide/svelte";
|
|
4
|
+
import { MapPinIcon, SearchIcon } from "@lucide/svelte";
|
|
5
5
|
import { useMonitorMapRouter } from "../router-context";
|
|
6
6
|
import { mapManager } from "../map/map.svelte";
|
|
7
7
|
import { debounce } from "../utils";
|
|
@@ -169,9 +169,9 @@
|
|
|
169
169
|
{@const comma = result.feature.place_name.indexOf(",")}
|
|
170
170
|
<button
|
|
171
171
|
onclick={() => selectGeocode(result)}
|
|
172
|
-
class="flex h-12 w-full items-center bg-white px-4 text-left hover:brightness-95"
|
|
172
|
+
class="flex h-12 w-full items-center gap-3 bg-white px-4 text-left hover:brightness-95"
|
|
173
173
|
>
|
|
174
|
-
<
|
|
174
|
+
<MapPinIcon class="text-brand h-6 w-6 shrink-0" />
|
|
175
175
|
<div class="min-w-0">
|
|
176
176
|
<p class="truncate text-sm font-medium">
|
|
177
177
|
{result.feature.place_name.substring(0, comma < 0 ? undefined : comma)}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { MonitorsMeta
|
|
2
|
+
import type { MonitorsMeta } from "@sjvair/sdk";
|
|
3
3
|
import DisplayOption from "$lib/components/DisplayOption.svelte";
|
|
4
4
|
import SegmentedControl from "$lib/components/SegmentedControl.svelte";
|
|
5
5
|
import ToggleSwitch from "$lib/components/ToggleSwitch.svelte";
|
|
@@ -22,17 +22,28 @@
|
|
|
22
22
|
}
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
// "inside" is a location filter (indoor vs outdoor), not tied to a monitor type or
|
|
26
|
+
// pollutant, so it's always shown, like "inactive".
|
|
27
|
+
const uiOnlyDisplayOptions = new Set(["inactive", "inside"]);
|
|
28
|
+
|
|
29
|
+
// "sjvair" (SJVAir non-FEM) isn't its own backend monitor type — it groups is_sjvair-flagged
|
|
30
|
+
// purpleair devices with airgradient devices (see monitorsMapIntegration.filters/featuresByType),
|
|
31
|
+
// so its visibility follows whichever of those two types supports the current pollutant.
|
|
32
|
+
const sjvairUnderlyingTypes = ["purpleair", "airgradient"];
|
|
33
|
+
|
|
34
|
+
function pollutantSupportedByType(type: string): boolean {
|
|
35
|
+
const deviceMeta = monitorsManager.meta?.monitors[type];
|
|
36
|
+
return (
|
|
37
|
+
!!deviceMeta && !!monitorsManager.pollutant && monitorsManager.pollutant in deviceMeta.entries
|
|
35
38
|
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const monitorDisplayOptions = $derived.by(() => {
|
|
42
|
+
return Object.entries(monitorsMapIntegration.displayOptions).filter(([key]) => {
|
|
43
|
+
if (uiOnlyDisplayOptions.has(key)) return true;
|
|
44
|
+
if (key === "sjvair") return sjvairUnderlyingTypes.some(pollutantSupportedByType);
|
|
45
|
+
return pollutantSupportedByType(key);
|
|
46
|
+
});
|
|
36
47
|
});
|
|
37
48
|
|
|
38
49
|
$effect(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onDestroy } from "svelte";
|
|
3
3
|
import { Marker } from "@maptiler/sdk";
|
|
4
|
-
import { SearchIcon } from "@lucide/svelte";
|
|
4
|
+
import { MapPinIcon, SearchIcon } from "@lucide/svelte";
|
|
5
5
|
import { useMonitorMapRouter } from "../router-context";
|
|
6
6
|
import { mapManager } from "$lib/map/map.svelte";
|
|
7
7
|
import { debounce } from "$lib/utils";
|
|
@@ -169,9 +169,9 @@
|
|
|
169
169
|
{@const comma = result.feature.place_name.indexOf(",")}
|
|
170
170
|
<button
|
|
171
171
|
onclick={() => selectGeocode(result)}
|
|
172
|
-
class="flex h-12 w-full items-center bg-white px-4 text-left hover:brightness-95"
|
|
172
|
+
class="flex h-12 w-full items-center gap-3 bg-white px-4 text-left hover:brightness-95"
|
|
173
173
|
>
|
|
174
|
-
<
|
|
174
|
+
<MapPinIcon class="text-brand h-6 w-6 shrink-0" />
|
|
175
175
|
<div class="min-w-0">
|
|
176
176
|
<p class="truncate text-sm font-medium">
|
|
177
177
|
{result.feature.place_name.substring(0, comma < 0 ? undefined : comma)}
|