@vidro/map-handler 1.2.179 → 1.2.180
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/README.md +1 -1
- package/dist/map-handler.js +1 -1
- package/examples/react-next/README.md +260 -18
- package/examples/react-next/components/AuthComponent.js +88 -0
- package/examples/react-next/components/MapButtons.js +151 -30
- package/examples/react-next/components/MapFilters.js +120 -0
- package/examples/react-next/components/MapInfo.js +36 -0
- package/examples/react-next/components/MapLayers.js +60 -0
- package/examples/react-next/components/MapList.js +43 -0
- package/examples/react-next/contexts/auth.js +3 -1
- package/examples/react-next/contexts/maps.js +35 -16
- package/examples/react-next/contexts/messages.js +1 -6
- package/examples/react-next/env.sample +3 -0
- package/examples/react-next/hooks/useMapEvents.js +41 -132
- package/examples/react-next/package.json +2 -2
- package/examples/react-next/pages/index.js +26 -16
- package/examples/react-next/public/discord.svg +8 -0
- package/examples/react-next/public/favicon.ico +0 -0
- package/examples/react-next/public/logo.png +0 -0
- package/package.json +1 -1
- package/src/index.js +2 -1
- package/examples/react-next/components/SessionComponent.js +0 -136
- package/examples/react-next/pages/_document.js +0 -13
- package/examples/react-next/public/globe.svg +0 -1
- package/examples/react-next/public/vercel.svg +0 -1
- package/examples/react-next/public/window.svg +0 -1
- package/examples/react-next/shared/maps-service.js +0 -65
@@ -1,199 +1,108 @@
|
|
1
1
|
"use client";
|
2
|
-
import { useEffect
|
3
|
-
import
|
4
|
-
import { useIntl } from "react-intl";
|
5
|
-
import { toast } from "react-toastify";
|
6
|
-
import { ERRORS, MAP_EVENTS, PLUGINS } from "@/shared/constants";
|
2
|
+
import { useEffect } from "react";
|
3
|
+
import { MAP_EVENTS } from "@/shared/constants";
|
7
4
|
import { useMessages } from "@/contexts/messages";
|
8
5
|
import { useMaps } from "@/contexts/maps";
|
9
|
-
|
10
|
-
|
11
|
-
const logger = new Logger("Hooks - useMapEvents");
|
12
|
-
const useMapEvents = (setShowInfo) => {
|
6
|
+
const useMapEvents = () => {
|
13
7
|
const {
|
14
|
-
doInfo,
|
15
|
-
setTiledReady,
|
16
8
|
setMapReady,
|
17
9
|
setDisplayedLayers,
|
18
10
|
setCurrentMapAction,
|
19
11
|
displayedLayers,
|
20
12
|
setZoomLevel,
|
21
|
-
mapInfo,
|
22
13
|
mapReady,
|
23
|
-
AddLayerToPreselectedLayers,
|
24
|
-
mapScale,
|
25
14
|
setMapScale,
|
15
|
+
setClickedCoordinates,
|
16
|
+
setSrid,
|
17
|
+
setBboxcoordinates,
|
18
|
+
setMapResolution,
|
26
19
|
} = useMaps();
|
27
|
-
const { message, setMessage,
|
28
|
-
const [cookieCoordinates, setCookieCoordindates] = useState(null);
|
29
|
-
const [cookieZoom, setCookieZoom] = useState(null);
|
30
|
-
const [cookieToc, setCookieToc] = useState(null);
|
31
|
-
|
32
|
-
useEffect(() => {
|
33
|
-
if (!cookieCoordinates) return;
|
34
|
-
if (!cookieZoom) return;
|
35
|
-
try {
|
36
|
-
logger.log("Cookie zoom", { cookieZoom, cookieCoordinates });
|
37
|
-
zoomToCoordinates(JSON.parse(cookieCoordinates), cookieZoom);
|
38
|
-
} catch (e) {
|
39
|
-
logger.error("error parsing coordinates", e);
|
40
|
-
}
|
41
|
-
}, [cookieCoordinates, cookieZoom]);
|
42
|
-
|
43
|
-
useEffect(() => {
|
44
|
-
if (!mapInfo) return;
|
45
|
-
if (mapInfo?.layers.length === 0) return;
|
46
|
-
logger.log("Cookie layers", { mapInfo, cookieToc });
|
47
|
-
if (!cookieToc || cookieToc === "undefined") return;
|
48
|
-
try {
|
49
|
-
const tocLayers = JSON.parse(cookieToc);
|
50
|
-
logger.log("Cookie layers", tocLayers);
|
51
|
-
tocLayers.forEach((element) => {
|
52
|
-
logger.log("Cookie layers adding", element);
|
53
|
-
//find layer in project layers
|
54
|
-
const lay = mapInfo.layers.find((ly) => ly.qgis_name === element);
|
55
|
-
//render layer
|
56
|
-
AddLayerToPreselectedLayers(lay.id);
|
57
|
-
});
|
58
|
-
} catch (e) {
|
59
|
-
logger.error("error parsing cookieToc", e);
|
60
|
-
}
|
61
|
-
}, [cookieToc, mapInfo]);
|
20
|
+
const { message, setMessage, Highlight } = useMessages();
|
62
21
|
|
63
22
|
useEffect(() => {
|
64
23
|
if (!message) return;
|
65
24
|
if (!mapReady) return;
|
66
|
-
if (!mapInfo) return;
|
67
25
|
|
68
26
|
switch (message.type) {
|
69
27
|
case MAP_EVENTS.ZOOM_CHANGE:
|
70
|
-
|
71
|
-
|
72
|
-
storeMapCookie(`${mapInfo.id}_zoom`, message.zoom);
|
73
|
-
setZoomLevel(message.zoom);
|
74
|
-
}
|
28
|
+
console.log("useMapEvents Zoom changed", message);
|
29
|
+
setZoomLevel(message.zoom);
|
75
30
|
setMapScale(message?.meta?.scale);
|
31
|
+
setMapResolution(message?.meta?.resolution);
|
76
32
|
setMessage(null);
|
77
33
|
break;
|
78
34
|
case MAP_EVENTS.CENTER_CHANGE:
|
79
|
-
if (mapInfo.zoomcookie) {
|
80
|
-
storeMapCookie(
|
81
|
-
`${mapInfo.id}_center`,
|
82
|
-
JSON.stringify(message.coordinates)
|
83
|
-
);
|
84
|
-
}
|
85
35
|
setMessage(null);
|
86
36
|
break;
|
87
37
|
default:
|
88
38
|
setMessage(null);
|
89
39
|
break;
|
90
40
|
}
|
91
|
-
}, [message,
|
41
|
+
}, [message, mapReady]);
|
92
42
|
|
93
43
|
useEffect(() => {
|
94
44
|
if (!message) return;
|
95
45
|
switch (message.type) {
|
96
|
-
case MAP_EVENTS.VERSION:
|
97
|
-
//ToDo
|
98
|
-
break;
|
99
46
|
case MAP_EVENTS.LOADED:
|
100
47
|
if (message.what === "map") {
|
101
|
-
|
102
|
-
//use cookie for zoom and position only if map is configured with zoomcookie
|
103
|
-
if (mapInfo.zoomcookie) {
|
104
|
-
setCookieCoordindates(readMapCookie(`${mapInfo.id}_center`));
|
105
|
-
setCookieZoom(readMapCookie(`${mapInfo.id}_zoom`));
|
106
|
-
}
|
107
|
-
//use cookie for toc layers configured with tocusecookie
|
108
|
-
if (mapInfo.tocusecookie) {
|
109
|
-
setCookieToc(readMapCookie(`${mapInfo.id}_toc`));
|
110
|
-
}
|
48
|
+
console.log("useMapEvents Map loaded and ready");
|
111
49
|
setMapReady(true);
|
112
50
|
} else if (message.what === "tiled") {
|
113
|
-
|
114
|
-
setTiledReady(true);
|
51
|
+
console.log("useMapEvents Tiled loaded");
|
115
52
|
}
|
116
53
|
if (message.what === "layer") {
|
117
|
-
if (mapInfo.tocusecookie) {
|
118
|
-
if (cookieToc && cookieToc !== "undefined") {
|
119
|
-
let currentCookie = JSON.parse(cookieToc);
|
120
|
-
if (!currentCookie.find((l) => l === message.layer)) {
|
121
|
-
logger.log("Store layer in TOC cookie", message.layer);
|
122
|
-
currentCookie.push(message.layer);
|
123
|
-
storeMapCookie(
|
124
|
-
`${mapInfo.id}_toc`,
|
125
|
-
JSON.stringify(currentCookie)
|
126
|
-
);
|
127
|
-
}
|
128
|
-
} else {
|
129
|
-
logger.log("Store layer in TOC cookie", message.layer);
|
130
|
-
storeMapCookie(
|
131
|
-
`${mapInfo.id}_toc`,
|
132
|
-
JSON.stringify([message.layer])
|
133
|
-
);
|
134
|
-
}
|
135
|
-
}
|
136
54
|
}
|
137
55
|
setMessage(null);
|
138
56
|
break;
|
139
57
|
case MAP_EVENTS.UNLOADED:
|
140
58
|
if (message.what === "tiled") {
|
141
|
-
|
142
|
-
setTiledReady(false);
|
59
|
+
console.log("useMapEvents Tiled unloaded");
|
143
60
|
}
|
144
61
|
setMessage(null);
|
145
62
|
break;
|
146
63
|
case MAP_EVENTS.LAYERS:
|
147
|
-
|
64
|
+
console.log("useMapEvents displayed layers", message.layers);
|
148
65
|
if (!message.layers) returns;
|
149
66
|
//check if is already displayed
|
150
67
|
setDisplayedLayers(message.layers);
|
151
68
|
setMessage(null);
|
152
69
|
break;
|
153
70
|
case MAP_EVENTS.GEOM_ADDED:
|
154
|
-
|
71
|
+
console.log("GeomAdded", message);
|
155
72
|
setCurrentMapAction(null);
|
73
|
+
//Highlight the added geom
|
74
|
+
Highlight(
|
75
|
+
{
|
76
|
+
feature_type: "HIGHLIGHT",
|
77
|
+
geom: message?.geom_astext,
|
78
|
+
},
|
79
|
+
2,
|
80
|
+
{
|
81
|
+
duration: 1500,
|
82
|
+
repeat: true,
|
83
|
+
},
|
84
|
+
0,
|
85
|
+
null
|
86
|
+
);
|
156
87
|
if (message?.geom_astext === null) {
|
157
88
|
setMessage(null);
|
158
89
|
return;
|
159
90
|
}
|
160
|
-
/************************************************************************************
|
161
|
-
***************** INFO *************************
|
162
|
-
***********************************************************************************/
|
163
|
-
(async () => {
|
164
|
-
/*
|
165
|
-
try {
|
166
|
-
const { data, error } = await doInfo(
|
167
|
-
message.geom_astext,
|
168
|
-
message.srid,
|
169
|
-
currentElementType.name
|
170
|
-
);
|
171
|
-
|
172
|
-
logger.log("GeomAdded info", { data, error });
|
173
|
-
if (error) {
|
174
|
-
return { error: error };
|
175
|
-
}
|
176
|
-
} catch (err) {
|
177
|
-
// Handle errors
|
178
|
-
logger.error("Error occurred:", err);
|
179
|
-
} finally {
|
180
|
-
// Clean up or perform additional actions
|
181
|
-
setMessage(null);
|
182
|
-
// setCurrentMapAction(null);
|
183
|
-
}*/
|
184
|
-
})();
|
185
|
-
break;
|
186
|
-
|
187
|
-
/************************************************************************************
|
188
|
-
***************** END INFO *************************
|
189
|
-
***********************************************************************************/
|
190
91
|
|
191
92
|
/************************************************************************************
|
192
93
|
***************** CLICKED COORDINATES *************************
|
193
94
|
***********************************************************************************/
|
194
95
|
|
195
|
-
|
196
|
-
|
96
|
+
//***************** MAP CLICKED COORDINATES *************************
|
97
|
+
case MAP_EVENTS.COORDINATES:
|
98
|
+
console.log("clicked coordinates", message);
|
99
|
+
|
100
|
+
setClickedCoordinates(message.coordinates);
|
101
|
+
setSrid(message.srid);
|
102
|
+
setBboxcoordinates(message.bbox);
|
103
|
+
setMessage(null);
|
104
|
+
break;
|
105
|
+
|
197
106
|
/************************************************************************************
|
198
107
|
***************** END CLICKED COORDINATES *************************
|
199
108
|
***********************************************************************************/
|
@@ -3,13 +3,13 @@
|
|
3
3
|
"version": "0.1.0",
|
4
4
|
"private": true,
|
5
5
|
"scripts": {
|
6
|
-
"dev": "next dev",
|
6
|
+
"dev": "next dev -p",
|
7
7
|
"build": "next build",
|
8
8
|
"start": "next start",
|
9
9
|
"lint": "next lint"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
|
-
"@vidro/map-handler": "^1.2.
|
12
|
+
"@vidro/map-handler": "^1.2.179",
|
13
13
|
"next": "15.1.6",
|
14
14
|
"react": "^19.0.0",
|
15
15
|
"react-dom": "^19.0.0"
|
@@ -1,10 +1,14 @@
|
|
1
1
|
import MapButtons from "@/components/MapButtons";
|
2
2
|
import MapIframe from "@/components/MapIframe";
|
3
|
-
import
|
3
|
+
import MapInfo from "@/components/MapInfo";
|
4
|
+
import AuthComponent from "@/components/AuthComponent";
|
4
5
|
import { AuthProvider } from "@/contexts/auth";
|
5
6
|
import { MapsProvider } from "@/contexts/maps";
|
6
7
|
import { MessageProvider } from "@/contexts/messages";
|
7
8
|
import Image from "next/image";
|
9
|
+
import MapList from "@/components/MapList";
|
10
|
+
import MapLayers from "@/components/MapLayers";
|
11
|
+
import MapFilters from "@/components/MapFilters";
|
8
12
|
|
9
13
|
export default function Home() {
|
10
14
|
return (
|
@@ -13,12 +17,19 @@ export default function Home() {
|
|
13
17
|
<MessageProvider>
|
14
18
|
<MapsProvider>
|
15
19
|
<main className="text-center">
|
16
|
-
<h1>Map component REACT integration</h1>
|
20
|
+
<h1 className="text-3xl">Map component REACT integration</h1>
|
17
21
|
<div className="my-5">
|
18
|
-
<
|
22
|
+
<AuthComponent />
|
19
23
|
</div>
|
24
|
+
<div className="my-5">
|
25
|
+
<MapList />
|
26
|
+
<MapLayers />
|
27
|
+
<MapFilters />
|
28
|
+
</div>
|
29
|
+
|
20
30
|
<div className="my-5 bg-gray-100 border border-gray-400 p-4">
|
21
31
|
<MapButtons />
|
32
|
+
<MapInfo />
|
22
33
|
<MapIframe />
|
23
34
|
</div>
|
24
35
|
</main>
|
@@ -28,48 +39,47 @@ export default function Home() {
|
|
28
39
|
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
|
29
40
|
<a
|
30
41
|
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
31
|
-
href="https://
|
42
|
+
href="https://www.vidrosoftware.com"
|
32
43
|
target="_blank"
|
33
44
|
rel="noopener noreferrer"
|
34
45
|
>
|
35
46
|
<Image
|
36
47
|
aria-hidden
|
37
|
-
src="/
|
38
|
-
alt="
|
39
|
-
width={
|
40
|
-
height={
|
48
|
+
src="/logo.png"
|
49
|
+
alt="Vidrosoftware"
|
50
|
+
width={150}
|
51
|
+
height={120}
|
41
52
|
/>
|
42
|
-
Learn
|
43
53
|
</a>
|
44
54
|
<a
|
45
55
|
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
46
|
-
href="https://
|
56
|
+
href="https://github.com/Vidro-Software-SL/maphandler"
|
47
57
|
target="_blank"
|
48
58
|
rel="noopener noreferrer"
|
49
59
|
>
|
50
60
|
<Image
|
51
61
|
aria-hidden
|
52
|
-
src="/
|
62
|
+
src="/file.svg"
|
53
63
|
alt="Window icon"
|
54
64
|
width={16}
|
55
65
|
height={16}
|
56
66
|
/>
|
57
|
-
|
67
|
+
Documentation
|
58
68
|
</a>
|
59
69
|
<a
|
60
70
|
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
61
|
-
href="https://
|
71
|
+
href="https://discord.com/channels/1305257097843179642/1305257098313072714"
|
62
72
|
target="_blank"
|
63
73
|
rel="noopener noreferrer"
|
64
74
|
>
|
65
75
|
<Image
|
66
76
|
aria-hidden
|
67
|
-
src="/
|
68
|
-
alt="
|
77
|
+
src="/discord.svg"
|
78
|
+
alt="Discord icon"
|
69
79
|
width={16}
|
70
80
|
height={16}
|
71
81
|
/>
|
72
|
-
|
82
|
+
Discord channel
|
73
83
|
</a>
|
74
84
|
</footer>
|
75
85
|
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
3
|
+
<svg width="800px" height="800px" viewBox="0 -28.5 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
4
|
+
<g>
|
5
|
+
<path d="M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z" fill="#5865F2" fill-rule="nonzero">
|
6
|
+
|
7
|
+
</g>
|
8
|
+
</svg>
|
Binary file
|
Binary file
|
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -505,10 +505,11 @@ class Communicator extends EventEmitter {
|
|
505
505
|
});
|
506
506
|
};
|
507
507
|
|
508
|
-
Geolocalize = (toggle) => {
|
508
|
+
Geolocalize = (toggle, options) => {
|
509
509
|
this.com.sendMessageToMap({
|
510
510
|
type: "Geolocalize",
|
511
511
|
toggle: toggle,
|
512
|
+
options: options,
|
512
513
|
sessionToken: this.sessionToken,
|
513
514
|
});
|
514
515
|
};
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import { useAuth } from "@/contexts/auth";
|
2
|
-
import { useMaps } from "@/contexts/maps";
|
3
|
-
import { useMessages } from "@/contexts/messages";
|
4
|
-
import { useEffect, useState } from "react";
|
5
|
-
|
6
|
-
const SessionComponent = () => {
|
7
|
-
const { sessionToken, setSessionToken, mapInfo, mapId, GetMap } = useMaps();
|
8
|
-
const { start } = useMessages();
|
9
|
-
const { apiUrl, setApiUrl, login, logged, logout, projects } = useAuth();
|
10
|
-
const [user, setUser] = useState("test@aiguesmataro.cat");
|
11
|
-
const [pwd, setPwd] = useState("test.12345");
|
12
|
-
const [selectedMap, setSelectedMap] = useState("-1");
|
13
|
-
// Handler for textarea changes
|
14
|
-
const handleTextChange = (event) => {
|
15
|
-
setText(event.target.value);
|
16
|
-
};
|
17
|
-
|
18
|
-
// Handler for API URL input changes
|
19
|
-
const handleApiUrlChange = (event) => {
|
20
|
-
setApiUrl(event.target.value);
|
21
|
-
};
|
22
|
-
|
23
|
-
// Handler for the button click
|
24
|
-
const handleButtonClick = () => {
|
25
|
-
console.log("API URL:", apiUrl);
|
26
|
-
start();
|
27
|
-
};
|
28
|
-
|
29
|
-
useEffect(() => {
|
30
|
-
setSessionToken(
|
31
|
-
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIwNjdhODM3NzQwOGI5NjdlNWZkZjFlYmZiMGRiMjNiNDA3NzY1ZjQ1IiwiZGF0YSI6eyJ6b29tIjoyLCJwcmV2aWV3IjpmYWxzZSwiYXBpIjoiaHR0cHM6XC9cL2JtYXBzZGV2LmFpZ3Vlc21hdGFyby5jb21cL2FwaVwvIiwidG9rZW4iOiJkMDc1N2JmNjAxMDc1ZDA0MWE5Y2JjYTJjOWQ3NWU2OSIsInNob3dfbGF5ZXJzIjpbXSwiaWQiOjUwOSwibG9nbyI6Imh0dHBzOlwvXC9ibWFwc2Rldi5haWd1ZXNtYXRhcm8uY29tXC9iYWNrb2ZmaWNlbmV3XC9fbmV4dFwvaW1hZ2U_dXJsPSUyRmJhY2tvZmZpY2VuZXclMkZsb2dvYW1zYS5wbmcmdz05NiZxPTc1IiwiZGVidWciOmZhbHNlLCJ2ZXJib3NlIjpmYWxzZX0sImV4cCI6NDg3NzY1OTI2Mn0.iq7ldyzhiy2iZv76pflmKwRbgj2h00b8vP6ooJRlUUB_ZFAkNNJ2D-wDL0lZBepj_I4NvnKFHymgZp9OMcncqYQvEmu_0FrL81v_L6Hnc81E1avQZN9O64o5asxKtszgfpANIKJIiNsagB6uk5hPS-e5hB6W26eYaAayQUQqbOYr1OgaCQa7opfAk0746Z5DxyXhy0TtbrHjJS7ObG2gHzxRjwp4gJHdBBJMbjGpo365_zcS1tGTCShRsu7xyr-QakVxJkXUl13OLyFluHSPDcAM9CQG_4XSSudn82Ot_Bg6PG1cd7V6cp-rXr7qXScv9y63YxIfhFP1oc9pA2t6-lEt94GhhPBAbZxfN7mMecFYoLWYbPjpAWmIYIHhySY0EdwYiHOVnpL5fg318OzNkqihpDejBwSwRDzNjmQVv83i1culB2vJx3rxQ8xs7wfqBCgRUlmW_gfFeDwPHRXP1fGGeX8VYMGy5XZt4ozyBETKIYUxqQJ10Lro8TUKS-Us1tUrn8Z7-NNp7zKse3bMl70lMPgbRRLvWfaJC9QPXSvhHayDGVEDAUnCW5PiervD5o1d5I_4AfxCfRXdNdRKcvjSdPNoSnbk3D_qrjQm0Uz9_pgGgl8HIUKr3fsCNTAzcbUtkM3C_nfXOeHAD-IOacTnc6O3kriso-CVKcCF_CE"
|
32
|
-
);
|
33
|
-
setApiUrl("https://bmapsdev.aiguesmataro.com/api/");
|
34
|
-
}, []);
|
35
|
-
|
36
|
-
useEffect(() => {
|
37
|
-
if (!mapInfo) return;
|
38
|
-
GetMap(mapId); //starts mapComponent
|
39
|
-
}, [mapInfo, mapId]);
|
40
|
-
|
41
|
-
return (
|
42
|
-
<div>
|
43
|
-
{logged && (
|
44
|
-
<div className="bg-gray-200 p-2 text-left">
|
45
|
-
<div className="text-xs">
|
46
|
-
Logged as <b>{user}</b>
|
47
|
-
</div>
|
48
|
-
<div className="text-xs">
|
49
|
-
API: <b>{apiUrl}</b>
|
50
|
-
</div>
|
51
|
-
<button
|
52
|
-
onClick={(e) => {
|
53
|
-
logout();
|
54
|
-
}}
|
55
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2 mt-1 text-xs"
|
56
|
-
>
|
57
|
-
Logout
|
58
|
-
</button>
|
59
|
-
<div className="mt-2">
|
60
|
-
<label className="block text-sm font-medium text-gray-700">
|
61
|
-
Maps
|
62
|
-
</label>
|
63
|
-
<select
|
64
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
65
|
-
onChange={(e) => setSelectedMap(e.target.value)}
|
66
|
-
value={selectedMap}
|
67
|
-
>
|
68
|
-
<option value="-1">Select a map</option>
|
69
|
-
{projects.map((projectId) => (
|
70
|
-
<option key={projectId} value={projectId}>
|
71
|
-
{projectId}
|
72
|
-
</option>
|
73
|
-
))}
|
74
|
-
</select>
|
75
|
-
</div>
|
76
|
-
<button
|
77
|
-
onClick={(e) => {
|
78
|
-
GetMap(selectedMap);
|
79
|
-
}}
|
80
|
-
disabled={selectedMap === "-1"}
|
81
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2 mt-1 text-xs"
|
82
|
-
>
|
83
|
-
Load map
|
84
|
-
</button>
|
85
|
-
</div>
|
86
|
-
)}
|
87
|
-
{!logged && (
|
88
|
-
<div>
|
89
|
-
<div className="mb-4 flex gap-1">
|
90
|
-
<label className="w-32">API URL</label>
|
91
|
-
<input
|
92
|
-
type="text"
|
93
|
-
value={apiUrl}
|
94
|
-
onChange={handleApiUrlChange}
|
95
|
-
placeholder="Enter API URL..."
|
96
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
97
|
-
/>
|
98
|
-
</div>
|
99
|
-
<div className="mb-4 flex gap-1">
|
100
|
-
<label className="w-32">User</label>
|
101
|
-
<input
|
102
|
-
type="text"
|
103
|
-
value={user}
|
104
|
-
onChange={(e) => setUser(e.target.value)}
|
105
|
-
placeholder="User"
|
106
|
-
disabled={logged}
|
107
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
108
|
-
/>
|
109
|
-
</div>
|
110
|
-
<div className="mb-4 flex gap-1">
|
111
|
-
<label className="w-32">Password</label>
|
112
|
-
<input
|
113
|
-
type="password"
|
114
|
-
value={pwd}
|
115
|
-
onChange={(e) => setPwd(e.target.value)}
|
116
|
-
disabled={logged}
|
117
|
-
placeholder="User"
|
118
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
119
|
-
/>
|
120
|
-
</div>
|
121
|
-
|
122
|
-
<button
|
123
|
-
onClick={(e) => {
|
124
|
-
login(user, pwd);
|
125
|
-
}}
|
126
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2"
|
127
|
-
>
|
128
|
-
Login
|
129
|
-
</button>
|
130
|
-
</div>
|
131
|
-
)}
|
132
|
-
</div>
|
133
|
-
);
|
134
|
-
};
|
135
|
-
|
136
|
-
export default SessionComponent;
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
@@ -1,65 +0,0 @@
|
|
1
|
-
// Helper function to handle fetch responses
|
2
|
-
const handleResponse = async (response) => {
|
3
|
-
if (!response.ok) {
|
4
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
5
|
-
}
|
6
|
-
return response.json();
|
7
|
-
};
|
8
|
-
|
9
|
-
/*** Get map */
|
10
|
-
const getMap = async (id) => {
|
11
|
-
let url = `map/${id}`;
|
12
|
-
|
13
|
-
try {
|
14
|
-
const response = await fetch(url, {
|
15
|
-
method: "GET",
|
16
|
-
headers: {
|
17
|
-
"Content-Type": "application/json",
|
18
|
-
},
|
19
|
-
});
|
20
|
-
return handleResponse(response);
|
21
|
-
} catch (error) {
|
22
|
-
console.error("Error fetching map:", error);
|
23
|
-
throw error;
|
24
|
-
}
|
25
|
-
};
|
26
|
-
|
27
|
-
/*** Get map info */
|
28
|
-
const getMapInfo = async (id) => {
|
29
|
-
try {
|
30
|
-
const response = await fetch(`map/detail/${id}`, {
|
31
|
-
method: "GET",
|
32
|
-
headers: {
|
33
|
-
"Content-Type": "application/json",
|
34
|
-
},
|
35
|
-
});
|
36
|
-
return handleResponse(response);
|
37
|
-
} catch (error) {
|
38
|
-
console.error("Error fetching map info:", error);
|
39
|
-
throw error;
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
/*** Get map toc */
|
44
|
-
const getMapToc = async (id) => {
|
45
|
-
try {
|
46
|
-
const response = await fetch(`map/toc/${id}`, {
|
47
|
-
method: "GET",
|
48
|
-
headers: {
|
49
|
-
"Content-Type": "application/json",
|
50
|
-
},
|
51
|
-
});
|
52
|
-
return handleResponse(response);
|
53
|
-
} catch (error) {
|
54
|
-
console.error("Error fetching map TOC:", error);
|
55
|
-
throw error;
|
56
|
-
}
|
57
|
-
};
|
58
|
-
|
59
|
-
const MapService = {
|
60
|
-
getMap,
|
61
|
-
getMapInfo,
|
62
|
-
getMapToc,
|
63
|
-
};
|
64
|
-
|
65
|
-
export default MapService;
|