mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
Telegram: Display username on accounts tab
This commit is contained in:
parent
36edd4ab0d
commit
0f41d1e6cf
4
api.go
4
api.go
@ -1171,7 +1171,9 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
|||||||
if ok {
|
if ok {
|
||||||
user.Expiry = expiry.Unix()
|
user.Expiry = expiry.Unix()
|
||||||
}
|
}
|
||||||
|
if tgUser, ok := app.storage.telegram[jfUser.ID]; ok {
|
||||||
|
user.Telegram = tgUser.Username
|
||||||
|
}
|
||||||
resp.UserList[i] = user
|
resp.UserList[i] = user
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,9 @@
|
|||||||
<th><input type="checkbox" value="" id="accounts-select-all"></th>
|
<th><input type="checkbox" value="" id="accounts-select-all"></th>
|
||||||
<th>{{ .strings.username }}</th>
|
<th>{{ .strings.username }}</th>
|
||||||
<th>{{ .strings.emailAddress }}</th>
|
<th>{{ .strings.emailAddress }}</th>
|
||||||
|
{{ if .telegram_enabled }}
|
||||||
|
<th>Telegram</th>
|
||||||
|
{{ end }}
|
||||||
<th>{{ .strings.expiry }}</th>
|
<th>{{ .strings.expiry }}</th>
|
||||||
<th>{{ .strings.lastActiveTime }}</th>
|
<th>{{ .strings.lastActiveTime }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -129,6 +129,7 @@ type respUser struct {
|
|||||||
Admin bool `json:"admin" example:"false"` // Whether or not the user is Administrator
|
Admin bool `json:"admin" example:"false"` // Whether or not the user is Administrator
|
||||||
Expiry int64 `json:"expiry" example:"1617737207510"` // Expiry time of user as Epoch/Unix time.
|
Expiry int64 `json:"expiry" example:"1617737207510"` // Expiry time of user as Epoch/Unix time.
|
||||||
Disabled bool `json:"disabled"` // Whether or not the user is disabled.
|
Disabled bool `json:"disabled"` // Whether or not the user is disabled.
|
||||||
|
Telegram string `json:"telegram"` // Telegram username (if known)
|
||||||
}
|
}
|
||||||
|
|
||||||
type getUsersDTO struct {
|
type getUsersDTO struct {
|
||||||
|
@ -11,6 +11,7 @@ interface User {
|
|||||||
admin: boolean;
|
admin: boolean;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
expiry: number;
|
expiry: number;
|
||||||
|
telegram: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class user implements User {
|
class user implements User {
|
||||||
@ -22,6 +23,8 @@ class user implements User {
|
|||||||
private _email: HTMLInputElement;
|
private _email: HTMLInputElement;
|
||||||
private _emailAddress: string;
|
private _emailAddress: string;
|
||||||
private _emailEditButton: HTMLElement;
|
private _emailEditButton: HTMLElement;
|
||||||
|
private _telegram: HTMLTableDataCellElement;
|
||||||
|
private _telegramUsername: string;
|
||||||
private _expiry: HTMLTableDataCellElement;
|
private _expiry: HTMLTableDataCellElement;
|
||||||
private _expiryUnix: number;
|
private _expiryUnix: number;
|
||||||
private _lastActive: HTMLTableDataCellElement;
|
private _lastActive: HTMLTableDataCellElement;
|
||||||
@ -72,6 +75,18 @@ class user implements User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get telegram(): string { return this._telegramUsername; }
|
||||||
|
set telegram(u: string) {
|
||||||
|
if (!window.telegramEnabled) return;
|
||||||
|
this._telegramUsername = u;
|
||||||
|
if (u == "") {
|
||||||
|
this._telegram.textContent = "";
|
||||||
|
} else {
|
||||||
|
this._telegram.innerHTML = `<a href="https://t.me/${u}" target="_blank">@${u}</a>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
get expiry(): number { return this._expiryUnix; }
|
get expiry(): number { return this._expiryUnix; }
|
||||||
set expiry(unix: number) {
|
set expiry(unix: number) {
|
||||||
this._expiryUnix = unix;
|
this._expiryUnix = unix;
|
||||||
@ -97,13 +112,21 @@ class user implements User {
|
|||||||
|
|
||||||
constructor(user: User) {
|
constructor(user: User) {
|
||||||
this._row = document.createElement("tr") as HTMLTableRowElement;
|
this._row = document.createElement("tr") as HTMLTableRowElement;
|
||||||
this._row.innerHTML = `
|
let innerHTML = `
|
||||||
<td><input type="checkbox" value=""></td>
|
<td><input type="checkbox" value=""></td>
|
||||||
<td><span class="accounts-username"></span> <span class="accounts-admin"></span> <span class="accounts-disabled"></span></td>
|
<td><span class="accounts-username"></span> <span class="accounts-admin"></span> <span class="accounts-disabled"></span></td>
|
||||||
<td><i class="icon ri-edit-line accounts-email-edit"></i><span class="accounts-email-container ml-half"></span></td>
|
<td><i class="icon ri-edit-line accounts-email-edit"></i><span class="accounts-email-container ml-half"></span></td>
|
||||||
<td class="accounts-expiry"></td>
|
|
||||||
<td class="accounts-last-active"></td>
|
|
||||||
`;
|
`;
|
||||||
|
if (window.telegramEnabled) {
|
||||||
|
innerHTML += `
|
||||||
|
<td class="accounts-telegram"></td>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
innerHTML += `
|
||||||
|
<td class="accounts-expiry"></td>
|
||||||
|
<td class="accounts-last-active"></td>
|
||||||
|
`;
|
||||||
|
this._row.innerHTML = innerHTML;
|
||||||
const emailEditor = `<input type="email" class="input ~neutral !normal stealth-input">`;
|
const emailEditor = `<input type="email" class="input ~neutral !normal stealth-input">`;
|
||||||
this._check = this._row.querySelector("input[type=checkbox]") as HTMLInputElement;
|
this._check = this._row.querySelector("input[type=checkbox]") as HTMLInputElement;
|
||||||
this._username = this._row.querySelector(".accounts-username") as HTMLSpanElement;
|
this._username = this._row.querySelector(".accounts-username") as HTMLSpanElement;
|
||||||
@ -111,6 +134,7 @@ class user implements User {
|
|||||||
this._disabled = this._row.querySelector(".accounts-disabled") as HTMLSpanElement;
|
this._disabled = this._row.querySelector(".accounts-disabled") as HTMLSpanElement;
|
||||||
this._email = this._row.querySelector(".accounts-email-container") as HTMLInputElement;
|
this._email = this._row.querySelector(".accounts-email-container") as HTMLInputElement;
|
||||||
this._emailEditButton = this._row.querySelector(".accounts-email-edit") as HTMLElement;
|
this._emailEditButton = this._row.querySelector(".accounts-email-edit") as HTMLElement;
|
||||||
|
this._telegram = this._row.querySelector(".accounts-telegram") as HTMLTableDataCellElement;
|
||||||
this._expiry = this._row.querySelector(".accounts-expiry") as HTMLTableDataCellElement;
|
this._expiry = this._row.querySelector(".accounts-expiry") as HTMLTableDataCellElement;
|
||||||
this._lastActive = this._row.querySelector(".accounts-last-active") as HTMLTableDataCellElement;
|
this._lastActive = this._row.querySelector(".accounts-last-active") as HTMLTableDataCellElement;
|
||||||
this._check.onchange = () => { this.selected = this._check.checked; }
|
this._check.onchange = () => { this.selected = this._check.checked; }
|
||||||
@ -173,6 +197,7 @@ class user implements User {
|
|||||||
this.id = user.id;
|
this.id = user.id;
|
||||||
this.name = user.name;
|
this.name = user.name;
|
||||||
this.email = user.email || "";
|
this.email = user.email || "";
|
||||||
|
this.telegram = user.telegram;
|
||||||
this.last_active = user.last_active;
|
this.last_active = user.last_active;
|
||||||
this.admin = user.admin;
|
this.admin = user.admin;
|
||||||
this.disabled = user.disabled;
|
this.disabled = user.disabled;
|
||||||
@ -188,9 +213,6 @@ class user implements User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class accountsList {
|
export class accountsList {
|
||||||
private _table = document.getElementById("accounts-list") as HTMLTableSectionElement;
|
private _table = document.getElementById("accounts-list") as HTMLTableSectionElement;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user