File size: 3,073 Bytes
7235cc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<%- include('header') %>

<div class="tableh1">Admin Control Panel</div>
<div class="tableb">
  <h2>Manage Categories</h2>
  <table class="form-table" style="margin-bottom: 20px;">
    <thead>
      <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Description</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      <% categories.forEach(cat => { %>
        <tr>
          <td><%= cat.cid %></td>
          <td><%= cat.name %></td>
          <td><%= cat.description %></td>
          <td>
            <form action="/admin/category/delete/<%= cat.cid %>" method="POST" style="display:inline;" onsubmit="return confirm('Delete category?');">
              <button type="submit" class="btn" style="background:#e74c3c;">Delete</button>
            </form>
          </td>
        </tr>
      <% }) %>
    </tbody>
  </table>

  <h3>Add New Category</h3>
  <form action="/admin/category/add" method="POST" style="margin-bottom: 30px;">
    <p><input type="text" name="name" placeholder="Category Name" required></p>
    <p><input type="text" name="description" placeholder="Description"></p>
    <p><button type="submit" class="btn">Create Category</button></p>
  </form>

  <hr>

  <h2>Manage Albums</h2>
  <table class="form-table" style="margin-bottom: 20px;">
    <thead>
      <tr>
        <th>ID</th>
        <th>Title</th>
        <th>Category</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      <% albums.forEach(alb => { %>
        <tr>
          <td><%= alb.aid %></td>
          <td><%= alb.title %></td>
          <td>Category #<%= alb.category %></td>
          <td>
            <form action="/admin/album/delete/<%= alb.aid %>" method="POST" style="display:inline;" onsubmit="return confirm('Delete album and all its pictures?');">
              <button type="submit" class="btn" style="background:#e74c3c;">Delete</button>
            </form>
          </td>
        </tr>
      <% }) %>
    </tbody>
  </table>

  <h3>Add New Album</h3>
  <form action="/admin/album/add" method="POST" style="margin-bottom: 30px;">
    <p><input type="text" name="title" placeholder="Album Title" required></p>
    <p><input type="text" name="description" placeholder="Description"></p>
    <p>
      Category:
      <select name="category">
        <option value="0">Root Category</option>
        <% categories.forEach(cat => { %>
          <option value="<%= cat.cid %>"><%= cat.name %></option>
        <% }) %>
      </select>
    </p>
    <p><button type="submit" class="btn">Create Album</button></p>
  </form>

  <hr>

  <h2>Gallery Configuration</h2>
  <form action="/admin/config/update" method="POST">
    <table class="form-table">
      <% configs.forEach(cfg => { %>
        <tr>
          <td><label><%= cfg.name %></label></td>
          <td><input type="text" name="<%= cfg.name %>" value="<%= cfg.value %>"></td>
        </tr>
      <% }) %>
      <tr>
        <td></td>
        <td><button type="submit" class="btn">Save Settings</button></td>
      </tr>
    </table>
  </form>
</div>

<%- include('footer') %>