mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-09 20:00:12 +00:00
accounts: make all components of profile application optional
Basically, added the ability to -not- apply the profile's policy.
This commit is contained in:
parent
a136800ff2
commit
d60dea61db
18
api-users.go
18
api-users.go
@ -1372,7 +1372,9 @@ func (app *appContext) ApplySettings(gc *gin.Context) {
|
|||||||
configuration = profile.Configuration
|
configuration = profile.Configuration
|
||||||
displayprefs = profile.Displayprefs
|
displayprefs = profile.Displayprefs
|
||||||
}
|
}
|
||||||
policy = profile.Policy
|
if req.Policy {
|
||||||
|
policy = profile.Policy
|
||||||
|
}
|
||||||
if req.Ombi && 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 {
|
if profile.Ombi != nil && len(profile.Ombi) != 0 {
|
||||||
ombi = profile.Ombi
|
ombi = profile.Ombi
|
||||||
@ -1394,7 +1396,9 @@ func (app *appContext) ApplySettings(gc *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
applyingFrom = "\"" + user.Name + "\""
|
applyingFrom = "\"" + user.Name + "\""
|
||||||
policy = user.Policy
|
if req.Policy {
|
||||||
|
policy = user.Policy
|
||||||
|
}
|
||||||
if req.Homescreen {
|
if req.Homescreen {
|
||||||
displayprefs, status, err = app.jf.GetDisplayPreferences(req.ID)
|
displayprefs, status, err = app.jf.GetDisplayPreferences(req.ID)
|
||||||
if !(status == 200 || status == 204) || err != nil {
|
if !(status == 200 || status == 204) || err != nil {
|
||||||
@ -1421,9 +1425,13 @@ func (app *appContext) ApplySettings(gc *gin.Context) {
|
|||||||
app.debug.Println("Adding delay between requests for large batch")
|
app.debug.Println("Adding delay between requests for large batch")
|
||||||
}
|
}
|
||||||
for _, id := range req.ApplyTo {
|
for _, id := range req.ApplyTo {
|
||||||
status, err := app.jf.SetPolicy(id, policy)
|
var status int
|
||||||
if !(status == 200 || status == 204) || err != nil {
|
var err error
|
||||||
errors["policy"][id] = fmt.Sprintf("%d: %s", status, err)
|
if req.Policy {
|
||||||
|
status, err = app.jf.SetPolicy(id, policy)
|
||||||
|
if !(status == 200 || status == 204) || err != nil {
|
||||||
|
errors["policy"][id] = fmt.Sprintf("%d: %s", status, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if shouldDelay {
|
if shouldDelay {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
|
@ -101,6 +101,10 @@
|
|||||||
<div class="select ~neutral @low unfocused">
|
<div class="select ~neutral @low unfocused">
|
||||||
<select id="modify-user-users"></select>
|
<select id="modify-user-users"></select>
|
||||||
</div>
|
</div>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" id="modify-user-configuration" checked>
|
||||||
|
<span>{{ .strings.applyConfigurationAndPolicy }}</span>
|
||||||
|
</label>
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input type="checkbox" id="modify-user-homescreen" checked>
|
<input type="checkbox" id="modify-user-homescreen" checked>
|
||||||
<span>{{ .strings.applyHomescreenLayout }}</span>
|
<span>{{ .strings.applyHomescreenLayout }}</span>
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
"useInviteExpiry": "Set expiry from profile/invite",
|
"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.",
|
"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",
|
"applyHomescreenLayout": "Apply homescreen layout",
|
||||||
|
"applyConfigurationAndPolicy": "Apply Jellyfin configuration/policy",
|
||||||
"applyOmbi": "Apply Ombi profile (if available)",
|
"applyOmbi": "Apply Ombi profile (if available)",
|
||||||
"applyJellyseerr": "Apply Jellyseerr profile (if available)",
|
"applyJellyseerr": "Apply Jellyseerr profile (if available)",
|
||||||
"sendDeleteNotificationEmail": "Send notification message",
|
"sendDeleteNotificationEmail": "Send notification message",
|
||||||
|
17
models.go
17
models.go
@ -174,13 +174,16 @@ type ombiUsersDTO struct {
|
|||||||
type modifyEmailsDTO map[string]string
|
type modifyEmailsDTO map[string]string
|
||||||
|
|
||||||
type userSettingsDTO struct {
|
type userSettingsDTO struct {
|
||||||
From string `json:"from"` // Whether to apply from "user" or "profile"
|
From string `json:"from"` // Whether to apply from "user" or "profile"
|
||||||
Profile string `json:"profile"` // Name of profile (if from = "profile")
|
Profile string `json:"profile"` // Name of profile (if from = "profile")
|
||||||
ApplyTo []string `json:"apply_to"` // Users to apply settings to
|
ApplyTo []string `json:"apply_to"` // Users to apply settings to
|
||||||
ID string `json:"id"` // ID of user (if from = "user")
|
ID string `json:"id"` // ID of user (if from = "user")
|
||||||
Homescreen bool `json:"homescreen"` // Whether to apply homescreen layout or not
|
// Note confusing name: "Configuration" on the admin UI just means it in the sense
|
||||||
Ombi bool `json:"ombi"` // Whether to apply ombi profile or not
|
// of the account's settings.
|
||||||
Jellyseerr bool `json:"jellyseerr"` // Whether to apply jellyseerr profile or not
|
Policy bool `json:"configuration"` // Whether to apply jf policy not
|
||||||
|
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 {
|
type announcementDTO struct {
|
||||||
|
@ -795,7 +795,8 @@ export class accountsList {
|
|||||||
private _searchBox = document.getElementById("accounts-search") as HTMLInputElement;
|
private _searchBox = document.getElementById("accounts-search") as HTMLInputElement;
|
||||||
private _search: Search;
|
private _search: Search;
|
||||||
|
|
||||||
private _applyHomesreen = document.getElementById("modify-user-homescreen") as HTMLInputElement;
|
private _applyHomescreen = document.getElementById("modify-user-homescreen") as HTMLInputElement;
|
||||||
|
private _applyConfiguration = document.getElementById("modify-user-configuration") as HTMLInputElement;
|
||||||
private _applyOmbi = document.getElementById("modify-user-ombi") as HTMLInputElement;
|
private _applyOmbi = document.getElementById("modify-user-ombi") as HTMLInputElement;
|
||||||
private _applyJellyseerr = document.getElementById("modify-user-jellyseerr") as HTMLInputElement;
|
private _applyJellyseerr = document.getElementById("modify-user-jellyseerr") as HTMLInputElement;
|
||||||
|
|
||||||
@ -1490,7 +1491,8 @@ export class accountsList {
|
|||||||
toggleLoader(button);
|
toggleLoader(button);
|
||||||
let send = {
|
let send = {
|
||||||
"apply_to": list,
|
"apply_to": list,
|
||||||
"homescreen": this._applyHomesreen.checked,
|
"homescreen": this._applyHomescreen.checked,
|
||||||
|
"configuration": this._applyConfiguration.checked,
|
||||||
"ombi": this._applyOmbi.checked,
|
"ombi": this._applyOmbi.checked,
|
||||||
"jellyseerr": this._applyJellyseerr.checked
|
"jellyseerr": this._applyJellyseerr.checked
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user