From 797037fe5da9b632166a17b9e7f57ec2ae0d35e3 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 26 Nov 2024 13:06:40 +0200 Subject: [PATCH] feat: conform to new protocol changes --- go.mod | 2 +- go.sum | 4 +-- internal/client/client.go | 6 ++--- internal/components/partials.templ | 41 +++++++++++++----------------- internal/handlers/api.go | 11 ++++---- 5 files changed, 29 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 0069244..77d5f1e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.src.quest/~liljamo/emerwen-web go 1.23.3 require ( - git.src.quest/~liljamo/emerwen-proto v0.0.0-20241120090258-63eb26154b46 + git.src.quest/~liljamo/emerwen-proto v0.0.0-20241126103339-8aa1fdcc154e github.com/a-h/templ v0.2.793 github.com/alexedwards/scs/v2 v2.8.0 github.com/coreos/go-oidc/v3 v3.11.0 diff --git a/go.sum b/go.sum index 99a9b01..814e3b2 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.src.quest/~liljamo/emerwen-proto v0.0.0-20241120090258-63eb26154b46 h1:+kCaPHVSpiXPVB5GzVP68LrgJ9HvYE7p7tnNUHjpGfM= -git.src.quest/~liljamo/emerwen-proto v0.0.0-20241120090258-63eb26154b46/go.mod h1:TZkTqP3/rDTcJDTDU61QvV+4+TsZIvW0lt4hOiYCrr0= +git.src.quest/~liljamo/emerwen-proto v0.0.0-20241126103339-8aa1fdcc154e h1:oGGhuNBEf9opVrez1lPYS64l5Nd3YEkRSfhuxCoZZFM= +git.src.quest/~liljamo/emerwen-proto v0.0.0-20241126103339-8aa1fdcc154e/go.mod h1:TZkTqP3/rDTcJDTDU61QvV+4+TsZIvW0lt4hOiYCrr0= github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY= github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/alexedwards/scs/v2 v2.8.0 h1:h31yUYoycPuL0zt14c0gd+oqxfRwIj6SOjHdKRZxhEw= diff --git a/internal/client/client.go b/internal/client/client.go index 214b1b7..13ba52c 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -20,9 +20,9 @@ import ( "google.golang.org/grpc/metadata" ) -// Client wraps the emerwen gRPC WebToMasterClient, along with a Context. +// Client wraps the emerwen gRPC CoordinatorControlServiceClient, along with a Context. type Client struct { - Client proto.WebToMasterClient + Client proto.CoordinatorControlServiceClient Ctx context.Context } @@ -33,7 +33,7 @@ func NewClient(c *config.Config) *Client { slog.Error("yay") } - client := proto.NewWebToMasterClient(conn) + client := proto.NewCoordinatorControlServiceClient(conn) // TODO: config read auth_token from file ctx := metadata.AppendToOutgoingContext(context.Background(), "authorization", "Bearer avain_perkele") diff --git a/internal/components/partials.templ b/internal/components/partials.templ index bb16ebb..824a895 100644 --- a/internal/components/partials.templ +++ b/internal/components/partials.templ @@ -5,14 +5,7 @@ import "fmt" import "strings" func getMethodString(target *shared.Target) string { - switch target.Method.(type) { - case *shared.Target_Ping: - return "ping" - case *shared.Target_Get: - return "get" - default: - return "invalid" - } + return shared.Method_name[int32(target.Method)] } templ PartialWorkers(workers []*shared.Worker) { @@ -21,24 +14,24 @@ templ PartialWorkers(workers []*shared.Worker) {
- +
- @trash("/api/worker", worker.Id, "delete worker?") + @trash("/api/worker", worker.WorkerId, "delete worker?")
- @smallDetails("id", worker.Id) + @smallDetails("id", worker.WorkerId)
auth token:
- @eyeToggle(fmt.Sprintf("auth_key_%s", worker.Id)) + @eyeToggle(fmt.Sprintf("auth_key_%s", worker.WorkerId))
targets
- @newTarget(worker.Id) + @newTarget(worker.WorkerId) for _, target := range worker.Targets { @editTarget(target) } @@ -53,7 +46,7 @@ script selectNewTargetMethod(worker_id string) { var value = document.getElementById(worker_id + "_new_target_method_select").value; var get_options = document.getElementById(worker_id + "_new_target_get_options"); - if (value === "get") { + if (value === "GET") { get_options.style.display = "block"; } else { get_options.style.display = "none"; @@ -75,8 +68,8 @@ templ newTarget(worker_id string) {