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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<!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/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: { session: [], url: [] },
emails: [],
showSessionTable: false,
showUrlTable: false,
showLogData: false,
showEmailData: false,
},
created() {
fetch(new Request('/admin/stats')).then(response => response.json())
.then(response => this.stats = response);
fetch(new Request('/admin/emails')).then(response => response.json())
.then(response => this.emails = response);
}
});
}
</script>
</head>
<body>
<noscript>Please enable Javascript!</noscript>
<h1>
<a class="navigation" href="/" title="marks.kitchen"><</a>
Admin
</h1>
<div>
<h1>Create Post</h1>
<div class="form">
<form action="/admin/posts" method="post" enctype="multipart/form-data">
<div>
<input name="title" placeholder="title">
</div>
<div>
<textarea name="description"></textarea>
</div>
<div>
<span>Tags: <input type="text" name="tags" /></span>
</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="blog">Blog</option>
<option value="index">Index</option>
</select>
</div>
<input type="submit" value="Submit">
</form>
</div>
</div>
<div>
<a href="/admin/chess" class="btn btn-primary">Chess</a>
</div>
<div id="stats">
<h1>Stats</h1>
<div>
<input type="checkbox" id="showSession" v-model="showSessionTable">
<label for="showSession">Show Session Stats</label>
</div>
<div>
<input type="checkbox" id="showUrl" v-model="showUrlTable">
<label for="showUrl">Show URL Stats</label>
</div>
<div>
<input type="checkbox" id="showLog" v-model="showLogData">
<label for="showLog">Show Log</label>
</div>
<div>
<input type="checkbox" id="showEmail" v-model="showEmailData">
<label for="showEmail">Show Emails</label>
</div>
<div v-if="showSessionTable">
{{stats.total}} total sessions
<table class="table session-table">
<tr>
<th>Host</th>
<th>Total Requests</th>
</tr>
<tr v-for="item in stats.session">
<td>{{item.session.substring(0,10)}}...</td>
<td>{{item.c}}</td>
</tr>
</table>
</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.substring(0, Math.min(30, item.url.length))}}</td>
<td>{{item.c}}</td>
</tr>
</table>
<table class="table log-table" v-if="showLogData">
<tr>
<th>Date</th>
<th>Session</th>
<th>Method</th>
<th>Path</th>
</tr>
<tr v-for="item in stats.log">
<td>{{item.createdAt.substring(0,19)}}</td>
<td>{{item.session.substring(0,10)}}...</td>
<td>{{item.method}}</td>
<td>{{item.url.substring(0, Math.min(30, item.url.length))}}</td>
<td>{{item.c}}</td>
</tr>
</table>
<table class="table" v-if="showEmailData">
<tr>
<th>Name</th>
<th>Address</th>
</tr>
<tr v-for="item in emails">
<td>{{item.name}}</td>
<td>{{item.address}}</td>
</tr>
</table>
</div>
</body>
</html>
|