DEVELOPMENT ENVIRONMENT

~liljamo/emerwen-web

ref: 6363d38d035b8b64a35fd40586ab563f07d46601 emerwen-web/internal/components/partials.templ -rw-r--r-- 1.9 KiB
6363d38dJonni Liljamo feat: gRPC client and fetch basic worker details 3 days ago
                                                                                
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
package components

import "git.src.quest/~liljamo/emerwen-proto/go/proto/shared"
import "fmt"

func getMethodString(target *shared.Target) string {
	switch target.Method.(type) {
	case *shared.Target_Ping:
		return "Ping"
	case *shared.Target_Get:
		return "Get"
	default:
		return "fuck"
	}
}

templ PartialWorkers(workers []*shared.Worker) {
	<div class="flex flex-col gap-2">
		for _, worker := range workers {
			<div class="flex flex-col bg-slate-100 p-2">
        <div class="flex gap-1">
          ID: { fmt.Sprintf("%d", worker.Id) }
        </div>
        <div class="flex items-center gap-1 border p-1">
          <div>Auth Token: </div>
          <input class="border" disabled type="password" value={ worker.AuthToken }
						id={ fmt.Sprintf("auth_key_%d", worker.Id) }
					/>
					@eyeToggle(fmt.Sprintf("auth_key_%d", worker.Id))
        </div>
				<details>
					<summary>Targets:</summary>
					<div class="flex flex-col gap-1 p-2">
						for _, target := range worker.Targets {
							<div class="flex flex-col bg-slate-200 p-2">
								<div class="flex gap-1">
									ID: { fmt.Sprintf("%d", target.Id) }
								</div>
								<div class="flex items-center gap-1 border p-1">
									<div>Addr: </div>
									<input class="border" value={ target.Addr }/>
								</div>
								<div class="flex items-center gap-1 border p-1">
									<div>Interval (ms): </div>
									<input class="border" value={ fmt.Sprint(target.Interval) }/>
								</div>
								<div class="flex flex-col gap-1">
									<div>Method:</div>
									switch m := target.Method.(type) {
									case *shared.Target_Ping:
										<div>Ping</div>
									case *shared.Target_Get:
										<div>Get</div>
										<input class="border" value={ fmt.Sprint(m.Get.OkCodes) }/>
									default:
										<div>fuck</div>
									}
								</div>
							</div>
						}
					</div>
				</details>
      </div>
		}
	</div>
}