reddit/app/templates/admin.html

92 lines
3.4 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reddit, but better</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div class="container">
<div class="sidebar">
{% for link in sidebar_links %}
<a href="{{ link }}">{{ link }}</a>
{% endfor %}
</div>
<div class="content">
<h1>Admin Panel</h1>
<div class="post">
<h2>Subreddits</h2>
<table>
<tr>
<th>Subreddit</th>
<th>Minimum Score</th>
<th>Fetch by</th>
<th>Fetch max</th>
<th>Update</th>
</tr>
{% for subreddit in subreddits %}
<tr>
<td>/r/{{ subreddit[0] }}</td>
<td>{{ subreddit[1] }}</td>
<td>{{ subreddit[2] }}</td>
<td>{{ subreddit[3] }}</td>
<td><button onclick='deleteEntry("sub","{{ subreddit[0] }}")'>Delete</button></td>
</tr>
{% endfor %}
<tr></tr>
<tr></tr>
<tr>
<form method="post">
<input name="type" type="text" value="sub" hidden>
<td>/r/<input name="name" type="text"></td>
<td><input name="score" type="text" value="100"></td>
<td>
<select name="by">
<option value="day">Day</option>
<option value="week">Week</option>
</select>
</td>
<td><input name="max" type="text" value="100"></td>
<td><button type="submit">Add</button></td>
</form>
</tr>
</table>
</div>
<div class="post">
<h2>Blocked</h2>
<table>
<tr>
<th>Name</th>
</tr>
{% for block in blocks %}
<tr>
<td>{{ block }}</td>
<td><button onclick='deleteEntry("block", "{{ block }}")'>Delete</button></td>
</tr>
{% endfor %}
<tr></tr>
<tr></tr>
<tr>
<form method="post">
<input name="type" type="text" value="block" hidden>
<td><input name="name" type="text"></td>
<td><button type="submit">Add</button></td>
</form>
</tr>
</table>
</div>
</div>
</div>
<script>
function deleteEntry(type, name) {
fetch('/admin?name='+ name + "&type=" + type, {
method: 'DELETE'
}).then(() => {
window.location.href = window.location.href;
});
}
</script>
</body>
</html>