This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
forked from PonomareVlad/LCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.html
104 lines (92 loc) · 2.92 KB
/
db.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="dark light" name="color-scheme">
<meta content="ie=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
name="viewport">
<title>LCMS DB API Test</title>
<style>
* {
box-sizing: border-box;
}
:root {
height: 100%;
}
body {
height: 100%;
margin: unset;
padding: 20px;
font-family: -apple-system, Helvetica, sans-serif;
}
h1 {
margin-top: unset;
margin-bottom: unset;
}
hr {
width: 100%;
/*height: 1px;*/
border: none;
border-bottom: 1px solid;
}
form {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
pre, output {
width: 100%;
height: 100%;
margin: unset;
}
pre {
overflow-y: scroll;
}
output {
margin: unset;
white-space: pre-wrap;
}
progress {
width: 100%;
}
form input {
margin: .5rem 0;
}
@supports (padding-top: env(safe-area-inset-top)) {
body {
padding: max(env(safe-area-inset-top), 20px) max(env(safe-area-inset-right), 20px) max(env(safe-area-inset-bottom), 20px) max(env(safe-area-inset-left), 20px);
}
}
</style>
<script type="module">
import {db} from '/lib/db/client.mjs'
window.db = db
let pendingRequests = 0
const queue = Promise.resolve()
const requestDB = async () => {
pendingRequests++;
progress.removeAttribute("value")
const query = Object.fromEntries(new FormData(form).entries())
const result = await db.request(method.value, query, collection.value).catch(e => e.result);
response.innerHTML = typeof result == 'object' ? JSON.stringify(result, null, 2) : result
pendingRequests--;
if (pendingRequests) progress.removeAttribute("value"); else progress.value = 100
}
window.onload = () => ['change', 'submit'].forEach(event => form.addEventListener(event, () => queue.then(requestDB)))
</script>
</head>
<body>
<form id="form">
<h1>LCMS DB API Test</h1>
<hr>
<pre><output id="response"></output></pre>
<progress id="progress" value="0"></progress>
<input id="collection" placeholder="collection" type="text">
<input id="method" placeholder="method" type="text">
<input name="args" placeholder="args" type="text">
<input name="chain" placeholder="chain" type="text">
</form>
</body>
</html>