diff --git a/src/main/java/cz/kamma/tvcom/HttpServerApp.java b/src/main/java/cz/kamma/tvcom/HttpServerApp.java index b11d845..5303998 100644 --- a/src/main/java/cz/kamma/tvcom/HttpServerApp.java +++ b/src/main/java/cz/kamma/tvcom/HttpServerApp.java @@ -13,9 +13,6 @@ import java.util.List; public class HttpServerApp { - // ✅ Statický API klíč - private static final String API_KEY = "6666-1234"; - public static void main(String[] args) throws Exception { TransmissionService service = new TransmissionService(); @@ -26,8 +23,6 @@ public class HttpServerApp { server.createContext("/transmissions", exchange -> { try { setCors(exchange); - if (!checkApiKey(exchange)) - return; URI uri = exchange.getRequestURI(); String query = uri.getQuery(); @@ -59,8 +54,6 @@ public class HttpServerApp { server.createContext("/search", exchange -> { try { setCors(exchange); - if (!checkApiKey(exchange)) - return; URI uri = exchange.getRequestURI(); String query = null; @@ -84,8 +77,6 @@ public class HttpServerApp { server.createContext("/refresh", exchange -> { try { setCors(exchange); - if (!checkApiKey(exchange)) - return; if ("GET".equalsIgnoreCase(exchange.getRequestMethod())) { // přečti volitelné datum z query stringu @@ -138,8 +129,6 @@ public class HttpServerApp { return; } - if (!checkApiKey(exchange)) - return; if ("/".equals(path) || path.isEmpty() || path.equals("/index.html")) { String html = readResource("/index.html"); if (html == null) { @@ -164,9 +153,9 @@ public class HttpServerApp { server.start(); System.out.println("🚀 HTTP server běží na http://localhost:8080"); - System.out.println(" ➜ /transmissions (všechny přenosy JSON, vyžaduje X-API-KEY)"); - System.out.println(" ➜ /search?q=Brno (vyhledávání JSON, vyžaduje X-API-KEY)"); - System.out.println(" ➜ /refresh (spustí opětovné načtení dat, vyžaduje X-API-KEY)"); + System.out.println(" ➜ /transmissions (všechny přenosy JSON)"); + System.out.println(" ➜ /search?q=Brno (vyhledávání JSON)"); + System.out.println(" ➜ /refresh (spustí opětovné načtení dat)"); System.out.println(" ➜ / (web UI)"); } @@ -187,32 +176,6 @@ public class HttpServerApp { } } - // ======= API Key ochrana ======= - private static boolean checkApiKey(HttpExchange exchange) throws IOException { - String query = exchange.getRequestURI().getQuery(); // např. apiKey=xxxx - String key = null; - - if (query != null) { - for (String part : query.split("&")) { - if (part.startsWith("apiKey=")) { - key = java.net.URLDecoder.decode(part.substring(7), StandardCharsets.UTF_8); - break; - } - } - } - - if (!API_KEY.equals(key)) { - exchange.getResponseHeaders().set("Content-Type", "application/json; charset=utf-8"); - byte[] bytes = "{\"error\":\"Unauthorized\"}".getBytes(StandardCharsets.UTF_8); - exchange.sendResponseHeaders(401, bytes.length); - try (OutputStream os = exchange.getResponseBody()) { - os.write(bytes); - } - return false; - } - return true; - } - // ======= CORS ======= private static void setCors(HttpExchange exchange) { Headers h = exchange.getResponseHeaders(); diff --git a/src/main/resources/index.html b/src/main/resources/index.html index 0c33753..b21ecdd 100644 --- a/src/main/resources/index.html +++ b/src/main/resources/index.html @@ -27,46 +27,122 @@ h1 { } input, select, button { - padding: 6px 10px; + padding: 8px 16px; font-size: 15px; + border: 1px solid #ddd; + border-radius: 5px; + cursor: pointer; } -.grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); - gap: 15px; +button { + background: white; + transition: all 0.2s; } -.card { +button:hover { + background: #f0f0f0; +} + +button.active { + background: #4a90e2; + color: white; + border-color: #4a90e2; +} + +.sport-buttons { + display: flex; + flex-wrap: wrap; + gap: 8px; + justify-content: center; + margin-bottom: 20px; +} + +.table-container { background: white; border-radius: 10px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); overflow: hidden; - transition: transform 0.2s; } -.card:hover { - transform: scale(1.02); -} - -.card img { +table { width: 100%; - height: 160px; + border-collapse: collapse; +} + +thead { + background: #4a90e2; + color: white; +} + +th { + padding: 12px; + text-align: left; + font-weight: 600; + font-size: 14px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +td { + padding: 12px; + border-bottom: 1px solid #e0e0e0; +} + +tbody tr { + transition: background-color 0.2s; +} + +tbody tr:hover { + background-color: #f8f9fa; +} + +tbody tr:last-child td { + border-bottom: none; +} + +.thumbnail { + width: 80px; + height: 60px; object-fit: cover; + border-radius: 5px; } -.card-content { - padding: 10px; +.title-cell { + font-weight: 500; + color: #333; } -.title { - font-weight: bold; - margin-bottom: 5px; +.title-cell a { + color: #333; + text-decoration: none; } -.meta { - font-size: 0.9em; +.title-cell a:hover { + color: #4a90e2; + text-decoration: underline; +} + +.time-cell { + white-space: nowrap; color: #666; + font-size: 14px; +} + +.sport-cell { + color: #666; + font-size: 14px; +} + +.league-cell { + color: #888; + font-size: 13px; +} + +.no-results { + text-align: center; + padding: 40px; + color: #666; + font-size: 16px; } #loading { @@ -75,9 +151,19 @@ input, select, button { margin-top: 30px; } -@media ( max-width : 500px) { - .card img { - height: 120px; +@media (max-width: 768px) { + th, td { + padding: 8px; + font-size: 13px; + } + + .thumbnail { + width: 60px; + height: 45px; + } + + th:nth-child(4), td:nth-child(4) { + display: none; } } @@ -86,30 +172,36 @@ input, select, button {