@sjvair/monitor-map 3.0.7 → 3.1.0
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/lib/LoadScreen.svelte +3 -3
- package/dist/lib/MapLegend.svelte +1 -1
- package/dist/lib/MonitorDetailPanel.svelte +5 -3
- package/dist/lib/MonitorMapLayout.svelte +41 -59
- package/dist/lib/components/MapLayersDisplayOptions.svelte +4 -4
- package/dist/lib/components/SegmentedControl.svelte +0 -9
- package/dist/lib/components/ui/button/button.svelte.d.ts +44 -44
- package/dist/lib/data-chart/chart-utils.js +1 -0
- package/dist/lib/ev-stations/components/EvStationsDisplayOptions.svelte +3 -3
- package/dist/lib/hms/components/HMSFireLegend.svelte +4 -4
- package/dist/lib/hms/hms-smoke-map-integration.svelte.js +15 -11
- package/dist/lib/map/Menu.svelte +6 -5
- package/dist/lib/monitors/components/MonitorMarkersLegend.svelte +5 -5
- package/dist/lib/monitors/components/MonitorSubscriptionManager.svelte +16 -9
- package/dist/lib/monitors/components/MonitorsDisplayOptions.svelte +2 -7
- package/dist/lib/monitors/monitor-utils.js +4 -0
- package/dist/lib/monitors/monitors-icon-manager.svelte.js +2 -0
- package/dist/lib/monitors/monitors-map-integration.svelte.d.ts +1 -0
- package/dist/lib/monitors/monitors-map-integration.svelte.js +5 -1
- package/dist/lib/search/Search.svelte +15 -15
- package/package.json +25 -25
- package/src/lib/LoadScreen.svelte +3 -3
- package/src/lib/MapLegend.svelte +1 -1
- package/src/lib/MonitorDetailPanel.svelte +5 -3
- package/src/lib/MonitorMapLayout.svelte +41 -59
- package/src/lib/collocation-sites/collocations-map-integration.svelte.ts +1 -4
- package/src/lib/components/MapLayersDisplayOptions.svelte +4 -4
- package/src/lib/components/SegmentedControl.svelte +0 -9
- package/src/lib/data-chart/chart-utils.ts +1 -0
- package/src/lib/ev-stations/components/EvStationsDisplayOptions.svelte +3 -3
- package/src/lib/hms/components/HMSFireLegend.svelte +4 -4
- package/src/lib/hms/hms-smoke-map-integration.svelte.ts +15 -11
- package/src/lib/map/Menu.svelte +6 -5
- package/src/lib/monitors/components/MonitorMarkersLegend.svelte +5 -5
- package/src/lib/monitors/components/MonitorSubscriptionManager.svelte +16 -9
- package/src/lib/monitors/components/MonitorsDisplayOptions.svelte +2 -7
- package/src/lib/monitors/monitor-utils.ts +6 -0
- package/src/lib/monitors/monitors-icon-manager.svelte.ts +3 -0
- package/src/lib/monitors/monitors-map-integration.svelte.ts +4 -1
- package/src/lib/search/Search.svelte +15 -15
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
const id = monitorId;
|
|
46
46
|
loading = true;
|
|
47
47
|
try {
|
|
48
|
-
const subscriptions = await getSubscriptions(
|
|
48
|
+
const subscriptions = await getSubscriptions(getApiToken());
|
|
49
49
|
if (id !== monitorId) return;
|
|
50
50
|
const match = subscriptions.find((s) => s.monitor === id);
|
|
51
51
|
subscribedLevel = match?.level ?? null;
|
|
@@ -54,17 +54,18 @@
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
async function handleLevelClick(
|
|
58
|
-
if (saving || !
|
|
57
|
+
async function handleLevelClick(level: string | null) {
|
|
58
|
+
if (saving || !level) return;
|
|
59
59
|
saving = true;
|
|
60
60
|
const previous = subscribedLevel;
|
|
61
|
+
const apiToken = getApiToken();
|
|
61
62
|
try {
|
|
62
|
-
if (
|
|
63
|
-
await unsubscribe({ monitorId, apiToken
|
|
63
|
+
if (level === subscribedLevel) {
|
|
64
|
+
await unsubscribe({ monitorId, apiToken, level });
|
|
64
65
|
subscribedLevel = null;
|
|
65
66
|
} else {
|
|
66
|
-
await subscribe({ monitorId, apiToken
|
|
67
|
-
subscribedLevel =
|
|
67
|
+
await subscribe({ monitorId, apiToken, level });
|
|
68
|
+
subscribedLevel = level;
|
|
68
69
|
}
|
|
69
70
|
} catch {
|
|
70
71
|
subscribedLevel = previous;
|
|
@@ -74,6 +75,12 @@
|
|
|
74
75
|
}
|
|
75
76
|
open = false;
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
function getApiToken(): string {
|
|
80
|
+
return (
|
|
81
|
+
(globalThis as unknown as Record<string, Record<string, string>>)["USER"]?.api_token ?? ""
|
|
82
|
+
);
|
|
83
|
+
}
|
|
77
84
|
</script>
|
|
78
85
|
|
|
79
86
|
<div class="relative select-none">
|
|
@@ -99,7 +106,7 @@
|
|
|
99
106
|
<div class="absolute top-full left-0 z-20 mt-1 w-full overflow-hidden rounded shadow-lg">
|
|
100
107
|
{#if subscribedLevel}
|
|
101
108
|
<button
|
|
102
|
-
class="
|
|
109
|
+
class="flex w-full cursor-pointer items-center justify-between rounded-t border border-black/30 px-4 py-2 text-sm hover:bg-[#F5F5F3]"
|
|
103
110
|
onclick={() => handleLevelClick(subscribedLevel)}
|
|
104
111
|
>
|
|
105
112
|
Unsubscribe
|
|
@@ -111,7 +118,7 @@
|
|
|
111
118
|
<button
|
|
112
119
|
class={[
|
|
113
120
|
"flex w-full items-center justify-between px-4 py-2 text-sm text-white last:rounded-b",
|
|
114
|
-
!isSubscribed ? "first:rounded-t hover:brightness-90
|
|
121
|
+
!isSubscribed ? "cursor-pointer first:rounded-t hover:brightness-90" : ""
|
|
115
122
|
]}
|
|
116
123
|
style="background-color: {level.color}"
|
|
117
124
|
disabled={saving}
|
|
@@ -23,10 +23,7 @@
|
|
|
23
23
|
];
|
|
24
24
|
|
|
25
25
|
const monitorDisplayOptions = $derived.by(() => {
|
|
26
|
-
|
|
27
|
-
return Object.entries(monitorsMapIntegration.displayOptions);
|
|
28
|
-
|
|
29
|
-
const validOptions = Object.entries(monitorsMapIntegration.displayOptions).filter(
|
|
26
|
+
return Object.entries(monitorsMapIntegration.displayOptions).filter(
|
|
30
27
|
([key, opt]) =>
|
|
31
28
|
key === "inactive" ||
|
|
32
29
|
monitorsManager.meta?.asIter.monitors.some(
|
|
@@ -36,8 +33,6 @@
|
|
|
36
33
|
monitorsManager.pollutant in m.entries
|
|
37
34
|
)
|
|
38
35
|
);
|
|
39
|
-
|
|
40
|
-
return validOptions;
|
|
41
36
|
});
|
|
42
37
|
|
|
43
38
|
$effect(() => {
|
|
@@ -68,7 +63,7 @@
|
|
|
68
63
|
|
|
69
64
|
{#each monitorDisplayOptions as [id, option] (option.label)}
|
|
70
65
|
{@const inputId = `${id}-monitor-display-option`}
|
|
71
|
-
<label for={inputId} class="flex gap-1
|
|
66
|
+
<label for={inputId} class="flex cursor-pointer gap-1 whitespace-nowrap select-none">
|
|
72
67
|
<input type="checkbox" id={inputId} name={option.label} bind:checked={option.value} />
|
|
73
68
|
{#if option.icon}
|
|
74
69
|
<img class="w-3" src={option.icon.image.src} alt={option.icon.image.alt} />
|
|
@@ -27,6 +27,9 @@ export function getOrder(monitor: MonitorData): number {
|
|
|
27
27
|
case "purpleair":
|
|
28
28
|
return monitor.is_sjvair ? 4 : 1;
|
|
29
29
|
|
|
30
|
+
case "vozbox":
|
|
31
|
+
return 7;
|
|
32
|
+
|
|
30
33
|
default:
|
|
31
34
|
throw new Error(`Map ordering for ${monitor.device} has not been set`);
|
|
32
35
|
}
|
|
@@ -45,6 +48,9 @@ export function getTypeShape(type: string): string {
|
|
|
45
48
|
case "purpleair":
|
|
46
49
|
return "square";
|
|
47
50
|
|
|
51
|
+
case "vozbox":
|
|
52
|
+
return "circle";
|
|
53
|
+
|
|
48
54
|
default:
|
|
49
55
|
return "circle";
|
|
50
56
|
}
|
|
@@ -24,6 +24,9 @@ export function getIconId<T extends MonitorData>(monitor: T, level: SJVAirEntryL
|
|
|
24
24
|
case "purpleair":
|
|
25
25
|
return `${id}-${monitor.is_sjvair ? "circle" : "square"}`;
|
|
26
26
|
|
|
27
|
+
case "vozbox":
|
|
28
|
+
return `${id}-circle`;
|
|
29
|
+
|
|
27
30
|
default:
|
|
28
31
|
throw new Error(`Map icon for ${monitor.device} has not been set`);
|
|
29
32
|
}
|
|
@@ -44,6 +44,7 @@ class MonitorsMapIntegration extends MapIconLayerIntegration<MonitorMarkerProper
|
|
|
44
44
|
aqview: new MapDisplayOption("AQview", true, this.icons.get("outside-display-triangle")),
|
|
45
45
|
bam1022: new MapDisplayOption("SJVAir FEM", true, this.icons.get("outside-display-triangle")),
|
|
46
46
|
airnow: new MapDisplayOption("AirNow", true, this.icons.get("outside-display-triangle")),
|
|
47
|
+
vozbox: new MapDisplayOption("VOZbox", true, this.icons.get("outside-display-circle")),
|
|
47
48
|
inactive: new MapDisplayOption("Inactive", false, this.icons.get("outside-default-square")),
|
|
48
49
|
inside: new MapDisplayOption("Inside", false, this.icons.get("inside-display-square"))
|
|
49
50
|
}));
|
|
@@ -117,6 +118,7 @@ class MonitorsMapIntegration extends MapIconLayerIntegration<MonitorMarkerProper
|
|
|
117
118
|
if (this.displayOptions.aqview.value) monitorFilters.push(filters.monitor("aqview"));
|
|
118
119
|
if (this.displayOptions.bam1022.value) monitorFilters.push(filters.monitor("bam1022"));
|
|
119
120
|
if (this.displayOptions.airnow.value) monitorFilters.push(filters.monitor("airnow"));
|
|
121
|
+
if (this.displayOptions.vozbox.value) monitorFilters.push(filters.monitor("vozbox"));
|
|
120
122
|
if (this.displayOptions.sjvair.value)
|
|
121
123
|
monitorFilters.push(filters.sjvPurpleair(), filters.monitor("airgradient"));
|
|
122
124
|
if (this.displayOptions.inside.value)
|
|
@@ -144,7 +146,8 @@ class MonitorsMapIntegration extends MapIconLayerIntegration<MonitorMarkerProper
|
|
|
144
146
|
airgradient: opts.sjvair.value,
|
|
145
147
|
aqview: opts.aqview.value,
|
|
146
148
|
bam1022: opts.bam1022.value,
|
|
147
|
-
airnow: opts.airnow.value
|
|
149
|
+
airnow: opts.airnow.value,
|
|
150
|
+
vozbox: opts.vozbox.value
|
|
148
151
|
};
|
|
149
152
|
if (!(typeVisible[p.type] ?? true)) continue;
|
|
150
153
|
|
|
@@ -111,34 +111,34 @@
|
|
|
111
111
|
|
|
112
112
|
<div
|
|
113
113
|
class={[
|
|
114
|
-
"flex flex-col bg-white shadow-md
|
|
115
|
-
collapsed ? "
|
|
114
|
+
"flex flex-col overflow-hidden bg-white shadow-md transition-all duration-300 select-none",
|
|
115
|
+
collapsed ? "h-12 w-12 rounded-full" : "w-90 rounded-3xl",
|
|
116
116
|
!collapsed && results.length ? "max-h-90" : "max-h-12"
|
|
117
117
|
]}
|
|
118
118
|
use:clickOutside
|
|
119
119
|
>
|
|
120
|
-
<div class="flex
|
|
120
|
+
<div class="flex h-12 w-full shrink-0 items-center">
|
|
121
121
|
<button
|
|
122
|
-
class="
|
|
122
|
+
class="bg-brand flex h-12 w-12 shrink-0 items-center justify-center rounded-full border-4 border-white"
|
|
123
123
|
onclick={openSearch}
|
|
124
124
|
aria-label="Open search"
|
|
125
125
|
>
|
|
126
126
|
<SearchIcon size="24" color="#FFFFFF" />
|
|
127
127
|
</button>
|
|
128
|
-
<div class="
|
|
128
|
+
<div class="flex h-full w-full items-center overflow-hidden">
|
|
129
129
|
<input
|
|
130
130
|
bind:this={inputEl}
|
|
131
131
|
bind:value={searchText}
|
|
132
132
|
oninput={debouncedSearch}
|
|
133
133
|
type="text"
|
|
134
134
|
placeholder="Search monitors or locations..."
|
|
135
|
-
class="h-full
|
|
135
|
+
class="h-full w-full border-none bg-transparent px-2 text-sm outline-none"
|
|
136
136
|
tabindex={collapsed ? -1 : 0}
|
|
137
137
|
/>
|
|
138
138
|
{#if searchText && !collapsed}
|
|
139
139
|
<button
|
|
140
140
|
onclick={clearSearch}
|
|
141
|
-
class="px-2 text-gray-400 hover:text-gray-600
|
|
141
|
+
class="cursor-pointer px-2 text-xl leading-none text-gray-400 hover:text-gray-600"
|
|
142
142
|
aria-label="Clear search">×</button
|
|
143
143
|
>
|
|
144
144
|
{/if}
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
</div>
|
|
147
147
|
<div
|
|
148
148
|
class={[
|
|
149
|
-
"overflow-y-auto transition-all duration-300
|
|
149
|
+
"divide-y divide-gray-100 overflow-y-auto transition-all duration-300",
|
|
150
150
|
!collapsed ? "max-h-80" : "max-h-0"
|
|
151
151
|
]}
|
|
152
152
|
>
|
|
@@ -154,30 +154,30 @@
|
|
|
154
154
|
{#if result.type === "monitor"}
|
|
155
155
|
<button
|
|
156
156
|
onclick={() => selectMonitor(result)}
|
|
157
|
-
class="flex
|
|
157
|
+
class="flex h-12 w-full items-center bg-white px-4 text-left hover:brightness-95"
|
|
158
158
|
>
|
|
159
159
|
{#if result.logo.url}
|
|
160
160
|
<img
|
|
161
161
|
src={result.logo.url}
|
|
162
162
|
alt={result.logo.alt}
|
|
163
|
-
class="
|
|
163
|
+
class="mr-3 h-10 w-10 shrink-0 object-contain"
|
|
164
164
|
/>
|
|
165
165
|
{/if}
|
|
166
|
-
<span class="text-sm
|
|
166
|
+
<span class="truncate text-sm">{result.monitor.name}</span>
|
|
167
167
|
</button>
|
|
168
168
|
{:else}
|
|
169
169
|
{@const comma = result.feature.place_name.indexOf(",")}
|
|
170
170
|
<button
|
|
171
171
|
onclick={() => selectGeocode(result)}
|
|
172
|
-
class="flex
|
|
172
|
+
class="flex h-12 w-full items-center bg-white px-4 text-left hover:brightness-95"
|
|
173
173
|
>
|
|
174
|
-
<span class="svg-icon location-on bg-brand
|
|
174
|
+
<span class="svg-icon location-on bg-brand mr-3 h-6 w-6 shrink-0"></span>
|
|
175
175
|
<div class="min-w-0">
|
|
176
|
-
<p class="text-sm font-medium
|
|
176
|
+
<p class="truncate text-sm font-medium">
|
|
177
177
|
{result.feature.place_name.substring(0, comma < 0 ? undefined : comma)}
|
|
178
178
|
</p>
|
|
179
179
|
{#if comma >= 0}
|
|
180
|
-
<p class="text-
|
|
180
|
+
<p class="text-muted-foreground truncate text-xs">
|
|
181
181
|
{result.feature.place_name.substring(comma + 1).trim()}
|
|
182
182
|
</p>
|
|
183
183
|
{/if}
|