mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
switch accounts tab to unix times
should now respect the client's locale.
This commit is contained in:
parent
7dcc9b20a1
commit
6ec2186bdf
5
api.go
5
api.go
@ -1041,16 +1041,15 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
||||
Admin: jfUser.Policy.IsAdministrator,
|
||||
Disabled: jfUser.Policy.IsDisabled,
|
||||
}
|
||||
user.LastActive = "n/a"
|
||||
if !jfUser.LastActivityDate.IsZero() {
|
||||
user.LastActive = app.formatDatetime(jfUser.LastActivityDate.Time)
|
||||
user.LastActive = jfUser.LastActivityDate.Unix()
|
||||
}
|
||||
if email, ok := app.storage.emails[jfUser.ID]; ok {
|
||||
user.Email = email.(string)
|
||||
}
|
||||
expiry, ok := app.storage.users[jfUser.ID]
|
||||
if ok {
|
||||
user.Expiry = app.formatDatetime(expiry)
|
||||
user.Expiry = expiry.Unix()
|
||||
}
|
||||
|
||||
resp.UserList[i] = user
|
||||
|
@ -112,9 +112,9 @@ type respUser struct {
|
||||
ID string `json:"id" example:"fdgsdfg45534fa"` // userID of user
|
||||
Name string `json:"name" example:"jeff"` // Username of user
|
||||
Email string `json:"email,omitempty" example:"jeff@jellyf.in"` // Email address of user (if available)
|
||||
LastActive string `json:"last_active"` // Time of last activity on Jellyfin
|
||||
LastActive int64 `json:"last_active" example:"1617737207510"` // Time of last activity on Jellyfin
|
||||
Admin bool `json:"admin" example:"false"` // Whether or not the user is Administrator
|
||||
Expiry string `json:"expiry" example:"01/02/21 12:00"` // Expiry time of user, if applicable.
|
||||
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.
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { _get, _post, _delete, toggleLoader } from "../modules/common.js";
|
||||
import { _get, _post, _delete, toggleLoader, toDateString } from "../modules/common.js";
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string | undefined;
|
||||
last_active: string;
|
||||
last_active: number;
|
||||
admin: boolean;
|
||||
disabled: boolean;
|
||||
expiry: string;
|
||||
expiry: number;
|
||||
}
|
||||
|
||||
class user implements User {
|
||||
@ -20,7 +20,9 @@ class user implements User {
|
||||
private _emailAddress: string;
|
||||
private _emailEditButton: HTMLElement;
|
||||
private _expiry: HTMLTableDataCellElement;
|
||||
private _expiryUnix: number;
|
||||
private _lastActive: HTMLTableDataCellElement;
|
||||
private _lastActiveUnix: number;
|
||||
id: string;
|
||||
private _selected: boolean;
|
||||
|
||||
@ -67,11 +69,25 @@ class user implements User {
|
||||
}
|
||||
}
|
||||
|
||||
get expiry(): string { return this._expiry.textContent; }
|
||||
set expiry(value: string) { this._expiry.textContent = value; }
|
||||
get expiry(): number { return this._expiryUnix; }
|
||||
set expiry(unix: number) {
|
||||
this._expiryUnix = unix;
|
||||
if (unix == 0) {
|
||||
this._expiry.textContent = "";
|
||||
} else {
|
||||
this._expiry.textContent = toDateString(new Date(unix*1000));
|
||||
}
|
||||
}
|
||||
|
||||
get last_active(): string { return this._lastActive.textContent; }
|
||||
set last_active(value: string) { this._lastActive.textContent = value; }
|
||||
get last_active(): number { return this._lastActiveUnix; }
|
||||
set last_active(unix: number) {
|
||||
this._lastActiveUnix = unix;
|
||||
if (unix == 0) {
|
||||
this._lastActive.textContent == "";
|
||||
} else {
|
||||
this._lastActive.textContent = toDateString(new Date(unix*1000));
|
||||
}
|
||||
}
|
||||
|
||||
private _checkEvent = new CustomEvent("accountCheckEvent");
|
||||
private _uncheckEvent = new CustomEvent("accountUncheckEvent");
|
||||
|
@ -6,6 +6,13 @@ export function createEl(html: string): HTMLElement {
|
||||
return div.firstElementChild as HTMLElement;
|
||||
}
|
||||
|
||||
export function toDateString(date: Date): string {
|
||||
return date.toLocaleDateString() + " " + date.toLocaleString([], {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
})
|
||||
}
|
||||
|
||||
export function serializeForm(id: string): Object {
|
||||
const form = document.getElementById(id) as HTMLFormElement;
|
||||
let formData = {};
|
||||
|
Loading…
Reference in New Issue
Block a user