Skip to content

Commit

Permalink
Show rooms in the list
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Oct 20, 2023
1 parent 10507d9 commit cb968d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/api/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Server struct {
PingURL string `json:"ping_url"`
Port string `json:"port,omitempty"`
Replicas uint32 `json:"replicas,omitempty"`
Room string `json:"room,omitempty"`
Tag string `json:"tag,omitempty"`
Zone string `json:"zone,omitempty"`
}
9 changes: 7 additions & 2 deletions pkg/coordinator/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ func (h *Hub) handleWorkerConnection() http.HandlerFunc {
}

func (h *Hub) GetServerList() (r []api.Server) {
debug := h.conf.Coordinator.Debug
h.workers.ForEach(func(w *Worker) {
r = append(r, api.Server{
server := api.Server{
Addr: w.Addr,
Id: w.Id(),
IsBusy: !w.HasSlot(),
Expand All @@ -154,7 +155,11 @@ func (h *Hub) GetServerList() (r []api.Server) {
Port: w.Port,
Tag: w.Tag,
Zone: w.Zone,
})
}
if debug {
server.Room = w.RoomId
}
r = append(r, server)
})
return
}
Expand Down
13 changes: 12 additions & 1 deletion web/js/workerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const workerManager = (() => {
},
'is_busy': {
caption: 'State',
renderer: (data) => data?.is_busy === true ? 'R' : ''
renderer: renderStateEl
},
'use': {
caption: 'Use',
Expand Down Expand Up @@ -112,6 +112,17 @@ const workerManager = (() => {
})
}

function renderStateEl(server) {
const state = server?.is_busy === true ? 'R' : ''
if (server.room) {
return gui.create('a', (el) => {
el.innerText = state;
el.href = "/?id="+server.room;
})
}
return state
}

panel.toggle(false);

trigger.addEventListener('click', () => {
Expand Down

0 comments on commit cb968d7

Please sign in to comment.