diff --git a/webclient/src/Admin.js b/webclient/src/Admin.js index e00921e..3e7ebe4 100644 --- a/webclient/src/Admin.js +++ b/webclient/src/Admin.js @@ -7,14 +7,24 @@ import { apiUrl, statusColor, BasicTable, staticUrl, requester } from './utils.j import { NotFound } from './Misc.js'; let historyCache = false; +let excludeSystemCache = true; +let focusCache = false; export function AdminHistory(props) { const { token, user } = props; const [history, setHistory] = useState(historyCache); + const [excludeSystem, setExcludeSystem] = useState(excludeSystemCache); + const [focus, setFocus] = useState(focusCache); const [error, setError] = useState(false); + const handleExcludeSystem = (e, v) => { + setExcludeSystem(v.checked); + excludeSystemCache = v.checked; + }; + useEffect(() => { - requester('/history/', 'GET', token) + const extra = excludeSystem ? '?exclude_system' : ''; + requester('/history/'+extra, 'GET', token) .then(res => { setHistory(res.results); historyCache = res.results; @@ -22,37 +32,77 @@ export function AdminHistory(props) { .catch(err => { console.log(err); }); - }, []); + }, [excludeSystem]); 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(', ')} +
+ + + Date + Username + Type + Owner + Object + Changed Fields - )} - -
+ + + + {history.map(x => + + + + setFocus(x.id)}> + {moment.utc(x.history_date).format('YYYY-MM-DD')} + + + {x.is_system ? 'System' : (x.history_user || 'Deleted User')} + {x.history_type} + {x.owner_name} + {x.object_name} + {x.changes.map(x => x.field).join(', ')} + + + {focus == x.id && + +

Object ID: {x.object_id}, Database Revert

+ {!!x.changes.length && + + + + Change + Before + After + + + + {x.changes.map(y => + + {y.field} + {y.old} + {y.new} + + )} + +
+ } + + } +
+ )} +
+ + :

Loading...

: @@ -122,8 +172,8 @@ export function Admin(props) {
Backup Downloads
-
History (Experimental)
-

Last 100 database changes:

+
History
+

Last 50 database changes: