mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Wersja probna
powinno cos dzialac
This commit is contained in:
51
WebApp/wwwroot/create.html
Normal file
51
WebApp/wwwroot/create.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Nowe wydarzenie</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="bg-light">
|
||||
<div class="container mt-5">
|
||||
<h1 class="mb-4">Utwórz wydarzenie</h1>
|
||||
|
||||
<div class="form-group mb-2">
|
||||
<label for="title">Tytuł</label>
|
||||
<input id="title" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label for="location">Lokalizacja</label>
|
||||
<input id="location" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label for="description">Opis</label>
|
||||
<textarea id="description" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label for="eventDate">Data</label>
|
||||
<input id="eventDate" type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group mb-4">
|
||||
<label for="organisationId">ID Organizacji</label>
|
||||
<input id="organisationId" type="number" class="form-control" />
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<button class="button"><span>Zapisz</span><span>⮞</span></button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script type="module" src="/js/eventCreate.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
37
WebApp/wwwroot/css/style.css
Normal file
37
WebApp/wwwroot/css/style.css
Normal file
@@ -0,0 +1,37 @@
|
||||
.button {
|
||||
border-radius: 4px;
|
||||
background-color: #f4511e;
|
||||
color: #FFFFFF;
|
||||
text-align: center;
|
||||
font-size: 28px;
|
||||
padding: 20px 30px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: all 0.5s;
|
||||
text-transform: uppercase;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: rgb(189, 0, 0);
|
||||
}
|
||||
|
||||
.button span:first-child {
|
||||
padding-left: 10px;
|
||||
transition: all 0.5s;
|
||||
}
|
||||
|
||||
.button:hover span:first-child {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.button span:last-child {
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.button:hover span:last-child {
|
||||
opacity: 1;
|
||||
padding-left: 10px;
|
||||
}
|
||||
25
WebApp/wwwroot/index.html
Normal file
25
WebApp/wwwroot/index.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Lista wydarzeń</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="text-primary">📅 Wydarzenia</h1>
|
||||
<a href="/create.html" class="btn btn-success">+ Dodaj nowe</a>
|
||||
</div>
|
||||
|
||||
<div id="eventList" class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/js/eventList.js"></script>
|
||||
<script type="module" src="/js/eventDelete.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,26 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const deleteButtons = document.querySelectorAll(".delete-btn");
|
||||
deleteButtons.forEach(button => {
|
||||
button.addEventListener("click", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const id = button.dataset.id;
|
||||
if (!id)
|
||||
return;
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
|
||||
if (!confirmed)
|
||||
return;
|
||||
const response = yield fetch(`/api/events/${id}`, {
|
||||
method: "DELETE"
|
||||
});
|
||||
if (response.ok) {
|
||||
const row = button.closest("tr");
|
||||
if (row)
|
||||
row.remove();
|
||||
}
|
||||
else {
|
||||
alert("Nie udało się usunąć wydarzenia.");
|
||||
}
|
||||
}));
|
||||
});
|
||||
document.body.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const target = e.target;
|
||||
if (!target.matches(".delete-btn"))
|
||||
return;
|
||||
const id = target.getAttribute("data-id");
|
||||
if (!id)
|
||||
return;
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
|
||||
if (!confirmed)
|
||||
return;
|
||||
const response = yield fetch(`/api/events/${id}`, {
|
||||
method: "DELETE"
|
||||
});
|
||||
if (response.ok) {
|
||||
const card = target.closest(".col");
|
||||
if (card)
|
||||
card.remove();
|
||||
}
|
||||
else {
|
||||
alert("Nie udało się usunąć wydarzenia.");
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
49
WebApp/wwwroot/js/eventList.js
Normal file
49
WebApp/wwwroot/js/eventList.js
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const container = document.getElementById("eventList");
|
||||
if (!container)
|
||||
return;
|
||||
try {
|
||||
const res = yield fetch("/api/events");
|
||||
if (!res.ok)
|
||||
throw new Error("Błąd pobierania wydarzeń");
|
||||
const events = yield res.json();
|
||||
if (events.length === 0) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
return;
|
||||
}
|
||||
for (const ev of events) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "col";
|
||||
card.innerHTML = `
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${ev.title}</h5>
|
||||
<p class="card-text">
|
||||
<strong>Miejsce:</strong> ${ev.location}<br/>
|
||||
<strong>Data:</strong> ${new Date(ev.eventDate).toLocaleString()}<br/>
|
||||
<strong>Organizacja ID:</strong> ${ev.organisationId}
|
||||
</p>
|
||||
<button class="btn btn-outline-danger delete-btn" data-id="${ev.eventId}">
|
||||
🗑️ Usuń
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(card);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||||
console.error(err);
|
||||
}
|
||||
}));
|
||||
Reference in New Issue
Block a user