feat: add org filter dropdown to Dashboard view
Add an org filter select to the dashboard that allows users to narrow the triage queue to a specific organization. The filter uses HTMX to update the view without a full page reload, mirroring the pattern already used in the issues and pulls views. Closes leeworks-agents/gitea-mobile#68 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -188,18 +188,30 @@ func (h *Handler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
token := getToken(r)
|
token := getToken(r)
|
||||||
orgs := h.getUserOrgs(r)
|
orgs := h.getUserOrgs(r)
|
||||||
|
selectedOrg := r.URL.Query().Get("org")
|
||||||
|
|
||||||
type dashboardData struct {
|
type dashboardData struct {
|
||||||
Items []giteaclient.TriageItem
|
Items []giteaclient.TriageItem
|
||||||
Error string
|
Orgs []string
|
||||||
|
SelectedOrg string
|
||||||
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
var data dashboardData
|
data := dashboardData{
|
||||||
|
Orgs: orgs,
|
||||||
|
SelectedOrg: selectedOrg,
|
||||||
|
}
|
||||||
|
|
||||||
if len(orgs) == 0 {
|
if len(orgs) == 0 {
|
||||||
data.Error = "No organizations found. Check your token permissions."
|
data.Error = "No organizations found. Check your token permissions."
|
||||||
} else {
|
} else {
|
||||||
queue, err := h.Client.GetTriageQueue(r.Context(), token, orgs)
|
// Determine which orgs to query.
|
||||||
|
queryOrgs := orgs
|
||||||
|
if selectedOrg != "" {
|
||||||
|
queryOrgs = []string{selectedOrg}
|
||||||
|
}
|
||||||
|
|
||||||
|
queue, err := h.Client.GetTriageQueue(r.Context(), token, queryOrgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("failed to get triage queue", "error", err)
|
slog.Error("failed to get triage queue", "error", err)
|
||||||
data.Error = "Error loading triage queue."
|
data.Error = "Error loading triage queue."
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<h1>Dashboard</h1>
|
<h1>Dashboard</h1>
|
||||||
|
|
||||||
|
{{if gt (len .Orgs) 1}}
|
||||||
|
<div class="filter-bar">
|
||||||
|
<select name="org" hx-get="/" hx-trigger="change" hx-target="#main-content" hx-swap="innerHTML" hx-push-url="true">
|
||||||
|
<option value="">All orgs</option>
|
||||||
|
{{range .Orgs}}
|
||||||
|
<option value="{{.}}" {{if eq . $.SelectedOrg}}selected{{end}}>{{.}}</option>
|
||||||
|
{{end}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .Error}}
|
{{if .Error}}
|
||||||
<p class="empty">{{.Error}}</p>
|
<p class="empty">{{.Error}}</p>
|
||||||
{{else if not .Items}}
|
{{else if not .Items}}
|
||||||
|
|||||||
Reference in New Issue
Block a user