From 8c32bce49eadc6fc55080b5d2807ed30bd4adef2 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Mon, 13 Nov 2023 16:44:12 +0000 Subject: [PATCH] New sites view --- .env.development | 1 + .env.production | 1 + src/app.scss | 68 ++++++++++++++ src/components/RedirectRow.svelte | 8 -- src/components/RouteRow.svelte | 8 -- src/stores/sites.ts | 13 +++ src/stores/target.ts | 6 +- src/utils/pair.ts | 4 + src/views/SitesView.svelte | 126 +++++++++++++++++++++++--- src/views/TargetManagementView.svelte | 54 +---------- test-server/main.go | 34 +++++++ 11 files changed, 236 insertions(+), 87 deletions(-) create mode 100644 src/stores/sites.ts create mode 100644 src/utils/pair.ts diff --git a/.env.development b/.env.development index 7997ffd..6126860 100644 --- a/.env.development +++ b/.env.development @@ -2,3 +2,4 @@ VITE_SSO_ORIGIN=http://localhost:9090 VITE_API_VIOLET=http://localhost:9095/v1/violet VITE_API_ORCHID=http://localhost:9095/v1/orchid +VITE_API_SITE_HOSTING=http://localhost:9095/v1/sites diff --git a/.env.production b/.env.production index d9011dc..88f5f35 100644 --- a/.env.production +++ b/.env.production @@ -2,3 +2,4 @@ VITE_SSO_ORIGIN=https://sso.1f349.com VITE_API_VIOLET=https://api.1f349.com/v1/violet VITE_API_ORCHID=https://api.1f349.com/v1/orchid +VITE_API_SITE_HOSTING=https://sites.1f349.com/api.php diff --git a/src/app.scss b/src/app.scss index b07455e..5a9f9ce 100644 --- a/src/app.scss +++ b/src/app.scss @@ -91,3 +91,71 @@ code, .btn-green { background-color: #04aa6d; } + +table.main-table { + border-collapse: collapse; + border-spacing: 0; + width: 100%; + + thead { + background-color: #333333; + position: sticky; + top: 0; + z-index: 9999; + box-shadow: 0 4px 8px #0003, 0 6px 20px #00000030; + } + + th, + td { + padding: 6px 8px 6px 8px; + text-align: center; + } + + tr:nth-child(2n) { + background-color: #2a2a2a; + } + + tr:nth-child(2n + 1) { + background-color: #242424; + } + + .invert-rows { + tr:nth-child(2n) { + background-color: #242424; + } + + tr:nth-child(2n + 1) { + background-color: #2a2a2a; + } + } +} + +.wrapper { + display: flex; + flex-direction: column; + width: 100%; + height: 100%; + overflow: hidden; + + .scrolling-area { + overflow: auto; + height: 100%; + } +} + +.text-padding { + padding: 4px 16px; +} + +.footer { + height: 50px; + background-color: #2c2c2c; + box-shadow: 0 -4px 8px #0003, 0 -6px 20px #00000030; + display: flex; + flex-direction: row; + + .meta-info { + line-height: 50px; + padding-inline: 16px; + } +} diff --git a/src/components/RedirectRow.svelte b/src/components/RedirectRow.svelte index 7e2367b..5255364 100644 --- a/src/components/RedirectRow.svelte +++ b/src/components/RedirectRow.svelte @@ -47,14 +47,6 @@ {/if} diff --git a/src/views/TargetManagementView.svelte b/src/views/TargetManagementView.svelte index c9380d2..80e500f 100644 --- a/src/views/TargetManagementView.svelte +++ b/src/views/TargetManagementView.svelte @@ -118,7 +118,7 @@
Loading...
{:then} - +
@@ -158,55 +158,3 @@ {/if} - - diff --git a/test-server/main.go b/test-server/main.go index 95a6b31..17b97de 100644 --- a/test-server/main.go +++ b/test-server/main.go @@ -150,6 +150,40 @@ func apiServer(verify mjwt.Verifier) { } json.NewEncoder(rw).Encode(m) })) + r.Handle("/v1/sites", hasPerm(verify, "sites:manage", func(rw http.ResponseWriter, req *http.Request) { + if req.Method == http.MethodPost { + defer req.Body.Close() + dec := json.NewDecoder(req.Body) + var m map[string]string + if err := dec.Decode(&m); err != nil { + http.Error(rw, err.Error(), http.StatusBadRequest) + return + } + switch m["submit"] { + case "secret": + rw.WriteHeader(http.StatusOK) + fmt.Fprintf(rw, "{\"secret\":\"%s\"}\n", uuid.NewString()) + return + case "delete-branch": + rw.WriteHeader(http.StatusOK) + } + return + } + m := make([]any, 0, 40) + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "domain": uuid.NewString() + ".example.com", + "branches": []string{"@", "@beta"}, + }) + } + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "domain": uuid.NewString() + ".example.org", + "branches": []string{"@", "@alpha"}, + }) + } + json.NewEncoder(rw).Encode(m) + })) logger := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { log.Println("[API Server]", req.URL.String())