mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
sysadmin reconstruct info page optimize js code (#3932)
* sysadmin reconstruct info page optimize js code * optimize code
This commit is contained in:
@@ -15,8 +15,7 @@ class Info extends Component {
|
||||
this.state = {
|
||||
loading: true,
|
||||
errorMsg: '',
|
||||
sysInfo: {},
|
||||
with_license: false
|
||||
sysInfo: {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,8 +23,7 @@ class Info extends Component {
|
||||
seafileAPI.getSysInfo().then((res) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
sysInfo: res.data,
|
||||
with_license: res.data.with_license
|
||||
sysInfo: res.data
|
||||
});
|
||||
}).catch((error) => {
|
||||
if (error.response) {
|
||||
@@ -58,10 +56,9 @@ class Info extends Component {
|
||||
const file = this.fileInput.current.files[0];
|
||||
seafileAPI.uploadLicense(file).then((res) => {
|
||||
let info = this.state.sysInfo;
|
||||
Object.assign(info, res.data);
|
||||
Object.assign(info, res.data, {with_license: true});
|
||||
this.setState({
|
||||
sysInfo: info,
|
||||
with_license: true
|
||||
sysInfo: info
|
||||
});
|
||||
}).catch((error) => {
|
||||
let errMsg = Utils.getErrorMsg(error);
|
||||
@@ -91,14 +88,9 @@ class Info extends Component {
|
||||
let { license_mode, license_to, license_expiration, org_count,
|
||||
repos_count, total_files_count, total_storage, total_devices_count,
|
||||
current_connected_devices_count, license_maxusers, multi_tenancy_enabled,
|
||||
active_users_count, users_count, groups_count } = this.state.sysInfo;
|
||||
let { loading, errorMsg, with_license } = this.state;
|
||||
active_users_count, users_count, groups_count, with_license } = this.state.sysInfo;
|
||||
let { loading, errorMsg } = this.state;
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
} else if (errorMsg) {
|
||||
return <p className="error text-center">{errorMsg}</p>;
|
||||
} else {
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="main-panel-north border-left-show">
|
||||
@@ -115,6 +107,9 @@ class Info extends Component {
|
||||
<h3 className="sf-heading">{gettext('Info')}</h3>
|
||||
</div>
|
||||
<div className="cur-view-content">
|
||||
{loading && <Loading />}
|
||||
{errorMsg && <p className="error text-center mt-4">{errorMsg}</p>}
|
||||
{(!loading && !errorMsg) &&
|
||||
<dl>
|
||||
<dt>{gettext('System Info')}</dt>
|
||||
{isPro ?
|
||||
@@ -165,6 +160,7 @@ class Info extends Component {
|
||||
</Fragment>
|
||||
}
|
||||
</dl>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -172,6 +168,5 @@ class Info extends Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Info;
|
||||
|
Reference in New Issue
Block a user