mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
System admin api (#6967)
* [system admin] moved related APIs from seafile-js to system-admin-api.js; made related fixup & improvements, and etc. * [system admin] use 'systemAdminAPI' instead of 'seafileAPI' for the pages * [system admin] use 'systemAdminAPI' instead of 'seafileAPI' for the dialogs
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
|
||||
const propTypes = {
|
||||
groupID: PropTypes.string,
|
||||
@@ -28,7 +28,7 @@ class AddDepartDialog extends React.Component {
|
||||
if (this.props.parentGroupID) {
|
||||
parentGroup = this.props.parentGroupID;
|
||||
}
|
||||
seafileAPI.sysAdminAddNewDepartment(parentGroup, this.state.departName.trim()).then((res) => {
|
||||
systemAdminAPI.sysAdminAddNewDepartment(parentGroup, this.state.departName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onAddNewDepartment(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
import UserSelect from '../../user-select';
|
||||
@@ -32,7 +32,7 @@ class AddMemberDialog extends React.Component {
|
||||
const emails = this.state.selectedOption.map(item => item.email);
|
||||
this.refs.orgSelect.clearSelect();
|
||||
this.setState({ errMessage: [] });
|
||||
seafileAPI.sysAdminAddGroupMember(this.props.groupID, emails).then((res) => {
|
||||
systemAdminAPI.sysAdminAddGroupMember(this.props.groupID, emails).then((res) => {
|
||||
this.setState({ selectedOption: null });
|
||||
if (res.data.failed.length > 0) {
|
||||
this.setState({ errMessage: res.data.failed[0].error_msg });
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
|
||||
const propTypes = {
|
||||
@@ -24,7 +24,7 @@ class AddRepoDialog extends React.Component {
|
||||
handleSubmit = () => {
|
||||
let isValid = this.validateName();
|
||||
if (isValid) {
|
||||
seafileAPI.sysAdminAddRepoInDepartment(this.props.groupID, this.state.repoName.trim()).then((res) => {
|
||||
systemAdminAPI.sysAdminAddRepoInDepartment(this.props.groupID, this.state.repoName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onAddNewRepo(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../../components/toast';
|
||||
|
||||
@@ -21,7 +21,7 @@ class DeleteDepartmentDialog extends React.Component {
|
||||
deleteDepart = () => {
|
||||
this.props.toggle();
|
||||
const { group } = this.props;
|
||||
seafileAPI.sysAdminDeleteDepartment(group.id).then((res) => {
|
||||
systemAdminAPI.sysAdminDeleteDepartment(group.id).then((res) => {
|
||||
this.props.onDeleteDepartment(group.id);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
|
||||
@@ -21,7 +21,7 @@ class DeleteMemberDialog extends React.Component {
|
||||
|
||||
deleteMember = () => {
|
||||
const userEmail = this.props.member.email;
|
||||
seafileAPI.sysAdminDeleteGroupMember(this.props.groupID, userEmail).then((res) => {
|
||||
systemAdminAPI.sysAdminDeleteGroupMember(this.props.groupID, userEmail).then((res) => {
|
||||
if (res.data.success) {
|
||||
this.props.onMemberChanged();
|
||||
this.props.toggle();
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
|
||||
@@ -13,7 +13,7 @@ class DeleteRepoDialog extends React.Component {
|
||||
}
|
||||
|
||||
deleteRepo = () => {
|
||||
seafileAPI.sysAdminDeleteRepoInDepartment(this.props.groupID, this.props.repo.repo_id).then((res) => {
|
||||
systemAdminAPI.sysAdminDeleteRepoInDepartment(this.props.groupID, this.props.repo.repo_id).then((res) => {
|
||||
if (res.data.success) {
|
||||
this.props.onRepoChanged();
|
||||
this.props.toggle();
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Label, Input, Alert } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
|
||||
@@ -28,7 +28,7 @@ class SysAdminLibHistorySettingDialog extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
seafileAPI.sysAdminGetRepoHistorySetting(this.props.repoID).then(res => {
|
||||
systemAdminAPI.sysAdminGetRepoHistorySetting(this.props.repoID).then(res => {
|
||||
this.setState({
|
||||
keepDays: res.data.keep_days,
|
||||
allHistory: res.data.keep_days < 0 ? true : false,
|
||||
@@ -53,7 +53,7 @@ class SysAdminLibHistorySettingDialog extends React.Component {
|
||||
let flag = reg.test(days);
|
||||
if (flag) {
|
||||
let message = gettext('Successfully set library history.');
|
||||
seafileAPI.sysAdminUpdateRepoHistorySetting(repoID, days).then(res => {
|
||||
systemAdminAPI.sysAdminUpdateRepoHistorySetting(repoID, days).then(res => {
|
||||
toaster.success(message);
|
||||
this.setState({ keepDays: res.data.keep_days });
|
||||
this.props.toggleDialog();
|
||||
|
@@ -2,11 +2,11 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, FormGroup, Label, Input, Alert } from 'reactstrap';
|
||||
import dayjs from 'dayjs';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import { gettext, siteRoot } from '../../../utils/constants';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { userAPI } from '../../../utils/user-api';
|
||||
import toaster from '../../../components/toast';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import SeahubIODialog from '../../dialog/seahub-io-dialog';
|
||||
|
||||
class LogsExportExcelDialog extends React.Component {
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Form, FormGroup, Label } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../../components/toast';
|
||||
|
||||
@@ -30,7 +30,7 @@ class RenameDepartmentDialog extends React.Component {
|
||||
handleSubmit = () => {
|
||||
let isValid = this.validateName();
|
||||
if (isValid) {
|
||||
seafileAPI.sysAdminRenameDepartment(this.props.groupID, this.state.departmentName.trim()).then((res) => {
|
||||
systemAdminAPI.sysAdminRenameDepartment(this.props.groupID, this.state.departmentName.trim()).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onDepartmentNameChanged(res.data);
|
||||
toaster.success(gettext('Department renamed'));
|
||||
|
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, InputGroupAddon, InputGroup } from 'reactstrap';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
|
||||
@@ -28,7 +28,7 @@ class SetGroupQuotaDialog extends React.Component {
|
||||
if ((quota.length && numberReg.test(quota)) || quota == -2) {
|
||||
this.setState({ errMessage: '' });
|
||||
let newQuota = this.state.quota == -2 ? this.state.quota : this.state.quota * 1000000;
|
||||
seafileAPI.sysAdminUpdateDepartmentQuota(this.props.groupID, newQuota).then((res) => {
|
||||
systemAdminAPI.sysAdminUpdateDepartmentQuota(this.props.groupID, newQuota).then((res) => {
|
||||
this.props.toggle();
|
||||
this.props.onSetQuota(res.data);
|
||||
}).catch(error => {
|
||||
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
||||
import { Button } from 'reactstrap';
|
||||
import { isPro, gettext } from '../../../utils/constants';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
import SharePermissionEditor from '../../select-editor/share-permission-editor';
|
||||
@@ -154,7 +155,7 @@ class SysAdminShareToGroup extends React.Component {
|
||||
|
||||
listSharedGroups = () => {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.sysAdminListRepoSharedItems(repoID, 'group').then((res) => {
|
||||
systemAdminAPI.sysAdminListRepoSharedItems(repoID, 'group').then((res) => {
|
||||
if (res.data.length !== 0) {
|
||||
this.setState({
|
||||
sharedItems: res.data
|
||||
@@ -176,7 +177,7 @@ class SysAdminShareToGroup extends React.Component {
|
||||
if (this.state.selectedOption) {
|
||||
groups[0] = this.state.selectedOption.id;
|
||||
}
|
||||
seafileAPI.sysAdminAddRepoSharedItem(repoID, 'group', groups, this.state.permission).then(res => {
|
||||
systemAdminAPI.sysAdminAddRepoSharedItem(repoID, 'group', groups, this.state.permission).then(res => {
|
||||
let errorMsg = [];
|
||||
if (res.data.failed.length > 0) {
|
||||
for (let i = 0 ; i < res.data.failed.length ; i++) {
|
||||
@@ -198,7 +199,7 @@ class SysAdminShareToGroup extends React.Component {
|
||||
|
||||
deleteShareItem = (groupID) => {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.sysAdminDeleteRepoSharedItem(repoID, 'group', groupID).then(() => {
|
||||
systemAdminAPI.sysAdminDeleteRepoSharedItem(repoID, 'group', groupID).then(() => {
|
||||
this.setState({
|
||||
sharedItems: this.state.sharedItems.filter(item => { return item.group_id !== groupID; })
|
||||
});
|
||||
@@ -211,7 +212,7 @@ class SysAdminShareToGroup extends React.Component {
|
||||
onChangeUserPermission = (item, permission) => {
|
||||
let repoID = this.props.repoID;
|
||||
let groupID = item.group_id;
|
||||
seafileAPI.sysAdminUpdateRepoSharedItemPermission(repoID, 'group', groupID, permission).then(() => {
|
||||
systemAdminAPI.sysAdminUpdateRepoSharedItemPermission(repoID, 'group', groupID, permission).then(() => {
|
||||
this.updateSharedItems(item, permission);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { isPro, gettext } from '../../../utils/constants';
|
||||
import { Button } from 'reactstrap';
|
||||
import { seafileAPI } from '../../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../../utils/system-admin-api';
|
||||
import { Utils } from '../../../utils/utils';
|
||||
import toaster from '../../toast';
|
||||
import UserSelect from '../../user-select';
|
||||
@@ -133,7 +133,7 @@ class SysAdminShareToUser extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.sysAdminListRepoSharedItems(repoID, 'user').then((res) => {
|
||||
systemAdminAPI.sysAdminListRepoSharedItems(repoID, 'user').then((res) => {
|
||||
if (res.data.length !== 0) {
|
||||
this.setState({ sharedItems: res.data });
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class SysAdminShareToUser extends React.Component {
|
||||
users[i] = this.state.selectedOption[i].email;
|
||||
}
|
||||
}
|
||||
seafileAPI.sysAdminAddRepoSharedItem(repoID, 'user', users, this.state.permission).then(res => {
|
||||
systemAdminAPI.sysAdminAddRepoSharedItem(repoID, 'user', users, this.state.permission).then(res => {
|
||||
let errorMsg = [];
|
||||
if (res.data.failed.length > 0) {
|
||||
for (let i = 0 ; i < res.data.failed.length ; i++) {
|
||||
@@ -185,7 +185,7 @@ class SysAdminShareToUser extends React.Component {
|
||||
|
||||
deleteShareItem = (useremail) => {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.sysAdminDeleteRepoSharedItem(repoID, 'user', useremail).then(res => {
|
||||
systemAdminAPI.sysAdminDeleteRepoSharedItem(repoID, 'user', useremail).then(res => {
|
||||
this.setState({
|
||||
sharedItems: this.state.sharedItems.filter(item => { return item.user_email !== useremail; })
|
||||
});
|
||||
@@ -198,7 +198,7 @@ class SysAdminShareToUser extends React.Component {
|
||||
onChangeUserPermission = (item, permission) => {
|
||||
let repoID = this.props.repoID;
|
||||
let userEmail = item.user_email;
|
||||
seafileAPI.sysAdminUpdateRepoSharedItemPermission(repoID, 'user', userEmail, permission).then(() => {
|
||||
systemAdminAPI.sysAdminUpdateRepoSharedItemPermission(repoID, 'user', userEmail, permission).then(() => {
|
||||
this.updateSharedItems(item, permission);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
@@ -1,19 +1,10 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalHeader,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
Nav,
|
||||
NavItem,
|
||||
NavLink,
|
||||
TabContent,
|
||||
TabPane
|
||||
} from 'reactstrap';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter,
|
||||
Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';
|
||||
import makeAnimated from 'react-select/animated';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { systemAdminAPI } from '../../utils/system-admin-api';
|
||||
import { gettext, isPro, orgID } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
@@ -82,7 +73,7 @@ class TransferDialog extends React.Component {
|
||||
});
|
||||
}
|
||||
else if (this.props.isSysAdmin) {
|
||||
seafileAPI.sysAdminListDepartments().then((res) => {
|
||||
systemAdminAPI.sysAdminListDepartments().then((res) => {
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let obj = {};
|
||||
obj.value = res.data[i].name;
|
||||
|
Reference in New Issue
Block a user