File size: 4,333 Bytes
bbe872c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{% extends "base.html" %}
{% set active = "admin" %}

{% block title %} — admin{% endblock %}

{% block content %}
<h1 class="page-title">Admin</h1>

<!-- Disk Management -->
<div class="card section-card">
  <div class="card-header">
    <h2 class="card-title">Disk Management</h2>
    <div class="card-actions">
      <button class="btn btn-secondary" onclick="deleteSelected()">Delete Selected</button>
      <button class="btn btn-danger" onclick="showPurgeModal()">Purge All</button>
    </div>
  </div>

  <div class="disk-summary">
    <span class="text-secondary">Downloads: <span class="mono">{% if downloads_bytes >= 1073741824 %}{{ "%.1f"|format(downloads_bytes / 1073741824) }} GB{% elif downloads_bytes >= 1048576 %}{{ "%.1f"|format(downloads_bytes / 1048576) }} MB{% else %}{{ "%.1f"|format(downloads_bytes / 1024) }} KB{% endif %}</span></span>
    <span class="text-secondary">Limit: <span class="mono">{{ "%.1f"|format(max_disk_mb / 1024) }} GB</span></span>
    <span class="text-secondary">Usage: <span class="mono">{{ disk_pct }}%</span></span>
  </div>

  <div class="table-scroll">
    <table class="data-table" id="file-table">
      <thead>
        <tr>
          <th class="col-check">
            <input type="checkbox" id="select-all" />
          </th>
          <th>Filename</th>
          <th>Size</th>
          <th>Type</th>
        </tr>
      </thead>
      <tbody>
        {% if files %}
          {% for f in files %}
          <tr>
            <td class="col-check">
              <input type="checkbox" class="file-check" value="{{ f.name }}" />
            </td>
            <td class="mono">{{ f.name }}</td>
            <td class="mono">
              {% if f.size >= 1073741824 %}
                {{ "%.1f"|format(f.size / 1073741824) }} GB
              {% elif f.size >= 1048576 %}
                {{ "%.1f"|format(f.size / 1048576) }} MB
              {% elif f.size >= 1024 %}
                {{ "%.1f"|format(f.size / 1024) }} KB
              {% else %}
                {{ f.size }} B
              {% endif %}
            </td>
            <td>
              {% if f.is_dir %}
                <span class="badge badge-platform">dir</span>
              {% else %}
                <span class="text-secondary">file</span>
              {% endif %}
            </td>
          </tr>
          {% endfor %}
        {% else %}
          <tr>
            <td colspan="4" class="empty-state">No files in downloads directory.</td>
          </tr>
        {% endif %}
      </tbody>
    </table>
  </div>
</div>

<!-- System Info -->
<div class="card section-card">
  <div class="card-header">
    <h2 class="card-title">System Info</h2>
  </div>
  <table class="info-table">
    <tbody>
      <tr>
        <td class="info-key">Files in downloads</td>
        <td class="mono">{{ files|length }}</td>
      </tr>
      <tr>
        <td class="info-key">Space used by downloads</td>
        <td class="mono">{% if downloads_bytes >= 1073741824 %}{{ "%.2f"|format(downloads_bytes / 1073741824) }} GB{% elif downloads_bytes >= 1048576 %}{{ "%.1f"|format(downloads_bytes / 1048576) }} MB{% else %}{{ downloads_bytes }} B{% endif %}</td>
      </tr>
      <tr>
        <td class="info-key">Cleanup limit</td>
        <td class="mono">{{ max_disk_mb }} MB ({{ "%.1f"|format(max_disk_mb / 1024) }} GB)</td>
      </tr>
      <tr>
        <td class="info-key">Usage</td>
        <td class="mono">{{ disk_pct }}%</td>
      </tr>
    </tbody>
  </table>
</div>

<!-- Purge Modal -->
<div class="modal-overlay" id="purge-modal" style="display:none" role="dialog" aria-modal="true" aria-labelledby="purge-modal-title">
  <div class="modal-card modal-card--danger">
    <h2 class="modal-title" id="purge-modal-title">Purge All Files</h2>
    <p class="modal-body">This will permanently delete <strong>all files</strong> in the downloads directory. This action cannot be undone.</p>
    <p class="modal-body">Type <strong>PURGE</strong> to confirm:</p>
    <input type="text" id="purge-confirm" class="filter-input" placeholder="PURGE" autocomplete="off" />
    <div class="modal-actions">
      <button class="btn btn-secondary" onclick="closePurgeModal()">Cancel</button>
      <button class="btn btn-danger" onclick="executePurge()">Purge All Files</button>
    </div>
  </div>
</div>
{% endblock %}