Rohan Sircar
4 years ago
14 changed files with 213 additions and 185 deletions
-
1package.json
-
14src/main/frontend/admin/main.ts
-
35src/main/frontend/admin/pages/user/ViewUsers.ts
-
8src/main/frontend/common/ajax/Messages.ts
-
15src/main/frontend/common/ajax/Users.ts
-
6src/main/frontend/common/dto/AdminUserDTO.ts
-
6src/main/frontend/common/routes/Admin.ts
-
16src/main/frontend/common/util/Util.ts
-
4src/main/resources/static/css/admin-custom.css
-
8src/main/resources/static/css/admin-table.css
-
1src/main/resources/static/css/dataTables.bootstrap4.min.css
-
122src/main/resources/templates/admin/users.html
-
51src/main/resources/templates/fragments/admin.html
-
7yarn.lock
@ -0,0 +1,35 @@ |
|||
import moment from "moment"; |
|||
import { capitalize } from "../../../common/util/Util"; |
|||
|
|||
export async function viewUsers(authToken: string) { |
|||
// const users = await getOtherUsers(authToken);
|
|||
|
|||
const usersTable = $("#usersTable").DataTable({ |
|||
ajax: { |
|||
url: "/api/admin/get/users", |
|||
headers: { |
|||
"X-AUTH-TOKEN": authToken, |
|||
}, |
|||
dataSrc: "", |
|||
}, |
|||
columns: [ |
|||
{ data: "id" }, |
|||
{ data: "userName" }, |
|||
{ |
|||
data: "role", |
|||
render: (data: string) => { |
|||
return capitalize(data.replace("_", " ").toLowerCase()); |
|||
}, |
|||
}, |
|||
{ |
|||
data: "joinDate", |
|||
render: (data: string, type) => { |
|||
return type === "sort" |
|||
? data |
|||
: moment.utc(data).format("DD/MM/YY").toString(); |
|||
}, |
|||
}, |
|||
], |
|||
lengthMenu: [2, 10, 25, 50, 75, 100], |
|||
}); |
|||
} |
@ -0,0 +1,15 @@ |
|||
import { Routes } from "../routes/Routes"; |
|||
import { createApiHeaders } from "./util"; |
|||
import { AdminUserDTO } from "../dto/AdminUserDTO"; |
|||
|
|||
export async function getOtherUsers( |
|||
authToken: string |
|||
): Promise<AdminUserDTO[]> { |
|||
const response = await fetch(Routes.Admin.getOtherUsers, { |
|||
method: "GET", |
|||
headers: createApiHeaders(authToken), |
|||
}); |
|||
|
|||
let data = (await response.json()) as AdminUserDTO[]; |
|||
return data; |
|||
} |
@ -0,0 +1,6 @@ |
|||
export interface AdminUserDTO { |
|||
id: number; |
|||
userName: string; |
|||
role: string; |
|||
joinDate: string; |
|||
} |
@ -1,5 +1,5 @@ |
|||
export namespace Admin { |
|||
export const getAllMessagesURL = `/api/admin/get/messages/`; //hostAddress set in thymeleaf backend
|
|||
export const reencryptURL = `/api/admin/post/re-encrypt`; |
|||
export const getAllRegularUsersURL = `/api/admin/get/users`; |
|||
export const getAllMessages = `/api/admin/get/messages/`; //hostAddress set in thymeleaf backend
|
|||
export const reencrypt = `/api/admin/post/re-encrypt`; |
|||
export const getOtherUsers = `/api/admin/get/users`; |
|||
} |
@ -0,0 +1,16 @@ |
|||
/** |
|||
* Capitalizes first letters of words in string. |
|||
* @param {string} str String to be modified |
|||
* @param {boolean=false} lower Whether all other letters should be lowercased |
|||
* @return {string} |
|||
* @usage |
|||
* capitalize('fix this string'); // -> 'Fix This String'
|
|||
* capitalize('javaSCrIPT'); // -> 'JavaSCrIPT'
|
|||
* capitalize('javaSCrIPT', true); // -> 'Javascript'
|
|||
*/ |
|||
export function capitalize(str: string, lower = false): string { |
|||
return (lower ? str.toLowerCase() : str).replace( |
|||
/(?:^|\s|["'([{])+\S/g, |
|||
(match) => match.toUpperCase() |
|||
); |
|||
} |
@ -0,0 +1,8 @@ |
|||
label, |
|||
#usersTable_info, |
|||
.dataTables_paginate, |
|||
.paginate_button, |
|||
#usersTable_next, |
|||
#usersTable_previous { |
|||
color: white !important; |
|||
} |
1
src/main/resources/static/css/dataTables.bootstrap4.min.css
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue