From 852ecb49935ead7cfe7c8bd314463aafdfbdab50 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Thu, 30 Jul 2020 13:25:44 +0530 Subject: [PATCH] Added buttons and selection mechanism --- package.json | 4 ++- .../frontend/admin/pages/user/ViewUsers.ts | 28 +++++++++++++++++++ .../resources/templates/fragments/admin.html | 16 ++++++++--- yarn.lock | 18 +++++++++++- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 9d3f4b5..f7b79ac 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,8 @@ "dependencies": { "@types/bootbox": "^5.2.0", "@types/datatables.net": "^1.10.19", + "@types/datatables.net-buttons": "^1.4.3", + "@types/datatables.net-select": "^1.2.6", "@types/dompurify": "^2.0.0", "@types/jquery": "^3.3.31", "@types/markdown-it": "^0.0.9", @@ -60,4 +62,4 @@ "watch": "watchify src/main/frontend/chat/main.ts -p [ tsify --target ES6 --noImplicitAny ] --debug -o src/main/resources/static/js/bundle.js", "watch:admin": "watchify src/main/frontend/admin/main.ts -p [ tsify --target ES6 --noImplicitAny ] --debug -o src/main/resources/static/js/adminBundle.js" } -} \ No newline at end of file +} diff --git a/src/main/frontend/admin/pages/user/ViewUsers.ts b/src/main/frontend/admin/pages/user/ViewUsers.ts index 4625d53..d16fe6c 100644 --- a/src/main/frontend/admin/pages/user/ViewUsers.ts +++ b/src/main/frontend/admin/pages/user/ViewUsers.ts @@ -1,5 +1,7 @@ import moment from "moment"; import { capitalize } from "../../../common/util/Util"; +import { AdminUserDTO } from "../../../common/dto/AdminUserDTO"; +import log from "loglevel"; export async function viewUsers(authToken: string) { // const users = await getOtherUsers(authToken); @@ -30,6 +32,32 @@ export async function viewUsers(authToken: string) { }, }, ], + buttons: [ + { + extend: "selectedSingle", + text: "User Profile", + action: (e, dt, button, config) => { + const username = (dt.row({ selected: true }).data() as AdminUserDTO) + .userName; + window.location.assign(`/admin/users/${username}`); + }, + }, + { + extend: "selectedSingle", + text: "Delete User", + action: (e, dt, button, config) => { + log.error("Not implemented yet"); + }, + }, + { + text: "New User", + action: () => { + log.error("Not implemented yet"); + }, + }, + ], + dom: "Blfrtip", lengthMenu: [2, 10, 25, 50, 75, 100], + select: true, }); } diff --git a/src/main/resources/templates/fragments/admin.html b/src/main/resources/templates/fragments/admin.html index 77adf24..e790c5b 100644 --- a/src/main/resources/templates/fragments/admin.html +++ b/src/main/resources/templates/fragments/admin.html @@ -64,11 +64,19 @@ integrity="sha512-1k7mWiTNoyx2XtmI96o+hdjP8nn0f3Z2N4oF/9ZZRgijyV4omsKOXEnqL1gKQNPy2MTSP9rIEWGcH/CInulptA==" crossorigin="anonymous" /> --> - - - + + + + + + + +