{% extends "crowdsec_base.html" %}

{% block title %}대시보드 - RealNAS security{% endblock %}

{% block content %}
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8" />
    <title>RealNAS Security 로그 조회</title>
    <style>
        body {
            font-family: 'Malgun Gothic', Arial, sans-serif;
            background: #f8f9fb;
            color: #222;
            margin: 0;
            padding: 20px;
        }
        h1 {
            margin-bottom: 20px;
        }
        form {
            margin-bottom: 20px;
        }
        input[type="text"] {
            padding: 8px;
            width: 300px;
            font-size: 14px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        button {
            padding: 8px 14px;
            font-size: 14px;
            border: none;
            background-color: #369;
            color: white;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #246;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px 12px;
            text-align: left;
        }
        th {
            background-color: #f0f2f7;
            font-weight: 600;
            color: #555;
        }
        .no-data {
            text-align: center;
            font-style: italic;
            color: #888;
            padding: 20px 0;
        }
    </style>
</head>
<body>

<h1>RealNAS Security 로그 조회</h1>

<form method="GET" action="{{ url_for('crowdsec_logs') }}">
    <input type="text" name="q" value="{{ request.args.get('q', '') }}" placeholder="IP, 메시지 등 검색어 입력">
    <button type="submit">검색</button>
</form>

{% if logs %}
<table>
    <thead>
        <tr>
            <th>시간</th>
            <th>IP</th>
            <th>이벤트 메시지</th>
        </tr>
    </thead>
    <tbody>
        {% for log in logs %}
        <tr>
            <td>{{ log.time }}</td>
            <td>{{ log.ip }}</td>
            <td>{{ log.message }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% else %}
<p class="no-data">검색 결과가 없습니다.</p>
{% endif %}



</body>
</html>
{% endblock %}