Files
vibetree/internal/web/handlers_search.go
T
Owen 218687a1ee Initial implementation of inventree
A small IT asset inventory system built around a nested folder tree,
matching the project brief: Go + html/template + Bootstrap 5 + vanilla JS,
SQLite storage (WAL, FKs, migrations), embedded templates/static assets,
single compiled binary.

- AJAX-driven inventory tree: lazy-loaded folder expansion with per-user
  persisted expand state, drag-and-drop move for folders/assets, safe
  delete-with-relocate-or-cascade confirmation, search with breadcrumbs.
- Assets: CRUD, duplicate, move, auto-generated IT-000001-style IDs,
  CSV import (with optional folder auto-create) and export.
- Admin-defined item types with custom fields (text/long_text/number/date/
  boolean/dropdown/url/ip_address).
- Configurable statuses, session-based auth (bcrypt, secure cookies),
  admin/user roles, user management.
- CLI: serve, version, database migrate, database backup; /healthz;
  graceful shutdown; Dockerfile/docker-compose/systemd unit; Go test suite.
2026-08-17 13:34:40 -05:00

23 lines
478 B
Go

package web
import (
"net/http"
"inventree/internal/models"
)
type SearchPanelData struct {
Query string
Results []models.Asset
}
func (a *App) handleSearch(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query().Get("q")
results, err := a.Assets.Search(r.Context(), q, 50)
if err != nil {
writeErr(w, http.StatusInternalServerError, err.Error())
return
}
a.RenderFragment(w, http.StatusOK, "panel_search", SearchPanelData{Query: q, Results: results})
}