Add public map with JWT admin login and protect admin APIs.
Keep map reads open; gate admin UI/nav and object mutations behind env-based admin credentials, and default parser batch limit to 10. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,12 +16,14 @@ import CoordsTools from "../components/map/CoordsTools.vue";
|
||||
import MapToolbar from "../components/map/MapToolbar.vue";
|
||||
import PlaceSearch from "../components/map/PlaceSearch.vue";
|
||||
import ObjectPanel from "../components/ObjectPanel.vue";
|
||||
import { useAuth } from "../composables/useAuth";
|
||||
import type { LeafletMapApi } from "../composables/useLeafletMap";
|
||||
import type { DateRangePreset, MapFilters, MapObjectWithEvent, MapQueryParams } from "../types/map";
|
||||
import type { MapObjectCreate, ObjectType } from "../types/object";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { authenticated } = useAuth();
|
||||
|
||||
const objects = ref<MapObjectWithEvent[]>([]);
|
||||
const mapFilters = ref<MapFilters | null>(null);
|
||||
@@ -162,6 +164,7 @@ function handleMapContextMenu(payload: {
|
||||
longitude: number;
|
||||
object: MapObjectWithEvent | null;
|
||||
}) {
|
||||
if (!authenticated.value) return;
|
||||
contextMenu.value = {
|
||||
visible: true,
|
||||
x: payload.x,
|
||||
@@ -257,6 +260,7 @@ async function handleMoveObject(payload: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}) {
|
||||
if (!authenticated.value) return;
|
||||
if (payload.object.event_id) return;
|
||||
try {
|
||||
await updateObject(payload.object.id, {
|
||||
@@ -327,17 +331,22 @@ onUnmounted(() => {
|
||||
:objects="objects"
|
||||
:selected-id="selectedId"
|
||||
:open-popup-id="openPopupId"
|
||||
:editable="authenticated"
|
||||
@ready="onMapReady"
|
||||
@center-change="onCenterChange"
|
||||
@select="handleSelectObject"
|
||||
@contextmenu="handleMapContextMenu"
|
||||
@move="handleMoveObject"
|
||||
/>
|
||||
<ObjectPanel :object="selectedObject" @open-events="openInEvents" />
|
||||
<ObjectPanel
|
||||
:object="selectedObject"
|
||||
:can-edit="authenticated"
|
||||
@open-events="openInEvents"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ContextMenu
|
||||
v-if="contextMenu.visible"
|
||||
v-if="contextMenu.visible && authenticated"
|
||||
:x="contextMenu.x"
|
||||
:y="contextMenu.y"
|
||||
:target="contextMenu.target"
|
||||
@@ -350,7 +359,7 @@ onUnmounted(() => {
|
||||
/>
|
||||
|
||||
<CreateObjectModal
|
||||
v-if="createModal.visible"
|
||||
v-if="createModal.visible && authenticated"
|
||||
:latitude="createModal.latitude"
|
||||
:longitude="createModal.longitude"
|
||||
@close="closeCreateModal"
|
||||
@@ -358,7 +367,7 @@ onUnmounted(() => {
|
||||
/>
|
||||
|
||||
<EditObjectModal
|
||||
v-if="editModal.visible && editModal.object"
|
||||
v-if="editModal.visible && editModal.object && authenticated"
|
||||
:object="editModal.object"
|
||||
@close="closeEditModal"
|
||||
@submit="handleEditObject"
|
||||
|
||||
Reference in New Issue
Block a user