Initialise le front-end Vue
- Vue 3, Vite, TypeScript, Vue Router, vue-i18n, MapLibre GL JS, Bootstrap 5 (CSS seul), Bootstrap Icons, police Roboto. - Pages : connexion, évaluation (adresse, carte avec couches WalOnMap, une carte par facteur avec badge, valeurs mesurées, onglets et références, état « indisponible » avec Réessayer), erreurs 403/404. - Design repris des maquettes Penpot (charte ssmg.be), bureau et mobile. - Garde de navigation, client API avec jeton CSRF ; l'adresse du patient ne quitte pas la mémoire du composant. - 51 tests Vitest ; README et CLAUDE.md mis à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d441b11c2
commit
7f29cec2a2
52 files changed
+9347
-4
No files matched your search
@@ -0,0 +1,233 @@
|
||||
<script setup lang="ts">
|
||||
import { Map as MapLibreMap, Marker, NavigationControl, ScaleControl } from 'maplibre-gl'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import type { Assessment } from '@/api/types'
|
||||
|
||||
const props = defineProps<{ location: Assessment['location'] | null }>()
|
||||
|
||||
const WALONMAP_WMS = 'https://geoservices.wallonie.be/arcgis/services'
|
||||
// Fond OpenStreetMap : les serveurs publics ne sont pas prévus pour la production
|
||||
// (specs, risque 12). À remplacer par un fournisseur de tuiles avant la mise en production.
|
||||
const OSM_TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
||||
const BELGIUM: [number, number] = [4.47, 50.5]
|
||||
|
||||
function wms(service: string, layers: string): string {
|
||||
const params = new URLSearchParams({
|
||||
service: 'WMS',
|
||||
request: 'GetMap',
|
||||
version: '1.3.0',
|
||||
layers,
|
||||
styles: '',
|
||||
format: 'image/png',
|
||||
transparent: 'true',
|
||||
crs: 'EPSG:3857',
|
||||
width: '256',
|
||||
height: '256',
|
||||
})
|
||||
return `${WALONMAP_WMS}/${service}/MapServer/WMSServer?${params}&bbox={bbox-epsg-3857}`
|
||||
}
|
||||
|
||||
const overlays = [
|
||||
{ id: 'flood', url: wms('EAU/ALEA_INOND', '2'), color: '#00b0f0' },
|
||||
{ id: 'noise', url: wms('INDUSTRIES_SERVICES/BRUIT_MROAD_2017', '1'), color: '#e85b25' },
|
||||
] as const
|
||||
|
||||
type OverlayId = (typeof overlays)[number]['id']
|
||||
|
||||
const container = ref<HTMLDivElement>()
|
||||
const layersPanel = ref<HTMLFieldSetElement>()
|
||||
const visible = ref<Record<OverlayId, boolean>>({ flood: true, noise: false })
|
||||
let map: MapLibreMap | null = null
|
||||
let marker: Marker | null = null
|
||||
|
||||
onMounted(() => {
|
||||
const instance = new MapLibreMap({
|
||||
container: container.value!,
|
||||
center: BELGIUM,
|
||||
zoom: 7,
|
||||
attributionControl: { compact: false },
|
||||
style: {
|
||||
version: 8,
|
||||
sources: {
|
||||
osm: {
|
||||
type: 'raster',
|
||||
tiles: [OSM_TILES],
|
||||
tileSize: 256,
|
||||
maxzoom: 19,
|
||||
attribution: '© OpenStreetMap contributors',
|
||||
},
|
||||
...Object.fromEntries(
|
||||
overlays.map((o) => [
|
||||
o.id,
|
||||
{ type: 'raster', tiles: [o.url], tileSize: 256, attribution: '© SPW – WalOnMap' },
|
||||
]),
|
||||
),
|
||||
},
|
||||
layers: [
|
||||
{ id: 'osm', type: 'raster', source: 'osm' },
|
||||
...overlays.map((o) => ({
|
||||
id: o.id,
|
||||
type: 'raster' as const,
|
||||
source: o.id,
|
||||
paint: { 'raster-opacity': 0.6 },
|
||||
layout: { visibility: visible.value[o.id] ? ('visible' as const) : ('none' as const) },
|
||||
})),
|
||||
],
|
||||
},
|
||||
})
|
||||
instance.addControl(new NavigationControl({ showCompass: false }), 'top-right')
|
||||
instance.addControl(new ScaleControl({ unit: 'metric' }), 'bottom-left')
|
||||
map = instance
|
||||
showLocation()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
map?.remove()
|
||||
map = null
|
||||
})
|
||||
|
||||
function showLocation() {
|
||||
if (!map || !props.location) return
|
||||
const lngLat: [number, number] = [props.location.lon, props.location.lat]
|
||||
marker?.remove()
|
||||
marker = new Marker({ color: '#e85b25' }).setLngLat(lngLat).addTo(map)
|
||||
// La mise en page peut avoir changé depuis la création de la carte.
|
||||
map.resize()
|
||||
// Décale le centre sous le panneau des couches pour que le marqueur reste visible.
|
||||
const top = (layersPanel.value?.offsetHeight ?? 0) + 12
|
||||
map.jumpTo({ center: lngLat, zoom: 15, padding: { top, bottom: 0, left: 0, right: 0 } })
|
||||
}
|
||||
|
||||
function toggle(id: OverlayId) {
|
||||
visible.value[id] = !visible.value[id]
|
||||
map?.setLayoutProperty(id, 'visibility', visible.value[id] ? 'visible' : 'none')
|
||||
}
|
||||
|
||||
watch(() => props.location, showLocation, { flush: 'post' })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="result-map prism-card">
|
||||
<div ref="container" class="map" role="region" :aria-label="$t('map.label')"></div>
|
||||
|
||||
<fieldset ref="layersPanel" class="map-panel layers">
|
||||
<legend>{{ $t('map.layers') }}</legend>
|
||||
<div class="form-check">
|
||||
<input id="layer-osm" class="form-check-input" type="checkbox" checked disabled />
|
||||
<label class="form-check-label" for="layer-osm">{{ $t('map.basemap') }}</label>
|
||||
</div>
|
||||
<div v-for="overlay in overlays" :key="overlay.id" class="form-check">
|
||||
<input
|
||||
:id="`layer-${overlay.id}`"
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
:checked="visible[overlay.id]"
|
||||
@change="toggle(overlay.id)"
|
||||
/>
|
||||
<label class="form-check-label" :for="`layer-${overlay.id}`">
|
||||
{{ $t(`map.${overlay.id}`) }}
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="map-panel legend">
|
||||
<strong>{{ $t('map.legend') }}</strong>
|
||||
<div>
|
||||
<span class="swatch round" style="background: #e85b25"></span>{{ $t('map.patient') }}
|
||||
</div>
|
||||
<template v-for="overlay in overlays" :key="overlay.id">
|
||||
<div v-if="visible[overlay.id]">
|
||||
<span class="swatch" :style="{ background: overlay.color }"></span>
|
||||
{{ $t(`map.${overlay.id}`) }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.result-map {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
height: 720px;
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.result-map {
|
||||
position: sticky;
|
||||
top: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 991.98px) {
|
||||
.result-map {
|
||||
height: 240px;
|
||||
}
|
||||
.legend {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
.map-panel {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
z-index: 2;
|
||||
background: var(--prism-surface);
|
||||
border: 1px solid var(--prism-border);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
font-size: 0.6875rem;
|
||||
box-shadow: 0 2px 8px rgb(9 41 51 / 10%);
|
||||
}
|
||||
|
||||
.layers {
|
||||
top: 12px;
|
||||
}
|
||||
|
||||
.layers legend {
|
||||
float: none;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: var(--prism-navy);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.form-check {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.form-check-input:checked {
|
||||
background-color: var(--prism-orange);
|
||||
border-color: var(--prism-orange);
|
||||
}
|
||||
|
||||
.legend {
|
||||
bottom: 40px;
|
||||
}
|
||||
|
||||
.legend strong {
|
||||
display: block;
|
||||
font-size: 0.75rem;
|
||||
color: var(--prism-navy);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.swatch {
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 8px;
|
||||
border-radius: 2px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.swatch.round {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user