From 2a6937228c34a07cedf51adb376ab2d25046d069 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 30 Jul 2024 21:36:06 +0100 Subject: [PATCH] accounts: make ombi/jellyseerr appliction optional on "modify settings" Checkboxes added when applying from a profile. --- api-users.go | 4 ++-- html/admin.html | 52 +++++++++++++++++++++++++----------------- lang/admin/en-us.json | 2 ++ models.go | 2 ++ ts/admin.ts | 1 + ts/modules/accounts.ts | 24 ++++++++++++++++++- 6 files changed, 61 insertions(+), 24 deletions(-) diff --git a/api-users.go b/api-users.go index 3a4891d..ddf8aa2 100644 --- a/api-users.go +++ b/api-users.go @@ -1374,12 +1374,12 @@ func (app *appContext) ApplySettings(gc *gin.Context) { displayprefs = profile.Displayprefs } policy = profile.Policy - if app.config.Section("ombi").Key("enabled").MustBool(false) { + if req.Ombi && app.config.Section("ombi").Key("enabled").MustBool(false) { if profile.Ombi != nil && len(profile.Ombi) != 0 { ombi = profile.Ombi } } - if app.config.Section("jellyseerr").Key("enabled").MustBool(false) { + if req.Jellyseerr && app.config.Section("jellyseerr").Key("enabled").MustBool(false) { if profile.Jellyseerr.Enabled { jellyseerr = profile.Jellyseerr } diff --git a/html/admin.html b/html/admin.html index f7de13e..126f9e1 100644 --- a/html/admin.html +++ b/html/admin.html @@ -84,30 +84,40 @@
×

{{ .strings.modifySettingsDescription }}

-
-
{{ if .referralsEnabled }} diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index 5d514b3..d9d2d93 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -81,6 +81,8 @@ "useInviteExpiry": "Set expiry from profile/invite", "useInviteExpiryNote": "By default, invites expire after 90 days but can be renewed by the user. Enable for the referral to be disabled after the time set.", "applyHomescreenLayout": "Apply homescreen layout", + "applyOmbi": "Apply Ombi profile (if available)", + "applyJellyseerr": "Apply Jellyseerr profile (if available)", "sendDeleteNotificationEmail": "Send notification message", "sendDeleteNotifiationExample": "Your account has been deleted.", "settingsRestart": "Restart", diff --git a/models.go b/models.go index 9bcb93e..9ee770d 100644 --- a/models.go +++ b/models.go @@ -179,6 +179,8 @@ type userSettingsDTO struct { ApplyTo []string `json:"apply_to"` // Users to apply settings to ID string `json:"id"` // ID of user (if from = "user") Homescreen bool `json:"homescreen"` // Whether to apply homescreen layout or not + Ombi bool `json:"ombi"` // Whether to apply ombi profile or not + Jellyseerr bool `json:"jellyseerr"` // Whether to apply jellyseerr profile or not } type announcementDTO struct { diff --git a/ts/admin.ts b/ts/admin.ts index 29098a8..333b9d1 100644 --- a/ts/admin.ts +++ b/ts/admin.ts @@ -187,6 +187,7 @@ login.onLogin = () => { console.log("Logged in."); window.updater = new Updater(); // FIXME: Decide whether to autoload activity or not + window.invites.reload() setInterval(() => { window.invites.reload(); accounts.reload(); }, 30*1000); const currentTab = window.tabs.current; switch (currentTab) { diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts index e90b3ba..d01b7c0 100644 --- a/ts/modules/accounts.ts +++ b/ts/modules/accounts.ts @@ -795,6 +795,10 @@ export class accountsList { private _searchBox = document.getElementById("accounts-search") as HTMLInputElement; private _search: Search; + private _applyHomesreen = document.getElementById("modify-user-homescreen") as HTMLInputElement; + private _applyOmbi = document.getElementById("modify-user-ombi") as HTMLInputElement; + private _applyJellyseerr = document.getElementById("modify-user-jellyseerr") as HTMLInputElement; + private _selectAll = document.getElementById("accounts-select-all") as HTMLInputElement; private _users: { [id: string]: user }; private _ordering: string[] = []; @@ -1459,6 +1463,7 @@ export class accountsList { const modalHeader = document.getElementById("header-modify-user"); modalHeader.textContent = window.lang.quantity("modifySettingsFor", this._collectUsers().length) let list = this._collectUsers(); + (() => { let innerHTML = ""; for (const profile of window.availableProfiles) { @@ -1477,6 +1482,7 @@ export class accountsList { const form = document.getElementById("form-modify-user") as HTMLFormElement; const button = form.querySelector("span.submit") as HTMLSpanElement; + this._modifySettingsProfile.checked = true; this._modifySettingsUser.checked = false; form.onsubmit = (event: Event) => { @@ -1484,7 +1490,9 @@ export class accountsList { toggleLoader(button); let send = { "apply_to": list, - "homescreen": (document.getElementById("modify-user-homescreen") as HTMLInputElement).checked + "homescreen": this._applyHomesreen.checked, + "ombi": this._applyOmbi.checked, + "jellyseerr": this._applyJellyseerr.checked }; if (this._modifySettingsProfile.checked && !this._modifySettingsUser.checked) { send["from"] = "profile"; @@ -1821,6 +1829,16 @@ export class accountsList { }; this._modifySettings.onclick = this.modifyUsers; this._modifySettings.classList.add("unfocused"); + + if (window.ombiEnabled) + this._applyOmbi.parentElement.classList.remove("unfocused"); + else + this._applyOmbi.parentElement.classList.add("unfocused"); + if (window.jellyseerrEnabled) + this._applyJellyseerr.parentElement.classList.remove("unfocused"); + else + this._applyJellyseerr.parentElement.classList.add("unfocused"); + const checkSource = () => { const profileSpan = this._modifySettingsProfile.nextElementSibling as HTMLSpanElement; const userSpan = this._modifySettingsUser.nextElementSibling as HTMLSpanElement; @@ -1831,6 +1849,8 @@ export class accountsList { profileSpan.classList.remove("@low"); userSpan.classList.remove("@high"); userSpan.classList.add("@low"); + this._applyOmbi.parentElement.classList.remove("unfocused"); + this._applyJellyseerr.parentElement.classList.remove("unfocused"); } else { this._userSelect.parentElement.classList.remove("unfocused"); this._profileSelect.parentElement.classList.add("unfocused"); @@ -1838,6 +1858,8 @@ export class accountsList { userSpan.classList.remove("@low"); profileSpan.classList.remove("@high"); profileSpan.classList.add("@low"); + this._applyOmbi.parentElement.classList.add("unfocused"); + this._applyJellyseerr.parentElement.classList.add("unfocused"); } }; this._modifySettingsProfile.onchange = checkSource;