Skip to content

Commit

Permalink
Adding, deleting, and editing users and roles (#3)
Browse files Browse the repository at this point in the history
* Fix routing discrepancies
Add docker-compose setup for tests
Disable leader election in UI for single-noce clusters

* Merge pull request #1 from utking/Adding,-deleting,-and-editing-users… (#2)
  • Loading branch information
utking authored Sep 29, 2024
1 parent 74cd127 commit da26835
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
UI_USER=admin
UI_PASSWORD=admin
ETCD_NODES="http://etcd:2379"
ETCD_ADMIN_USER=
ETCD_ADMIN_PASSWORD=
# SSL_KEY=./ssl/key.pem
# SSL_CA=./ssl/ca.pem
# SSL_CERT=./ssl/cert.pem
# LOG_DIR_PATH=logs
ETCD_TIMEOUT=1
26 changes: 26 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '2'

networks:
app-tier:
driver: bridge

services:
Etcd:
image: 'bitnami/etcd:latest'
environment:
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
ports:
- 2379:2379
- 2380:2380
networks:
- app-tier
myapp:
image: 'etcd-ui:local'
volumes:
- ./ssl:/app/ssl:ro
- ./.env.docker:/app/.env:ro
ports:
- 8080:8080
networks:
- app-tier
11 changes: 6 additions & 5 deletions internal/controllers/cluster/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ func clusterIndex(c echo.Context) error {
code,
"cluster/stats.html",
map[string]interface{}{
"Title": "Cluster Stats",
"Error": utils.ErrorMessage(err),
"Items": members,
"Alarms": alarms,
"Header": stats,
"Title": "Cluster Stats",
"Error": utils.ErrorMessage(err),
"Items": members,
"SingleNode": len(members) == 1,
"Alarms": alarms,
"Header": stats,
},
)
}
Expand Down
5 changes: 5 additions & 0 deletions templates/cluster/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h4>Cluster Members</h4>
</thead>

<tbody id="items-list">
{{$singleNode := .data.SingleNode}}
{{range $item := .data.Items}}
<tr>
<td>{{ $item.Name }}</td>
Expand All @@ -64,7 +65,11 @@ <h4>Cluster Members</h4>
<td>{{ $item.Health.Version }}</td>
<td>{{ $item.Health.DBSize }}</td>
<td>
{{if $singleNode}}
{{ hex $item.ID }}
{{else}}
{{ hex $item.ID }} (<a href="/cluster/elect/{{$item.ID}}">elect as leader</a>)
{{end}}
</td>
</tr>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion templates/users/add-roles.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3>{{.data.Title}} for {{.data.Item.Name}}</h3>
<input type="checkbox" name="add_roles" value="{{$item}}">
</td>
<td>
<a href="/cluster/role/{{$item}}">{{$item}}</a>
<a href="/cluster/role?name={{$item}}">{{$item}}</a>
</td>
</tr>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion templates/users/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3>{{.data.Title}}</h3>
placeholder="Username"
autofocus
minlength="2"
name="key"
name="name"
maxlength="256">
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion templates/users/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3>{{.data.Title}}</h3>
<input type="checkbox" name="revoke_roles" value="{{$item}}">
</td>
<td>
<a href="/cluster/role/{{$item}}">{{$item}}</a>
<a href="/cluster/role?name={{$item}}">{{$item}}</a>
</td>
</tr>
{{ end }}
Expand Down

0 comments on commit da26835

Please sign in to comment.