-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
137 lines (126 loc) · 6.08 KB
/
index.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
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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Fancy Meilisearch UI</title>
<link rel="icon" href="images/logo.svg" />
<style>
@layer reset, framework, layout, components, utilities;
</style>
<link rel="stylesheet" href="css/framework.css" />
<link rel="stylesheet" href="css/layout.css" />
<link rel="stylesheet" href="css/utilities.css" />
<link rel="stylesheet" href="css/instance.css" />
<link rel="stylesheet" href="css/search.css" />
<link rel="stylesheet" href="css/error-message.css" />
<script type="importmap">
{
"imports": {
"MeiliSearch": "https://esm.sh/meilisearch",
"WebComponent": "https://unpkg.com/web-component-base@latest/index.js",
"FileSize": "https://cdn.filesizejs.com/filesize.min.js"
}
}
</script>
<script src="js/meili-instance.js" type="module"></script>
<script src="js/instance-settings.js" type="module"></script>
<script src="js/instance-name.js" type="module"></script>
<script src="js/instance-host.js" type="module"></script>
<script src="js/instance-size.js" type="module"></script>
<script src="js/instance-status.js" type="module"></script>
<script src="js/instance-version.js" type="module"></script>
<script src="js/instance-indexes.js" type="module"></script>
<script src="js/index-facets.js" type="module"></script>
<script src="js/search-form.js" type="module"></script>
<script src="js/search-results.js" type="module"></script>
<script src="js/input-field.js" type="module"></script>
<script async src="js/svg-icon.js" type="module"></script>
<script type="module">
document.querySelector("instance-indexes").addEventListener("change", (event) => {
// update search-form's selected index
document.querySelector("search-form")?.setAttribute("index", event.detail.index);
document.querySelector("#query")?.focus();
window.localStorage.setItem("index", event.detail.index);
});
document.querySelector("instance-indexes").addEventListener("load", (event) => {
// select previously selected index on page load
let indexes = Array.from(document.querySelectorAll("index-item")),
index = indexes[0];
if (window.localStorage.getItem("index")) {
index = indexes.find((index) => {
return index.getAttribute("id") === window.localStorage.getItem("index");
});
}
// or fallback to the first index
index?.dispatchEvent(new CustomEvent("click", { bubbles: true }));
});
</script>
</head>
<body>
<meili-instance>
<header>
<div class="flex gap-2 items-center">
<img width="68" height="40" src="images/logo.svg" alt="" />
<div class="flex col">
<h1 class="text-3">Meilisearch UI</h1>
<instance-version class="text-0" onerror="document.querySelector('#instance-settings-dialog').showModal()"></instance-version>
</div>
</div>
<instance-details>
<instance-name></instance-name>
<instance-host></instance-host>
<instance-size></instance-size>
<instance-status></instance-status>
<svg-icon
aria-role="button"
title="Open Instance Settings"
class="pointer"
width="20"
height="20"
icon="settings"
onclick="document.getElementById('instance-settings-dialog').showModal()"
></svg-icon>
</instance-details>
</header>
<nav>
<header>
<h2>Indexes</h2>
<!-- <button id="add-index" aria-label="Create Index">+</button> -->
</header>
<instance-indexes></instance-indexes>
</nav>
<main>
<search-form input="#query" on="input focus">
<section>
<input id="query" name="query" type="search" autocomplete="off" placeholder="search" required />
<result-stats>
<label for="strategy"><input type="checkbox" id="strategy" name="strategy" value="all" title="Search Strategy: All" /> Search Strategy: All</label>
<search-time id="processing-time">0ms</search-time>
<total-hits>0 Hits</total-hits>
</result-stats>
</section>
<search-results>Loading...</search-results>
</search-form>
<index-details>
<h2></h2>
</index-details>
</main>
<dialog id="index-settings-dialog">
<header>Index Settings</header>
<form id="index-settings" method="dialog">
<button>Confirm</button>
</form>
</dialog>
<dialog id="instance-settings-dialog">
<header>Instance Settings</header>
<error-message class="mb-4"></error-message>
<instance-settings>
<input name="name" type="text" placeholder="Default" autocomplete="off" required />
<input name="host" type="url" placeholder="http://localhost:7700" required />
<input name="key" type="text" placeholder="Empty API Key" />
<button>Confirm</button>
</instance-settings>
</dialog>
</meili-instance>
</body>
</html>