aboutsummaryrefslogtreecommitdiff
path: root/_www/rescached.js
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-01-22 02:50:19 +0700
committerShulhan <ms@kilabit.info>2021-01-22 02:50:19 +0700
commit2a1e1c368ce9c3a6105aa85192cbaa8fdcbd28bb (patch)
tree4721d843e52c7c6dad28a83b50db4c4a808a7540 /_www/rescached.js
parent4f51cd8d9dee4fe57bf060ae66b9dd180e2625d3 (diff)
downloadrescached-2a1e1c368ce9c3a6105aa85192cbaa8fdcbd28bb.tar.xz
_www: display the list of caches in front page
When user open the rescached web interface, the front page will render and refresh the list of non-local caches per 10 seconds.
Diffstat (limited to '_www/rescached.js')
-rw-r--r--_www/rescached.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/_www/rescached.js b/_www/rescached.js
index 5610e4e..1b76331 100644
--- a/_www/rescached.js
+++ b/_www/rescached.js
@@ -30,6 +30,8 @@ function getRRTypeName(k) {
class Rescached {
static nanoSeconds = 1000000000
+ static apiCaches = "/api/caches"
+ static apiCachesSearch = "/api/caches/search"
static apiHostsd = "/api/hosts.d/"
static apiZoned = "/api/zone.d/"
@@ -38,6 +40,26 @@ class Rescached {
this.env = {}
}
+ async Caches() {
+ const res = await fetch(this.server + Rescached.apiCaches, {
+ headers: {
+ Connection: "keep-alive",
+ },
+ })
+ return await res.json()
+ }
+
+ async Search(query) {
+ console.log("Search: ", query)
+ const res = await fetch(
+ this.server +
+ Rescached.apiCachesSearch +
+ "?query=" +
+ query,
+ )
+ return await res.json()
+ }
+
async HostsFileCreate(name) {
const httpRes = await fetch(
this.server + Rescached.apiHostsd + name,
@@ -55,14 +77,6 @@ class Rescached {
return res
}
- async Search(query) {
- console.log("Search: ", query)
- const res = await fetch(
- this.server + "/api/caches" + "?query=" + query,
- )
- return await res.json()
- }
-
async getEnvironment() {
const httpRes = await fetch(this.server + "/api/environment")
const res = await httpRes.json()