Merge remote-tracking branch 'origin/master'
This commit is contained in:
+158
-51
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick, onBeforeUnmount, computed } from 'vue'
|
||||
import { computed, nextTick, onBeforeUnmount, reactive, ref, watch } from 'vue'
|
||||
import { BARI_BOUNDS, BARI_CENTER, isWithinBariBounds } from '~/utils/bari'
|
||||
|
||||
definePageMeta({
|
||||
@@ -24,8 +24,8 @@ const actionError = ref('')
|
||||
const deletingAreaId = ref<number | null>(null)
|
||||
const areaPendingDelete = ref<any | null>(null)
|
||||
|
||||
// Map variables
|
||||
let map: any = null
|
||||
let mainMap: any = null
|
||||
let polygon: any = null
|
||||
const mapPoints = ref<[number, number][]>([])
|
||||
|
||||
@@ -34,9 +34,98 @@ const submitLabel = computed(() => editingAreaId.value ? 'Salva Modifiche' : 'Cr
|
||||
const isEditing = computed(() => editingAreaId.value !== null)
|
||||
const areas = computed(() => areasRes.value?.areas || [])
|
||||
const areaDeleteMessage = computed(() =>
|
||||
areaPendingDelete.value ? `Vuoi eliminare area "${areaPendingDelete.value.name}"? Operazione irreversibile.` : ''
|
||||
areaPendingDelete.value ? `Vuoi eliminare area "${areaPendingDelete.value.name}"? Operazione irreversibile.` : ''
|
||||
)
|
||||
|
||||
const initMainMap = async () => {
|
||||
const mapElement = document.getElementById('mainMap')
|
||||
if (!mapElement) return
|
||||
|
||||
const L = (await import('leaflet')).default
|
||||
|
||||
if (mainMap) {
|
||||
mainMap.remove()
|
||||
mainMap = null
|
||||
}
|
||||
|
||||
const bariBounds = L.latLngBounds(
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
)
|
||||
|
||||
mainMap = L.map('mainMap', {
|
||||
maxBounds: bariBounds,
|
||||
maxBoundsViscosity: 1,
|
||||
minZoom: 11
|
||||
}).setView(BARI_CENTER, 12)
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: '© OpenStreetMap'
|
||||
}).addTo(mainMap)
|
||||
|
||||
const featureGroup = L.featureGroup().addTo(mainMap)
|
||||
let hasLayers = false
|
||||
|
||||
areas.value.forEach((area: any) => {
|
||||
if (area.boundary_geojson) {
|
||||
try {
|
||||
const layer = L.geoJSON(JSON.parse(area.boundary_geojson), {
|
||||
style: {
|
||||
color: '#0d6efd',
|
||||
weight: 2,
|
||||
fillOpacity: 0.2
|
||||
}
|
||||
}).bindPopup(`<strong>${area.name}</strong><br/>${area.description || ''}`)
|
||||
|
||||
layer.addTo(featureGroup)
|
||||
hasLayers = true
|
||||
} catch (e) {
|
||||
console.error('Invalid geojson for area', area.id, e)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (hasLayers) {
|
||||
mainMap.fitBounds(featureGroup.getBounds())
|
||||
} else {
|
||||
mainMap.fitBounds(bariBounds)
|
||||
}
|
||||
}
|
||||
|
||||
watch([areas, pending], () => {
|
||||
if (!pending.value) {
|
||||
if (areas.value.length > 0) {
|
||||
nextTick(() => {
|
||||
initMainMap()
|
||||
})
|
||||
} else if (mainMap) {
|
||||
mainMap.remove()
|
||||
mainMap = null
|
||||
}
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
const renderExistingAreasInModal = (L: any, currentMap: any) => {
|
||||
areas.value.forEach((area: any) => {
|
||||
if (area.id === editingAreaId.value) return
|
||||
|
||||
if (area.boundary_geojson) {
|
||||
try {
|
||||
L.geoJSON(JSON.parse(area.boundary_geojson), {
|
||||
style: {
|
||||
color: '#6c757d',
|
||||
weight: 2,
|
||||
dashArray: '5, 5',
|
||||
fillOpacity: 0.1
|
||||
},
|
||||
interactive: false
|
||||
}).addTo(currentMap)
|
||||
} catch(e) {}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const openCreateModal = () => {
|
||||
actionError.value = ''
|
||||
editingAreaId.value = null
|
||||
@@ -46,19 +135,18 @@ const openCreateModal = () => {
|
||||
jsonError.value = ''
|
||||
mapPoints.value = []
|
||||
isCreating.value = true
|
||||
|
||||
|
||||
nextTick(async () => {
|
||||
// Import leaflet solo client-side
|
||||
const L = (await import('leaflet')).default
|
||||
|
||||
|
||||
if (map) {
|
||||
map.remove()
|
||||
map = null
|
||||
}
|
||||
|
||||
const bariBounds = L.latLngBounds(
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
)
|
||||
|
||||
map = L.map('areaMap', {
|
||||
@@ -74,6 +162,8 @@ const openCreateModal = () => {
|
||||
polygon = L.polygon([], { color: 'red' }).addTo(map)
|
||||
map.fitBounds(bariBounds)
|
||||
|
||||
renderExistingAreasInModal(L, map)
|
||||
|
||||
map.on('click', (e: any) => {
|
||||
if (!isWithinBariBounds(e.latlng.lat, e.latlng.lng)) {
|
||||
jsonError.value = 'Puoi disegnare aree solo entro confini del Comune di Bari.'
|
||||
@@ -96,8 +186,8 @@ const loadPolygonFromGeoJson = (boundaryGeojson: any) => {
|
||||
}
|
||||
|
||||
const normalized = coordinates
|
||||
.slice(0, -1)
|
||||
.map(([longitude, latitude]: [number, number]) => [latitude, longitude] as [number, number])
|
||||
.slice(0, -1)
|
||||
.map(([longitude, latitude]: [number, number]) => [latitude, longitude] as [number, number])
|
||||
|
||||
mapPoints.value = normalized
|
||||
if (polygon) {
|
||||
@@ -110,7 +200,7 @@ const openEditModal = (area: any) => {
|
||||
editingAreaId.value = area.id
|
||||
formData.name = area.name || ''
|
||||
formData.description = area.description || ''
|
||||
formData.geojson = area.boundary_geojson ? JSON.stringify(area.boundary_geojson, null, 2) : ''
|
||||
formData.geojson = area.boundary_geojson || ''
|
||||
jsonError.value = ''
|
||||
mapPoints.value = []
|
||||
isCreating.value = true
|
||||
@@ -124,8 +214,8 @@ const openEditModal = (area: any) => {
|
||||
}
|
||||
|
||||
const bariBounds = L.latLngBounds(
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
)
|
||||
|
||||
map = L.map('areaMap', {
|
||||
@@ -137,9 +227,20 @@ const openEditModal = (area: any) => {
|
||||
maxZoom: 19,
|
||||
attribution: '© OpenStreetMap'
|
||||
}).addTo(map)
|
||||
console.log(JSON.parse(area.boundary_geojson))
|
||||
L.geoJSON(JSON.parse(area.boundary_geojson), {
|
||||
style: {
|
||||
color: '#0d6efd',
|
||||
weight: 2,
|
||||
fillOpacity: 0.2
|
||||
}
|
||||
}).addTo(map)
|
||||
|
||||
polygon = L.polygon([], { color: 'red' }).addTo(map)
|
||||
map.fitBounds(bariBounds)
|
||||
|
||||
renderExistingAreasInModal(L, map)
|
||||
|
||||
loadPolygonFromGeoJson(area.boundary_geojson)
|
||||
|
||||
map.on('click', (e: any) => {
|
||||
@@ -171,7 +272,7 @@ const updateGeojson = () => {
|
||||
}
|
||||
const coords = mapPoints.value.map(p => [p[1], p[0]] as [number, number]) // Lng, Lat
|
||||
if (coords[0]) {
|
||||
coords.push([...coords[0]]) // Chiudi poligono
|
||||
coords.push([...coords[0]])
|
||||
}
|
||||
|
||||
formData.geojson = JSON.stringify({
|
||||
@@ -191,12 +292,13 @@ const closeCreateModal = () => {
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (map) map.remove()
|
||||
if (mainMap) mainMap.remove()
|
||||
})
|
||||
|
||||
const handleCreate = async () => {
|
||||
jsonError.value = ''
|
||||
let parsedGeojson = null
|
||||
|
||||
|
||||
try {
|
||||
parsedGeojson = JSON.parse(formData.geojson)
|
||||
if (!parsedGeojson.type || !parsedGeojson.coordinates) {
|
||||
@@ -221,9 +323,9 @@ const handleCreate = async () => {
|
||||
}
|
||||
|
||||
const res = editingAreaId.value
|
||||
? await updateArea(editingAreaId.value, payload)
|
||||
: await createArea(payload)
|
||||
|
||||
? await updateArea(editingAreaId.value, payload)
|
||||
: await createArea(payload)
|
||||
|
||||
if (res.ok) {
|
||||
await refresh()
|
||||
closeCreateModal()
|
||||
@@ -291,13 +393,18 @@ const handleDeleteArea = async () => {
|
||||
Nessuna area configurata.
|
||||
</div>
|
||||
|
||||
<div v-if="actionError" class="alert alert-danger">
|
||||
{{ actionError }}
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="card mb-4 shadow-sm border-0">
|
||||
<div id="mainMap" class="rounded" style="height: 400px; width: 100%; z-index: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div v-else class="table-responsive">
|
||||
<table class="table table-hover align-middle bg-white shadow-sm rounded">
|
||||
<thead class="table-light">
|
||||
<div v-if="actionError" class="alert alert-danger">
|
||||
{{ actionError }}
|
||||
</div>
|
||||
|
||||
<div v-else class="table-responsive">
|
||||
<table class="table table-hover align-middle bg-white shadow-sm rounded">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome</th>
|
||||
@@ -305,8 +412,8 @@ const handleDeleteArea = async () => {
|
||||
<th>GeoJSON</th>
|
||||
<th class="text-end">Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="area in areas" :key="area.id">
|
||||
<td>{{ area.id }}</td>
|
||||
<td><strong>{{ area.name }}</strong></td>
|
||||
@@ -320,20 +427,20 @@ const handleDeleteArea = async () => {
|
||||
Modifica
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-outline-danger ms-2"
|
||||
:disabled="deletingAreaId === area.id"
|
||||
@click="askDeleteArea(area)"
|
||||
class="btn btn-sm btn-outline-danger ms-2"
|
||||
:disabled="deletingAreaId === area.id"
|
||||
@click="askDeleteArea(area)"
|
||||
>
|
||||
<span v-if="deletingAreaId === area.id" class="spinner-border spinner-border-sm me-1"></span>
|
||||
Elimina
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Modale Creazione -->
|
||||
<div v-if="isCreating" class="modal-backdrop fade show d-block" style="background: rgba(0,0,0,0.5); z-index: 1040;"></div>
|
||||
<div v-if="isCreating" class="modal fade show d-block" tabindex="-1" style="z-index: 1050;">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
|
||||
@@ -356,18 +463,18 @@ const handleDeleteArea = async () => {
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">GeoJSON Generato</label>
|
||||
<textarea
|
||||
class="form-control font-monospace text-sm"
|
||||
rows="6"
|
||||
v-model="formData.geojson"
|
||||
required
|
||||
readonly
|
||||
placeholder='{ "type": "Polygon", "coordinates": [...] }'
|
||||
<textarea
|
||||
class="form-control font-monospace text-sm"
|
||||
rows="6"
|
||||
v-model="formData.geojson"
|
||||
required
|
||||
readonly
|
||||
placeholder='{ "type": "Polygon", "coordinates": [...] }'
|
||||
></textarea>
|
||||
<div v-if="jsonError" class="form-text text-danger mt-1">{{ jsonError }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-7">
|
||||
<div class="mb-2 d-flex justify-content-between align-items-center">
|
||||
<label class="form-label mb-0">Disegna Poligono sulla Mappa</label>
|
||||
@@ -394,24 +501,24 @@ const handleDeleteArea = async () => {
|
||||
</div>
|
||||
|
||||
<ConfirmModal
|
||||
:open="areaPendingDelete !== null"
|
||||
title="Elimina area"
|
||||
:message="areaDeleteMessage"
|
||||
confirm-label="Elimina area"
|
||||
confirm-class="btn-danger"
|
||||
:pending="deletingAreaId !== null"
|
||||
@cancel="closeDeleteAreaModal"
|
||||
@confirm="handleDeleteArea"
|
||||
:open="areaPendingDelete !== null"
|
||||
title="Elimina area"
|
||||
:message="areaDeleteMessage"
|
||||
confirm-label="Elimina area"
|
||||
confirm-class="btn-danger"
|
||||
:pending="deletingAreaId !== null"
|
||||
@cancel="closeDeleteAreaModal"
|
||||
@confirm="handleDeleteArea"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
#areaMap {
|
||||
#areaMap, #mainMap {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.modal-dialog {
|
||||
margin-block: 0!important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -444,3 +444,10 @@ const handleDeleteTeam = async () => {
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.text-end .btn {
|
||||
margin: 0 !important;
|
||||
width: 120px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref } from 'vue'
|
||||
|
||||
definePageMeta({
|
||||
middleware: 'auth',
|
||||
@@ -28,9 +28,9 @@ const dismissModal = reactive({
|
||||
})
|
||||
|
||||
const { data: flagsRes, pending, refresh } = useAsyncData(
|
||||
'admin-moderation-flags',
|
||||
() => getModerationFlags({ page: page.value, per_page: perPage.value, status: statusFilter.value || undefined }),
|
||||
{ watch: [page, statusFilter] }
|
||||
'admin-moderation-flags',
|
||||
() => getModerationFlags({ page: page.value, per_page: perPage.value, status: statusFilter.value || undefined }),
|
||||
{ watch: [page, statusFilter] }
|
||||
)
|
||||
|
||||
const openResolveModal = (id: number, rejectReport: boolean) => {
|
||||
@@ -54,15 +54,14 @@ const handleResolve = async () => {
|
||||
actionError.value = ''
|
||||
|
||||
try {
|
||||
const res = await updateModerationFlag(resolveModal.flagId, {
|
||||
status: 'RESOLVED',
|
||||
await updateModerationFlag(resolveModal.flagId, {
|
||||
status: 'RESOLVED',
|
||||
reject_report: resolveModal.rejectReport,
|
||||
resolution_note: resolveModal.note || undefined
|
||||
})
|
||||
if (res.ok) {
|
||||
await refresh()
|
||||
closeResolveModal()
|
||||
}
|
||||
|
||||
await refresh()
|
||||
closeResolveModal()
|
||||
} catch (err) {
|
||||
console.error('Failed to resolve flag', err)
|
||||
actionError.value = 'Errore durante la risoluzione della segnalazione.'
|
||||
@@ -89,11 +88,10 @@ const handleDismiss = async () => {
|
||||
actionError.value = ''
|
||||
|
||||
try {
|
||||
const res = await updateModerationFlag(dismissModal.flagId, { status: 'DISMISSED' })
|
||||
if (res.ok) {
|
||||
await refresh()
|
||||
closeDismissModal()
|
||||
}
|
||||
await updateModerationFlag(dismissModal.flagId, { status: 'DISMISSED' })
|
||||
|
||||
await refresh()
|
||||
closeDismissModal()
|
||||
} catch (err) {
|
||||
console.error('Failed to dismiss flag', err)
|
||||
actionError.value = 'Errore durante l\'aggiornamento.'
|
||||
@@ -103,7 +101,7 @@ const handleDismiss = async () => {
|
||||
}
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
return new Date(dateStr).toLocaleString('it-IT', {
|
||||
return new Date(dateStr).toLocaleString('it-IT', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
})
|
||||
@@ -129,23 +127,28 @@ const formatDate = (dateStr: string) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="actionError" class="alert alert-danger mb-4">
|
||||
{{ actionError }}
|
||||
</div>
|
||||
|
||||
<div v-if="pending" class="text-center py-5">
|
||||
<div class="spinner-border text-danger" role="status"></div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!flagsRes?.flags || flagsRes.flags.length === 0" class="alert alert-success">
|
||||
<div v-else-if="!flagsRes || !flagsRes.flags || flagsRes.flags.length === 0" class="alert alert-success">
|
||||
Nessun elemento da moderare al momento.
|
||||
</div>
|
||||
|
||||
<div v-if="actionError" class="alert alert-danger">
|
||||
{{ actionError }}
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div class="card mb-3 shadow-sm border-0" v-for="flag in flagsRes.flags" :key="flag.id">
|
||||
<div class="card-header bg-light d-flex justify-content-between align-items-center">
|
||||
<div
|
||||
class="card mb-3 border-0"
|
||||
:class="flag.status === 'DISMISSED' ? 'dismissed-card shadow-none' : 'shadow-sm'"
|
||||
v-for="flag in flagsRes.flags"
|
||||
:key="flag.id"
|
||||
>
|
||||
<div class="card-header d-flex justify-content-between align-items-center" :class="flag.status === 'DISMISSED' ? 'bg-transparent' : 'bg-light'">
|
||||
<div>
|
||||
<strong>Flag #{{ flag.id }}</strong> -
|
||||
<strong>Flag #{{ flag.id }}</strong> -
|
||||
<span class="badge" :class="{
|
||||
'bg-warning': flag.status === 'OPEN',
|
||||
'bg-success': flag.status === 'RESOLVED',
|
||||
@@ -161,8 +164,8 @@ const formatDate = (dateStr: string) => {
|
||||
<p class="card-text text-muted mb-2">
|
||||
{{ flag.details || 'Nessun dettaglio aggiuntivo fornito.' }}
|
||||
</p>
|
||||
|
||||
<div class="mt-3">
|
||||
|
||||
<div class="mt-info">
|
||||
<span class="badge bg-info me-2">{{ flag.content_type }}</span>
|
||||
<span v-if="flag.report_id">
|
||||
Rif:
|
||||
@@ -174,17 +177,17 @@ const formatDate = (dateStr: string) => {
|
||||
| Messaggio #{{ flag.message_id }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 small">
|
||||
|
||||
<div class="mt-info small text-muted">
|
||||
Segnalato da: {{ flag.created_by_email }} (ID: {{ flag.created_by_user_id }})
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="flag.status !== 'OPEN'" class="mt-2 small text-muted border-top pt-2">
|
||||
<strong>Risolto/Ignorato da:</strong> {{ flag.resolved_by_email }} in data {{ flag.resolved_at ? formatDate(flag.resolved_at) : 'N/D' }}
|
||||
<div v-if="flag.resolution_note"><strong>Nota:</strong> {{ flag.resolution_note }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4 text-end" v-if="flag.status === 'OPEN'">
|
||||
<div class="d-flex flex-column gap-2 mt-3 mt-md-0">
|
||||
<button class="btn btn-outline-danger btn-sm" @click="openResolveModal(flag.id, true)">
|
||||
@@ -202,12 +205,12 @@ const formatDate = (dateStr: string) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Pagination
|
||||
v-if="(flagsRes.total || flagsRes.flags.length) > perPage"
|
||||
:current-page="page"
|
||||
:per-page="perPage"
|
||||
:total-items="flagsRes.total || (page * perPage + 1)"
|
||||
@page-change="page = $event"
|
||||
<Pagination
|
||||
v-if="(flagsRes.total || flagsRes.flags.length) > perPage"
|
||||
:current-page="page"
|
||||
:per-page="perPage"
|
||||
:total-items="flagsRes.total || (page * perPage + 1)"
|
||||
@page-change="page = $event"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -235,14 +238,46 @@ const formatDate = (dateStr: string) => {
|
||||
</div>
|
||||
|
||||
<ConfirmModal
|
||||
:open="dismissModal.open"
|
||||
title="Ignora flag"
|
||||
message="Vuoi ignorare questo flag? Azione registrata in moderazione."
|
||||
confirm-label="Ignora flag"
|
||||
confirm-class="btn-outline-secondary"
|
||||
:pending="dismissModal.pending"
|
||||
@cancel="closeDismissModal"
|
||||
@confirm="handleDismiss"
|
||||
:open="dismissModal.open"
|
||||
title="Ignora flag"
|
||||
message="Vuoi ignorare questo flag? Azione registrata in moderazione."
|
||||
confirm-label="Ignora flag"
|
||||
confirm-class="btn-outline-secondary"
|
||||
:pending="dismissModal.pending"
|
||||
@cancel="closeDismissModal"
|
||||
@confirm="handleDismiss"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dismissed-card {
|
||||
background-color: #f8f9fa;
|
||||
opacity: 0.7;
|
||||
border: 1px solid #e9ecef !important;
|
||||
}
|
||||
|
||||
.dismissed-card .card-header {
|
||||
padding-top: 0.35rem;
|
||||
padding-bottom: 0.35rem;
|
||||
border-bottom: 1px solid rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.dismissed-card .card-body {
|
||||
padding-top: 0.6rem;
|
||||
padding-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.dismissed-card h5.card-title {
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.mt-info {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.dismissed-card .mt-info {
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
@@ -17,7 +17,7 @@ const banError = ref('')
|
||||
const roleError = ref('')
|
||||
const pendingBanUser = ref<any | null>(null)
|
||||
const isUpdatingBan = ref(false)
|
||||
const parseRoles = (roles?: string) => roles ? roles.split(',').map((r) => r.trim().toUpperCase()).filter(Boolean) : []
|
||||
const parseRoles = (roles?: string) => roles ? roles.split(',').map(normalizeRole).filter(Boolean) : []
|
||||
const banConfirmMessage = computed(() =>
|
||||
pendingBanUser.value
|
||||
? `Vuoi ${pendingBanUser.value.banned ? 'sbloccare' : 'bannare'} utente ${pendingBanUser.value.first_name} ${pendingBanUser.value.last_name}?`
|
||||
@@ -68,7 +68,6 @@ const handleToggleBan = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Modal per i ruoli
|
||||
const editingUserId = ref<number | null>(null)
|
||||
const selectedRoles = ref<string[]>([])
|
||||
const availableRoles = ['CITIZEN', 'OPERATOR', 'ADMIN']
|
||||
|
||||
@@ -10,7 +10,6 @@ useHead({ title: 'Accedi - Visione' })
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const { requestOtp, verifyOtp, handleLoginSuccess, startCieLogin } = useAuth()
|
||||
|
||||
// UI State
|
||||
const otpStep = ref<1 | 2>(1)
|
||||
const isLoading = ref(false)
|
||||
const isCieLoading = ref(false)
|
||||
|
||||
@@ -97,7 +97,6 @@ const handleRegister = async () => {
|
||||
|
||||
<h2 class="h5 text-primary font-weight-bold mb-4 border-bottom pb-2">Dati Anagrafici</h2>
|
||||
|
||||
<!-- FIX LAYOUT: form-group separato da col -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 col-md-6 mb-4 mb-md-0">
|
||||
<div class="form-group">
|
||||
@@ -136,7 +135,6 @@ const handleRegister = async () => {
|
||||
<small class="form-text text-muted">Faciliterà il contatto da parte degli operatori comunali in caso di intervento.</small>
|
||||
</div>
|
||||
|
||||
<!-- Privacy Checkbox -->
|
||||
<div class="form-check mb-4">
|
||||
<input class="form-check-input" type="checkbox" id="privacyCheck" v-model="form.privacy" required>
|
||||
<label class="form-check-label small" for="privacyCheck">
|
||||
|
||||
@@ -10,24 +10,21 @@ import OperatorDashboard from '~/components/dashboard/OperatorDashboard.vue'
|
||||
import AdminDashboard from '~/components/dashboard/AdminDashboard.vue'
|
||||
|
||||
const currentDashboard = computed(() => {
|
||||
const role = user.value?.role?.toUpperCase()
|
||||
if (role === 'CITIZEN') return CitizenDashboard
|
||||
if (role === 'OPERATOR') return OperatorDashboard
|
||||
if (role === 'ADMIN') return AdminDashboard
|
||||
if (isCitizen(user.value?.role)) return CitizenDashboard
|
||||
if (isOperator(user.value?.role)) return OperatorDashboard
|
||||
if (isAdmin(user.value?.role)) return AdminDashboard
|
||||
return null
|
||||
})
|
||||
|
||||
const heroTitle = computed(() => {
|
||||
const role = user.value?.role?.toUpperCase()
|
||||
if (role === 'ADMIN') return 'Pannello Admin'
|
||||
if (role === 'OPERATOR') return 'Gestione Operativa'
|
||||
if (isAdmin(user.value?.role)) return 'Pannello Admin'
|
||||
if (isOperator(user.value?.role)) return 'Gestione Operativa'
|
||||
return 'Dashboard'
|
||||
})
|
||||
|
||||
const heroSubtitle = computed(() => {
|
||||
const role = user.value?.role?.toUpperCase()
|
||||
if (role === 'ADMIN') return 'Accesso amministrativo per configurazioni, utenti e moderazione'
|
||||
if (role === 'OPERATOR') return 'Prendi in carico e gestisci le segnalazioni in corso'
|
||||
if (isAdmin(user.value?.role)) return 'Accesso amministrativo per configurazioni, utenti e moderazione'
|
||||
if (isOperator(user.value?.role)) return 'Prendi in carico e gestisci le segnalazioni in corso'
|
||||
return 'Riepilogo rapido delle tue segnalazioni e dei punti cittadino'
|
||||
})
|
||||
</script>
|
||||
|
||||
+38
-31
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
// La pagina è statica, usiamo solo i componenti UI
|
||||
useHead({
|
||||
title: 'Informazioni sul Progetto - Visione',
|
||||
})
|
||||
@@ -7,7 +6,6 @@ useHead({
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- HERO SECTION (Senza pt-5/mt-5 come richiesto) -->
|
||||
<div class="it-hero-wrapper it-primary">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -24,72 +22,79 @@ useHead({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- OBIETTIVO DEL PROGETTO -->
|
||||
<div class="container my-5 py-3">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-8 offset-lg-2">
|
||||
<h2 class="mb-4 font-weight-bold">Migliorare la qualità della vita in città</h2>
|
||||
<p class="lead text-muted">
|
||||
Visione nasce dall'esigenza di fornire alle amministrazioni comunali uno strumento moderno per mappare, gestire e risolvere disservizi presenti sul territorio (buche stradali, illuminazione guasta, rifiuti abbandonati).
|
||||
Visione nasce dall'esigenza di fornire alle amministrazioni comunali uno strumento moderno per mappare,
|
||||
gestire e risolvere disservizi presenti sul territorio (buche stradali, illuminazione guasta, rifiuti
|
||||
abbandonati).
|
||||
</p>
|
||||
<p>
|
||||
Il sistema non si limita a raccogliere dati, ma automatizza l'assegnazione alle squadre operative competenti tramite logiche geospaziali, traccia l'intero ciclo di vita della segnalazione e restituisce trasparenza ai cittadini tramite un portale Open Data dedicato.
|
||||
Il sistema non si limita a raccogliere dati, ma automatizza l'assegnazione alle squadre operative competenti
|
||||
tramite logiche geospaziali, traccia l'intero ciclo di vita della segnalazione e restituisce trasparenza ai
|
||||
cittadini tramite un portale Open Data dedicato.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- RUOLI E FUNZIONALITÀ (Card Grid) -->
|
||||
<div class="bg-light py-5">
|
||||
<div class="container">
|
||||
<h2 class="text-center mb-5 font-weight-bold">Come funziona il sistema</h2>
|
||||
<div class="row">
|
||||
|
||||
<!-- Cittadino -->
|
||||
<div class="col-12 col-md-4 mb-4">
|
||||
<div class="card-wrapper card-space h-100">
|
||||
<div class="card card-bg h-100">
|
||||
<div class="card-body">
|
||||
<BIIcon name="it-user" size="xl" color="primary" class="mb-3" />
|
||||
<BIIcon class="mb-3" color="primary" name="it-user" size="xl"/>
|
||||
<h3 class="card-title h5 font-weight-bold">Cittadini</h3>
|
||||
<p class="card-text text-muted">
|
||||
Tramite autenticazione sicura (OTP via email o CIE), i cittadini possono inviare segnalazioni geolocalizzate complete di foto.
|
||||
Tramite autenticazione sicura (OTP via email o CIE), i cittadini possono inviare segnalazioni
|
||||
geolocalizzate complete di foto.
|
||||
<br><br>
|
||||
Per incentivare la partecipazione, è integrato un sistema di <strong>gamification</strong>: ogni segnalazione valida e risolta fa guadagnare Punti Cittadino, premiando la cittadinanza attiva. Possono inoltre chattare con gli operatori e lasciare un feedback finale.
|
||||
Per incentivare la partecipazione, è integrato un sistema di <strong>gamification</strong>: ogni
|
||||
segnalazione valida e risolta fa guadagnare Punti Cittadino, premiando la cittadinanza attiva.
|
||||
Possono inoltre chattare con gli operatori e lasciare un feedback finale.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Operatore -->
|
||||
<div class="col-12 col-md-4 mb-4">
|
||||
<div class="card-wrapper card-space h-100">
|
||||
<div class="card card-bg h-100">
|
||||
<div class="card-body">
|
||||
<BIIcon name="it-tool" size="xl" color="primary" class="mb-3" />
|
||||
<BIIcon class="mb-3" color="primary" name="it-tool" size="xl"/>
|
||||
<h3 class="card-title h5 font-weight-bold">Operatori e Squadre</h3>
|
||||
<p class="card-text text-muted">
|
||||
Il personale comunale visualizza una dashboard con le segnalazioni in ingresso. Possono prenderle in carico, comunicare con l'utente e assegnarle alle squadre di intervento sul territorio.
|
||||
Il personale comunale visualizza una dashboard con le segnalazioni in ingresso. Possono prenderle in
|
||||
carico, comunicare con l'utente e assegnarle alle squadre di intervento sul territorio.
|
||||
<br><br>
|
||||
Il sistema gestisce l'intero flusso di stato: da <em>Aperta</em> a <em>In Revisione</em>, fino a <em>In Lavorazione</em> e <em>Risolta</em>.
|
||||
Il sistema gestisce l'intero flusso di stato: da <em>Aperta</em> a <em>In Revisione</em>, fino a
|
||||
<em>In Lavorazione</em> e <em>Risolta</em>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Amministratore -->
|
||||
<div class="col-12 col-md-4 mb-4">
|
||||
<div class="card-wrapper card-space h-100">
|
||||
<div class="card card-bg h-100">
|
||||
<div class="card-body">
|
||||
<BIIcon name="it-settings" size="xl" color="primary" class="mb-3" />
|
||||
<BIIcon class="mb-3" color="primary" name="it-settings" size="xl"/>
|
||||
<h3 class="card-title h5 font-weight-bold">Amministrazione</h3>
|
||||
<p class="card-text text-muted">
|
||||
Gli amministratori hanno il controllo completo della piattaforma. Possono definire le aree urbane tramite poligoni GeoJSON, gestire i permessi degli utenti, supervisionare i feedback e moderare eventuali abusi.
|
||||
Gli amministratori hanno il controllo completo della piattaforma. Possono definire le aree urbane
|
||||
tramite poligoni GeoJSON, gestire i permessi degli utenti, supervisionare i feedback e moderare
|
||||
eventuali abusi.
|
||||
<br><br>
|
||||
Hanno inoltre accesso a statistiche avanzate per individuare le criticità sul territorio e monitorare i tempi medi di risoluzione.
|
||||
Hanno inoltre accesso a statistiche avanzate per individuare le criticità sul territorio e
|
||||
monitorare i tempi medi di risoluzione.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -100,44 +105,46 @@ useHead({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- STACK TECNOLOGICO E FILOSOFIA -->
|
||||
<div class="container my-5 py-4">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-12 col-lg-6 mb-4 mb-lg-0">
|
||||
<h2 class="font-weight-bold mb-4">Tecnologia e Indipendenza</h2>
|
||||
<ul class="it-list">
|
||||
<li>
|
||||
<BIIcon name="it-code-circle" color="primary" class="me-2" />
|
||||
<strong>Architettura:</strong> Frontend reattivo e multipiattaforma sviluppato in <em>Vue.js/Nuxt 3</em>. Backend ad altissime prestazioni scritto in <em>C++</em> utilizzando il framework <em>Drogon</em>.
|
||||
<BIIcon class="me-2" color="primary" name="it-code-circle"/>
|
||||
<strong>Architettura:</strong> Frontend reattivo e multipiattaforma sviluppato in <em>Vue.js/Nuxt 3</em>.
|
||||
Backend ad altissime prestazioni scritto in <em>C++</em> utilizzando il framework <em>Drogon</em>.
|
||||
</li>
|
||||
<li class="mt-3">
|
||||
<BIIcon name="it-lock" color="primary" class="me-2" />
|
||||
<BIIcon class="me-2" color="primary" name="it-lock"/>
|
||||
<strong>Sicurezza:</strong> Accesso con OTP e sistema di autorizzazione Role-Based basato su token JWT.
|
||||
</li>
|
||||
<li class="mt-3">
|
||||
<BIIcon name="it-piu" color="primary" class="me-2" />
|
||||
<strong>Open Data:</strong> Piena aderenza alle linee guida AGID sulla trasparenza, con esportazione di dati anonimizzati accessibili al pubblico.
|
||||
<BIIcon class="me-2" color="primary" name="it-piu"/>
|
||||
<strong>Open Data:</strong> Piena aderenza alle linee guida AGID sulla trasparenza, con esportazione di
|
||||
dati anonimizzati accessibili al pubblico.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-lg-5 offset-lg-1">
|
||||
<!-- Callout Ribellione Gitea -->
|
||||
<div class="callout callout-highlight callout-warning">
|
||||
<div class="callout-title">
|
||||
<BIIcon name="it-warning-circle" />
|
||||
<BIIcon name="it-warning-circle"/>
|
||||
Un approccio etico al codice sorgente
|
||||
</div>
|
||||
<p>
|
||||
In risposta alle policy sempre più aggressive delle grandi piattaforme commerciali riguardo l'addestramento non consensuale di modelli di Intelligenza Artificiale sui repository privati, lo sviluppo di questo progetto è ospitato su un'istanza <strong>self-hosted di Gitea</strong>.
|
||||
In risposta alle policy sempre più aggressive delle grandi piattaforme commerciali riguardo
|
||||
l'addestramento non consensuale di modelli di Intelligenza Artificiale sui repository privati, lo sviluppo
|
||||
di questo progetto è ospitato su un'istanza <strong>self-hosted di Gitea</strong>.
|
||||
<br><br>
|
||||
Una scelta di principio per garantire il controllo totale, la privacy e la vera sovranità sui dati e sul codice.
|
||||
Una scelta di principio per garantire il controllo totale, la privacy e la vera sovranità sui dati e sul
|
||||
codice.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CREDITI ACCADEMICI (Footer Style Callout) -->
|
||||
<div class="container mb-5 pb-5">
|
||||
<div class="card-wrapper card-space">
|
||||
<div class="card card-bg border-start border-primary border-5">
|
||||
@@ -146,7 +153,8 @@ useHead({
|
||||
<div class="col-12 col-md-8">
|
||||
<h4 class="h5 font-weight-bold text-primary mb-2">Crediti Accademici</h4>
|
||||
<p class="mb-1">
|
||||
Questo progetto è stato realizzato nell'ambito del corso di <strong>Laboratorio di Programmazione</strong> (tenuto dal Prof. Vessio).
|
||||
Questo progetto è stato realizzato nell'ambito del corso di <strong>Laboratorio di
|
||||
Programmazione</strong> (tenuto dal Prof. Vessio).
|
||||
</p>
|
||||
<p class="text-muted small mb-0">
|
||||
Università degli Studi di Bari "Aldo Moro" - Dipartimento di Informatica.
|
||||
@@ -170,7 +178,6 @@ useHead({
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Leggere correzioni stilistiche per le liste */
|
||||
.it-list {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
|
||||
@@ -6,7 +6,6 @@ useHead({
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- HERO SECTION -->
|
||||
<div class="it-hero-wrapper it-primary">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -22,7 +21,6 @@ useHead({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENUTO PRINCIPALE -->
|
||||
<div class="container my-5 py-4">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-8 offset-lg-2">
|
||||
@@ -53,7 +51,6 @@ useHead({
|
||||
Gli operatori e gli amministratori di sistema si riservano il diritto di moderare, nascondere o rimuovere segnalazioni contenenti materiale inappropriato, offensivo, non pertinente o illegale. L'abuso ripetuto del sistema comporterà il ban permanente dell'account dell'utente, associato al proprio Codice Fiscale.
|
||||
</p>
|
||||
|
||||
<!-- DISCLAIMER ACCADEMICO -->
|
||||
<div class="callout callout-highlight callout-info mt-5">
|
||||
<div class="callout-title">
|
||||
<BIIcon name="it-info-circle" />
|
||||
|
||||
@@ -92,7 +92,6 @@ const getNotificationColor = (type: string): string => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- HERO -->
|
||||
<div class="bg-light border-bottom py-4 mb-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -109,18 +108,15 @@ const getNotificationColor = (type: string): string => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENUTO -->
|
||||
<div class="container mb-5">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-10 offset-lg-1">
|
||||
|
||||
<!-- FILTRI (Opzionale) -->
|
||||
<div class="d-flex gap-2 mb-4">
|
||||
<button class="btn btn-sm btn-outline-primary active">Tutti</button>
|
||||
<button class="btn btn-sm btn-outline-secondary">Solo non letti</button>
|
||||
</div>
|
||||
|
||||
<!-- LISTA NOTIFICHE -->
|
||||
<div v-if="notifications.length === 0" class="text-center py-5">
|
||||
<BIIcon name="it-bell" size="xl" color="info" class="mb-3 d-block" />
|
||||
<h6 class="text-muted">Nessuna notifica</h6>
|
||||
@@ -140,14 +136,12 @@ const getNotificationColor = (type: string): string => {
|
||||
@click="handleNotificationClick(notification)"
|
||||
>
|
||||
<div class="d-flex align-items-start gap-3">
|
||||
<!-- ICONA -->
|
||||
<div class="flex-shrink-0 mt-1">
|
||||
<div class="rounded-circle p-2" :class="`bg-${getNotificationColor(notification.type)}`" style="width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;">
|
||||
<BIIcon :name="getNotificationIcon(notification.type)" size="sm" color="white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENUTO -->
|
||||
<div class="flex-grow-1">
|
||||
<div class="d-flex align-items-start justify-content-between">
|
||||
<div>
|
||||
@@ -162,13 +156,11 @@ const getNotificationColor = (type: string): string => {
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- INDICATORE NON LETTO -->
|
||||
<div v-if="!notification.read_at" class="flex-shrink-0">
|
||||
<span class="badge bg-primary rounded-pill">Nuovo</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- AZIONI RAPIDE -->
|
||||
<div v-if="notification.report_id" class="mt-2 d-flex gap-2">
|
||||
<NuxtLink :to="`/reports/${notification.report_id}`" class="btn btn-sm btn-outline-primary">
|
||||
<BIIcon name="it-arrow-right" size="xs" class="me-1" />
|
||||
@@ -188,7 +180,6 @@ const getNotificationColor = (type: string): string => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- PAGINATION -->
|
||||
<Pagination
|
||||
v-if="notifications.length > 0"
|
||||
:current-page="page"
|
||||
|
||||
+35
-40
@@ -1,26 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import type { Map as LeafletMap, CircleMarker, LatLngBoundsExpression } from 'leaflet'
|
||||
import type { CircleMarker, LatLngBoundsExpression, Map as LeafletMap } from 'leaflet'
|
||||
import { BARI_BOUNDS, BARI_CENTER, isWithinBariBounds } from '~/utils/bari'
|
||||
|
||||
const { getOpenDataReports } = usePublic()
|
||||
|
||||
// Reactive pagination state
|
||||
const currentPage = ref(1)
|
||||
const perPage = ref(9)
|
||||
|
||||
// Fetch data automatically when currentPage changes
|
||||
const { data: openDataResponse, pending } = await useAsyncData(
|
||||
'open-data-reports',
|
||||
() => getOpenDataReports({ page: currentPage.value, per_page: perPage.value }),
|
||||
{ watch: [currentPage] } // Nuxt will re-fetch when currentPage changes
|
||||
{ watch: [currentPage] }
|
||||
)
|
||||
|
||||
const visibleReports = computed(() =>
|
||||
(openDataResponse.value?.reports || []).filter((report) => isWithinBariBounds(report.latitude, report.longitude))
|
||||
(openDataResponse.value?.reports || []).filter((report) => isWithinBariBounds(report.latitude, report.longitude))
|
||||
)
|
||||
|
||||
// Pagination logic: If we receive less items than `perPage`, we are on the last page.
|
||||
const isLastPage = computed(() => {
|
||||
if (!openDataResponse.value?.reports) return true
|
||||
return openDataResponse.value.reports.length < perPage.value
|
||||
@@ -41,9 +37,12 @@ let markers: CircleMarker[] = []
|
||||
|
||||
const getStatusBadge = (status: string) => {
|
||||
switch (status) {
|
||||
case 'RESOLVED': return { class: 'bg-success', text: 'Risolto', icon: 'it-check-circle' }
|
||||
case 'CLOSED': return { class: 'bg-secondary', text: 'Chiuso', icon: 'it-lock' }
|
||||
default: return { class: 'bg-info', text: status, icon: 'it-info-circle' }
|
||||
case 'RESOLVED':
|
||||
return { class: 'bg-success', text: 'Risolto', icon: 'it-check-circle' }
|
||||
case 'CLOSED':
|
||||
return { class: 'bg-secondary', text: 'Chiuso', icon: 'it-lock' }
|
||||
default:
|
||||
return { class: 'bg-info', text: status, icon: 'it-info-circle' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +102,8 @@ const initMap = async () => {
|
||||
|
||||
const L = await loadLeaflet()
|
||||
const bariBounds = L.latLngBounds(
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
[BARI_BOUNDS.south, BARI_BOUNDS.west],
|
||||
[BARI_BOUNDS.north, BARI_BOUNDS.east]
|
||||
)
|
||||
|
||||
map = L.map(mapContainer.value, {
|
||||
@@ -123,9 +122,13 @@ const initMap = async () => {
|
||||
watch(currentView, async (view) => {
|
||||
if (view !== 'map') return
|
||||
await nextTick()
|
||||
await initMap()
|
||||
map?.invalidateSize()
|
||||
await renderMapMarkers()
|
||||
// Inizializza la mappa se non esiste, altrimenti aggiornane solo dimensioni e dati
|
||||
if (!map) {
|
||||
await initMap()
|
||||
} else {
|
||||
map.invalidateSize()
|
||||
await renderMapMarkers()
|
||||
}
|
||||
})
|
||||
|
||||
watch(visibleReports, async () => {
|
||||
@@ -143,7 +146,6 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- HERO SECTION (Small version for internal pages) -->
|
||||
<div class="it-hero-wrapper it-primary">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -159,19 +161,15 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MAIN CONTENT -->
|
||||
<div class="container my-5">
|
||||
|
||||
<!-- TOOLBAR: View Toggles & Export -->
|
||||
<div class="row align-items-center mb-5 pb-3 border-bottom">
|
||||
<div class="col-12 col-md-6 mb-3 mb-md-0 d-flex gap-2">
|
||||
<!-- View Toggle Buttons -->
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
:class="currentView === 'grid' ? 'btn-primary' : 'btn-outline-primary'"
|
||||
@click="currentView = 'grid'"
|
||||
>
|
||||
<BIIcon name="it-grid" size="sm" class="me-1" :color="currentView === 'grid' ? 'white' : 'primary'" />
|
||||
<BIIcon :color="currentView === 'grid' ? 'white' : 'primary'" class="me-1" name="it-grid" size="sm"/>
|
||||
Griglia Dati
|
||||
</button>
|
||||
<button
|
||||
@@ -179,39 +177,37 @@ onBeforeUnmount(() => {
|
||||
:class="currentView === 'map' ? 'btn-primary' : 'btn-outline-primary'"
|
||||
@click="currentView = 'map'"
|
||||
>
|
||||
<BIIcon name="it-map-marker" size="sm" class="me-1" :color="currentView === 'map' ? 'white' : 'primary'" />
|
||||
<BIIcon :color="currentView === 'map' ? 'white' : 'primary'" class="me-1" name="it-map-marker" size="sm"/>
|
||||
Mappa
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 text-md-end">
|
||||
<!-- Fake Export CTA (Very common in Open Data portals) -->
|
||||
<button class="btn btn-sm btn-outline-secondary" title="Scarica dataset in formato JSON">
|
||||
<BIIcon name="it-download" size="sm" class="me-1" />
|
||||
<BIIcon class="me-1" name="it-download" size="sm"/>
|
||||
Scarica JSON
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LOADER -->
|
||||
<!-- Sostituito v-else-if con v-show -->
|
||||
<div v-if="pending" class="d-flex justify-content-center my-5 py-5">
|
||||
<div class="progress-spinner progress-spinner-active" role="status">
|
||||
<span class="visually-hidden">Caricamento in corso...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- GRID VIEW -->
|
||||
<div v-else-if="currentView === 'grid'">
|
||||
<div v-show="!pending && currentView === 'grid'">
|
||||
<div class="row" v-if="openDataResponse?.reports && openDataResponse.reports.length > 0">
|
||||
<div class="col-12 col-md-6 col-lg-4 mb-4" v-for="report in visibleReports" :key="report.id">
|
||||
<!-- Strict BI Card -->
|
||||
<div class="card-wrapper card-space h-100">
|
||||
<div class="card card-bg h-100 shadow-sm">
|
||||
<div class="card-body d-flex flex-column">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div class="category-top m-0">
|
||||
<span class="badge rounded-pill text-white px-3 py-1" :class="getStatusBadge(report.status).class">
|
||||
<BIIcon :name="getStatusBadge(report.status).icon" size="xs" color="white" class="me-1" />
|
||||
<span :class="getStatusBadge(report.status).class"
|
||||
class="badge rounded-pill text-white px-3 py-1">
|
||||
<BIIcon :name="getStatusBadge(report.status).icon" class="me-1" color="white" size="xs"/>
|
||||
{{ getStatusBadge(report.status).text }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -221,7 +217,7 @@ onBeforeUnmount(() => {
|
||||
<h3 class="card-title h5 font-weight-bold">{{ report.category_name }}</h3>
|
||||
|
||||
<p class="card-text text-muted mb-4">
|
||||
<BIIcon name="it-map-marker-circle" size="sm" class="me-1" />
|
||||
<BIIcon class="me-1" name="it-map-marker-circle" size="sm"/>
|
||||
{{ report.area_name || 'Area comunale non specificata' }}
|
||||
</p>
|
||||
|
||||
@@ -248,12 +244,11 @@ onBeforeUnmount(() => {
|
||||
Nessun dato pubblico disponibile al momento.
|
||||
</div>
|
||||
|
||||
<!-- BOOTSTRAP ITALIA PAGINATION -->
|
||||
<nav class="pagination-wrapper justify-content-center mt-5" aria-label="Navigazione pagine open data">
|
||||
<ul class="pagination">
|
||||
<li class="page-item" :class="{ disabled: currentPage === 1 }">
|
||||
<a class="page-link" href="#" tabindex="-1" aria-disabled="true" @click.prevent="prevPage">
|
||||
<BIIcon name="it-chevron-left" size="sm" />
|
||||
<BIIcon name="it-chevron-left" size="sm"/>
|
||||
<span class="visually-hidden">Pagina precedente</span>
|
||||
</a>
|
||||
</li>
|
||||
@@ -263,15 +258,14 @@ onBeforeUnmount(() => {
|
||||
<li class="page-item" :class="{ disabled: isLastPage }">
|
||||
<a class="page-link" href="#" @click.prevent="nextPage">
|
||||
<span class="visually-hidden">Pagina successiva</span>
|
||||
<BIIcon name="it-chevron-right" size="sm" />
|
||||
<BIIcon name="it-chevron-right" size="sm"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- MAP VIEW -->
|
||||
<div v-else-if="currentView === 'map'" class="map-view-wrapper">
|
||||
<div v-show="!pending && currentView === 'map'" class="map-view-wrapper">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
|
||||
<p class="text-muted mb-0">Mappa pubblica delle segnalazioni nell'area di Bari.</p>
|
||||
<span class="badge bg-light text-dark border">{{ visibleReports.length }} punti</span>
|
||||
@@ -286,17 +280,18 @@ onBeforeUnmount(() => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Ensures the cards inside the grid stretch to equal heights */
|
||||
.card-wrapper {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.card-bg {
|
||||
border: 1px solid rgba(0,0,0,0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.card-bg:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
|
||||
}
|
||||
|
||||
.open-data-map {
|
||||
@@ -312,4 +307,4 @@ onBeforeUnmount(() => {
|
||||
line-height: 1.4;
|
||||
min-width: 12rem;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -20,7 +20,6 @@ const { getReportDetail, getMessages, addMessage, flagMessage } = useReports()
|
||||
const { getInterventionSummary, updateReportStatus, assignTeam, getTeams, createInterventionLink, revokeInterventionLink } = useOperator()
|
||||
const { user } = useAuth()
|
||||
|
||||
// Dati principali
|
||||
const { data: reportData, refresh: refreshReport } = await useAsyncData(`op-report-${reportId}`, () => getReportDetail(reportId))
|
||||
const { data: messagesData, refresh: refreshMessages } = await useAsyncData(`op-messages-${reportId}`, () => getMessages(reportId))
|
||||
const { data: summaryData, refresh: refreshSummary } = await useAsyncData(`op-summary-${reportId}`, () => getInterventionSummary(reportId))
|
||||
@@ -81,7 +80,6 @@ const newStatus = ref<ReportStatus>('IN_PROGRESS')
|
||||
const statusNote = ref('')
|
||||
const isUpdatingStatus = ref(false)
|
||||
|
||||
// Form Assegna Squadra
|
||||
const isAssignModalOpen = ref(false)
|
||||
const selectedTeamId = ref<number | null>(null)
|
||||
const isAssigning = ref(false)
|
||||
@@ -93,7 +91,6 @@ const interventionLinkError = ref('')
|
||||
const interventionLinkSuccess = ref('')
|
||||
const isRevokeInterventionModalOpen = ref(false)
|
||||
|
||||
// Messaggi
|
||||
const isSubmittingMessage = ref(false)
|
||||
const flaggedMessageIds = ref<number[]>([])
|
||||
const isFlagMessageModalOpen = ref(false)
|
||||
@@ -129,7 +126,9 @@ const handleStatusUpdate = async () => {
|
||||
}
|
||||
|
||||
const handleAssignTeam = async () => {
|
||||
if (isAdmin(user.value?.role)) return
|
||||
if (!selectedTeamId.value) return
|
||||
|
||||
isAssigning.value = true
|
||||
try {
|
||||
const res = await assignTeam(reportId, {
|
||||
@@ -229,6 +228,8 @@ const handleSendMessage = async (msgText: string, files: File[]) => {
|
||||
|
||||
const canFlagMessage = (message: Message) => {
|
||||
if (!user.value) return false
|
||||
if (isAdmin(user.value?.role)) return false
|
||||
|
||||
const isCitizenMessage = message.user_id !== user.value.id && message.user_id === report.value?.user_id
|
||||
const isAlreadyFlagged = flaggedMessageIds.value.includes(message.id)
|
||||
return isCitizenMessage && !isAlreadyFlagged
|
||||
@@ -408,7 +409,7 @@ const formattedInterventionLinkExpiry = computed(() =>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div v-if="!isAdmin(user?.role)" class="card-body pt-0">
|
||||
<button class="btn btn-outline-primary w-100" @click="isAssignModalOpen = true" :disabled="teams.length === 0">
|
||||
Assegna team
|
||||
</button>
|
||||
@@ -522,7 +523,6 @@ const formattedInterventionLinkExpiry = computed(() =>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modale Assegnazione -->
|
||||
<div v-if="isAssignModalOpen" class="modal-backdrop fade show d-block" style="background: rgba(0,0,0,0.5); z-index: 1040;"></div>
|
||||
<div v-if="isAssignModalOpen" class="modal fade show d-block" tabindex="-1" style="z-index: 1050;">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
|
||||
@@ -6,7 +6,6 @@ useHead({
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- HERO SECTION -->
|
||||
<div class="it-hero-wrapper it-primary">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -22,7 +21,6 @@ useHead({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENUTO PRINCIPALE -->
|
||||
<div class="container my-5 py-4">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-8 offset-lg-2">
|
||||
|
||||
@@ -71,7 +71,7 @@ const formatDate = (dateString: string) =>
|
||||
</div>
|
||||
<div class="col-md-6 mb-0">
|
||||
<small class="text-muted d-block">Ruolo</small>
|
||||
<span class="badge bg-info">{{ user?.role }}</span>
|
||||
<span class="badge bg-info">{{ normalizeRole(user?.role) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,6 @@ if (!reportId) {
|
||||
navigateTo('/')
|
||||
}
|
||||
|
||||
// Fetch dati
|
||||
const { data: reportData, refresh: refreshReport } = await useAsyncData(`report-${reportId}`, () =>
|
||||
getReportDetail(reportId)
|
||||
)
|
||||
@@ -42,7 +41,6 @@ const isSubmittingFeedback = ref(false)
|
||||
const selectedMediaIndex = ref(0)
|
||||
const isGalleryOpen = ref(false)
|
||||
|
||||
// Gestione selezione file
|
||||
const handleFileSelect = (event: Event) => {
|
||||
const target = event.target as HTMLInputElement
|
||||
if (target.files) {
|
||||
@@ -50,7 +48,6 @@ const handleFileSelect = (event: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Invia messaggio
|
||||
const handleSendMessage = async () => {
|
||||
if (!newMessage.value.trim() && selectedFiles.value.length === 0) return
|
||||
|
||||
@@ -58,7 +55,6 @@ const handleSendMessage = async () => {
|
||||
try {
|
||||
await addMessage(reportId, { body: newMessage.value })
|
||||
|
||||
// Pulisci i campi
|
||||
newMessage.value = ''
|
||||
selectedFiles.value = []
|
||||
if (fileInput.value) fileInput.value.value = ''
|
||||
@@ -71,7 +67,6 @@ const handleSendMessage = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Invia feedback (solo se risolta)
|
||||
const handleSubmitFeedback = async () => {
|
||||
isSubmittingFeedback.value = true
|
||||
try {
|
||||
@@ -92,7 +87,6 @@ const handleSubmitFeedback = async () => {
|
||||
|
||||
const isOwner = computed(() => report.value?.user_id === user.value?.id)
|
||||
|
||||
// Valutazione solo se lo stato è specificamente "RESOLVED"
|
||||
const canFeedback = computed(() => report.value?.status === 'RESOLVED')
|
||||
|
||||
const statusMeta: Record<string, { label: string; tone: string }> = {
|
||||
|
||||
Reference in New Issue
Block a user