aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-10-06 17:14:42 -0500
committerJP Dillingham <jp@dillingham.me>2024-10-06 17:14:42 -0500
commit83bda1f237997f27b2860a7b887420de795983dc (patch)
treebd92a33a95a37acdb4cbda7f66a285a8b9bc13dc /src/web
parentced0e915da59d3d6008f6da53adb9da1c8a5217b (diff)
downloadslskd-83bda1f237997f27b2860a7b887420de795983dc.tar.gz
finish event screen
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/System/Events/index.jsx43
-rw-r--r--src/web/src/components/System/System.css12
-rw-r--r--src/web/src/components/System/System.jsx2
3 files changed, 34 insertions, 23 deletions
diff --git a/src/web/src/components/System/Events/index.jsx b/src/web/src/components/System/Events/index.jsx
index 5dfc5868..7f708908 100644
--- a/src/web/src/components/System/Events/index.jsx
+++ b/src/web/src/components/System/Events/index.jsx
@@ -3,30 +3,38 @@ import { LoaderSegment } from '../../Shared';
import React, { useEffect, useState } from 'react';
import { Icon, Pagination, Popup, Table } from 'semantic-ui-react';
-const PER_PAGE = 50;
+const PER_PAGE = 10;
+
+const replaceHyphensWithNonBreakingEquivalent = (string) =>
+ string?.replaceAll('-', '‑');
const Events = () => {
const [page, setPage] = useState(1);
+ const [totalPages, setTotalPages] = useState(0);
const [loading, setLoading] = useState(false);
const [events, setEvents] = useState([]);
const fetch = async () => {
setLoading(true);
- const eventResult = await list({
+ const { events: items, totalCount } = await list({
limit: PER_PAGE,
offset: (page - 1) * PER_PAGE,
});
- setEvents(eventResult);
+ const tp = Math.ceil(totalCount / PER_PAGE);
+
+ setEvents(items);
+ setTotalPages(Number.isNaN(tp) ? 0 : tp);
setLoading(false);
- return eventResult;
+ return items;
};
const paginationChanged = ({ activePage }) => {
- console.log(activePage);
- setPage(activePage);
+ if (activePage >= 1) {
+ setPage(activePage);
+ }
};
useEffect(() => {
@@ -39,6 +47,14 @@ const Events = () => {
return (
<>
+ <div className="header-buttons">
+ <Pagination
+ activePage={page}
+ className="header-buttons"
+ onPageChange={(event, data) => paginationChanged({ ...data })}
+ totalPages={totalPages}
+ />
+ </div>
<Table
className="events-table, unstackable"
compact="very"
@@ -49,7 +65,9 @@ const Events = () => {
<Table.HeaderCell className="events-list-timestamp">
Timestamp
</Table.HeaderCell>
- <Table.HeaderCell classname="">Type</Table.HeaderCell>
+ <Table.HeaderCell className="events-list-type">
+ Type
+ </Table.HeaderCell>
<Table.HeaderCell className="events-list-data">
Data
</Table.HeaderCell>
@@ -81,21 +99,18 @@ const Events = () => {
wide="very"
/>
</Table.Cell>
- <Table.Cell>{event.timestamp}</Table.Cell>
+ <Table.Cell>
+ {replaceHyphensWithNonBreakingEquivalent(event.timestamp)}
+ </Table.Cell>
<Table.Cell>{event.type}</Table.Cell>
<Table.Cell className="events-table-data">
- {event.data.slice(0, 10)}
+ {JSON.stringify(JSON.parse(event.data), null, 2)}
</Table.Cell>
</Table.Row>
))
)}
</Table.Body>
</Table>
- <Pagination
- activePage={page}
- onPageChange={(event, data) => paginationChanged({ ...data })}
- totalPages={100}
- />
</>
);
};
diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css
index 1d285ed8..a3a2c83a 100644
--- a/src/web/src/components/System/System.css
+++ b/src/web/src/components/System/System.css
@@ -20,20 +20,16 @@
word-break: break-all;
}
-.events-table-data {
- white-space: pre;
-}
-
.events-list-id {
- width: 0px; /* small as possible */
+ width: 0px; /* shrink to fit */
}
.events-list-timestamp {
- width: 233px;
+ width: 0px; /* shrink to fit */
}
-.events-list-data {
- width: 200px;
+.events-list-type {
+ width: 0px; /* shrink to fit */
}
.logs {
diff --git a/src/web/src/components/System/System.jsx b/src/web/src/components/System/System.jsx
index 790a4c45..2dbd9d91 100644
--- a/src/web/src/components/System/System.jsx
+++ b/src/web/src/components/System/System.jsx
@@ -124,7 +124,7 @@ const System = ({ options = {}, state = {}, theme }) => {
{
menuItem: {
content: 'Events',
- icon: 'history',
+ icon: 'calendar check',
key: 'events',
},
render: () => (