blob: 1ec7e15860b3cbcf667a4c4372bc04dc54897937 (
plain)
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
|
<!doctype html>
<html lang="en">
<head>
<title>Mark's Kitchen - Admin</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/css/styles.css">
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
<script>
window.onload = function () {
var feed = new Vue({
el: '#stats',
data: {
stats: {ip: [], url: []},
showIpTable: true,
showUrlTable: true,
},
created() {
fetch(new Request('/admin/stats')).then(response => response.json())
.then(response => this.stats = response);
}
});
}
</script>
</head>
<body>
<div>
<h1>Create Post</h1>
<div class="form">
<form action="/posts" method="post" enctype="multipart/form-data">
<div>
<textarea rows="4" cols="50" name="description"></textarea>
</div>
<div>
Images: <input type="file" name="images" multiple>
</div>
<div>
<select name="type">
<option value="" disabled selected>Select...</option>
<option value="bread">Bread</option>
<option value="index">Index</option>
</select>
</div>
<input type="submit" value="Submit">
</form>
</div>
</div>
<div id="stats">
<h1>Stats</h1>
<div>
<input type="checkbox" id="showIp" v-model="showIpTable">
<label for="showIp">Show IP Stats</label>
</div>
<table class="table ip-table" v-if="showIpTable">
<tr><th>Host</th><th>Total Requests</th></tr>
<tr v-for="item in stats.ip">
<td>{{item.ip}}</td><td>{{item.c}}</td>
</tr>
</table>
<div>
<input type="checkbox" id="showUrl" v-model="showUrlTable">
<label for="showUrl">Show URL Stats</label>
</div>
<table class="table url-table" v-if="showUrlTable">
<tr><th>Method</th><th>Path</th><th>Total Requests</th></tr>
<tr v-for="item in stats.url">
<td>{{item.method}}</td><td>{{item.url}}</td><td>{{item.c}}</td>
</tr>
</table>
</div>
</body>
</html>
|