+
+
+ {isOpIconShown && !userFilteredBy && (
+
+ )}
+ |
{item.event_type} |
- {item.ip}{' / '}{item.device} |
+ {item.ip}{' / '}{item.device || '--'} |
{moment(item.time).fromNow()} |
- {item.repo_name ? item.repo_name : gettext('Deleted')} |
+
+ {item.repo_name ? item.repo_name : gettext('Deleted')}
+ {isOpIconShown && item.repo_name && !repoFilteredBy && (
+
+ )}
+ |
{item.file_or_dir_name} |
);
@@ -140,15 +230,17 @@ class FileAccessLogs extends Component {
const { currentPage, perPage } = this.state;
this.setState({
perPage: parseInt(urlParams.get('per_page') || perPage),
- currentPage: parseInt(urlParams.get('page') || currentPage)
+ currentPage: parseInt(urlParams.get('page') || currentPage),
+ userFilteredBy: urlParams.get('email'),
+ repoFilteredBy: urlParams.get('repo_id')
}, () => {
this.getLogsByPage(this.state.currentPage);
});
}
getLogsByPage = (page) => {
- let { perPage } = this.state;
- seafileAPI.sysAdminListFileAccessLogs(page, perPage).then((res) => {
+ const { perPage, userFilteredBy, repoFilteredBy } = this.state;
+ seafileAPI.sysAdminListFileAccessLogs(page, perPage, userFilteredBy, repoFilteredBy).then((res) => {
this.setState({
logList: res.data.file_access_log_list,
loading: false,
@@ -169,8 +261,43 @@ class FileAccessLogs extends Component {
}, () => this.getLogsByPage(this.initPage));
}
+ updateURL = (obj) => {
+ let url = new URL(location.href);
+ let searchParams = new URLSearchParams(url.search);
+ for (let key in obj) {
+ obj[key] == null ?
+ searchParams.delete(key) :
+ searchParams.set(key, obj[key]);
+ }
+ url.search = searchParams.toString();
+ navigate(url.toString());
+ }
+
+ filterByUser = (email) => {
+ this.setState({
+ userFilteredBy: email
+ }, () => {
+ this.getLogsByPage(this.initPage);
+ this.updateURL({'email': email});
+ });
+ }
+
+ filterByRepo = (repoID) => {
+ this.setState({
+ repoFilteredBy: repoID
+ }, () => {
+ this.getLogsByPage(this.initPage);
+ this.updateURL({'repo_id': repoID});
+ });
+ }
+
render() {
- let { logList, currentPage, perPage, hasNextPage, isExportExcelDialogOpen } = this.state;
+ const {
+ logList,
+ userFilteredBy, repoFilteredBy,
+ currentPage, perPage, hasNextPage,
+ isExportExcelDialogOpen
+ } = this.state;
return (