Added buttons and selection mechanism

This commit is contained in:
Rohan Sircar 2020-07-30 13:25:44 +05:30
parent b5373fd286
commit 852ecb4993
4 changed files with 60 additions and 6 deletions

View File

@ -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",

View File

@ -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,
});
}

View File

@ -64,11 +64,19 @@
integrity="sha512-1k7mWiTNoyx2XtmI96o+hdjP8nn0f3Z2N4oF/9ZZRgijyV4omsKOXEnqL1gKQNPy2MTSP9rIEWGcH/CInulptA=="
crossorigin="anonymous" /> -->
<!-- <link rel="stylesheet" th:href="@{/css/admin-table.css}" href="../../../resources/static/css/admin-table.css"> -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.21/datatables.min.css" />
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.21/datatables.min.js"></script>
<link rel="stylesheet" th:href="@{/css/dataTables.bootstrap4.min.css}"
href="../../../resources/static/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.21/b-1.6.2/b-html5-1.6.2/datatables.min.css" />
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript"
src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.21/b-1.6.2/b-html5-1.6.2/datatables.min.js"></script>
<script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
<link th:href="@{/css/admin-custom.css}" href="../../static/css/admin-custom.css" rel="stylesheet">
<script th:src="@{'/js/' + ${@environment.getProperty('admin-bundle')}}" src="../../static/js/adminBundle.js"

View File

@ -9,7 +9,23 @@
dependencies:
"@types/jquery" "*"
"@types/datatables.net@^1.10.19":
"@types/datatables.net-buttons@^1.4.3":
version "1.4.3"
resolved "https://registry.yarnpkg.com/@types/datatables.net-buttons/-/datatables.net-buttons-1.4.3.tgz#bcb6e196afbb5024cf6c8b2655a3cb012a1b846c"
integrity sha512-4Lyuxui1V1pA8OD4PCihJH3HxT779e39aUtT4vhPAjKUd0t9wPNRL3CEfEtG0yOa/RYkJvJw9ZAxdTaym1p8NA==
dependencies:
"@types/datatables.net" "*"
"@types/jquery" "*"
"@types/datatables.net-select@^1.2.6":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@types/datatables.net-select/-/datatables.net-select-1.2.6.tgz#2a3ca96f9f528a45895c491c2d6087a07de1b451"
integrity sha512-F114lcN6EuAELInU/ZSb1gGyQNfUFCAdZRbo12dRNtdt+HYxiRHVmow46J7Qy0Hv44/6DaPHwHKhVq35eY3LPg==
dependencies:
"@types/datatables.net" "*"
"@types/jquery" "*"
"@types/datatables.net@*", "@types/datatables.net@^1.10.19":
version "1.10.19"
resolved "https://registry.yarnpkg.com/@types/datatables.net/-/datatables.net-1.10.19.tgz#17c5f94433f761086131c6c8dc055a0e1099d1f9"
integrity sha512-WuzgytEmsIpVYZbkce+EvK1UqBI7/cwcC/WgYeAtXdq2zi+yWzJwMT5Yb6irAiOi52DBjeAEeRt3bYzFYvHWCQ==