Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/authentication/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ router.post("", async function (req, res) {
if (!user) {
user = new User({
email: payload["email"],
password: "default-google-password-to-be-changed",
password: "google-pass-to-be-changed",
});
await user.save();
}
Expand Down
1 change: 1 addition & 0 deletions backend/controllers/reportsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const updateReport = async (req, res) => {
res.status(200).json(report);
} catch (error) {
res.status(400).json({ message: "Error in report update" });
console.log(error.message)
}
};

Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/Mappa/Mappa.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const props = defineProps({
},
});

const filteredEmergencies = ref([])

onMounted(() => {
// Recupero i bordi del comune di Trento da OpenStreetMap
fetch('https://nominatim.openstreetmap.org/search.php?city=Trento&polygon_geojson=1&format=json')
Expand All @@ -34,14 +36,20 @@ onMounted(() => {
.catch(error => {
console.error('Errore caricamento mappa:', error);
});

filteredEmergencies.value = props.emergencies?.filter(emergency => {
return emergency.coordinates.lat !== null &&
emergency.coordinates.lon !== null;
})
console.log(filteredEmergencies)
});
</script>

<template>
<div class="map-div w-full h-full m-0 p-0 z-40">
<l-map :zoom="zoom" :center="center">
<l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
<l-marker v-for="marker in emergencies" :key="marker.id"
<l-marker v-for="marker in filteredEmergencies" :key="marker.id"
:lat-lng="[marker.coordinates.lat, marker.coordinates.lon]">
<l-popup>
<div class="flex justify-start">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navbar/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function chiudiMenuNavbar() {
<p class="ms-1 mt-0.5">Storico emergenze</p>
</router-link>
</li>
<li class="menu-title px-0">
<li v-if="!loggedUser.role" class="menu-title px-0">
<router-link to="/accedi" class="px-0 flex" @click="chiudiMenuNavbar()">
<KeyIcon class="size-6 mx-2" />
<p class="ms-1 mt-0.5">Accedi</p>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Tabelle/TabellaSegnalazioni.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const filteredReports = computed(() => {
{{ index + 1 }}
</td>
<td v-if="props.isOperator">
{{ report.email }}
<span v-html="report.email ? report.email : '<i>Utente rimosso</i>'"></span>
</td>
<td v-else>
{{ report.createdAt }}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/Toast/Toast.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup>
import { computed } from 'vue';

import {
CheckCircleIcon,
ExclamationTriangleIcon,
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/data/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,25 @@ export async function createReport(data) {
return null;
}
}

export async function updateReport(data) {
try {
const response = await fetch(apiReports + data.id, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${loggedUser.token}`,
},
body: JSON.stringify(data),
});

if (!response.ok) {
throw new Error("Errore nell'aggiornamento del report");
}

return response.json();
} catch (error) {
console.error("Errore da updateReport(): ", error);
return null;
}
}
5 changes: 5 additions & 0 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const router = createRouter({
name: 'invia_segnalazione',
component: () => import('../views/user/ViewSegnalazione.vue'),
},
{
path: '/conferma_segnalazione',
name: 'conferma_segnalazione',
component: () => import('../views/dashboard/ViewEditSegnalazione.vue'),
},
{
path: '/pubblica_comunicazione',
name: 'pubblica_comunicazione',
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/views/dashboard/ViewDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ onMounted(async () => {
if (route.query.published === 'true') {
createToast("success", "Successo!", "Comunicazione pubblicata correttamente")
}

if (route.query.published === 'true') {
createToast("success", "Successo!", "Comunicazione modificata correttamente")
}

if (route.query.approved === 'true') {
createToast("info", "Successo!", "Segnalazione approvata correttamente")
Expand Down Expand Up @@ -98,7 +102,7 @@ function createToast(type, title, msg) {
</div>
</div>
<div class="stat">
<div class="stat-figure text-ghost">
<div class="stat-figure text-warning">
<ShieldExclamationIcon class="inline-block size-12" />
</div>
<div class="stat-title">Segnalazioni inviate</div>
Expand All @@ -108,7 +112,7 @@ function createToast(type, title, msg) {
</div>
</div>
<div class="stat">
<div class="stat-figure text-ghost">
<div class="stat-figure text-primary">
<ShieldCheckIcon class="inline-block size-12" />
</div>
<div class="stat-title">Emergenze pubblicate</div>
Expand Down Expand Up @@ -177,7 +181,7 @@ function createToast(type, title, msg) {
}

.stat:hover {
color: var(--primary);
color: var(--primary) !important;
transform: scale(1.05);
}

Expand Down
14 changes: 8 additions & 6 deletions frontend/src/views/dashboard/ViewEditComunicazione.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { loggedUser } from '../../states/loggedUser.js';
import { updateEmergency } from '@/data/emergencies.js';

Expand All @@ -11,19 +11,21 @@ import WrongURL from '@/components/Error/WrongURL.vue';
import Toast from '@/components/Toast/Toast.vue';

const route = useRoute();
const router = useRouter();

const apiEmergencies = import.meta.env.VITE_API_BASE_URL + "/emergencies/";

const self = ref()
const title = ref()
const category = ref("Di che tipo è l'emergenza?")
const category = ref()
const startDate = ref()
const startTime = ref()
const location = ref()
const coordinates = ref({
lat: null,
lon: null
});
const state = ref("In che stato è l'emergenza?")
const state = ref()
const description = ref()

onMounted(() => {
Expand Down Expand Up @@ -93,7 +95,7 @@ function modificaComunicazione() {

console.log('Values: ', updatedEmergency)
updateEmergency(updatedEmergency)
createToast("success", "Successo!", "Comunicazione modificata correttamente")
router.push({ path: '/dashboard', query: { edited: 'true' } })
}

const showToast = ref(false)
Expand All @@ -116,7 +118,7 @@ function createToast(type, title, msg) {

<template>
<div v-if="loggedUser.token && loggedUser.role === 'operator'">
<div v-if="self === null">
<div v-if="!self">
<WrongURL />
</div>

Expand Down Expand Up @@ -215,7 +217,7 @@ function createToast(type, title, msg) {
<div class="w-full">
<input @click="modificaComunicazione()" type="button" value="Modifica comunicazione"
class="btn btn-primary float-end rounded-lg mt-6" />
<input @click="$router.go(-1)" type="button" value="Annulla"
<input @click="$router.go(-1)" type="button" value="Torna alla dashboard"
class="btn btn-ghost btn-outline float-end rounded-lg mt-6 me-2" />
</div>
</form>
Expand Down
Loading