A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB

  1. import moment from "moment";
  2. import { capitalize } from "../../../common/util/Util";
  3. import { AdminUserDTO } from "../../../common/dto/AdminUserDTO";
  4. import log from "loglevel";
  5. export async function viewUsers(authToken: string) {
  6. // const users = await getOtherUsers(authToken);
  7. const usersTable = $("#usersTable").DataTable({
  8. ajax: {
  9. url: "/api/admin/get/users",
  10. headers: {
  11. "X-AUTH-TOKEN": authToken,
  12. },
  13. dataSrc: "",
  14. },
  15. columns: [
  16. { data: "id" },
  17. { data: "userName" },
  18. {
  19. data: "role",
  20. render: (data: string) => {
  21. return capitalize(data.replace("_", " ").toLowerCase());
  22. },
  23. },
  24. {
  25. data: "joinDate",
  26. render: (data: string, type) => {
  27. return type === "sort"
  28. ? data
  29. : moment.utc(data).format("DD/MM/YY").toString();
  30. },
  31. },
  32. ],
  33. buttons: [
  34. {
  35. extend: "selectedSingle",
  36. text: "User Profile",
  37. action: (e, dt, button, config) => {
  38. const username = (dt.row({ selected: true }).data() as AdminUserDTO)
  39. .userName;
  40. window.location.assign(`/admin/users/${username}`);
  41. },
  42. },
  43. {
  44. extend: "selectedSingle",
  45. text: "Delete User",
  46. action: (e, dt, button, config) => {
  47. log.error("Not implemented yet");
  48. },
  49. },
  50. {
  51. text: "New User",
  52. action: () => {
  53. log.error("Not implemented yet");
  54. },
  55. },
  56. ],
  57. dom: "Blfrtip",
  58. lengthMenu: [2, 10, 25, 50, 75, 100],
  59. select: true,
  60. });
  61. }