<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>WarpBox Admin Tags</title>
        <link rel="icon" type="image/png" href="/static/WarpBoxLogo.png">
        <link rel="stylesheet" href="/static/css/app.css">
        <link rel="stylesheet" href="/static/css/window.css">
        <link rel="stylesheet" href="/static/css/admin.css">
    </head>
    <body>
        <main>
            <section class="win98-window admin-window" aria-labelledby="admin-tags-title">
                <header class="win98-titlebar">
                    <div class="win98-titlebar-label">
                        <img class="win98-titlebar-icon" src="/static/WarpBoxLogo.png" alt="" aria-hidden="true">
                        <h1 id="admin-tags-title">Tags</h1>
                    </div>
                </header>
                <div class="win98-panel admin-panel">
                    <nav class="admin-nav">
                        <a class="win98-button" href="/admin">Admin</a>
                        <a class="win98-button" href="/admin/boxes">Boxes</a>
                        <a class="win98-button" href="/admin/users">Users</a>
                        <a class="win98-button" href="/admin/settings">Settings</a>
                        <span class="admin-spacer"></span>
                        <span>{{ .CurrentUser }}</span>
                    </nav>
                    {{ if .Error }}
                        <p class="admin-error">{{ .Error }}</p>
					{{ end }}
					<form class="admin-form win98-panel" action="/admin/tags" method="post">
						<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
						<label class="admin-form-row">
							<span>Name</span>
							<input name="name" required>
                        </label>
                        <label class="admin-form-row">
                            <span>Description</span>
                            <textarea name="description" rows="2"></textarea>
                        </label>
                        <div class="admin-checks">
                            <label><input type="checkbox" name="admin_access" value="true"><span>Admin access</span></label>
                            <label><input type="checkbox" name="admin_users_manage" value="true"><span>Manage users</span></label>
                            <label><input type="checkbox" name="admin_settings_manage" value="true"><span>Manage settings</span></label>
                            <label><input type="checkbox" name="admin_boxes_view" value="true"><span>View boxes</span></label>
                            <label><input type="checkbox" name="upload_allowed" value="true"><span>Upload allowed</span></label>
                            <label><input type="checkbox" name="zip_download_allowed" value="true"><span>ZIP allowed</span></label>
                            <label><input type="checkbox" name="one_time_download_allowed" value="true"><span>One-time allowed</span></label>
                            <label><input type="checkbox" name="renewable_allowed" value="true"><span>Renewable allowed</span></label>
                        </div>
                        <label class="admin-form-row">
                            <span>Max file size bytes</span>
                            <input name="max_file_size_bytes" inputmode="numeric">
                        </label>
                        <label class="admin-form-row">
                            <span>Max box size bytes</span>
                            <input name="max_box_size_bytes" inputmode="numeric">
                        </label>
                        <label class="admin-form-row">
                            <span>Allowed expiry seconds</span>
                            <input name="allowed_expiry_seconds" placeholder="600, 3600, 86400">
                        </label>
                        <button class="win98-button" type="submit">Create Tag</button>
                    </form>
                    <table class="admin-table">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Description</th>
                                <th>Flags</th>
                                <th>Max file</th>
                                <th>Max box</th>
                                <th>Expiry seconds</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{ range .Tags }}
                                <tr>
                                    <td>{{ .Name }} {{ if .Protected }}(protected){{ end }}</td>
                                    <td>{{ .Description }}</td>
                                    <td>
                                        {{ if .AdminAccess }}admin {{ end }}
                                        {{ if .UploadAllowed }}upload {{ end }}
                                        {{ if .ZipDownloadAllowed }}zip {{ end }}
                                        {{ if .OneTimeDownloadAllowed }}one-time {{ end }}
                                        {{ if .RenewableAllowed }}renew {{ end }}
                                    </td>
                                    <td>{{ .MaxFileSizeBytes }}</td>
                                    <td>{{ .MaxBoxSizeBytes }}</td>
                                    <td>{{ .AllowedExpirySeconds }}</td>
                                </tr>
                            {{ else }}
                                <tr><td colspan="6">No tags found.</td></tr>
                            {{ end }}
                        </tbody>
                    </table>
                </div>
            </section>
        </main>
    </body>
</html>
