From 5a0677bac87989b70ce57274431556c63a7102b1 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 19 Oct 2023 22:44:27 +0100 Subject: [PATCH] activity: allow multiple types in route filter --- api-activities.go | 9 +++-- html/admin.html | 88 +++++++++++++++++++++++++++++++++++++++++++ lang/admin/en-us.json | 1 + models.go | 8 ++-- 4 files changed, 99 insertions(+), 7 deletions(-) diff --git a/api-activities.go b/api-activities.go index d6fdd60..305a66f 100644 --- a/api-activities.go +++ b/api-activities.go @@ -96,9 +96,12 @@ func (app *appContext) GetActivities(gc *gin.Context) { req := GetActivitiesDTO{} gc.BindJSON(&req) query := &badgerhold.Query{} - activityType := stringToActivityType(req.Type) - if activityType != ActivityUnknown { - query = badgerhold.Where("Type").Eq(activityType) + activityTypes := make([]interface{}, len(req.Type)) + for i, v := range req.Type { + activityTypes[i] = stringToActivityType(v) + } + if len(activityTypes) != 0 { + query = badgerhold.Where("Type").In(activityTypes...) } if req.Ascending { diff --git a/html/admin.html b/html/admin.html index 48818a9..6ea2dfb 100644 --- a/html/admin.html +++ b/html/admin.html @@ -475,6 +475,7 @@
{{ .strings.invites }} {{ .strings.accounts }} + {{ .strings.activity }} {{ .strings.settings }}
@@ -719,6 +720,93 @@ +
+
+
+ {{ .strings.activity }} + + + +
+ +
+ + +
+
{{ .strings.actions }}
+
+ {{ .quantityStrings.addUser.Singular }} + + {{ .strings.modifySettings }} + {{ if .referralsEnabled }} + {{ .strings.enableReferrals }} + {{ end }} + {{ .strings.extendExpiry }} + + {{ .strings.sendPWR }} + {{ .quantityStrings.deleteUser.Singular }} +
+
+ + + + + + {{ if .jellyfinLogin }} + + {{ end }} + + {{ if .telegramEnabled }} + + {{ end }} + {{ if .matrixEnabled }} + + {{ end }} + {{ if .discordEnabled }} + + {{ end }} + {{ if .referralsEnabled }} + + {{ end }} + + + + + +
{{ .strings.username }}{{ .strings.accessJFA }}{{ .strings.emailAddress }}TelegramMatrixDiscord{{ .strings.referrals }}{{ .strings.expiry }}{{ .strings.lastActiveTime }}
+
+
+ {{ .strings.noResultsFound }} + +
+
+
+
+
diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index 32f473f..e343d1b 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -6,6 +6,7 @@ "invites": "Invites", "invite": "Invite", "accounts": "Accounts", + "activity": "Activity", "settings": "Settings", "inviteMonths": "Months", "inviteDays": "Days", diff --git a/models.go b/models.go index aa77f2f..0a4afa6 100644 --- a/models.go +++ b/models.go @@ -443,10 +443,10 @@ type ActivityDTO struct { } type GetActivitiesDTO struct { - Type string `json:"type"` // Type of activity to get. Leave blank for all. - Limit int `json:"limit"` - Page int `json:"page"` // zero-indexed - Ascending bool `json:"ascending"` + Type []string `json:"type"` // Types of activity to get. Leave blank for all. + Limit int `json:"limit"` + Page int `json:"page"` // zero-indexed + Ascending bool `json:"ascending"` } type GetActivitiesRespDTO struct {