Skip to content

Commit 189b391

Browse files
authored
Merge pull request #386 from OpenGeoscience/client-bug-fixes
Misc client bug fixes
2 parents d7d100e + ce506f1 commit 189b391

6 files changed

Lines changed: 73 additions & 44 deletions

File tree

web/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"chroma-js": "3.2.0",
2525
"dayjs": "1.11.20",
2626
"django-s3-file-field": "1.1.0",
27-
"html2canvas": "1.4.1",
27+
"html2canvas-pro": "^2.0.2",
2828
"json-editor-vue": "0.18.1",
2929
"lodash": "4.18.1",
3030
"maplibre-gl": "5.24.0",

web/src/components/ControlsBar.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import { debounce } from "lodash";
23
import { ref, watch, computed } from "vue";
3-
import html2canvas from "html2canvas";
4-
import { Map } from "maplibre-gl";
4+
import html2canvas from "html2canvas-pro";
5+
import { Map, type LngLatBoundsLike } from "maplibre-gl";
56
67
import JsonEditorVue from "json-editor-vue";
78
import "vanilla-jsoneditor/themes/jse-theme-dark.css";
@@ -81,7 +82,7 @@ const userHasEditPermission = computed(() => {
8182
function createBasemapPreviews() {
8283
if (basemapList.value) {
8384
const map = mapStore.getMap();
84-
const bounds = map.getBounds();
85+
const bounds = map.getBounds().toArray() as LngLatBoundsLike;
8586
mapStore.availableBasemaps.forEach((basemap) => {
8687
if (basemap.id === undefined || basemap.style === undefined) return;
8788
if (basemapPreviews.value[basemap.id]) {
@@ -140,7 +141,7 @@ function setNewBasemapStyleFromTileURL() {
140141
}
141142
}
142143
143-
function createNewBasemapPreview() {
144+
async function createNewBasemapPreview() {
144145
const map = mapStore.getMap();
145146
const center = map.getCenter();
146147
const zoom = map.getZoom();
@@ -153,7 +154,17 @@ function createNewBasemapPreview() {
153154
newBasemapPreview.value.setCenter(center);
154155
newBasemapPreview.value.setZoom(zoom);
155156
if (newBasemapStyleJSON.value) {
156-
jsonErrors.value = validateStyleMin(newBasemapStyleJSON.value);
157+
if (typeof newBasemapStyleJSON.value == "string") {
158+
try {
159+
const response = await fetch(newBasemapStyleJSON.value);
160+
const content = await response.json();
161+
jsonErrors.value = validateStyleMin(content);
162+
} catch {
163+
jsonErrors.value = [{ message: "Invalid URL." }];
164+
}
165+
} else {
166+
jsonErrors.value = validateStyleMin(newBasemapStyleJSON.value);
167+
}
157168
if (!jsonErrors.value?.length) {
158169
newBasemapPreview.value.setStyle(newBasemapStyleJSON.value);
159170
return;
@@ -288,8 +299,8 @@ function copyViewStateLink(viewState: ViewState) {
288299
289300
watch(basemapList, createBasemapPreviews);
290301
watch(newBasemapTab, switchBasemapCreateTab);
291-
watch(newBasemapTileURL, setNewBasemapStyleFromTileURL);
292-
watch(newBasemapStyleJSON, createNewBasemapPreview);
302+
watch(newBasemapTileURL, debounce(setNewBasemapStyleFromTileURL, 1000));
303+
watch(newBasemapStyleJSON, debounce(createNewBasemapPreview, 1000));
293304
</script>
294305

295306
<template>

web/src/components/map/ToggleCompareMap.vue

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script setup lang="ts">
22
import { useAppStore, useLayerStore, useMapStore } from "@/store";
33
import { useMapCompareStore } from "@/store/compare";
4-
import { computed, ref, watch } from "vue";
4+
import { computed, onMounted, ref, watch } from "vue";
55
import type { Ref } from "vue";
66
import { ToggleCompare } from "vue-maplibre-compare";
77
import { oauthClient } from "@/api/auth";
88
import "vue-maplibre-compare/dist/vue-maplibre-compare.css";
99
import { addProtocol, AttributionControl, Popup } from "maplibre-gl";
10-
import type { StyleSpecification, Map } from "maplibre-gl";
10+
import { type StyleSpecification, Map } from "maplibre-gl";
1111
import { useTheme } from "vuetify";
1212
import { Protocol } from "pmtiles";
1313
import { storeToRefs } from "pinia";
@@ -246,10 +246,37 @@ const swiperColor = computed(() => {
246246
arrow: theme.global.current.value.colors["button-text"] as string,
247247
};
248248
});
249+
250+
onMounted(() => {
251+
if (!appStore.currentUser) {
252+
const lightDefault =
253+
"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png";
254+
const darkDefault =
255+
"https://basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png";
256+
new Map({
257+
container: "mapContainer",
258+
attributionControl: false,
259+
style: {
260+
layers: [{ id: "light", type: "raster", source: "light" }],
261+
sources: {
262+
light: {
263+
type: "raster",
264+
tiles: [appStore.theme === "light" ? lightDefault : darkDefault],
265+
maxzoom: 19,
266+
tileSize: 256,
267+
},
268+
},
269+
version: 8,
270+
},
271+
center: [0, 0],
272+
zoom: 1, // Initial zoom level
273+
});
274+
}
275+
});
249276
</script>
250277

251278
<template>
252-
<div>
279+
<div v-if="appStore.currentUser">
253280
<ToggleCompare
254281
:map-style-a="mapStyleA"
255282
:map-style-b="mapBStyle"
@@ -288,6 +315,7 @@ const swiperColor = computed(() => {
288315
<MapTooltip compare-map />
289316
</div>
290317
</div>
318+
<div v-else id="mapContainer" class="map"></div>
291319
</template>
292320

293321
<style scoped>

web/src/components/projects/ProjectConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ watch(
574574
<style>
575575
.project-row {
576576
display: flex;
577-
margin: 0px 8px;
577+
margin: 8px;
578578
align-items: center;
579579
justify-content: space-between;
580580
}

web/src/components/sidebars/SideBars.vue

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,18 @@ function togglePanelVisibility(id: string) {
189189
v-tooltip="'Panel Visibility'"
190190
></v-icon>
191191
</template>
192-
<v-list
193-
:items="panelStore.panelArrangement.filter((p) => p.closeable)"
194-
item-title="label"
195-
item-value="id"
196-
selectable
197-
:selected="panelStore.panelArrangement.filter((p) => p.visible)"
198-
@click:select="(item) => togglePanelVisibility(item.id as string)"
199-
select-strategy="leaf"
200-
return-object
201-
>
202-
<template v-slot:prepend="{ item, isSelected }">
203-
<v-list-item-action start>
204-
<v-checkbox-btn
205-
:model-value="isSelected"
206-
@change="togglePanelVisibility(item.id)"
207-
></v-checkbox-btn>
208-
</v-list-item-action>
209-
</template>
192+
<v-list>
193+
<v-list-item
194+
v-for="item in panelStore.panelArrangement.filter(
195+
(p) => p.closeable,
196+
)"
197+
@click="togglePanelVisibility(item.id)"
198+
>
199+
<v-checkbox-btn
200+
:model-value="item.visible"
201+
:label="item.label"
202+
></v-checkbox-btn>
203+
</v-list-item>
210204
</v-list>
211205
</v-menu>
212206
</div>
@@ -304,15 +298,11 @@ function togglePanelVisibility(id: string) {
304298
max-height: calc(100% - 100px);
305299
}
306300
307-
.v-icon {
308-
color: rgb(var(--v-theme-secondary-text)) !important;
309-
}
310-
311-
.v-btn.bg-primary .v-icon {
312-
color: rgb(var(--v-theme-button-text)) !important;
313-
}
314-
315301
.v-text-field {
316302
background-color: rgb(var(--v-theme-background));
317303
}
304+
305+
.v-checkbox-btn .v-label {
306+
margin-left: 5px;
307+
}
318308
</style>

0 commit comments

Comments
 (0)