2021-04-06 19:53:30 +00:00
|
|
|
import { _get, _post, _delete, toggleLoader, toDateString } from "../modules/common.js";
|
2021-05-03 17:35:27 +00:00
|
|
|
import { templateEmail } from "../modules/settings.js";
|
|
|
|
import { Marked } from "@ts-stack/markdown";
|
|
|
|
import { stripMarkdown } from "../modules/stripmd.js";
|
2020-10-22 16:50:40 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
interface User {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
email: string | undefined;
|
2021-04-06 19:53:30 +00:00
|
|
|
last_active: number;
|
2021-01-05 18:16:23 +00:00
|
|
|
admin: boolean;
|
2021-02-28 17:52:24 +00:00
|
|
|
disabled: boolean;
|
2021-04-06 19:53:30 +00:00
|
|
|
expiry: number;
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
class user implements User {
|
|
|
|
private _row: HTMLTableRowElement;
|
|
|
|
private _check: HTMLInputElement;
|
|
|
|
private _username: HTMLSpanElement;
|
|
|
|
private _admin: HTMLSpanElement;
|
2021-02-28 17:52:24 +00:00
|
|
|
private _disabled: HTMLSpanElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
private _email: HTMLInputElement;
|
|
|
|
private _emailAddress: string;
|
|
|
|
private _emailEditButton: HTMLElement;
|
2021-02-28 17:52:24 +00:00
|
|
|
private _expiry: HTMLTableDataCellElement;
|
2021-04-06 19:53:30 +00:00
|
|
|
private _expiryUnix: number;
|
2021-01-05 18:16:23 +00:00
|
|
|
private _lastActive: HTMLTableDataCellElement;
|
2021-04-06 19:53:30 +00:00
|
|
|
private _lastActiveUnix: number;
|
2021-01-05 18:16:23 +00:00
|
|
|
id: string;
|
|
|
|
private _selected: boolean;
|
|
|
|
|
|
|
|
get selected(): boolean { return this._selected; }
|
|
|
|
set selected(state: boolean) {
|
|
|
|
this._selected = state;
|
|
|
|
this._check.checked = state;
|
|
|
|
state ? document.dispatchEvent(this._checkEvent) : document.dispatchEvent(this._uncheckEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
get name(): string { return this._username.textContent; }
|
|
|
|
set name(value: string) { this._username.textContent = value; }
|
|
|
|
|
|
|
|
get admin(): boolean { return this._admin.classList.contains("chip"); }
|
|
|
|
set admin(state: boolean) {
|
|
|
|
if (state) {
|
|
|
|
this._admin.classList.add("chip", "~info", "ml-1");
|
2021-02-28 17:52:24 +00:00
|
|
|
this._admin.textContent = window.lang.strings("admin");
|
2020-10-22 16:50:40 +00:00
|
|
|
} else {
|
2021-01-05 18:16:23 +00:00
|
|
|
this._admin.classList.remove("chip", "~info", "ml-1");
|
2021-02-28 17:52:24 +00:00
|
|
|
this._admin.textContent = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get disabled(): boolean { return this._disabled.classList.contains("chip"); }
|
|
|
|
set disabled(state: boolean) {
|
|
|
|
if (state) {
|
|
|
|
this._disabled.classList.add("chip", "~warning", "ml-1");
|
|
|
|
this._disabled.textContent = window.lang.strings("disabled");
|
|
|
|
} else {
|
|
|
|
this._disabled.classList.remove("chip", "~warning", "ml-1");
|
|
|
|
this._disabled.textContent = "";
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
get email(): string { return this._emailAddress; }
|
2021-02-05 18:24:27 +00:00
|
|
|
set email(value: string) {
|
|
|
|
this._emailAddress = value;
|
|
|
|
const input = this._email.querySelector("input");
|
|
|
|
if (input) {
|
|
|
|
input.value = value;
|
|
|
|
} else {
|
|
|
|
this._email.textContent = value;
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
|
2021-04-06 19:53:30 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
2021-02-28 17:52:24 +00:00
|
|
|
|
2021-04-06 19:53:30 +00:00
|
|
|
get last_active(): number { return this._lastActiveUnix; }
|
|
|
|
set last_active(unix: number) {
|
|
|
|
this._lastActiveUnix = unix;
|
|
|
|
if (unix == 0) {
|
2021-04-07 13:05:17 +00:00
|
|
|
this._lastActive.textContent == "n/a";
|
2021-04-06 19:53:30 +00:00
|
|
|
} else {
|
|
|
|
this._lastActive.textContent = toDateString(new Date(unix*1000));
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
|
|
|
|
private _checkEvent = new CustomEvent("accountCheckEvent");
|
|
|
|
private _uncheckEvent = new CustomEvent("accountUncheckEvent");
|
|
|
|
|
|
|
|
constructor(user: User) {
|
|
|
|
this._row = document.createElement("tr") as HTMLTableRowElement;
|
|
|
|
this._row.innerHTML = `
|
|
|
|
<td><input type="checkbox" value=""></td>
|
2021-02-28 17:52:24 +00:00
|
|
|
<td><span class="accounts-username"></span> <span class="accounts-admin"></span> <span class="accounts-disabled"></span></td>
|
2021-02-05 18:24:27 +00:00
|
|
|
<td><i class="icon ri-edit-line accounts-email-edit"></i><span class="accounts-email-container ml-half"></span></td>
|
2021-02-28 17:52:24 +00:00
|
|
|
<td class="accounts-expiry"></td>
|
2021-01-05 18:16:23 +00:00
|
|
|
<td class="accounts-last-active"></td>
|
|
|
|
`;
|
2021-02-05 18:24:27 +00:00
|
|
|
const emailEditor = `<input type="email" class="input ~neutral !normal stealth-input">`;
|
2021-01-05 18:16:23 +00:00
|
|
|
this._check = this._row.querySelector("input[type=checkbox]") as HTMLInputElement;
|
|
|
|
this._username = this._row.querySelector(".accounts-username") as HTMLSpanElement;
|
|
|
|
this._admin = this._row.querySelector(".accounts-admin") as HTMLSpanElement;
|
2021-02-28 17:52:24 +00:00
|
|
|
this._disabled = this._row.querySelector(".accounts-disabled") as HTMLSpanElement;
|
2021-02-05 18:24:27 +00:00
|
|
|
this._email = this._row.querySelector(".accounts-email-container") as HTMLInputElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
this._emailEditButton = this._row.querySelector(".accounts-email-edit") as HTMLElement;
|
2021-02-28 17:52:24 +00:00
|
|
|
this._expiry = this._row.querySelector(".accounts-expiry") as HTMLTableDataCellElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
this._lastActive = this._row.querySelector(".accounts-last-active") as HTMLTableDataCellElement;
|
|
|
|
this._check.onchange = () => { this.selected = this._check.checked; }
|
|
|
|
|
|
|
|
const toggleStealthInput = () => {
|
2021-02-05 18:24:27 +00:00
|
|
|
if (this._emailEditButton.classList.contains("ri-edit-line")) {
|
|
|
|
this._email.innerHTML = emailEditor;
|
|
|
|
this._email.querySelector("input").value = this._emailAddress;
|
|
|
|
this._email.classList.remove("ml-half");
|
|
|
|
} else {
|
|
|
|
this._email.textContent = this._emailAddress;
|
|
|
|
this._email.classList.add("ml-half");
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
this._emailEditButton.classList.toggle("ri-check-line");
|
|
|
|
this._emailEditButton.classList.toggle("ri-edit-line");
|
|
|
|
};
|
|
|
|
const outerClickListener = (event: Event) => {
|
|
|
|
if (!(event.target instanceof HTMLElement && (this._email.contains(event.target) || this._emailEditButton.contains(event.target)))) {
|
|
|
|
toggleStealthInput();
|
|
|
|
this.email = this.email;
|
|
|
|
document.removeEventListener("click", outerClickListener);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this._emailEditButton.onclick = () => {
|
2021-02-05 18:24:27 +00:00
|
|
|
if (this._emailEditButton.classList.contains("ri-edit-line")) {
|
2021-01-05 18:16:23 +00:00
|
|
|
document.addEventListener('click', outerClickListener);
|
|
|
|
} else {
|
|
|
|
this._updateEmail();
|
|
|
|
document.removeEventListener('click', outerClickListener);
|
|
|
|
}
|
|
|
|
toggleStealthInput();
|
|
|
|
};
|
|
|
|
|
|
|
|
this.update(user);
|
2021-04-07 14:09:44 +00:00
|
|
|
|
|
|
|
document.addEventListener("timefmt-change", () => {
|
|
|
|
this.expiry = this.expiry;
|
|
|
|
this.last_active = this.last_active;
|
|
|
|
});
|
2020-12-03 20:49:50 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
|
|
|
|
private _updateEmail = () => {
|
|
|
|
let oldEmail = this.email;
|
2021-02-05 18:24:27 +00:00
|
|
|
this.email = this._email.querySelector("input").value;
|
2020-12-03 20:49:50 +00:00
|
|
|
let send = {};
|
2021-01-05 18:16:23 +00:00
|
|
|
send[this.id] = this.email;
|
|
|
|
_post("/users/emails", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 200) {
|
2021-01-12 23:15:12 +00:00
|
|
|
window.notifications.customSuccess("emailChanged", window.lang.var("notifications", "changedEmailAddress", `"${this.name}"`));
|
2020-12-03 20:49:50 +00:00
|
|
|
} else {
|
2021-01-05 18:16:23 +00:00
|
|
|
this.email = oldEmail;
|
2021-01-12 23:15:12 +00:00
|
|
|
window.notifications.customError("emailChanged", window.lang.var("notifications", "errorChangedEmailAddress", `"${this.name}"`));
|
2020-12-03 20:49:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update = (user: User) => {
|
|
|
|
this.id = user.id;
|
|
|
|
this.name = user.name;
|
|
|
|
this.email = user.email || "";
|
|
|
|
this.last_active = user.last_active;
|
|
|
|
this.admin = user.admin;
|
2021-02-28 17:52:24 +00:00
|
|
|
this.disabled = user.disabled;
|
|
|
|
this.expiry = user.expiry;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
asElement = (): HTMLTableRowElement => { return this._row; }
|
|
|
|
remove = () => {
|
|
|
|
if (this.selected) {
|
|
|
|
document.dispatchEvent(this._uncheckEvent);
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
this._row.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class accountsList {
|
|
|
|
private _table = document.getElementById("accounts-list") as HTMLTableSectionElement;
|
|
|
|
|
|
|
|
private _addUserButton = document.getElementById("accounts-add-user") as HTMLSpanElement;
|
2021-02-18 14:58:53 +00:00
|
|
|
private _announceButton = document.getElementById("accounts-announce") as HTMLSpanElement;
|
2021-05-03 17:35:27 +00:00
|
|
|
private _announcePreview: HTMLElement;
|
|
|
|
private _previewLoaded = false;
|
|
|
|
private _announceTextarea = document.getElementById("textarea-announce") as HTMLTextAreaElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
private _deleteUser = document.getElementById("accounts-delete-user") as HTMLSpanElement;
|
2021-04-12 20:28:36 +00:00
|
|
|
private _disableEnable = document.getElementById("accounts-disable-enable") as HTMLSpanElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
private _deleteNotify = document.getElementById("delete-user-notify") as HTMLInputElement;
|
|
|
|
private _deleteReason = document.getElementById("textarea-delete-user") as HTMLTextAreaElement;
|
2021-02-28 17:52:24 +00:00
|
|
|
private _extendExpiry = document.getElementById("accounts-extend-expiry") as HTMLSpanElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
private _modifySettings = document.getElementById("accounts-modify-user") as HTMLSpanElement;
|
|
|
|
private _modifySettingsProfile = document.getElementById("radio-use-profile") as HTMLInputElement;
|
|
|
|
private _modifySettingsUser = document.getElementById("radio-use-user") as HTMLInputElement;
|
|
|
|
private _profileSelect = document.getElementById("modify-user-profiles") as HTMLSelectElement;
|
|
|
|
private _userSelect = document.getElementById("modify-user-users") as HTMLSelectElement;
|
2021-03-13 14:26:29 +00:00
|
|
|
private _search = document.getElementById("accounts-search") as HTMLInputElement;
|
2021-01-05 18:16:23 +00:00
|
|
|
|
|
|
|
private _selectAll = document.getElementById("accounts-select-all") as HTMLInputElement;
|
|
|
|
private _users: { [id: string]: user };
|
2021-03-13 14:26:29 +00:00
|
|
|
private _sortedByName: string[] = [];
|
2021-01-05 18:16:23 +00:00
|
|
|
private _checkCount: number = 0;
|
2021-03-13 14:26:29 +00:00
|
|
|
private _inSearch = false;
|
2021-04-12 20:28:36 +00:00
|
|
|
// Whether the enable/disable button should enable or not.
|
|
|
|
private _shouldEnable = false;
|
2021-01-05 18:16:23 +00:00
|
|
|
|
|
|
|
private _addUserForm = document.getElementById("form-add-user") as HTMLFormElement;
|
|
|
|
private _addUserName = this._addUserForm.querySelector("input[type=text]") as HTMLInputElement;
|
|
|
|
private _addUserEmail = this._addUserForm.querySelector("input[type=email]") as HTMLInputElement;
|
|
|
|
private _addUserPassword = this._addUserForm.querySelector("input[type=password]") as HTMLInputElement;
|
|
|
|
|
2021-02-28 17:52:24 +00:00
|
|
|
private _count = 30;
|
|
|
|
private _populateNumbers = () => {
|
2021-04-08 19:43:01 +00:00
|
|
|
const fieldIDs = ["months", "days", "hours", "minutes"];
|
2021-02-28 17:52:24 +00:00
|
|
|
const prefixes = ["extend-expiry-"];
|
|
|
|
for (let i = 0; i < fieldIDs.length; i++) {
|
|
|
|
for (let j = 0; j < prefixes.length; j++) {
|
|
|
|
const field = document.getElementById(prefixes[j] + fieldIDs[i]);
|
|
|
|
field.textContent = '';
|
|
|
|
for (let n = 0; n <= this._count; n++) {
|
|
|
|
const opt = document.createElement("option") as HTMLOptionElement;
|
|
|
|
opt.textContent = ""+n;
|
|
|
|
opt.value = ""+n;
|
|
|
|
field.appendChild(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-13 14:26:29 +00:00
|
|
|
|
|
|
|
search = (query: string): string[] => {
|
|
|
|
query = query.toLowerCase()
|
|
|
|
let result: string[] = [];
|
|
|
|
if (query.includes(":")) { // Support admin:<true/false> and disabled:<true/false>
|
|
|
|
const words = query.split(" ");
|
|
|
|
query = "";
|
|
|
|
for (let word of words) {
|
|
|
|
if (word.includes(":")) {
|
|
|
|
const querySplit = word.split(":")
|
|
|
|
let state = false;
|
|
|
|
if (querySplit[1] == "true") {
|
|
|
|
state = true;
|
|
|
|
}
|
|
|
|
for (let id in this._users) {
|
|
|
|
const user = this._users[id];
|
|
|
|
let attrib: boolean;
|
|
|
|
if (querySplit[0] == "admin") { attrib = user.admin; }
|
|
|
|
else if (querySplit[0] == "disabled") { attrib = user.disabled; }
|
|
|
|
if (attrib == state) { result.push(id); }
|
|
|
|
}
|
|
|
|
} else { query += word + " "; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (query == "") { return result; }
|
|
|
|
for (let id in this._users) {
|
|
|
|
const user = this._users[id];
|
|
|
|
if (user.name.toLowerCase().includes(query)) {
|
|
|
|
result.push(id);
|
|
|
|
} else if (user.email.toLowerCase().includes(query)) {
|
|
|
|
result.push(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2021-02-28 17:52:24 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
get selectAll(): boolean { return this._selectAll.checked; }
|
2021-03-13 14:26:29 +00:00
|
|
|
set selectAll(state: boolean) {
|
|
|
|
let count = 0;
|
2021-01-05 18:16:23 +00:00
|
|
|
for (let id in this._users) {
|
2021-03-13 14:26:29 +00:00
|
|
|
if (this._table.contains(this._users[id].asElement())) { // Only select visible elements
|
|
|
|
this._users[id].selected = state;
|
|
|
|
count++;
|
|
|
|
}
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
this._selectAll.checked = state;
|
|
|
|
this._selectAll.indeterminate = false;
|
2021-03-13 14:26:29 +00:00
|
|
|
state ? this._checkCount = count : 0;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add = (u: User) => {
|
|
|
|
let domAccount = new user(u);
|
|
|
|
this._users[u.id] = domAccount;
|
2021-03-13 14:26:29 +00:00
|
|
|
this.unhide(u.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
unhide = (id: string) => {
|
|
|
|
const keys = Object.keys(this._users);
|
|
|
|
if (keys.length == 0) {
|
|
|
|
this._table.appendChild(this._users[id].asElement());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._sortedByName = keys.sort((a, b) => this._users[a].name.localeCompare(this._users[b].name));
|
|
|
|
let index = this._sortedByName.indexOf(id)+1;
|
|
|
|
if (index == this._sortedByName.length-1) {
|
|
|
|
this._table.appendChild(this._users[id].asElement());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (index < this._sortedByName.length) {
|
|
|
|
if (this._table.contains(this._users[this._sortedByName[index]].asElement())) {
|
|
|
|
this._table.insertBefore(this._users[id].asElement(), this._users[this._sortedByName[index]].asElement());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
this._table.appendChild(this._users[id].asElement());
|
|
|
|
}
|
|
|
|
|
|
|
|
hide = (id: string) => {
|
|
|
|
const el = this._users[id].asElement();
|
|
|
|
if (this._table.contains(el)) {
|
|
|
|
this._table.removeChild(this._users[id].asElement());
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private _checkCheckCount = () => {
|
2021-03-13 14:26:29 +00:00
|
|
|
const list = this._collectUsers();
|
|
|
|
this._checkCount = list.length;
|
2021-01-05 18:16:23 +00:00
|
|
|
if (this._checkCount == 0) {
|
|
|
|
this._selectAll.indeterminate = false;
|
|
|
|
this._selectAll.checked = false;
|
|
|
|
this._modifySettings.classList.add("unfocused");
|
|
|
|
this._deleteUser.classList.add("unfocused");
|
2021-02-18 14:58:53 +00:00
|
|
|
if (window.emailEnabled) {
|
|
|
|
this._announceButton.classList.add("unfocused");
|
|
|
|
}
|
2021-02-28 17:52:24 +00:00
|
|
|
this._extendExpiry.classList.add("unfocused");
|
2021-04-12 20:28:36 +00:00
|
|
|
this._disableEnable.classList.add("unfocused");
|
2021-01-05 18:16:23 +00:00
|
|
|
} else {
|
2021-03-13 14:26:29 +00:00
|
|
|
let visibleCount = 0;
|
|
|
|
for (let id in this._users) {
|
|
|
|
if (this._table.contains(this._users[id].asElement())) {
|
|
|
|
visibleCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this._checkCount == visibleCount) {
|
2021-01-05 18:16:23 +00:00
|
|
|
this._selectAll.checked = true;
|
|
|
|
this._selectAll.indeterminate = false;
|
|
|
|
} else {
|
|
|
|
this._selectAll.checked = false;
|
|
|
|
this._selectAll.indeterminate = true;
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
this._modifySettings.classList.remove("unfocused");
|
|
|
|
this._deleteUser.classList.remove("unfocused");
|
2021-03-13 14:26:29 +00:00
|
|
|
this._deleteUser.textContent = window.lang.quantity("deleteUser", list.length);
|
2021-02-18 14:58:53 +00:00
|
|
|
if (window.emailEnabled) {
|
|
|
|
this._announceButton.classList.remove("unfocused");
|
|
|
|
}
|
2021-03-13 14:26:29 +00:00
|
|
|
let anyNonExpiries = list.length == 0 ? true : false;
|
2021-04-12 20:28:36 +00:00
|
|
|
// Only show enable/disable button if all selected have the same state.
|
|
|
|
this._shouldEnable = this._users[list[0]].disabled
|
|
|
|
let showDisableEnable = true;
|
2021-02-28 17:52:24 +00:00
|
|
|
for (let id of list) {
|
2021-04-12 20:28:36 +00:00
|
|
|
if (!anyNonExpiries && !this._users[id].expiry) {
|
2021-02-28 17:52:24 +00:00
|
|
|
anyNonExpiries = true;
|
|
|
|
this._extendExpiry.classList.add("unfocused");
|
|
|
|
}
|
2021-04-12 20:28:36 +00:00
|
|
|
if (showDisableEnable && this._users[id].disabled != this._shouldEnable) {
|
|
|
|
showDisableEnable = false;
|
|
|
|
this._disableEnable.classList.add("unfocused");
|
|
|
|
}
|
|
|
|
if (!showDisableEnable && anyNonExpiries) { break; }
|
2021-02-28 17:52:24 +00:00
|
|
|
}
|
|
|
|
if (!anyNonExpiries) {
|
|
|
|
this._extendExpiry.classList.remove("unfocused");
|
|
|
|
}
|
2021-04-12 20:28:36 +00:00
|
|
|
if (showDisableEnable) {
|
|
|
|
let message: string;
|
|
|
|
if (this._shouldEnable) {
|
|
|
|
message = window.lang.strings("reEnable");
|
|
|
|
this._disableEnable.classList.add("~positive");
|
|
|
|
this._disableEnable.classList.remove("~warning");
|
|
|
|
} else {
|
|
|
|
message = window.lang.strings("disable");
|
|
|
|
this._disableEnable.classList.add("~warning");
|
|
|
|
this._disableEnable.classList.remove("~positive");
|
|
|
|
}
|
|
|
|
this._disableEnable.classList.remove("unfocused");
|
|
|
|
this._disableEnable.textContent = message;
|
|
|
|
}
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private _collectUsers = (): string[] => {
|
|
|
|
let list: string[] = [];
|
|
|
|
for (let id in this._users) {
|
2021-03-13 14:26:29 +00:00
|
|
|
if (this._table.contains(this._users[id].asElement()) && this._users[id].selected) { list.push(id); }
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
return list;
|
2020-10-22 16:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
private _addUser = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
const button = this._addUserForm.querySelector("span.submit") as HTMLSpanElement;
|
|
|
|
const send = {
|
|
|
|
"username": this._addUserName.value,
|
|
|
|
"email": this._addUserEmail.value,
|
|
|
|
"password": this._addUserPassword.value
|
|
|
|
};
|
|
|
|
for (let field in send) {
|
|
|
|
if (!send[field]) {
|
2021-01-12 23:15:12 +00:00
|
|
|
window.notifications.customError("addUserBlankField", window.lang.notif("errorBlankFields"));
|
2021-01-05 18:16:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
toggleLoader(button);
|
|
|
|
_post("/users", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(button);
|
2021-01-24 15:19:58 +00:00
|
|
|
if (req.status == 200 || (req.response["user"] as boolean)) {
|
2021-01-12 23:15:12 +00:00
|
|
|
window.notifications.customSuccess("addUser", window.lang.var("notifications", "userCreated", `"${send['username']}"`));
|
2021-01-24 15:19:58 +00:00
|
|
|
if (!req.response["email"]) {
|
|
|
|
window.notifications.customError("sendWelcome", window.lang.notif("errorSendWelcomeEmail"));
|
|
|
|
console.log("User created, but welcome email failed");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
window.notifications.customError("addUser", window.lang.var("notifications", "errorUserCreated", `"${send['username']}"`));
|
|
|
|
}
|
|
|
|
if (req.response["error"] as String) {
|
|
|
|
console.log(req.response["error"]);
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
2021-01-24 15:19:58 +00:00
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
this.reload();
|
|
|
|
window.modals.addUser.close();
|
|
|
|
}
|
2021-01-24 15:19:58 +00:00
|
|
|
}, true);
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
2021-05-03 17:35:27 +00:00
|
|
|
loadPreview = () => {
|
|
|
|
let content = this._announceTextarea.value;
|
|
|
|
if (!this._previewLoaded) {
|
|
|
|
content = stripMarkdown(content);
|
|
|
|
this._announcePreview.textContent = content;
|
|
|
|
} else {
|
|
|
|
content = Marked.parse(content);
|
|
|
|
this._announcePreview.innerHTML = content;
|
|
|
|
}
|
|
|
|
}
|
2021-02-18 14:58:53 +00:00
|
|
|
announce = () => {
|
|
|
|
const modalHeader = document.getElementById("header-announce");
|
2021-03-13 14:26:29 +00:00
|
|
|
modalHeader.textContent = window.lang.quantity("announceTo", this._collectUsers().length);
|
2021-02-18 14:58:53 +00:00
|
|
|
const form = document.getElementById("form-announce") as HTMLFormElement;
|
|
|
|
let list = this._collectUsers();
|
|
|
|
const button = form.querySelector("span.submit") as HTMLSpanElement;
|
|
|
|
const subject = document.getElementById("announce-subject") as HTMLInputElement;
|
2021-05-03 17:35:27 +00:00
|
|
|
|
2021-02-18 14:58:53 +00:00
|
|
|
subject.value = "";
|
2021-05-03 17:35:27 +00:00
|
|
|
this._announceTextarea.value = "";
|
2021-02-18 14:58:53 +00:00
|
|
|
form.onsubmit = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
toggleLoader(button);
|
|
|
|
let send = {
|
|
|
|
"users": list,
|
|
|
|
"subject": subject.value,
|
2021-05-03 17:35:27 +00:00
|
|
|
"message": this._announceTextarea.value
|
2021-02-18 14:58:53 +00:00
|
|
|
}
|
|
|
|
_post("/users/announce", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(button);
|
|
|
|
window.modals.announce.close();
|
|
|
|
if (req.status != 200 && req.status != 204) {
|
|
|
|
window.notifications.customError("announcementError", window.lang.notif("errorFailureCheckLogs"));
|
|
|
|
} else {
|
|
|
|
window.notifications.customSuccess("announcementSuccess", window.lang.notif("sentAnnouncement"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2021-05-03 17:35:27 +00:00
|
|
|
_get("/config/emails/Announcement", null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
const preview = document.getElementById("announce-preview") as HTMLDivElement;
|
|
|
|
if (req.status != 200) {
|
|
|
|
preview.innerHTML = `<pre class="preview-content" class="monospace"></pre>`;
|
|
|
|
window.modals.announce.show();
|
|
|
|
this._previewLoaded = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let templ = req.response as templateEmail;
|
|
|
|
if (!templ.html) {
|
|
|
|
preview.innerHTML = `<pre class="preview-content" class="monospace"></pre>`;
|
|
|
|
this._previewLoaded = false;
|
|
|
|
} else {
|
|
|
|
preview.innerHTML = templ.html;
|
|
|
|
this._previewLoaded = true;
|
|
|
|
}
|
|
|
|
this._announcePreview = preview.getElementsByClassName("preview-content")[0] as HTMLElement;
|
|
|
|
this.loadPreview();
|
|
|
|
window.modals.announce.show();
|
|
|
|
}
|
|
|
|
});
|
2021-02-18 14:58:53 +00:00
|
|
|
}
|
2021-04-12 20:28:36 +00:00
|
|
|
|
|
|
|
enableDisableUsers = () => {
|
|
|
|
// We can share the delete modal for this
|
|
|
|
const modalHeader = document.getElementById("header-delete-user");
|
|
|
|
const form = document.getElementById("form-delete-user") as HTMLFormElement;
|
|
|
|
const button = form.querySelector("span.submit") as HTMLSpanElement;
|
|
|
|
let list = this._collectUsers();
|
|
|
|
if (this._shouldEnable) {
|
|
|
|
modalHeader.textContent = window.lang.quantity("reEnableUsers", list.length);
|
|
|
|
button.textContent = window.lang.strings("reEnable");
|
|
|
|
button.classList.add("~urge");
|
|
|
|
button.classList.remove("~critical");
|
|
|
|
} else {
|
|
|
|
modalHeader.textContent = window.lang.quantity("disableUsers", list.length);
|
|
|
|
button.textContent = window.lang.strings("disable");
|
|
|
|
button.classList.add("~critical");
|
|
|
|
button.classList.remove("~urge");
|
|
|
|
}
|
|
|
|
this._deleteNotify.checked = false;
|
|
|
|
this._deleteReason.value = "";
|
|
|
|
this._deleteReason.classList.add("unfocused");
|
|
|
|
form.onsubmit = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
toggleLoader(button);
|
|
|
|
let send = {
|
|
|
|
"users": list,
|
|
|
|
"enabled": this._shouldEnable,
|
|
|
|
"notify": this._deleteNotify.checked,
|
|
|
|
"reason": this._deleteNotify ? this._deleteReason.value : ""
|
|
|
|
};
|
|
|
|
_post("/users/enable", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(button);
|
|
|
|
window.modals.deleteUser.close();
|
|
|
|
if (req.status != 200 && req.status != 204) {
|
|
|
|
let errorMsg = window.lang.notif("errorFailureCheckLogs");
|
|
|
|
if (!("error" in req.response)) {
|
|
|
|
errorMsg = window.lang.notif("errorPartialFailureCheckLogs");
|
|
|
|
}
|
|
|
|
window.notifications.customError("deleteUserError", errorMsg);
|
|
|
|
} else if (this._shouldEnable) {
|
|
|
|
window.notifications.customSuccess("enableUserSuccess", window.lang.quantity("enabledUser", list.length));
|
|
|
|
} else {
|
|
|
|
window.notifications.customSuccess("disableUserSuccess", window.lang.quantity("disabledUser", list.length));
|
|
|
|
}
|
|
|
|
this.reload();
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
window.modals.deleteUser.show();
|
|
|
|
}
|
2021-01-05 18:16:23 +00:00
|
|
|
|
|
|
|
deleteUsers = () => {
|
|
|
|
const modalHeader = document.getElementById("header-delete-user");
|
|
|
|
let list = this._collectUsers();
|
2021-04-12 20:28:36 +00:00
|
|
|
modalHeader.textContent = window.lang.quantity("deleteNUsers", list.length);
|
2021-01-05 18:16:23 +00:00
|
|
|
const form = document.getElementById("form-delete-user") as HTMLFormElement;
|
|
|
|
const button = form.querySelector("span.submit") as HTMLSpanElement;
|
2021-04-12 20:28:36 +00:00
|
|
|
button.textContent = window.lang.strings("delete");
|
|
|
|
button.classList.add("~critical");
|
|
|
|
button.classList.remove("~urge");
|
2021-01-05 18:16:23 +00:00
|
|
|
this._deleteNotify.checked = false;
|
|
|
|
this._deleteReason.value = "";
|
|
|
|
this._deleteReason.classList.add("unfocused");
|
|
|
|
form.onsubmit = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
toggleLoader(button);
|
|
|
|
let send = {
|
|
|
|
"users": list,
|
|
|
|
"notify": this._deleteNotify.checked,
|
|
|
|
"reason": this._deleteNotify ? this._deleteReason.value : ""
|
|
|
|
};
|
|
|
|
_delete("/users", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(button);
|
|
|
|
window.modals.deleteUser.close();
|
|
|
|
if (req.status != 200 && req.status != 204) {
|
2021-01-12 23:15:12 +00:00
|
|
|
let errorMsg = window.lang.notif("errorFailureCheckLogs");
|
2021-01-05 18:16:23 +00:00
|
|
|
if (!("error" in req.response)) {
|
2021-01-12 23:15:12 +00:00
|
|
|
errorMsg = window.lang.notif("errorPartialFailureCheckLogs");
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
window.notifications.customError("deleteUserError", errorMsg);
|
|
|
|
} else {
|
2021-04-12 20:28:36 +00:00
|
|
|
window.notifications.customSuccess("deleteUserSuccess", window.lang.quantity("deletedUser", list.length));
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
this.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
window.modals.deleteUser.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
modifyUsers = () => {
|
|
|
|
const modalHeader = document.getElementById("header-modify-user");
|
2021-03-13 14:26:29 +00:00
|
|
|
modalHeader.textContent = window.lang.quantity("modifySettingsFor", this._collectUsers().length)
|
2021-01-05 18:16:23 +00:00
|
|
|
let list = this._collectUsers();
|
|
|
|
(() => {
|
|
|
|
let innerHTML = "";
|
|
|
|
for (const profile of window.availableProfiles) {
|
|
|
|
innerHTML += `<option value="${profile}">${profile}</option>`;
|
|
|
|
}
|
|
|
|
this._profileSelect.innerHTML = innerHTML;
|
|
|
|
})();
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
let innerHTML = "";
|
|
|
|
for (let id in this._users) {
|
|
|
|
innerHTML += `<option value="${id}">${this._users[id].name}</option>`;
|
|
|
|
}
|
|
|
|
this._userSelect.innerHTML = innerHTML;
|
|
|
|
})();
|
|
|
|
|
|
|
|
const form = document.getElementById("form-modify-user") as HTMLFormElement;
|
|
|
|
const button = form.querySelector("span.submit") as HTMLSpanElement;
|
|
|
|
this._modifySettingsProfile.checked = true;
|
|
|
|
this._modifySettingsUser.checked = false;
|
|
|
|
form.onsubmit = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
toggleLoader(button);
|
|
|
|
let send = {
|
|
|
|
"apply_to": list,
|
|
|
|
"homescreen": (document.getElementById("modify-user-homescreen") as HTMLInputElement).checked
|
|
|
|
};
|
|
|
|
if (this._modifySettingsProfile.checked && !this._modifySettingsUser.checked) {
|
|
|
|
send["from"] = "profile";
|
|
|
|
send["profile"] = this._profileSelect.value;
|
|
|
|
} else if (this._modifySettingsUser.checked && !this._modifySettingsProfile.checked) {
|
|
|
|
send["from"] = "user";
|
|
|
|
send["id"] = this._userSelect.value;
|
|
|
|
}
|
|
|
|
_post("/users/settings", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
toggleLoader(button);
|
|
|
|
if (req.status == 500) {
|
|
|
|
let response = JSON.parse(req.response);
|
|
|
|
let errorMsg = "";
|
|
|
|
if ("homescreen" in response && "policy" in response) {
|
|
|
|
const homescreen = Object.keys(response["homescreen"]).length;
|
|
|
|
const policy = Object.keys(response["policy"]).length;
|
|
|
|
if (homescreen != 0 && policy == 0) {
|
2021-01-12 23:15:12 +00:00
|
|
|
errorMsg = window.lang.notif("errorSettingsAppliedNoHomescreenLayout");
|
2021-01-05 18:16:23 +00:00
|
|
|
} else if (policy != 0 && homescreen == 0) {
|
2021-01-12 23:15:12 +00:00
|
|
|
errorMsg = window.lang.notif("errorHomescreenAppliedNoSettings");
|
2021-01-05 18:16:23 +00:00
|
|
|
} else if (policy != 0 && homescreen != 0) {
|
2021-01-12 23:15:12 +00:00
|
|
|
errorMsg = window.lang.notif("errorSettingsFailed");
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
} else if ("error" in response) {
|
|
|
|
errorMsg = response["error"];
|
|
|
|
}
|
|
|
|
window.notifications.customError("modifySettingsError", errorMsg);
|
|
|
|
} else if (req.status == 200 || req.status == 204) {
|
2021-03-13 14:26:29 +00:00
|
|
|
window.notifications.customSuccess("modifySettingsSuccess", window.lang.quantity("appliedSettings", this._collectUsers().length));
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
this.reload();
|
|
|
|
window.modals.modifyUser.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
window.modals.modifyUser.show();
|
|
|
|
}
|
|
|
|
|
2021-02-28 17:52:24 +00:00
|
|
|
extendExpiry = () => {
|
|
|
|
const list = this._collectUsers();
|
|
|
|
let applyList: string[] = [];
|
|
|
|
for (let id of list) {
|
|
|
|
if (this._users[id].expiry) {
|
|
|
|
applyList.push(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getElementById("header-extend-expiry").textContent = window.lang.quantity("extendExpiry", applyList.length);
|
|
|
|
const form = document.getElementById("form-extend-expiry") as HTMLFormElement;
|
|
|
|
form.onsubmit = (event: Event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
let send = { "users": applyList }
|
2021-04-08 19:43:01 +00:00
|
|
|
for (let field of ["months", "days", "hours", "minutes"]) {
|
2021-02-28 17:52:24 +00:00
|
|
|
send[field] = +(document.getElementById("extend-expiry-"+field) as HTMLSelectElement).value;
|
|
|
|
}
|
|
|
|
_post("/users/extend", send, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status != 200 && req.status != 204) {
|
|
|
|
window.notifications.customError("extendExpiryError", window.lang.notif("errorFailureCheckLogs"));
|
|
|
|
} else {
|
|
|
|
window.notifications.customSuccess("extendExpiry", window.lang.quantity("extendedExpiry", applyList.length));
|
|
|
|
}
|
|
|
|
window.modals.extendExpiry.close()
|
|
|
|
this.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
window.modals.extendExpiry.show();
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
constructor() {
|
2021-02-28 17:52:24 +00:00
|
|
|
this._populateNumbers();
|
2021-01-05 18:16:23 +00:00
|
|
|
this._users = {};
|
|
|
|
this._selectAll.checked = false;
|
2021-03-13 14:26:29 +00:00
|
|
|
this._selectAll.onchange = () => {
|
|
|
|
this.selectAll = this._selectAll.checked;
|
|
|
|
};
|
2021-01-05 18:16:23 +00:00
|
|
|
document.addEventListener("accountCheckEvent", () => { this._checkCount++; this._checkCheckCount(); });
|
|
|
|
document.addEventListener("accountUncheckEvent", () => { this._checkCount--; this._checkCheckCount(); });
|
|
|
|
this._addUserButton.onclick = window.modals.addUser.toggle;
|
|
|
|
this._addUserForm.addEventListener("submit", this._addUser);
|
|
|
|
|
|
|
|
this._deleteNotify.onchange = () => {
|
|
|
|
if (this._deleteNotify.checked) {
|
|
|
|
this._deleteReason.classList.remove("unfocused");
|
|
|
|
} else {
|
|
|
|
this._deleteReason.classList.add("unfocused");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this._modifySettings.onclick = this.modifyUsers;
|
|
|
|
this._modifySettings.classList.add("unfocused");
|
|
|
|
const checkSource = () => {
|
|
|
|
const profileSpan = this._modifySettingsProfile.nextElementSibling as HTMLSpanElement;
|
|
|
|
const userSpan = this._modifySettingsUser.nextElementSibling as HTMLSpanElement;
|
|
|
|
if (this._modifySettingsProfile.checked) {
|
|
|
|
this._userSelect.parentElement.classList.add("unfocused");
|
|
|
|
this._profileSelect.parentElement.classList.remove("unfocused")
|
|
|
|
profileSpan.classList.add("!high");
|
|
|
|
profileSpan.classList.remove("!normal");
|
|
|
|
userSpan.classList.remove("!high");
|
|
|
|
userSpan.classList.add("!normal");
|
|
|
|
} else {
|
|
|
|
this._userSelect.parentElement.classList.remove("unfocused");
|
|
|
|
this._profileSelect.parentElement.classList.add("unfocused");
|
|
|
|
userSpan.classList.add("!high");
|
|
|
|
userSpan.classList.remove("!normal");
|
|
|
|
profileSpan.classList.remove("!high");
|
|
|
|
profileSpan.classList.add("!normal");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this._modifySettingsProfile.onchange = checkSource;
|
|
|
|
this._modifySettingsUser.onchange = checkSource;
|
|
|
|
|
|
|
|
this._deleteUser.onclick = this.deleteUsers;
|
|
|
|
this._deleteUser.classList.add("unfocused");
|
|
|
|
|
2021-02-18 14:58:53 +00:00
|
|
|
this._announceButton.onclick = this.announce;
|
|
|
|
this._announceButton.classList.add("unfocused");
|
|
|
|
|
2021-02-28 17:52:24 +00:00
|
|
|
this._extendExpiry.onclick = this.extendExpiry;
|
|
|
|
this._extendExpiry.classList.add("unfocused");
|
|
|
|
|
2021-04-12 20:28:36 +00:00
|
|
|
this._disableEnable.onclick = this.enableDisableUsers;
|
|
|
|
this._disableEnable.classList.add("unfocused");
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
if (!window.usernameEnabled) {
|
|
|
|
this._addUserName.classList.add("unfocused");
|
|
|
|
this._addUserName = this._addUserEmail;
|
|
|
|
}
|
|
|
|
/*if (!window.emailEnabled) {
|
|
|
|
this._deleteNotify.parentElement.classList.add("unfocused");
|
|
|
|
this._deleteNotify.checked = false;
|
|
|
|
}*/
|
2021-03-13 14:26:29 +00:00
|
|
|
|
|
|
|
const setVisibility = (users: string[], visible: boolean) => {
|
|
|
|
for (let id in this._users) {
|
|
|
|
if (users.indexOf(id) != -1) {
|
|
|
|
if (visible) {
|
|
|
|
this.unhide(id);
|
|
|
|
} else {
|
|
|
|
this.hide(id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (visible) {
|
|
|
|
this.hide(id);
|
|
|
|
} else {
|
|
|
|
this.unhide(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._search.oninput = () => {
|
|
|
|
const query = this._search.value;
|
|
|
|
if (!query) {
|
|
|
|
setVisibility(Object.keys(this._users), true);
|
|
|
|
this._inSearch = false;
|
|
|
|
} else {
|
|
|
|
this._inSearch = true;
|
|
|
|
setVisibility(this.search(query), true);
|
|
|
|
}
|
|
|
|
this._checkCheckCount();
|
|
|
|
};
|
2021-05-03 17:35:27 +00:00
|
|
|
|
|
|
|
this._announceTextarea.onkeyup = this.loadPreview;
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reload = () => _get("/users", null, (req: XMLHttpRequest) => {
|
|
|
|
if (req.readyState == 4 && req.status == 200) {
|
|
|
|
// same method as inviteList.reload()
|
|
|
|
let accountsOnDOM: { [id: string]: boolean } = {};
|
|
|
|
for (let id in this._users) { accountsOnDOM[id] = true; }
|
|
|
|
for (let u of (req.response["users"] as User[])) {
|
|
|
|
if (u.id in this._users) {
|
|
|
|
this._users[u.id].update(u);
|
|
|
|
delete accountsOnDOM[u.id];
|
|
|
|
} else {
|
|
|
|
this.add(u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let id in accountsOnDOM) {
|
|
|
|
this._users[id].remove();
|
|
|
|
delete this._users[id];
|
|
|
|
}
|
2021-05-03 17:55:46 +00:00
|
|
|
this._checkCheckCount();
|
2021-01-05 18:16:23 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|