mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-28 03:50:10 +00:00
Compare commits
2 Commits
1224aceaa4
...
09972797b7
Author | SHA1 | Date | |
---|---|---|---|
|
09972797b7 | ||
10c8d4ad2f |
14
api-users.go
14
api-users.go
@ -707,7 +707,7 @@ func (app *appContext) DeleteUsers(gc *gin.Context) {
|
|||||||
respondBool(200, true, gc)
|
respondBool(200, true, gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Extend time before the user(s) expiry, or create and expiry if it doesn't exist.
|
// @Summary Extend time before the user(s) expiry, or create an expiry if it doesn't exist.
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param extendExpiryDTO body extendExpiryDTO true "Extend expiry object"
|
// @Param extendExpiryDTO body extendExpiryDTO true "Extend expiry object"
|
||||||
// @Success 200 {object} boolResponse
|
// @Success 200 {object} boolResponse
|
||||||
@ -737,6 +737,17 @@ func (app *appContext) ExtendExpiry(gc *gin.Context) {
|
|||||||
respondBool(204, true, gc)
|
respondBool(204, true, gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Remove an expiry from a user's account.
|
||||||
|
// @Produce json
|
||||||
|
// @Param id path string true "id of user to extend expiry of."
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Router /users/{id}/expiry [delete]
|
||||||
|
// @tags Users
|
||||||
|
func (app *appContext) RemoveExpiry(gc *gin.Context) {
|
||||||
|
app.storage.DeleteUserExpiryKey(gc.Param("id"))
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
|
||||||
// @Summary Enable referrals for the given user(s) based on the rules set in the given invite code, or profile.
|
// @Summary Enable referrals for the given user(s) based on the rules set in the given invite code, or profile.
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param EnableDisableReferralDTO body EnableDisableReferralDTO true "List of users"
|
// @Param EnableDisableReferralDTO body EnableDisableReferralDTO true "List of users"
|
||||||
@ -753,6 +764,7 @@ func (app *appContext) EnableReferralForUsers(gc *gin.Context) {
|
|||||||
var req EnableDisableReferralDTO
|
var req EnableDisableReferralDTO
|
||||||
gc.BindJSON(&req)
|
gc.BindJSON(&req)
|
||||||
mode := gc.Param("mode")
|
mode := gc.Param("mode")
|
||||||
|
|
||||||
source := gc.Param("source")
|
source := gc.Param("source")
|
||||||
useExpiry := gc.Param("useExpiry") == "with-expiry"
|
useExpiry := gc.Param("useExpiry") == "with-expiry"
|
||||||
baseInv := Invite{}
|
baseInv := Invite{}
|
||||||
|
@ -679,7 +679,15 @@
|
|||||||
{{ if .referralsEnabled }}
|
{{ if .referralsEnabled }}
|
||||||
<span class="col button ~urge @low center max-w-[20%]" id="accounts-enable-referrals">{{ .strings.enableReferrals }}</span>
|
<span class="col button ~urge @low center max-w-[20%]" id="accounts-enable-referrals">{{ .strings.enableReferrals }}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<span class="col button ~warning @low center max-w-[20%]" id="accounts-extend-expiry">{{ .strings.extendExpiry }}</span>
|
<div id="accounts-expiry-dropdown" class="col dropdown pb-0i max-w-[20%]" tabindex="0">
|
||||||
|
<span class="w-100 button ~positive @low center" id="accounts-expiry-dropdown-button">{{ .strings.expiry }} <i class="ri-arrow-down-s-line ml-2"></i></span>
|
||||||
|
<div class="dropdown-display">
|
||||||
|
<div class="card ~neutral @low">
|
||||||
|
<span class="button ~warning full-width @low center" id="accounts-extend-expiry">{{ .strings.extendExpiry }}</span>
|
||||||
|
<span class="button ~critical full-width @low center mt-2" id="accounts-remove-expiry">{{ .strings.removeExpiry }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="accounts-disable-enable-dropdown" class="col dropdown manual pb-0i max-w-[20%]" tabindex="0">
|
<div id="accounts-disable-enable-dropdown" class="col dropdown manual pb-0i max-w-[20%]" tabindex="0">
|
||||||
<span class="w-100 button ~positive @low center" id="accounts-disable-enable">{{ .strings.disable }}</span>
|
<span class="w-100 button ~positive @low center" id="accounts-disable-enable">{{ .strings.disable }}</span>
|
||||||
<div class="dropdown-display">
|
<div class="dropdown-display">
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"select": "Select",
|
"select": "Select",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"setExpiry": "Set expiry",
|
|
||||||
"updates": "Updates",
|
"updates": "Updates",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"download": "Download",
|
"download": "Download",
|
||||||
@ -63,6 +62,8 @@
|
|||||||
"keepSearchingDescription": "Only the current loaded activities were searched. Click below if you wish to search all activities.",
|
"keepSearchingDescription": "Only the current loaded activities were searched. Click below if you wish to search all activities.",
|
||||||
"contactThrough": "Contact through:",
|
"contactThrough": "Contact through:",
|
||||||
"extendExpiry": "Extend expiry",
|
"extendExpiry": "Extend expiry",
|
||||||
|
"setExpiry": "Set expiry",
|
||||||
|
"removeExpiry": "Remove expiry",
|
||||||
"sendPWRManual": "User {n} has no method of contact, press copy to get a link to send to them.",
|
"sendPWRManual": "User {n} has no method of contact, press copy to get a link to send to them.",
|
||||||
"sendPWRSuccess": "Password reset link sent.",
|
"sendPWRSuccess": "Password reset link sent.",
|
||||||
"sendPWRSuccessManual": "If the user hasn't received it, press copy to get a link to manually send to them.",
|
"sendPWRSuccessManual": "If the user hasn't received it, press copy to get a link to manually send to them.",
|
||||||
|
@ -173,6 +173,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
|||||||
api.GET(p+"/users", app.GetUsers)
|
api.GET(p+"/users", app.GetUsers)
|
||||||
api.POST(p+"/users", app.NewUserAdmin)
|
api.POST(p+"/users", app.NewUserAdmin)
|
||||||
api.POST(p+"/users/extend", app.ExtendExpiry)
|
api.POST(p+"/users/extend", app.ExtendExpiry)
|
||||||
|
api.DELETE(p+"/users/:id/expiry", app.RemoveExpiry)
|
||||||
api.POST(p+"/users/enable", app.EnableDisableUsers)
|
api.POST(p+"/users/enable", app.EnableDisableUsers)
|
||||||
api.POST(p+"/invites", app.GenerateInvite)
|
api.POST(p+"/invites", app.GenerateInvite)
|
||||||
api.GET(p+"/invites", app.GetInvites)
|
api.GET(p+"/invites", app.GetInvites)
|
||||||
|
@ -769,7 +769,9 @@ export class accountsList {
|
|||||||
private _enableExpiry = document.getElementById("accounts-enable-expiry") as HTMLSpanElement;
|
private _enableExpiry = document.getElementById("accounts-enable-expiry") as HTMLSpanElement;
|
||||||
private _deleteNotify = document.getElementById("delete-user-notify") as HTMLInputElement;
|
private _deleteNotify = document.getElementById("delete-user-notify") as HTMLInputElement;
|
||||||
private _deleteReason = document.getElementById("textarea-delete-user") as HTMLTextAreaElement;
|
private _deleteReason = document.getElementById("textarea-delete-user") as HTMLTextAreaElement;
|
||||||
|
private _expiryDropdown = document.getElementById("accounts-expiry-dropdown") as HTMLElement;
|
||||||
private _extendExpiry = document.getElementById("accounts-extend-expiry") as HTMLSpanElement;
|
private _extendExpiry = document.getElementById("accounts-extend-expiry") as HTMLSpanElement;
|
||||||
|
private _removeExpiry = document.getElementById("accounts-remove-expiry") as HTMLSpanElement;
|
||||||
private _enableExpiryNotify = document.getElementById("expiry-extend-enable") as HTMLInputElement;
|
private _enableExpiryNotify = document.getElementById("expiry-extend-enable") as HTMLInputElement;
|
||||||
private _enableExpiryReason = document.getElementById("textarea-extend-enable") as HTMLTextAreaElement;
|
private _enableExpiryReason = document.getElementById("textarea-extend-enable") as HTMLTextAreaElement;
|
||||||
private _modifySettings = document.getElementById("accounts-modify-user") as HTMLSpanElement;
|
private _modifySettings = document.getElementById("accounts-modify-user") as HTMLSpanElement;
|
||||||
@ -985,7 +987,7 @@ export class accountsList {
|
|||||||
if (window.emailEnabled || window.telegramEnabled) {
|
if (window.emailEnabled || window.telegramEnabled) {
|
||||||
this._announceButton.parentElement.classList.add("unfocused");
|
this._announceButton.parentElement.classList.add("unfocused");
|
||||||
}
|
}
|
||||||
this._extendExpiry.classList.add("unfocused");
|
this._expiryDropdown.classList.add("unfocused");
|
||||||
this._disableEnable.parentElement.classList.add("unfocused");
|
this._disableEnable.parentElement.classList.add("unfocused");
|
||||||
this._sendPWR.classList.add("unfocused");
|
this._sendPWR.classList.add("unfocused");
|
||||||
} else {
|
} else {
|
||||||
@ -1021,7 +1023,7 @@ export class accountsList {
|
|||||||
for (let id of list) {
|
for (let id of list) {
|
||||||
if (!anyNonExpiries && !this._users[id].expiry) {
|
if (!anyNonExpiries && !this._users[id].expiry) {
|
||||||
anyNonExpiries = true;
|
anyNonExpiries = true;
|
||||||
this._extendExpiry.classList.add("unfocused");
|
this._expiryDropdown.classList.add("unfocused");
|
||||||
}
|
}
|
||||||
if (this._users[id].expiry) {
|
if (this._users[id].expiry) {
|
||||||
allNonExpiries = false;
|
allNonExpiries = false;
|
||||||
@ -1040,13 +1042,15 @@ export class accountsList {
|
|||||||
}
|
}
|
||||||
this._settingExpiry = false;
|
this._settingExpiry = false;
|
||||||
if (!anyNonExpiries && !allNonExpiries) {
|
if (!anyNonExpiries && !allNonExpiries) {
|
||||||
this._extendExpiry.classList.remove("unfocused");
|
this._expiryDropdown.classList.remove("unfocused");
|
||||||
this._extendExpiry.textContent = window.lang.strings("extendExpiry");
|
this._extendExpiry.textContent = window.lang.strings("extendExpiry");
|
||||||
|
this._removeExpiry.classList.remove("unfocused");
|
||||||
}
|
}
|
||||||
if (allNonExpiries) {
|
if (allNonExpiries) {
|
||||||
this._extendExpiry.classList.remove("unfocused");
|
this._expiryDropdown.classList.remove("unfocused");
|
||||||
this._extendExpiry.textContent = window.lang.strings("setExpiry");
|
this._extendExpiry.textContent = window.lang.strings("setExpiry");
|
||||||
this._settingExpiry = true;
|
this._settingExpiry = true;
|
||||||
|
this._removeExpiry.classList.add("unfocused");
|
||||||
}
|
}
|
||||||
// Only show "Send PWR" if a maximum of 1 user selected doesn't have a contact method
|
// Only show "Send PWR" if a maximum of 1 user selected doesn't have a contact method
|
||||||
if (noContactCount > 1) {
|
if (noContactCount > 1) {
|
||||||
@ -1598,6 +1602,29 @@ export class accountsList {
|
|||||||
window.modals.enableReferralsUser.show();
|
window.modals.enableReferralsUser.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeExpiry = () => {
|
||||||
|
const list = this._collectUsers();
|
||||||
|
|
||||||
|
let success = true;
|
||||||
|
for (let id of list) {
|
||||||
|
_delete("/users/" + id + "/expiry", null, (req: XMLHttpRequest) => {
|
||||||
|
if (req.readyState != 4) return;
|
||||||
|
if (req.status != 200) {
|
||||||
|
success = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!success) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
window.notifications.customSuccess("modifySettingsSuccess", window.lang.quantity("appliedSettings", list.length));
|
||||||
|
} else {
|
||||||
|
window.notifications.customError("modifySettingsError", window.lang.notif("errorSettingsFailed"));
|
||||||
|
}
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
extendExpiry = (enableUser?: boolean) => {
|
extendExpiry = (enableUser?: boolean) => {
|
||||||
const list = this._collectUsers();
|
const list = this._collectUsers();
|
||||||
let applyList: string[] = [];
|
let applyList: string[] = [];
|
||||||
@ -1792,7 +1819,8 @@ export class accountsList {
|
|||||||
this._announceButton.parentElement.classList.add("unfocused");
|
this._announceButton.parentElement.classList.add("unfocused");
|
||||||
|
|
||||||
this._extendExpiry.onclick = () => { this.extendExpiry(); };
|
this._extendExpiry.onclick = () => { this.extendExpiry(); };
|
||||||
this._extendExpiry.classList.add("unfocused");
|
this._removeExpiry.onclick = () => { this.removeExpiry(); };
|
||||||
|
this._expiryDropdown.classList.add("unfocused");
|
||||||
|
|
||||||
this._disableEnable.onclick = this.enableDisableUsers;
|
this._disableEnable.onclick = this.enableDisableUsers;
|
||||||
this._disableEnable.parentElement.classList.add("unfocused");
|
this._disableEnable.parentElement.classList.add("unfocused");
|
||||||
|
Loading…
Reference in New Issue
Block a user