feat(webui): responsive tweaks for mobile; seed channels from config when DB empty; expose KnownChannels on server
This commit is contained in:
parent
bb60430df2
commit
f78dc43374
2 changed files with 10 additions and 0 deletions
|
|
@ -122,6 +122,7 @@ func main() {
|
||||||
Commit: commit,
|
Commit: commit,
|
||||||
BuiltAt: builtAt,
|
BuiltAt: builtAt,
|
||||||
StartedAt: time.Now(),
|
StartedAt: time.Now(),
|
||||||
|
KnownChannels: cfg.Channels,
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
if err := api.Start(ctx); err != nil && err != http.ErrServerClosed {
|
if err := api.Start(ctx); err != nil && err != http.ErrServerClosed {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ type Server struct {
|
||||||
Commit string
|
Commit string
|
||||||
BuiltAt string
|
BuiltAt string
|
||||||
StartedAt time.Time
|
StartedAt time.Time
|
||||||
|
// Optional seed list from config for /api/channels when DB is empty
|
||||||
|
KnownChannels []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Start(ctx context.Context) error {
|
func (s *Server) Start(ctx context.Context) error {
|
||||||
|
|
@ -217,6 +219,10 @@ func (s *Server) handleUI(w http.ResponseWriter, r *http.Request) {
|
||||||
body { padding: 1rem; }
|
body { padding: 1rem; }
|
||||||
pre { max-height: 50vh; overflow: auto; }
|
pre { max-height: 50vh; overflow: auto; }
|
||||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
|
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.grid { grid-template-columns: 1fr !important; }
|
||||||
|
pre { max-height: 40vh; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const st={token: localStorage.getItem('token')||''};
|
const st={token: localStorage.getItem('token')||''};
|
||||||
|
|
@ -328,6 +334,9 @@ func (s *Server) handleChannels(w http.ResponseWriter, r *http.Request) {
|
||||||
_, _ = w.Write([]byte("store error"))
|
_, _ = w.Write([]byte("store error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(chs) == 0 && len(s.KnownChannels) > 0 {
|
||||||
|
chs = append(chs, s.KnownChannels...)
|
||||||
|
}
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
_ = json.NewEncoder(w).Encode(chs)
|
_ = json.NewEncoder(w).Encode(chs)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue