Multi-device support, dynamic grid adaptation, keyboard action
- Multi-device: OpenAllDecks(), GET /api/decks, per-deck PageManagers - Dynamic grid: frontend adapts to connected device layout - Keyboard action: new action type for sending key combos via wtype/xdotool - Key recorder UI: click-based modifier toggles + single key capture - Config: remove hardcoded maxKey validation - Screensaver and auto-switch sync across all decks
This commit is contained in:
@@ -37,6 +37,7 @@ type WebServer struct {
|
||||
cfg *config.Config
|
||||
configPath string
|
||||
pm *PageManager
|
||||
decks []*Deck
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -56,6 +57,12 @@ func (s *WebServer) SetPageManager(pm *PageManager) {
|
||||
s.pm = pm
|
||||
}
|
||||
|
||||
func (s *WebServer) SetDecks(decks []*Deck) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.decks = decks
|
||||
}
|
||||
|
||||
func (s *WebServer) Serve(ctx context.Context, addr string) error {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
@@ -75,6 +82,8 @@ func (s *WebServer) Serve(ctx context.Context, addr string) error {
|
||||
|
||||
mux.HandleFunc("GET /api/models", s.handleGetModels)
|
||||
|
||||
mux.HandleFunc("GET /api/decks", s.handleGetDecks)
|
||||
|
||||
mux.HandleFunc("GET /api/status", s.handleGetStatus)
|
||||
|
||||
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticRoot))))
|
||||
@@ -471,6 +480,19 @@ func (s *WebServer) handleGetModels(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(models)
|
||||
}
|
||||
|
||||
func (s *WebServer) handleGetDecks(w http.ResponseWriter, r *http.Request) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
infos := make([]DeckInfo, 0, len(s.decks))
|
||||
for _, d := range s.decks {
|
||||
infos = append(infos, d.DeckInfo())
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(infos)
|
||||
}
|
||||
|
||||
func (s *WebServer) handleGetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user