userpage: show placeholder message card for admins

user-page
Harvey Tindall 1 year ago
parent cc4a97db28
commit e7f7dcbb78
No known key found for this signature in database
GPG Key ID: BBC65952848FB1A2

@ -28,6 +28,14 @@ func (app *appContext) MyDetails(gc *gin.Context) {
}
resp.Username = user.Name
resp.Admin = user.Policy.IsAdministrator
resp.AccountsAdmin = false
if !app.config.Section("ui").Key("allow_all").MustBool(false) {
adminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
if emailStore, ok := app.storage.GetEmailsKey(resp.Id); ok {
resp.AccountsAdmin = emailStore.Admin
}
resp.AccountsAdmin = resp.AccountsAdmin || (adminOnly && resp.Admin)
}
resp.Disabled = user.Policy.IsDisabled
if exp, ok := app.storage.users[user.ID]; ok {

@ -85,7 +85,7 @@
</div>
{{ if index . "PageMessageEnabled" }}
{{ if .PageMessageEnabled }}
<div class="card @low dark:~d_neutral content">
<div class="card @low dark:~d_neutral content" id="card-message">
{{ .PageMessageContent }}
</div>
{{ end }}

@ -23,7 +23,9 @@
"welcomeUser": "Welcome, {user}!",
"addContactMethod": "Add Contact Method",
"editContactMethod": "Edit Contact Method",
"joinTheServer": "Join the server:"
"joinTheServer": "Join the server:",
"customMessagePlaceholderHeader": "Customize this card",
"customMessagePlaceholderContent": "Click the user page edit button in settings to customize this card, or show one on the login screen, and don't worry, the user can't see this."
},
"notifications": {
"errorUserExists": "User already exists.",

@ -380,6 +380,7 @@ type MyDetailsDTO struct {
Username string `json:"username"`
Expiry int64 `json:"expiry"`
Admin bool `json:"admin"`
AccountsAdmin bool `json:"accounts_admin"`
Disabled bool `json:"disabled"`
Email *MyDetailsContactMethodsDTO `json:"email,omitempty"`
Discord *MyDetailsContactMethodsDTO `json:"discord,omitempty"`

@ -62,6 +62,7 @@ interface MyDetails {
username: string;
expiry: number;
admin: boolean;
accounts_admin: boolean;
disabled: boolean;
email?: MyDetailsContactMethod;
discord?: MyDetailsContactMethod;
@ -388,6 +389,23 @@ document.addEventListener("details-reload", () => {
}
expiryCard.expiry = details.expiry;
if (details.accounts_admin) {
let messageCard = document.getElementById("card-message")
if (typeof(messageCard) == "undefined" || messageCard == null) {
messageCard = document.createElement("div");
messageCard.classList.add("card", "@low", "dark:~d_neutral", "content");
messageCard.id = "card-message";
contactCard.parentElement.appendChild(messageCard);
}
if (!messageCard.textContent) {
messageCard.innerHTML = `
<span class="heading mb-2">${window.lang.strings("customMessagePlaceholderHeader")} </span>
<span class="block">${window.lang.strings("customMessagePlaceholderContent")}</span>
`;
}
}
}
});
});

Loading…
Cancel
Save