aboutsummaryrefslogtreecommitdiff
path: root/src/html/admin.html
blob: b2b1f64390d6897af8df832497d3850a105c0f96 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!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: []},
                    showSessionTable: false,
                    showUrlTable: false,
                    showLogData: false,
                },
                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>
                    <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 id="stats">
        <h1>Stats</h1>
        <div>
            <input type="checkbox" id="showSession" v-model="showSessionTable">
            <label for="showSession">Show Session Stats</label>
        </div>
        <table class="table session-table" v-if="showSessionTable">
            <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>
            <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.substring(0, Math.min(30, item.url.length))}}</td>
                <td>{{item.c}}</td>
            </tr>
        </table>
        <div>
            <input type="checkbox" id="showLog" v-model="showLogData">
            <label for="showLog">Show Log</label>
        </div>
        <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}}</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>
    </div>
</body>

</html>