mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
feat: image support
also translated some strings back into english
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
|
||||
async function createEvent() {
|
||||
// Pobieranie danych z formularza
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw) {
|
||||
@@ -19,6 +20,7 @@ async function createEvent() {
|
||||
title,
|
||||
location,
|
||||
description,
|
||||
imageURL,
|
||||
eventDate,
|
||||
};
|
||||
|
||||
@@ -62,4 +64,4 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
createEvent();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Obsługuje kliknięcie na przycisk "Usuń"
|
||||
document.body.addEventListener("click", async (e) => {
|
||||
const target = e.target as HTMLElement;
|
||||
@@ -13,7 +13,7 @@
|
||||
window.location.href = "/modify.html?event=" + id;
|
||||
break;
|
||||
case "remove-btn":
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
|
||||
const confirmed = confirm("Are you sure?"); // Potwierdzenie usunięcia
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
@@ -27,14 +27,14 @@
|
||||
const card = target.closest(".event-card");
|
||||
if (card) card.remove();
|
||||
} else {
|
||||
alert("Błąd podczas usuwania wydarzenia.");
|
||||
alert("Couldn't delete that event.");
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Błąd połączenia z serwerem.");
|
||||
alert("Server connection failure.");
|
||||
console.error(err);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ async function getEvents(titleOrDescription?: string) {
|
||||
|
||||
if (titleOrDescription == null) {
|
||||
res = await fetch("/api/events" + (isAscending ? "?sort=asc" : ""));
|
||||
if (!res.ok) throw new Error("Błąd pobierania wydarzeń");
|
||||
if (!res.ok) throw new Error("Couldn't load events");
|
||||
} else {
|
||||
const payload = {
|
||||
titleOrDescription
|
||||
@@ -23,7 +23,7 @@ async function getEvents(titleOrDescription?: string) {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!res.ok) throw new Error("Błąd wyszukiwania wydarzeń");
|
||||
if (!res.ok) throw new Error("Failed to get search results");
|
||||
}
|
||||
|
||||
const events = await res.json();
|
||||
@@ -44,13 +44,16 @@ async function loadEvents(org_id: number, evs?: Promise<any>) {
|
||||
}
|
||||
|
||||
if (events.length === 0) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>No events to display at this moment.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
// Wyczyść kontener przed dodaniem nowych
|
||||
container.innerHTML = '';
|
||||
|
||||
const styleDefault = "color: #2898BD";
|
||||
const styleHighlighted = "#2393BD";
|
||||
|
||||
for (const ev of events) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "event-card filled";
|
||||
@@ -83,7 +86,7 @@ async function loadEvents(org_id: number, evs?: Promise<any>) {
|
||||
container.appendChild(card);
|
||||
}
|
||||
} catch (err) {
|
||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||||
container.innerHTML = `<p class="text-danger">General failure when trying to load data.</p>`;
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
@@ -7,10 +7,11 @@ const eventId = urlParams.get('event');
|
||||
async function modifyEvent()
|
||||
{
|
||||
// Pobieranie danych z formularza
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw)
|
||||
@@ -24,6 +25,7 @@ async function modifyEvent()
|
||||
const payload = {
|
||||
title,
|
||||
location,
|
||||
imageURL,
|
||||
description,
|
||||
eventDate,
|
||||
};
|
||||
@@ -42,11 +44,11 @@ async function modifyEvent()
|
||||
throw new Error(errorText);
|
||||
}
|
||||
|
||||
alert("Wydarzenie zmodyfikowane!");
|
||||
alert("Event modified!");
|
||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||
} catch (error) {
|
||||
console.error("Błąd podczas modyfikowania:", error);
|
||||
alert("Nie udało się zmodyfikować wydarzenia: " + error);
|
||||
console.error("Error occurred while trying to modify event:", error);
|
||||
alert("Couldn't modify event, an error occurred: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,16 +83,18 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
const locationInput = document.getElementById( 'location') as HTMLInputElement;
|
||||
const descriptionInput = document.getElementById('description') as HTMLInputElement;
|
||||
const dateInput = document.getElementById( 'eventDate') as HTMLInputElement;
|
||||
const imageInput = document.getElementById( 'imageURL') as HTMLInputElement;
|
||||
var ev = await getEvent(eventId);
|
||||
|
||||
if (ev === null) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>Failed to load event data.</p>";
|
||||
return;
|
||||
} else {
|
||||
titleInput.value = ev.title || '';
|
||||
locationInput.value = ev.location || '';
|
||||
descriptionInput.value = ev.description || '';
|
||||
dateInput.value = ev.eventDate.slice(0, 16) || '';
|
||||
imageInput.value = ev.imageURL || '';
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
@@ -99,4 +103,4 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
const descText = document.getElementById( "descText") as HTMLElement;
|
||||
const dateText = document.getElementById( "dateText") as HTMLElement;
|
||||
const organizerText = document.getElementById("organizerText") as HTMLElement;
|
||||
const coverImage = document.getElementById( "coverImage") as HTMLImageElement;
|
||||
const newdateText = new Date(thisEvent.eventDate).toLocaleDateString('pl-PL');
|
||||
const newtimeText = new Date(thisEvent.eventDate).toLocaleTimeString('pl-PL');
|
||||
|
||||
@@ -52,6 +53,10 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
descText.innerHTML = thisEvent.description;
|
||||
dateText.innerHTML = "📅 When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||
organizerText.innerHTML = "👥 Organized by: " + thisEvent.organisationName;
|
||||
coverImage.src = thisEvent.imageURL
|
||||
|
||||
console.log(thisEvent.imageURL);
|
||||
if (thisEvent.imageURL !== "") unhideElementById(document, "imgdiv");
|
||||
|
||||
if (org_id == thisEvent.organisationId) {
|
||||
// Użytkownik jest organizacją, która
|
||||
|
||||
@@ -2,6 +2,7 @@ interface EventData {
|
||||
title: string;
|
||||
location: string;
|
||||
description: string;
|
||||
imageURL: string;
|
||||
eventDate: string;
|
||||
organisationName: string,
|
||||
organisationId: number
|
||||
|
||||
Reference in New Issue
Block a user