mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
profiles: "add jellyseerr" checkbox on profile creation
makes things clearer to new users. Fixes #438.
This commit is contained in:
@@ -62,7 +62,7 @@ func (app *appContext) SetJellyseerrProfile(gc *gin.Context) {
|
||||
}
|
||||
u, err := app.js.UserByID(jellyseerrID)
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedGetUsers, lm.Jellyseerr, err)
|
||||
app.err.Printf(lm.FailedGetUser, jellyseerrID, lm.Jellyseerr, err)
|
||||
respond(500, "Couldn't get user", gc)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,6 +196,21 @@ func (app *appContext) CreateProfile(gc *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if req.Jellyseerr && app.config.Section("jellyseerr").Key("enabled").MustBool(false) {
|
||||
user, err := app.js.MustGetUser(req.ID)
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedGetUser, user.Name, lm.Jellyseerr, err)
|
||||
} else {
|
||||
profile.Jellyseerr.User = user.UserTemplate
|
||||
n, err := app.js.GetNotificationPreferencesByID(user.ID)
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedGetJellyseerrNotificationPrefs, user.ID, err)
|
||||
} else {
|
||||
profile.Jellyseerr.Notifications = n.NotificationsTemplate
|
||||
profile.Jellyseerr.Enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
app.storage.SetProfileKey(req.Name, profile)
|
||||
// Refresh discord bots, profile list
|
||||
if discordEnabled {
|
||||
|
||||
@@ -459,7 +459,7 @@ section.section:not(.\~neutral) {
|
||||
|
||||
@layer components {
|
||||
.switch {
|
||||
@apply flex flex-row gap-1 items-center;
|
||||
@apply flex flex-row gap-2 items-center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -467,25 +467,32 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-add-profile" class="modal">
|
||||
<form class="card relative mx-auto my-[10%] w-11/12 sm:w-4/5 lg:w-1/3" id="form-add-profile" href="">
|
||||
<span class="heading">{{ .strings.addProfile }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.addProfileDescription }}</p>
|
||||
<label>
|
||||
<form class="card relative mx-auto my-[10%] w-11/12 sm:w-4/5 lg:w-1/3 flex flex-col gap-2" id="form-add-profile" href="">
|
||||
<h1 class="heading">{{ .strings.addProfile }} <span class="modal-close">×</span></h1>
|
||||
<p class="content">{{ .strings.addProfileDescription }}</p>
|
||||
<label class="flex flex-col gap-2">
|
||||
<span class="supra">{{ .strings.addProfileNameOf }} </span>
|
||||
<input type="text" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.name }}" id="add-profile-name">
|
||||
<label>
|
||||
<input type="text" class="field input ~neutral @high" placeholder="{{ .strings.name }}" id="add-profile-name">
|
||||
</label>
|
||||
<label class="flex flex-col gap-2">
|
||||
<span class="supra">{{ .strings.user }}</span>
|
||||
<div class="select ~neutral @low mt-4 mb-2">
|
||||
<div class="select ~neutral @low">
|
||||
<select id="add-profile-user"></select>
|
||||
</div>
|
||||
</label>
|
||||
<label class="switch mb-4">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="add-profile-homescreen" checked>
|
||||
<span>{{ .strings.addProfileStoreHomescreenLayout }}</span>
|
||||
</label>
|
||||
{{ if .jellyseerrEnabled }}
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="add-profile-jellyseerr" checked>
|
||||
<span>{{ .strings.addProfileStoreJellyseerr }}</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
<label>
|
||||
<input type="submit" class="unfocused">
|
||||
<span class="button ~urge @low full-width center supra submit">{{ .strings.create }}</span>
|
||||
<span class="button ~urge @low w-full center supra submit">{{ .strings.create }}</span>
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
"addProfileDescription": "Create a Jellyfin user and configure it, then select it below. When this profile is applied to an invite, new users will be created with the settings.",
|
||||
"addProfileNameOf": "Profile Name",
|
||||
"addProfileStoreHomescreenLayout": "Store homescreen layout",
|
||||
"addProfileStoreJellyseerr": "Create Jellyseerr profile",
|
||||
"inviteNoUsersCreated": "None yet!",
|
||||
"inviteUsersCreated": "Created users",
|
||||
"inviteNoProfile": "No Profile",
|
||||
|
||||
@@ -102,6 +102,7 @@ type newProfileDTO struct {
|
||||
ID string `json:"id" example:"ZXhhbXBsZTEyMzQ1Njc4OQo" binding:"required"` // ID of user to source settings from
|
||||
Homescreen bool `json:"homescreen" example:"true"` // Whether to store homescreen layout or not
|
||||
OmbiID string `json:"ombi_id" example:"ZXhhbXBsZTEyMzQ1Njc4OQo"` // ID of Ombi user to source settings from (optional)
|
||||
Jellyseerr bool `json:"jellyseerr"` // Whether or not to generate Jellyseerr profile from user
|
||||
}
|
||||
|
||||
type inviteDTO struct {
|
||||
|
||||
@@ -199,6 +199,7 @@ export class ProfileEditor {
|
||||
private _profileName = document.getElementById("add-profile-name") as HTMLInputElement;
|
||||
private _userSelect = document.getElementById("add-profile-user") as HTMLSelectElement;
|
||||
private _storeHomescreen = document.getElementById("add-profile-homescreen") as HTMLInputElement;
|
||||
private _createJellyseerrProfile = window.jellyseerrEnabled ? document.getElementById("add-profile-jellyseerr") as HTMLInputElement : null;
|
||||
|
||||
get empty(): boolean { return (Object.keys(this._table.children).length == 0) }
|
||||
set empty(state: boolean) {
|
||||
@@ -439,6 +440,7 @@ export class ProfileEditor {
|
||||
}
|
||||
this._userSelect.innerHTML = innerHTML;
|
||||
this._storeHomescreen.checked = true;
|
||||
this._createJellyseerrProfile.checked = true;
|
||||
window.modals.profiles.close();
|
||||
window.modals.addProfile.show();
|
||||
} else {
|
||||
@@ -456,6 +458,7 @@ export class ProfileEditor {
|
||||
"id": this._userSelect.value,
|
||||
"name": this._profileName.value
|
||||
}
|
||||
if (this._createJellyseerrProfile) send["jellyseerr"] = this._createJellyseerrProfile.checked;
|
||||
_post("/profiles", send, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
toggleLoader(button);
|
||||
|
||||
Reference in New Issue
Block a user