diff --git a/api.go b/api.go
index 494a19e..75a013c 100644
--- a/api.go
+++ b/api.go
@@ -1171,7 +1171,9 @@ func (app *appContext) GetUsers(gc *gin.Context) {
if ok {
user.Expiry = expiry.Unix()
}
-
+ if tgUser, ok := app.storage.telegram[jfUser.ID]; ok {
+ user.Telegram = tgUser.Username
+ }
resp.UserList[i] = user
i++
}
diff --git a/html/admin.html b/html/admin.html
index 408b2bf..955e1be 100644
--- a/html/admin.html
+++ b/html/admin.html
@@ -504,6 +504,9 @@
|
{{ .strings.username }} |
{{ .strings.emailAddress }} |
+ {{ if .telegram_enabled }}
+ Telegram |
+ {{ end }}
{{ .strings.expiry }} |
{{ .strings.lastActiveTime }} |
diff --git a/models.go b/models.go
index 28a2241..8bb844f 100644
--- a/models.go
+++ b/models.go
@@ -129,6 +129,7 @@ type respUser struct {
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.
Disabled bool `json:"disabled"` // Whether or not the user is disabled.
+ Telegram string `json:"telegram"` // Telegram username (if known)
}
type getUsersDTO struct {
diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts
index 9db78a5..60bef54 100644
--- a/ts/modules/accounts.ts
+++ b/ts/modules/accounts.ts
@@ -11,6 +11,7 @@ interface User {
admin: boolean;
disabled: boolean;
expiry: number;
+ telegram: string;
}
class user implements User {
@@ -22,6 +23,8 @@ class user implements User {
private _email: HTMLInputElement;
private _emailAddress: string;
private _emailEditButton: HTMLElement;
+ private _telegram: HTMLTableDataCellElement;
+ private _telegramUsername: string;
private _expiry: HTMLTableDataCellElement;
private _expiryUnix: number;
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 = `@${u}`;
+ }
+ }
+
+
get expiry(): number { return this._expiryUnix; }
set expiry(unix: number) {
this._expiryUnix = unix;
@@ -97,13 +112,21 @@ class user implements User {
constructor(user: User) {
this._row = document.createElement("tr") as HTMLTableRowElement;
- this._row.innerHTML = `
+ let innerHTML = `
|
|
|
- |
- |
`;
+ if (window.telegramEnabled) {
+ innerHTML += `
+ |
+ `;
+ }
+ innerHTML += `
+ |
+ |
+ `;
+ this._row.innerHTML = innerHTML;
const emailEditor = ``;
this._check = this._row.querySelector("input[type=checkbox]") as HTMLInputElement;
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._email = this._row.querySelector(".accounts-email-container") as HTMLInputElement;
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._lastActive = this._row.querySelector(".accounts-last-active") as HTMLTableDataCellElement;
this._check.onchange = () => { this.selected = this._check.checked; }
@@ -173,6 +197,7 @@ class user implements User {
this.id = user.id;
this.name = user.name;
this.email = user.email || "";
+ this.telegram = user.telegram;
this.last_active = user.last_active;
this.admin = user.admin;
this.disabled = user.disabled;
@@ -188,9 +213,6 @@ class user implements User {
}
}
-
-
-
export class accountsList {
private _table = document.getElementById("accounts-list") as HTMLTableSectionElement;