8357d9d76e
- All 7 pages rewritten: Dashboard, Terminal, Snippets, Keychain, SFTP, Settings, Brief - Apply consistent Lumina glassmorphic theme (rounded-2xl, shadows, borders, tracking) - Fix SVG icons not rendering — return template.HTML instead of string - Fix Alpine x-data scoping: terminal tabs, SFTP modals, snippet tag buttons - Fix dashboard search sending literal ?q=... - Rebuild CSS with all new Tailwind classes (62KB) - Add .air.toml with hot-reload config, docs/PERBAIKANUI.md checklist - Remove unused backup partials
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/model"
|
|
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/store"
|
|
)
|
|
|
|
var deviceStore = model.NewDeviceStore()
|
|
var settingsStore = store.NewSettingsStore()
|
|
|
|
func Settings(c *fiber.Ctx) error {
|
|
data := fiber.Map{
|
|
"View": "settings",
|
|
"Title": "Settings",
|
|
"Config": settingsStore.Get(),
|
|
"Devices": deviceStore.All(),
|
|
"NavItems": navItems,
|
|
}
|
|
if c.Get("HX-Request") != "" {
|
|
return c.Render("settings_content", data)
|
|
}
|
|
return c.Render("settings", data)
|
|
}
|
|
|
|
func UpdateConfig(c *fiber.Ctx) error {
|
|
cfg := settingsStore.Get()
|
|
if v := c.FormValue("theme"); v != "" { cfg.Theme = v }
|
|
if v := c.FormValue("fontSize"); v != "" { cfg.FontSize = parseInt(v, 14) }
|
|
if v := c.FormValue("scrollback"); v != "" { cfg.Scrollback = parseInt(v, 5000) }
|
|
if v := c.FormValue("autoLock"); v != "" { cfg.AutoLock = parseInt(v, 5) }
|
|
cfg.Keepalive = c.FormValue("keepalive") == "on"
|
|
cfg.CopyOnSelect = c.FormValue("copyOnSelect") == "on"
|
|
cfg.BellEnabled = c.FormValue("bellEnabled") == "on"
|
|
cfg.AutoReconnect = c.FormValue("autoReconnect") == "on"
|
|
cfg.BlinkCursor = c.FormValue("blinkCursor") == "on"
|
|
settingsStore.Update(cfg)
|
|
return c.Redirect("/settings", 303)
|
|
}
|
|
|
|
func parseInt(s string, def int) int {
|
|
i := 0
|
|
for _, c := range s {
|
|
if c < '0' || c > '9' { return def }
|
|
i = i*10 + int(c-'0')
|
|
}
|
|
if i == 0 { return def }
|
|
return i
|
|
}
|