1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 09:21:54 +00:00

Org admin page (#5298)

* orgadmin import users

* orgadmin devices page

* orgadmin statistic page

* orgadmin devices page

use seafile_api.list_org_repo_sync_errors

* [org admin] bugfix & improvements

Co-authored-by: lian <lian@seafile.com>
Co-authored-by: llj <lingjun.li1@gmail.com>
This commit is contained in:
lian
2022-11-10 13:27:55 +08:00
committed by GitHub
parent 53e2e70d8c
commit b0d0874013
30 changed files with 2775 additions and 30 deletions

View File

@@ -122,7 +122,7 @@ class Account extends Component {
};
} else if (isOrgStaff) {
data = {
url: `${siteRoot}org/useradmin/`,
url: `${siteRoot}org/info/`,
text: gettext('Organization Admin')
};
} else if (isInstAdmin) {

View File

@@ -0,0 +1,67 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Alert, Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
import { gettext, siteRoot } from '../../utils/constants';
const propTypes = {
toggle: PropTypes.func.isRequired,
importUsersInBatch: PropTypes.func.isRequired,
};
class ImportOrgUsersDialog extends React.Component {
constructor(props) {
super(props);
this.fileInputRef = React.createRef();
this.state = {
errorMsg: ''
};
}
toggle = () => {
this.props.toggle();
}
openFileInput = () => {
this.fileInputRef.current.click();
}
uploadFile = (e) => {
// no file selected
if (!this.fileInputRef.current.files.length) {
return;
}
// check file extension
let fileName = this.fileInputRef.current.files[0].name;
if(fileName.substr(fileName.lastIndexOf('.') + 1) != 'xlsx') {
this.setState({
errorMsg: gettext('Please choose a .xlsx file.')
});
return;
}
const file = this.fileInputRef.current.files[0];
this.props.importUsersInBatch(file);
this.toggle();
}
render() {
let { errorMsg } = this.state;
return (
<Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext('Import users from a .xlsx file')}</ModalHeader>
<ModalBody>
<p><a className="text-secondary small" href={`${siteRoot}useradmin/batchadduser/example/`}>{gettext('Download an example file')}</a></p>
<button className="btn btn-outline-primary" onClick={this.openFileInput}>{gettext('Upload file')}</button>
<input className="d-none" type="file" onChange={this.uploadFile} ref={this.fileInputRef} />
{errorMsg && <Alert color="danger">{errorMsg}</Alert>}
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
</ModalFooter>
</Modal>
);
}
}
ImportOrgUsersDialog.propTypes = propTypes;
export default ImportOrgUsersDialog;