File size: 3,734 Bytes
c03d895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChessTB — Admin Dashboard</title>
<link rel="stylesheet" href="{{ url_for('static', filename='dist/admin.css') }}">
</head>
<body class="admin-page">

{% if not authenticated %}
<!-- Shown when GET /admin has no valid session cookie. Submits the token
     to POST /admin/login (static/js/admin.js's login()); on success the
     page reloads and this branch renders the dashboard instead. -->
<div class="login-card">
  <h1>
    ♟ ChessTB Admin
    {% if source_repository_url %}
    <a href="{{ source_repository_url }}" class="site-header__link site-header__link--icon"
       title="Source repository" aria-label="Source repository" target="_blank" rel="noopener">
      <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor"
           stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
        <path d="M7 8.5v7m10-7V10a4 4 0 0 1-4 4H7" />
        <circle cx="7" cy="6" r="2.5" />
        <circle cx="7" cy="18" r="2.5" />
        <circle cx="17" cy="6" r="2.5" />
      </svg>
    </a>
    {% endif %}
  </h1>
  {% if not admin_configured %}
  <p class="status err">Admin panel disabled: ADMIN_TOKEN is not configured.</p>
  {% else %}
  <p class="login-card__hint">Enter the admin token to continue.</p>
  <input type="password" id="login-token-input" class="login-input"
         placeholder="Admin token" autocomplete="current-password">
  <button class="btn btn--apply" id="login-btn">Log in</button>
  <div class="status" id="login-status"></div>
  {% endif %}
  <a href="/" class="login-card__back">← Back to explorer</a>
</div>
{% else %}
<h1>
  ♟ ChessTB Cache Dashboard
  {% if source_repository_url %}
  <a href="{{ source_repository_url }}" class="site-header__link site-header__link--icon"
     title="Source repository" aria-label="Source repository" target="_blank" rel="noopener">
    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor"
           stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
        <path d="M7 8.5v7m10-7V10a4 4 0 0 1-4 4H7" />
        <circle cx="7" cy="6" r="2.5" />
        <circle cx="7" cy="18" r="2.5" />
        <circle cx="17" cy="6" r="2.5" />
      </svg>
  </a>
  {% endif %}
  <button class="btn" id="logout-btn">Log out</button>
  <a href="/" class="admin-page__back-link">← Back to explorer</a>
</h1>

<div class="toolbar-row">
  <button class="btn" id="refresh-btn">Refresh</button>
  <button class="btn danger" id="clear-btn">Clear all caches</button>
</div>

<div class="refresh-row">
  <span id="next-refresh">Auto-refreshes every 5 s</span>
  <span id="last-updated"></span>
</div>

<div class="grid">
  <div class="card" id="card-eval">
    <h2>Root Probe Cache (evaluate_fen)</h2>
    <div class="bar-wrap"><div class="bar-fill" id="bar-eval" style="width:0%"></div></div>
    <div id="stats-eval"><div class="stat"><span class="label">Loading…</span></div></div>
  </div>
  <div class="card" id="card-probe">
    <h2>Child Probe Cache (_probe_fen)</h2>
    <div class="bar-wrap"><div class="bar-fill" id="bar-probe" style="width:0%"></div></div>
    <div id="stats-probe"><div class="stat"><span class="label">Loading…</span></div></div>
  </div>
</div>

<div class="card" style="margin-bottom:16px">
  <h2>Thread Pool &amp; Configuration</h2>
  <div id="stats-pool"><div class="stat"><span class="label">Loading…</span></div></div>
</div>

<div class="status" id="status-msg"></div>
{% endif %}

<script src="{{ url_for('static', filename='js/admin.js') }}"></script>
</body>
</html>