mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 06:34:40 +00:00
admin filter completed
This commit is contained in:
@@ -83,10 +83,10 @@ class LogUserSelector extends Component {
|
|||||||
<span className="cur-activity-modifiers d-inline-block p-2 rounded" onClick={this.onToggleClick}>
|
<span className="cur-activity-modifiers d-inline-block p-2 rounded" onClick={this.onToggleClick}>
|
||||||
{selectedItems.length > 0 ? (
|
{selectedItems.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<span>{gettext('Users:')}</span>
|
<span>{gettext(this.props.componentName + ":")}</span>
|
||||||
<span className="d-inline-block ml-1">{selectedItems.map(item => item.name).join(', ')}</span>
|
<span className="d-inline-block ml-1">{selectedItems.map(item => item.name).join(', ')}</span>
|
||||||
</>
|
</>
|
||||||
) : gettext('Users')}
|
) : gettext(this.props.componentName)}
|
||||||
<i className="sf3-font sf3-font-down ml-2 toggle-icon"></i>
|
<i className="sf3-font sf3-font-down ml-2 toggle-icon"></i>
|
||||||
</span>
|
</span>
|
||||||
{isOpen && (
|
{isOpen && (
|
||||||
@@ -143,6 +143,7 @@ class LogUserSelector extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogUserSelector.propTypes = {
|
LogUserSelector.propTypes = {
|
||||||
|
componentName: PropTypes.string,
|
||||||
items: PropTypes.array.isRequired,
|
items: PropTypes.array.isRequired,
|
||||||
selectedItems: PropTypes.array.isRequired,
|
selectedItems: PropTypes.array.isRequired,
|
||||||
onSelect: PropTypes.func.isRequired,
|
onSelect: PropTypes.func.isRequired,
|
||||||
|
@@ -48,6 +48,7 @@ class Content extends Component {
|
|||||||
loading, errorMsg, items,
|
loading, errorMsg, items,
|
||||||
perPage, currentPage, hasNextPage
|
perPage, currentPage, hasNextPage
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
console.log(currentPage)
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
} else if (errorMsg) {
|
} else if (errorMsg) {
|
||||||
@@ -328,7 +329,7 @@ class FileAccessLogs extends Component {
|
|||||||
openSelector: wasOpen ? null : selectorType
|
openSelector: wasOpen ? null : selectorType
|
||||||
}, () => {
|
}, () => {
|
||||||
if (wasOpen) {
|
if (wasOpen) {
|
||||||
this.getLogsByPage();
|
this.getLogsByPage(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -355,6 +356,7 @@ class FileAccessLogs extends Component {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="d-flex align-items-center mb-2">
|
<div className="d-flex align-items-center mb-2">
|
||||||
<LogUserSelector
|
<LogUserSelector
|
||||||
|
componentName="Users"
|
||||||
items={availableUsers}
|
items={availableUsers}
|
||||||
selectedItems={selectedUsers}
|
selectedItems={selectedUsers}
|
||||||
onSelect={this.handleUserFilter}
|
onSelect={this.handleUserFilter}
|
||||||
|
@@ -13,6 +13,7 @@ import MainPanelTopbar from '../main-panel-topbar';
|
|||||||
import UserLink from '../user-link';
|
import UserLink from '../user-link';
|
||||||
import LogsNav from './logs-nav';
|
import LogsNav from './logs-nav';
|
||||||
import LogUserSelector from '../../dashboard/log-user-selector';
|
import LogUserSelector from '../../dashboard/log-user-selector';
|
||||||
|
import LogRepoSelector from '../../dashboard/log-repo-selector';
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
dayjs.extend(relativeTime);
|
||||||
|
|
||||||
@@ -164,7 +165,12 @@ class FIleTransferLogs extends Component {
|
|||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
availableUsers: [],
|
availableUsers: [],
|
||||||
selectedUsers: [],
|
selectedFromUsers: [],
|
||||||
|
selectedToUsers: [],
|
||||||
|
selectedOperators: [],
|
||||||
|
openSelector: null,
|
||||||
|
availableRepos: [],
|
||||||
|
selectedRepos: [],
|
||||||
};
|
};
|
||||||
this.initPage = 1;
|
this.initPage = 1;
|
||||||
}
|
}
|
||||||
@@ -181,9 +187,19 @@ class FIleTransferLogs extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getLogsByPage = (page) => {
|
getLogsByPage = (page) => {
|
||||||
let { perPage, selectedUsers } = this.state;
|
let { perPage, selectedFromUsers, selectedToUsers, selectedOperators, selectedRepos } = this.state;
|
||||||
let emails = selectedUsers.map(user => user.email);
|
const emails = {
|
||||||
systemAdminAPI.sysAdminListFileTransferLogs(page, perPage, emails).then((res) => {
|
from_emails: selectedFromUsers.map(user => user.email),
|
||||||
|
to_emails: selectedToUsers.map(user => user.email),
|
||||||
|
operator_emails: selectedOperators.map(user => user.email)
|
||||||
|
};
|
||||||
|
|
||||||
|
systemAdminAPI.sysAdminListFileTransferLogs(
|
||||||
|
page,
|
||||||
|
perPage,
|
||||||
|
emails,
|
||||||
|
selectedRepos
|
||||||
|
).then((res) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
logList: res.data.repo_transfer_log_list,
|
logList: res.data.repo_transfer_log_list,
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -193,7 +209,8 @@ class FIleTransferLogs extends Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
|
currentPage: page,
|
||||||
|
errorMsg: Utils.getErrorMsg(error, true)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -204,23 +221,123 @@ class FIleTransferLogs extends Component {
|
|||||||
}, () => this.getLogsByPage(this.initPage));
|
}, () => this.getLogsByPage(this.initPage));
|
||||||
};
|
};
|
||||||
|
|
||||||
handleUserFilter = (user, shouldFetchData = true) => {
|
handleFromUserFilter = (user, shouldFetchData = true) => {
|
||||||
const { selectedUsers } = this.state;
|
const { selectedFromUsers } = this.state;
|
||||||
let newSelectedUsers;
|
let newSelectedUsers;
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
newSelectedUsers = selectedUsers;
|
newSelectedUsers = selectedFromUsers;
|
||||||
} else {
|
} else {
|
||||||
const isSelected = selectedUsers.find(item => item.email === user.email);
|
const isSelected = selectedFromUsers.find(item => item.email === user.email);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
newSelectedUsers = selectedUsers.filter(item => item.email !== user.email);
|
newSelectedUsers = selectedFromUsers.filter(item => item.email !== user.email);
|
||||||
} else {
|
} else {
|
||||||
newSelectedUsers = [...selectedUsers, user];
|
newSelectedUsers = [...selectedFromUsers, user];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedUsers: newSelectedUsers,
|
selectedFromUsers: newSelectedUsers,
|
||||||
|
currentPage: 1
|
||||||
|
}, () => {
|
||||||
|
if (shouldFetchData) {
|
||||||
|
this.getLogsByPage(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleToUserFilter = (user, shouldFetchData = true) => {
|
||||||
|
const { selectedToUsers } = this.state;
|
||||||
|
let newSelectedUsers;
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
newSelectedUsers = selectedToUsers;
|
||||||
|
} else {
|
||||||
|
const isSelected = selectedToUsers.find(item => item.email === user.email);
|
||||||
|
if (isSelected) {
|
||||||
|
newSelectedUsers = selectedToUsers.filter(item => item.email !== user.email);
|
||||||
|
} else {
|
||||||
|
newSelectedUsers = [...selectedToUsers, user];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedToUsers: newSelectedUsers,
|
||||||
|
currentPage: 1
|
||||||
|
}, () => {
|
||||||
|
if (shouldFetchData) {
|
||||||
|
this.getLogsByPage(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOperatorFilter = (user, shouldFetchData = true) => {
|
||||||
|
const { selectedOperators } = this.state;
|
||||||
|
let newSelectedUsers;
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
newSelectedUsers = selectedOperators;
|
||||||
|
} else {
|
||||||
|
const isSelected = selectedOperators.find(item => item.email === user.email);
|
||||||
|
if (isSelected) {
|
||||||
|
newSelectedUsers = selectedOperators.filter(item => item.email !== user.email);
|
||||||
|
} else {
|
||||||
|
newSelectedUsers = [...selectedOperators, user];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedOperators: newSelectedUsers,
|
||||||
|
currentPage: 1
|
||||||
|
}, () => {
|
||||||
|
if (shouldFetchData) {
|
||||||
|
this.getLogsByPage(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSelectorToggle = (selectorType) => {
|
||||||
|
const { openSelector } = this.state;
|
||||||
|
const wasOpen = openSelector === selectorType;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
openSelector: wasOpen ? null : selectorType
|
||||||
|
}, () => {
|
||||||
|
if (wasOpen) {
|
||||||
|
this.getLogsByPage(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getAvailableRepos = () => {
|
||||||
|
systemAdminAPI.sysAdminListRepos().then((res) => {
|
||||||
|
this.setState({
|
||||||
|
availableRepos: res.data.repos
|
||||||
|
});
|
||||||
|
}).catch((error) => {
|
||||||
|
this.setState({
|
||||||
|
errorMsg: Utils.getErrorMsg(error, true)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleRepoFilter = (repo, shouldFetchData = true) => {
|
||||||
|
const { selectedRepos } = this.state;
|
||||||
|
let newSelectedRepos;
|
||||||
|
|
||||||
|
if (repo === null) {
|
||||||
|
newSelectedRepos = [];
|
||||||
|
} else {
|
||||||
|
const isSelected = selectedRepos.find(item => item.id === repo.id);
|
||||||
|
if (isSelected) {
|
||||||
|
newSelectedRepos = selectedRepos.filter(item => item.id !== repo.id);
|
||||||
|
} else {
|
||||||
|
newSelectedRepos = [...selectedRepos, repo];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedRepos: newSelectedRepos,
|
||||||
currentPage: 1
|
currentPage: 1
|
||||||
}, () => {
|
}, () => {
|
||||||
if (shouldFetchData) {
|
if (shouldFetchData) {
|
||||||
@@ -230,7 +347,13 @@ class FIleTransferLogs extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { logList, currentPage, perPage, hasNextPage, availableUsers, selectedUsers } = this.state;
|
let {
|
||||||
|
logList, currentPage, perPage, hasNextPage,
|
||||||
|
availableUsers, selectedFromUsers, selectedToUsers, selectedOperators,
|
||||||
|
availableRepos, selectedRepos,
|
||||||
|
openSelector
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<MainPanelTopbar {...this.props} />
|
<MainPanelTopbar {...this.props} />
|
||||||
@@ -239,12 +362,40 @@ class FIleTransferLogs extends Component {
|
|||||||
<LogsNav currentItem="fileTransfer" />
|
<LogsNav currentItem="fileTransfer" />
|
||||||
<div className="cur-view-content">
|
<div className="cur-view-content">
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<LogUserSelector
|
<div className="d-flex align-items-center mb-2">
|
||||||
label={gettext('User')}
|
<LogUserSelector
|
||||||
items={availableUsers}
|
componentName="Transfer From"
|
||||||
selectedItems={selectedUsers}
|
items={availableUsers}
|
||||||
onSelect={this.handleUserFilter}
|
selectedItems={selectedFromUsers}
|
||||||
/>
|
onSelect={this.handleFromUserFilter}
|
||||||
|
isOpen={openSelector === 'fromUser'}
|
||||||
|
onToggle={() => this.handleSelectorToggle('fromUser')}
|
||||||
|
/>
|
||||||
|
<LogUserSelector
|
||||||
|
componentName="Transfer To"
|
||||||
|
items={availableUsers}
|
||||||
|
selectedItems={selectedToUsers}
|
||||||
|
onSelect={this.handleToUserFilter}
|
||||||
|
isOpen={openSelector === 'toUser'}
|
||||||
|
onToggle={() => this.handleSelectorToggle('toUser')}
|
||||||
|
/>
|
||||||
|
<LogUserSelector
|
||||||
|
componentName="Operator"
|
||||||
|
items={availableUsers}
|
||||||
|
selectedItems={selectedOperators}
|
||||||
|
onSelect={this.handleOperatorFilter}
|
||||||
|
isOpen={openSelector === 'operator'}
|
||||||
|
onToggle={() => this.handleSelectorToggle('operator')}
|
||||||
|
/>
|
||||||
|
<div className="mx-3"></div>
|
||||||
|
<LogRepoSelector
|
||||||
|
items={availableRepos}
|
||||||
|
selectedItems={selectedRepos}
|
||||||
|
onSelect={this.handleRepoFilter}
|
||||||
|
isOpen={openSelector === 'repo'}
|
||||||
|
onToggle={() => this.handleSelectorToggle('repo')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<Content
|
<Content
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
errorMsg={this.state.errorMsg}
|
errorMsg={this.state.errorMsg}
|
||||||
|
@@ -325,6 +325,7 @@ class FileUpdateLogs extends Component {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="d-flex align-items-center mb-2">
|
<div className="d-flex align-items-center mb-2">
|
||||||
<LogUserSelector
|
<LogUserSelector
|
||||||
|
componentName="Users"
|
||||||
items={availableUsers}
|
items={availableUsers}
|
||||||
selectedItems={selectedUsers}
|
selectedItems={selectedUsers}
|
||||||
onSelect={this.handleUserFilter}
|
onSelect={this.handleUserFilter}
|
||||||
|
@@ -244,6 +244,7 @@ class LoginLogs extends Component {
|
|||||||
<div className="cur-view-content">
|
<div className="cur-view-content">
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<LogUserSelector
|
<LogUserSelector
|
||||||
|
componentName="Users"
|
||||||
items={availableUsers}
|
items={availableUsers}
|
||||||
selectedItems={selectedUsers}
|
selectedItems={selectedUsers}
|
||||||
onSelect={this.handleUserFilter}
|
onSelect={this.handleUserFilter}
|
||||||
|
@@ -154,7 +154,8 @@ class SharePermissionLogs extends Component {
|
|||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
isExportExcelDialogOpen: false,
|
isExportExcelDialogOpen: false,
|
||||||
availableUsers: [],
|
availableUsers: [],
|
||||||
selectedUsers: [],
|
selectedFromUsers: [],
|
||||||
|
selectedToUsers: [],
|
||||||
availableRepos: [],
|
availableRepos: [],
|
||||||
selectedRepos: [],
|
selectedRepos: [],
|
||||||
openSelector: null,
|
openSelector: null,
|
||||||
@@ -178,9 +179,20 @@ class SharePermissionLogs extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getLogsByPage = (page) => {
|
getLogsByPage = (page) => {
|
||||||
let { perPage, selectedUsers, selectedRepos } = this.state;
|
let { perPage, selectedFromUsers, selectedToUsers, selectedRepos } = this.state;
|
||||||
let emails = selectedUsers.map(user => user.email);
|
let fromEmails = selectedFromUsers.map(user => user.email);
|
||||||
systemAdminAPI.sysAdminListSharePermissionLogs(page, perPage, emails, selectedRepos).then((res) => {
|
let toEmails = selectedToUsers.map(user => user.email);
|
||||||
|
const emails = {
|
||||||
|
from_emails: fromEmails,
|
||||||
|
to_emails: toEmails
|
||||||
|
}
|
||||||
|
console.log(emails)
|
||||||
|
systemAdminAPI.sysAdminListSharePermissionLogs(
|
||||||
|
page,
|
||||||
|
perPage,
|
||||||
|
emails,
|
||||||
|
selectedRepos
|
||||||
|
).then((res) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
logList: res.data.share_permission_log_list,
|
logList: res.data.share_permission_log_list,
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -190,7 +202,7 @@ class SharePermissionLogs extends Component {
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
|
errorMsg: Utils.getErrorMsg(error, true)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -201,23 +213,48 @@ class SharePermissionLogs extends Component {
|
|||||||
}, () => this.getLogsByPage(this.initPage));
|
}, () => this.getLogsByPage(this.initPage));
|
||||||
};
|
};
|
||||||
|
|
||||||
handleUserFilter = (user, shouldFetchData = true) => {
|
handleFromUserFilter = (user, shouldFetchData = true) => {
|
||||||
const { selectedUsers } = this.state;
|
const { selectedFromUsers } = this.state;
|
||||||
let newSelectedUsers;
|
let newSelectedUsers;
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
newSelectedUsers = selectedUsers;
|
newSelectedUsers = selectedFromUsers;
|
||||||
} else {
|
} else {
|
||||||
const isSelected = selectedUsers.find(item => item.email === user.email);
|
const isSelected = selectedFromUsers.find(item => item.email === user.email);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
newSelectedUsers = selectedUsers.filter(item => item.email !== user.email);
|
newSelectedUsers = selectedFromUsers.filter(item => item.email !== user.email);
|
||||||
} else {
|
} else {
|
||||||
newSelectedUsers = [...selectedUsers, user];
|
newSelectedUsers = [...selectedFromUsers, user];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedUsers: newSelectedUsers,
|
selectedFromUsers: newSelectedUsers,
|
||||||
|
currentPage: 1
|
||||||
|
}, () => {
|
||||||
|
if (shouldFetchData) {
|
||||||
|
this.getLogsByPage(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleToUserFilter = (user, shouldFetchData = true) => {
|
||||||
|
const { selectedToUsers } = this.state;
|
||||||
|
let newSelectedUsers;
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
newSelectedUsers = selectedToUsers;
|
||||||
|
} else {
|
||||||
|
const isSelected = selectedToUsers.find(item => item.email === user.email);
|
||||||
|
if (isSelected) {
|
||||||
|
newSelectedUsers = selectedToUsers.filter(item => item.email !== user.email);
|
||||||
|
} else {
|
||||||
|
newSelectedUsers = [...selectedToUsers, user];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedToUsers: newSelectedUsers,
|
||||||
currentPage: 1
|
currentPage: 1
|
||||||
}, () => {
|
}, () => {
|
||||||
if (shouldFetchData) {
|
if (shouldFetchData) {
|
||||||
@@ -289,7 +326,11 @@ class SharePermissionLogs extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { logList, currentPage, perPage, hasNextPage, isExportExcelDialogOpen, availableUsers, selectedUsers, availableRepos, selectedRepos } = this.state;
|
let {
|
||||||
|
logList, currentPage, perPage, hasNextPage, isExportExcelDialogOpen,
|
||||||
|
availableUsers, selectedFromUsers, selectedToUsers,
|
||||||
|
availableRepos, selectedRepos, openSelector
|
||||||
|
} = this.state;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<MainPanelTopbar {...this.props}>
|
<MainPanelTopbar {...this.props}>
|
||||||
@@ -302,18 +343,27 @@ class SharePermissionLogs extends Component {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="d-flex align-items-center mb-2">
|
<div className="d-flex align-items-center mb-2">
|
||||||
<LogUserSelector
|
<LogUserSelector
|
||||||
|
componentName="Share From"
|
||||||
items={availableUsers}
|
items={availableUsers}
|
||||||
selectedItems={selectedUsers}
|
selectedItems={selectedFromUsers}
|
||||||
onSelect={this.handleUserFilter}
|
onSelect={this.handleFromUserFilter}
|
||||||
isOpen={this.state.openSelector === 'user'}
|
isOpen={openSelector === 'fromUser'}
|
||||||
onToggle={() => this.handleSelectorToggle('user')}
|
onToggle={() => this.handleSelectorToggle('fromUser')}
|
||||||
|
/>
|
||||||
|
<LogUserSelector
|
||||||
|
componentName="Share To"
|
||||||
|
items={availableUsers}
|
||||||
|
selectedItems={selectedToUsers}
|
||||||
|
onSelect={this.handleToUserFilter}
|
||||||
|
isOpen={openSelector === 'toUser'}
|
||||||
|
onToggle={() => this.handleSelectorToggle('toUser')}
|
||||||
/>
|
/>
|
||||||
<div className="mx-3"></div>
|
<div className="mx-3"></div>
|
||||||
<LogRepoSelector
|
<LogRepoSelector
|
||||||
items={availableRepos}
|
items={availableRepos}
|
||||||
selectedItems={selectedRepos}
|
selectedItems={selectedRepos}
|
||||||
onSelect={this.handleRepoFilter}
|
onSelect={this.handleRepoFilter}
|
||||||
isOpen={this.state.openSelector === 'repo'}
|
isOpen={openSelector === 'repo'}
|
||||||
onToggle={() => this.handleSelectorToggle('repo')}
|
onToggle={() => this.handleSelectorToggle('repo')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -728,8 +728,11 @@ class SystemAdminAPI {
|
|||||||
page: page,
|
page: page,
|
||||||
per_page: perPage
|
per_page: perPage
|
||||||
};
|
};
|
||||||
if (emails && emails.length) {
|
if (emails.from_emails && emails.from_emails.length) {
|
||||||
params.emails = emails.join(',');
|
params.from_emails = emails.from_emails.join(',')
|
||||||
|
}
|
||||||
|
if (emails.to_emails && emails.to_emails.length) {
|
||||||
|
params.to_emails = emails.to_emails.join(',')
|
||||||
}
|
}
|
||||||
if (repos && repos.length) {
|
if (repos && repos.length) {
|
||||||
params.repos = repos.map(repo => repo.id).join(',');
|
params.repos = repos.map(repo => repo.id).join(',');
|
||||||
@@ -737,17 +740,23 @@ class SystemAdminAPI {
|
|||||||
return this.req.get(url, { params: params });
|
return this.req.get(url, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
sysAdminListFileTransferLogs(page, perPage, emails, repoID) {
|
sysAdminListFileTransferLogs(page, perPage, emails, repos) {
|
||||||
const url = this.server + '/api/v2.1/admin/logs/repo-transfer-logs/';
|
const url = this.server + '/api/v2.1/admin/logs/repo-transfer-logs/';
|
||||||
let params = {
|
let params = {
|
||||||
page: page,
|
page: page,
|
||||||
per_page: perPage
|
per_page: perPage
|
||||||
};
|
};
|
||||||
if (emails && emails.length) {
|
if (emails.from_emails && emails.from_emails.length) {
|
||||||
params.emails = emails.join(',');
|
params.from_emails = emails.from_emails.join(',');
|
||||||
}
|
}
|
||||||
if (repoID != undefined) {
|
if (emails.to_emails && emails.to_emails.length) {
|
||||||
params.repo_id = repoID;
|
params.to_emails = emails.to_emails.join(',');
|
||||||
|
}
|
||||||
|
if (emails.operator_emails && emails.operator_emails.length) {
|
||||||
|
params.operator_emails = emails.operator_emails.join(',');
|
||||||
|
}
|
||||||
|
if (repos && repos.length) {
|
||||||
|
params.repos = repos.map(repo => repo.id).join(',');
|
||||||
}
|
}
|
||||||
return this.req.get(url, { params: params });
|
return this.req.get(url, { params: params });
|
||||||
}
|
}
|
||||||
|
@@ -120,18 +120,20 @@ class AdminLogsFileAccessLogs(APIView):
|
|||||||
if not is_valid_email(user_selected):
|
if not is_valid_email(user_selected):
|
||||||
error_msg = 'email %s invalid.' % user_selected
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
repos = request.GET.get('repos')
|
repos = request.GET.get('repos', None)
|
||||||
repos = repos.split(',') if repos else []
|
if repos:
|
||||||
for repo_selected in repos:
|
repos = repos.split(',') if repos else []
|
||||||
if not is_valid_repo_id_format(repo_selected):
|
for repo_selected in repos:
|
||||||
error_msg = 'repo_id %s invalid.' % repo_selected
|
if not is_valid_repo_id_format(repo_selected):
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
error_msg = 'repo_id %s invalid.' % repo_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
start = per_page * (current_page - 1)
|
start = per_page * (current_page - 1)
|
||||||
limit = per_page + 1
|
limit = per_page + 1
|
||||||
|
|
||||||
events = get_log_events_by_type_users_repo('file_audit', emails, repos, start, limit) or []
|
events = get_log_events_by_type_users_repo('file_audit', emails, repos, start, limit) or []
|
||||||
|
if events is None:
|
||||||
|
events = []
|
||||||
if len(events) > per_page:
|
if len(events) > per_page:
|
||||||
events = events[:per_page]
|
events = events[:per_page]
|
||||||
has_next_page = True
|
has_next_page = True
|
||||||
@@ -219,16 +221,20 @@ class AdminLogsFileUpdateLogs(APIView):
|
|||||||
error_msg = 'email %s invalid.' % user_selected
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
repo_id_selected = request.GET.get('repo_id', None)
|
repos = request.GET.get('repos', None)
|
||||||
if repo_id_selected and not is_valid_repo_id_format(repo_id_selected):
|
if repos:
|
||||||
error_msg = 'repo_id %s invalid.' % repo_id_selected
|
repos = repos.split(',')
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
for repo_selected in repos:
|
||||||
|
if not is_valid_repo_id_format(repo_selected):
|
||||||
|
error_msg = 'repo_id %s invalid.' % repo_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
start = per_page * (current_page - 1)
|
start = per_page * (current_page - 1)
|
||||||
limit = per_page
|
limit = per_page
|
||||||
|
|
||||||
events = get_log_events_by_type_users_repo('file_update', emails, repo_id_selected, start, limit)
|
events = get_log_events_by_type_users_repo('file_update', emails, repos, start, limit)
|
||||||
|
if events is None:
|
||||||
|
events = []
|
||||||
has_next_page = True if len(events) == per_page else False
|
has_next_page = True if len(events) == per_page else False
|
||||||
|
|
||||||
# Use dict to reduce memcache fetch cost in large for-loop.
|
# Use dict to reduce memcache fetch cost in large for-loop.
|
||||||
@@ -299,22 +305,40 @@ class AdminLogsSharePermissionLogs(APIView):
|
|||||||
current_page = 1
|
current_page = 1
|
||||||
per_page = 100
|
per_page = 100
|
||||||
|
|
||||||
emails = request.GET.get('emails')
|
|
||||||
emails = emails.split(',') if emails else []
|
from_emails = request.GET.get('from_emails')
|
||||||
for user_selected in emails:
|
from_emails = from_emails.split(',') if from_emails else []
|
||||||
|
for user_selected in from_emails:
|
||||||
if not is_valid_email(user_selected):
|
if not is_valid_email(user_selected):
|
||||||
error_msg = 'email %s invalid.' % user_selected
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
repo_id_selected = request.GET.get('repo_id', None)
|
to_emails = request.GET.get('to_emails')
|
||||||
if repo_id_selected and not is_valid_repo_id_format(repo_id_selected):
|
to_emails = to_emails.split(',') if to_emails else []
|
||||||
error_msg = 'repo_id %s invalid.' % repo_id_selected
|
for user_selected in to_emails:
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
if not is_valid_email(user_selected):
|
||||||
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
emails = {
|
||||||
|
'from_emails': from_emails,
|
||||||
|
'to_emails': to_emails
|
||||||
|
}
|
||||||
|
|
||||||
|
repos = request.GET.get('repos', None)
|
||||||
|
if repos:
|
||||||
|
repos = repos.split(',')
|
||||||
|
for repo_selected in repos:
|
||||||
|
if not is_valid_repo_id_format(repo_selected):
|
||||||
|
error_msg = 'repo_id %s invalid.' % repo_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
start = per_page * (current_page - 1)
|
start = per_page * (current_page - 1)
|
||||||
limit = per_page
|
limit = per_page
|
||||||
|
|
||||||
events = get_log_events_by_type_users_repo('perm_audit', emails, repo_id_selected, start, limit) or []
|
|
||||||
|
events = get_log_events_by_type_users_repo('perm_audit', emails, repos, start, limit) or []
|
||||||
|
if events is None:
|
||||||
|
events = []
|
||||||
has_next_page = True if len(events) == per_page else False
|
has_next_page = True if len(events) == per_page else False
|
||||||
|
|
||||||
# Use dict to reduce memcache fetch cost in large for-loop.
|
# Use dict to reduce memcache fetch cost in large for-loop.
|
||||||
@@ -454,21 +478,45 @@ class AdminLogsFileTransferLogs(APIView):
|
|||||||
error_msg = 'limit invalid'
|
error_msg = 'limit invalid'
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
emails = request.GET.get('emails')
|
from_emails = request.GET.get('from_emails')
|
||||||
emails = emails.split(',') if emails else []
|
from_emails = from_emails.split(',') if from_emails else []
|
||||||
for user_selected in emails:
|
for user_selected in from_emails:
|
||||||
if not is_valid_email(user_selected):
|
if not is_valid_email(user_selected):
|
||||||
error_msg = 'email %s invalid.' % user_selected
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
if emails:
|
to_emails = request.GET.get('to_emails')
|
||||||
events = RepoTransfer.objects.filter(
|
to_emails = to_emails.split(',') if to_emails else []
|
||||||
Q(from_user__in=emails) |
|
for user_selected in to_emails:
|
||||||
Q(to__in=emails) |
|
if not is_valid_email(user_selected):
|
||||||
Q(operator__in=emails)
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
).order_by('-timestamp')[start:start+limit+1]
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
else:
|
operator_emails = request.GET.get('operator_emails')
|
||||||
events = RepoTransfer.objects.all().order_by('-timestamp')[start:start+limit+1]
|
operator_emails = operator_emails.split(',') if operator_emails else []
|
||||||
if len(events) > limit:
|
for user_selected in operator_emails:
|
||||||
|
if not is_valid_email(user_selected):
|
||||||
|
error_msg = 'email %s invalid.' % user_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
|
repos = request.GET.get('repos', None)
|
||||||
|
if repos:
|
||||||
|
repos = repos.split(',')
|
||||||
|
for repo_selected in repos:
|
||||||
|
if not is_valid_repo_id_format(repo_selected):
|
||||||
|
error_msg = 'repo_id %s invalid.' % repo_selected
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
|
queryset = RepoTransfer.objects.all()
|
||||||
|
if from_emails:
|
||||||
|
queryset = queryset.by_from_user(from_emails)
|
||||||
|
if to_emails:
|
||||||
|
queryset = queryset.by_to_user(to_emails)
|
||||||
|
if operator_emails:
|
||||||
|
queryset = queryset.by_operator(operator_emails)
|
||||||
|
if repos:
|
||||||
|
queryset = queryset.by_repo_ids(repos)
|
||||||
|
events = queryset.order_by('-timestamp')[start:start+limit+1]
|
||||||
|
|
||||||
|
if events and len(events) > limit:
|
||||||
has_next_page = True
|
has_next_page = True
|
||||||
events = events[:limit]
|
events = events[:limit]
|
||||||
else:
|
else:
|
||||||
|
@@ -466,6 +466,20 @@ class ClientSSOToken(models.Model):
|
|||||||
return super(ClientSSOToken, self).save(*args, **kwargs)
|
return super(ClientSSOToken, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class RepoTransferQuerySet(models.QuerySet):
|
||||||
|
def by_from_user(self, from_users):
|
||||||
|
return self.filter(from_user__in=from_users)
|
||||||
|
|
||||||
|
def by_to_user(self, to_users):
|
||||||
|
return self.filter(to__in=to_users)
|
||||||
|
|
||||||
|
def by_operator(self, operators):
|
||||||
|
return self.filter(operator__in=operators)
|
||||||
|
|
||||||
|
def by_repo_ids(self, repo_ids):
|
||||||
|
return self.filter(repo_id__in=repo_ids)
|
||||||
|
|
||||||
|
|
||||||
class RepoTransfer(models.Model):
|
class RepoTransfer(models.Model):
|
||||||
repo_id = models.CharField(max_length=36)
|
repo_id = models.CharField(max_length=36)
|
||||||
org_id = models.IntegerField(db_index=True)
|
org_id = models.IntegerField(db_index=True)
|
||||||
@@ -473,6 +487,7 @@ class RepoTransfer(models.Model):
|
|||||||
to = models.CharField(max_length=255)
|
to = models.CharField(max_length=255)
|
||||||
operator = models.CharField(max_length=255)
|
operator = models.CharField(max_length=255)
|
||||||
timestamp = models.DateTimeField(default=timezone.now, db_index=True)
|
timestamp = models.DateTimeField(default=timezone.now, db_index=True)
|
||||||
|
objects = RepoTransferQuerySet.as_manager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'RepoTransfer'
|
db_table = 'RepoTransfer'
|
||||||
|
Reference in New Issue
Block a user