edia all routes

This commit is contained in:
2025-09-05 13:15:11 +02:00
parent 3872397082
commit a78a8dc3ce
8 changed files with 230 additions and 76 deletions

View File

@@ -46,7 +46,7 @@ function setupEventListeners() {
async function checkAuth() {
try {
const response = await fetch('/api/check-session');
const response = await fetch('/api/v1/web/check-session');
const result = await response.json();
if (!result.success) {
@@ -74,7 +74,7 @@ async function checkAuth() {
async function logout() {
try {
await fetch('/api/logout', { method: 'POST' });
await fetch('/api/v1/public/logout', { method: 'POST' });
window.location.href = '/adminlogin.html';
} catch (error) {
console.error('Logout failed:', error);
@@ -84,7 +84,7 @@ async function logout() {
async function loadStatistics() {
try {
const response = await fetch('/api/admin-stats');
const response = await fetch('/api/v1/admin/stats');
const stats = await response.json();
if (stats.success) {
@@ -100,7 +100,7 @@ async function loadStatistics() {
async function loadPageStatistics() {
try {
const response = await fetch('/api/admin-page-stats');
const response = await fetch('/api/v1/admin/page-stats');
const result = await response.json();
if (result.success) {
@@ -202,7 +202,7 @@ async function loadUsers() {
async function loadPlayers() {
try {
const response = await fetch('/api/admin-players');
const response = await fetch('/api/v1/admin/players');
const result = await response.json();
if (result.success) {
@@ -219,7 +219,7 @@ async function loadPlayers() {
async function loadRuns() {
try {
const response = await fetch('/api/admin-runs');
const response = await fetch('/api/v1/admin/runs');
const result = await response.json();
if (result.success) {
@@ -236,7 +236,7 @@ async function loadRuns() {
async function loadLocations() {
try {
const response = await fetch('/api/admin-locations');
const response = await fetch('/api/v1/admin/locations');
const result = await response.json();
if (result.success) {
@@ -253,7 +253,7 @@ async function loadLocations() {
async function loadAdminUsers() {
try {
const response = await fetch('/api/admin-adminusers');
const response = await fetch('/api/v1/admin/adminusers');
const result = await response.json();
if (result.success) {
@@ -537,22 +537,22 @@ async function handleAddSubmit(e) {
switch(currentDataType) {
case 'players':
endpoint = isEdit ? `/api/admin-players/${editId}` : '/api/admin-players';
endpoint = isEdit ? `/api/v1/admin/players/${editId}` : '/api/v1/admin/players';
successMessage = isEdit ? 'Spieler erfolgreich aktualisiert' : 'Spieler erfolgreich hinzugefügt';
method = isEdit ? 'PUT' : 'POST';
break;
case 'locations':
endpoint = isEdit ? `/api/admin-locations/${editId}` : '/api/admin-locations';
endpoint = isEdit ? `/api/v1/admin/locations/${editId}` : '/api/v1/admin/locations';
successMessage = isEdit ? 'Standort erfolgreich aktualisiert' : 'Standort erfolgreich hinzugefügt';
method = isEdit ? 'PUT' : 'POST';
break;
case 'adminusers':
endpoint = isEdit ? `/api/admin-adminusers/${editId}` : '/api/admin-adminusers';
endpoint = isEdit ? `/api/v1/admin/adminusers/${editId}` : '/api/v1/admin/adminusers';
successMessage = isEdit ? 'Admin-Benutzer erfolgreich aktualisiert' : 'Admin-Benutzer erfolgreich hinzugefügt';
method = isEdit ? 'PUT' : 'POST';
break;
case 'runs':
endpoint = isEdit ? `/api/admin-runs/${editId}` : '/api/admin-runs';
endpoint = isEdit ? `/api/v1/admin/runs/${editId}` : '/api/v1/admin/runs';
successMessage = isEdit ? 'Lauf erfolgreich aktualisiert' : 'Lauf erfolgreich hinzugefügt';
method = isEdit ? 'PUT' : 'POST';
break;
@@ -697,7 +697,7 @@ async function editRun(id) {
async function deletePlayer(id) {
if (await confirmDelete(`Spieler mit ID ${id} löschen?`)) {
try {
const response = await fetch(`/api/admin-players/${id}`, { method: 'DELETE' });
const response = await fetch(`/api/v1/admin/players/${id}`, { method: 'DELETE' });
const result = await response.json();
if (result.success) {
@@ -716,7 +716,7 @@ async function deletePlayer(id) {
async function deleteRun(id) {
if (await confirmDelete(`Lauf mit ID ${id} löschen?`)) {
try {
const response = await fetch(`/api/admin-runs/${id}`, { method: 'DELETE' });
const response = await fetch(`/api/v1/admin/runs/${id}`, { method: 'DELETE' });
const result = await response.json();
if (result.success) {
@@ -735,7 +735,7 @@ async function deleteRun(id) {
async function deleteLocation(id) {
if (await confirmDelete(`Standort mit ID ${id} löschen?`)) {
try {
const response = await fetch(`/api/admin-locations/${id}`, { method: 'DELETE' });
const response = await fetch(`/api/v1/admin/locations/${id}`, { method: 'DELETE' });
const result = await response.json();
if (result.success) {
@@ -754,7 +754,7 @@ async function deleteLocation(id) {
async function deleteAdminUser(id) {
if (await confirmDelete(`Admin-Benutzer mit ID ${id} löschen?`)) {
try {
const response = await fetch(`/api/admin-adminusers/${id}`, { method: 'DELETE' });
const response = await fetch(`/api/v1/admin/adminusers/${id}`, { method: 'DELETE' });
const result = await response.json();
if (result.success) {

View File

@@ -42,7 +42,7 @@ async function handleLogin(event) {
setLoading(true);
try {
const response = await fetch('/api/login', {
const response = await fetch('/api/v1/public/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View File

@@ -314,7 +314,7 @@ async function linkUserByRfidUid(rfidUid) {
try {
// First, find the player with this RFID UID
const response = await fetch('/api/link-by-rfid', {
const response = await fetch('/api/v1/public/link-by-rfid', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -362,7 +362,7 @@ async function loadUserTimesSection(playerData) {
showTimesLoading();
try {
const response = await fetch(`/api/user-times/${currentUser.id}`);
const response = await fetch(`/api/v1/public/user-times/${currentUser.id}`);
const times = await response.json();
// Update stats

View File

@@ -114,7 +114,7 @@ function toggleTokenFields() {
const standorte = document.getElementById("standorte").value.trim();
try {
const response = await fetch('/api/web/save-token', {
const response = await fetch('/api/v1/web/save-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -477,7 +477,7 @@ function toggleTokenFields() {
saveBtn.disabled = true;
// Web-authenticated API für Standortverwaltung aufrufen
const response = await fetch('/api/web/create-location', {
const response = await fetch('/api/v1/web/create-location', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -524,7 +524,7 @@ function toggleTokenFields() {
// Logout-Funktion
async function logout() {
try {
const response = await fetch('/api/logout', {
const response = await fetch('/api/v1/public/logout', {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View File

@@ -106,7 +106,7 @@ async function logout() {
// Load locations from database
async function loadLocations() {
try {
const response = await fetch('/public-api/locations');
const response = await fetch('/api/v1/public/locations');
if (!response.ok) {
throw new Error('Failed to fetch locations');
}
@@ -330,7 +330,7 @@ async function loadData() {
}
// Fetch times with player and location data from local database
const response = await fetch(`/public-api/times-with-details?${params.toString()}`);
const response = await fetch(`/api/v1/public/times-with-details?${params.toString()}`);
if (!response.ok) {
throw new Error('Failed to fetch times');
}

View File

@@ -5,7 +5,7 @@ function trackPageView(pageName) {
const referer = document.referrer || '';
// Send tracking data to server
fetch('/api/track-page-view', {
fetch('/api/v1/public/track-page-view', {
method: 'POST',
headers: {
'Content-Type': 'application/json',