diff --git a/admin-dashboard.html b/admin-dashboard.html
index f5aec1f..12ee56f 100644
--- a/admin-dashboard.html
+++ b/admin-dashboard.html
@@ -1144,49 +1144,7 @@
Přednastavené aplikace
-
-
-
Rezervace vozidel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- | Jméno řidiče |
- Vozidlo |
- Od |
- Do |
- Účel |
- Akce |
-
-
-
-
-
-
-
-
-
+
Načítám přednastavené aplikace...
@@ -4599,25 +4557,13 @@ async function loadReservations() {
const tbody = document.querySelector('#reservationsTable tbody');
try {
const response = await fetch('/api/reservations');
- if (!response.ok) {
- throw new Error('Failed to load reservations');
- }
+ if (!response.ok) throw new Error('Failed to load reservations');
const reservations = await response.json();
- // Transform data to match frontend format
- const transformedReservations = reservations.map(res => ({
- id: res.ID,
- driverName: res.DriverName,
- vehicle: res.Vehicle,
- start: new Date(res.StartDate + 'T' + res.StartTime).toISOString(),
- end: new Date(res.EndDate + 'T' + res.EndTime).toISOString(),
- purpose: res.Purpose
- }));
+ window.allReservations = reservations; // Store for filtering
- window.allReservations = transformedReservations; // Store for filtering
-
- displayReservations(transformedReservations);
- updateVehicleFilter(transformedReservations);
+ displayReservations(reservations);
+ updateVehicleFilter(reservations);
} catch (error) {
console.error('Error loading reservations:', error);
tbody.innerHTML = `
@@ -5009,91 +4955,6 @@ async function saveReservation(event) {
}
}
-// Function to load and display reservations
-function loadReservations() {
- fetch('/api/reservations')
- .then(response => response.json())
- .then(data => {
- const reservations = data.reservations || [];
- displayReservations(reservations);
- updateVehicleFilter(reservations);
- })
- .catch(error => {
- console.error('Error loading reservations:', error);
- showNotification('Nepodařilo se načíst rezervace', 'error');
- });
-}
-
-// Function to display reservations
-function displayReservations(reservations) {
- const reservationsContainer = document.getElementById('reservationsContainer');
- if (!reservationsContainer) return;
-
- // Clear existing content
- reservationsContainer.innerHTML = '';
-
- if (reservations.length === 0) {
- // Show no reservations message
- const noReservations = document.createElement('div');
- noReservations.className = 'text-center py-6 text-gray-500';
- noReservations.innerHTML = 'Zatím nebyly vytvořeny žádné rezervace.';
- reservationsContainer.appendChild(noReservations);
- return;
- }
-
- // Sort reservations by date
- reservations.sort((a, b) => new Date(a.date) - new Date(b.date));
-
- // Add table header
- const table = document.createElement('table');
- table.className = 'min-w-full divide-y divide-gray-200';
- const thead = document.createElement('thead');
- thead.className = 'bg-gray-50';
- const headerRow = document.createElement('tr');
-
- const headers = ['Datum', 'Čas', 'Vozidlo', 'Jméno', 'Telefon', 'Email', 'Délka', 'Akce'];
- headers.forEach(header => {
- const th = document.createElement('th');
- th.className = 'px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider';
- th.textContent = header;
- headerRow.appendChild(th);
- });
- thead.appendChild(headerRow);
- table.appendChild(thead);
-
- // Add table body
- const tbody = document.createElement('tbody');
- tbody.className = 'bg-white divide-y divide-gray-200';
-
- // Add reservations
- reservations.forEach(reservation => {
- const row = document.createElement('tr');
- row.className = 'hover:bg-gray-50';
-
- // Add cells
- const cells = [
- formatDateTime(reservation.date, reservation.time),
- reservation.vehicle,
- reservation.name,
- reservation.phone,
- reservation.email,
- calculateDuration(reservation),
- ' '
- ];
-
- cells.forEach(cellContent => {
- const cell = document.createElement('td');
- cell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-900';
- cell.innerHTML = cellContent;
- row.appendChild(cell);
- });
-
- tbody.appendChild(row);
- });
-
- table.appendChild(tbody);
- reservationsContainer.appendChild(table);
-}
// Add event listeners when the page loads
document.addEventListener('DOMContentLoaded', function() {
diff --git a/main.go b/main.go
index ff7bd53..9296c4d 100644
--- a/main.go
+++ b/main.go
@@ -145,20 +145,8 @@ func trackVisit(w http.ResponseWriter, r *http.Request) {
stats.TodayVisits++
}
- // Extract IP address (remove port)
- ip := r.RemoteAddr
- if strings.Contains(ip, ":") {
- // Split at the last colon to remove port
- parts := strings.Split(ip, ":")
- ip = strings.Join(parts[:len(parts)-1], ":")
- // Remove IPv6 brackets if present
- if strings.HasPrefix(ip, "[") && strings.HasSuffix(ip, "]") {
- ip = ip[1 : len(ip)-1]
- }
- }
-
- // Get visitor ID (using cleaned IP and User-Agent)
- visitorID := fmt.Sprintf("%s-%s", ip, r.UserAgent())
+ // Get visitor ID (using IP and User-Agent)
+ visitorID := fmt.Sprintf("%s-%s", r.RemoteAddr, r.UserAgent())
// Update or create visitor stats
if visitor, exists := stats.UniqueVisitors[visitorID]; exists {
@@ -369,36 +357,6 @@ type Reservation struct {
Purpose string `json:"purpose,omitempty"`
}
-func getReservations(w http.ResponseWriter, r *http.Request) {
- // Load reservations from JSON file
- data, err := os.ReadFile("data/reservations.json")
- if err != nil {
- if os.IsNotExist(err) {
- // Return empty array if file doesn't exist
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- w.Write([]byte("[]"))
- return
- }
- log.Printf("Error reading reservations: %v", err)
- w.WriteHeader(http.StatusInternalServerError)
- return
- }
-
- var reservations []Reservation
- if err := json.Unmarshal(data, &reservations); err != nil {
- log.Printf("Error unmarshaling reservations: %v", err)
- w.WriteHeader(http.StatusInternalServerError)
- return
- }
-
- w.Header().Set("Content-Type", "application/json")
- if err := json.NewEncoder(w).Encode(reservations); err != nil {
- log.Printf("Error encoding reservations: %v", err)
- w.WriteHeader(http.StatusInternalServerError)
- }
-}
-
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
@@ -415,9 +373,6 @@ func main() {
// Visitor tracking endpoints
r.HandleFunc("/api/track-visit", trackVisit).Methods("GET")
r.HandleFunc("/api/visitor-stats", getVisitorStats).Methods("GET")
-
- // Reservations endpoints
- r.HandleFunc("/api/reservations", getReservations).Methods("GET")
// Set up reverse proxy to kontakt service
kontaktURL, _ := url.Parse("http://webportal:8080")