-
diff --git a/src/ts/main.ts b/src/ts/main.ts
index 6611626..5c48c19 100644
--- a/src/ts/main.ts
+++ b/src/ts/main.ts
@@ -25,6 +25,8 @@ const elements = {
usersPage: document.getElementById('usersPage') as HTMLInputElement,
usersPerPage: document.getElementById('usersPerPage') as HTMLInputElement,
usersPageCount: document.getElementById('usersPageCount') as HTMLSpanElement,
+ usersPrevPage: document.getElementById('usersPrevPage') as HTMLButtonElement,
+ usersNextPage: document.getElementById('usersNextPage') as HTMLButtonElement,
usersTableBody: document.getElementById('usersTableBody') as HTMLTableSectionElement,
usersNavLink: document.getElementById('usersNavLink') as HTMLAnchorElement,
@@ -105,6 +107,10 @@ elements.searchUsersForm.addEventListener('submit', async e => {
elements.usersTableBody.innerHTML = "";
elements.usersPageCount.innerText = data.totalPageCount!.toString(10);
elements.usersPage.max = data.totalPageCount!.toString(10);
+ if (page == data.totalPageCount) elements.usersNextPage.disabled = true;
+ else elements.usersNextPage.disabled = false;
+ if (page == 1) elements.usersPrevPage.disabled = true;
+ else elements.usersPrevPage.disabled = false;
data.users?.forEach(user => {
var row = elements.usersTableBody.insertRow();
var cell = row.insertCell();
@@ -162,6 +168,16 @@ elements.searchUsersForm.addEventListener('submit', async e => {
});
return false;
});
+elements.usersNextPage.addEventListener('click', async e => {
+ if (parseInt(elements.usersPage.value) >= parseInt(elements.usersPage.max)) return false;
+ elements.usersPage.value = (parseInt(elements.usersPage.value) + 1).toString(10);
+ elements.searchUsersForm.requestSubmit();
+});
+elements.usersPrevPage.addEventListener('click', async e => {
+ if (parseInt(elements.usersPage.value) <= 1) return false;
+ elements.usersPage.value = (parseInt(elements.usersPage.value) - 1).toString(10);
+ elements.searchUsersForm.requestSubmit();
+});
elements.searchBotsForm.addEventListener('submit', async e => {
e.preventDefault();
@@ -288,6 +304,7 @@ function loadLoginForm() {
}
function loadUsersView() {
+ elements.usersPage.value = "1";
elements.searchUsersForm.requestSubmit();
elements.usersNavLink.classList.add('active');
elements.botsNavLink.classList.remove('active');