From 244a78d8b516a9c1690a85d1a764f49716953144 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 28 Feb 2020 01:24:38 +0000 Subject: [PATCH] Display Admin history in table --- webclient/src/Admin.js | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/webclient/src/Admin.js b/webclient/src/Admin.js index fa3ec51..05c1f21 100644 --- a/webclient/src/Admin.js +++ b/webclient/src/Admin.js @@ -6,6 +6,62 @@ import moment from 'moment'; import { apiUrl, statusColor, BasicTable, staticUrl, requester } from './utils.js'; import { NotFound } from './Misc.js'; +let historyCache = false; + +export function AdminHistory(props) { + const { token, user } = props; + const [history, setHistory] = useState(historyCache); + const [error, setError] = useState(false); + + useEffect(() => { + requester('/history/', 'GET', token) + .then(res => { + setHistory(res.results); + historyCache = res.results; + }) + .catch(err => { + console.log(err); + }); + }, []); + + return ( +
+ {!error ? + history ? + + + + Date + Username + Type + Owner + Object + Changed Fields + + + + + {history.map(x => + + {moment().utc(x.history_date).format('YYYY-MM-DD')} + {x.history_user || 'System'} + {x.history_type} + {x.owner_name} + {x.object_name} + {x.changes.map(x => x.field).join(', ')} + + )} + +
+ : +

Loading...

+ : +

Error loading.

+ } +
+ ); +}; + export function Admin(props) { return ( @@ -16,6 +72,11 @@ export function Admin(props) {

Backups contain the complete member data and must be kept secure.

Talk to Tanner to learn how to get backups.

+
History (Experimental)
+

Last 100 database changes:

+ + +
); };