1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

sysadmin reconstruct info page optimize js code (#3932)

* sysadmin reconstruct info page optimize js code

* optimize code
This commit is contained in:
Leo
2019-08-09 14:55:08 +08:00
committed by llj
parent 5be4cadbbc
commit 9a1f6dd61d

View File

@@ -15,8 +15,7 @@ class Info extends Component {
this.state = { this.state = {
loading: true, loading: true,
errorMsg: '', errorMsg: '',
sysInfo: {}, sysInfo: {}
with_license: false
}; };
} }
@@ -24,8 +23,7 @@ class Info extends Component {
seafileAPI.getSysInfo().then((res) => { seafileAPI.getSysInfo().then((res) => {
this.setState({ this.setState({
loading: false, loading: false,
sysInfo: res.data, sysInfo: res.data
with_license: res.data.with_license
}); });
}).catch((error) => { }).catch((error) => {
if (error.response) { if (error.response) {
@@ -58,10 +56,9 @@ class Info extends Component {
const file = this.fileInput.current.files[0]; const file = this.fileInput.current.files[0];
seafileAPI.uploadLicense(file).then((res) => { seafileAPI.uploadLicense(file).then((res) => {
let info = this.state.sysInfo; let info = this.state.sysInfo;
Object.assign(info, res.data); Object.assign(info, res.data, {with_license: true});
this.setState({ this.setState({
sysInfo: info, sysInfo: info
with_license: true
}); });
}).catch((error) => { }).catch((error) => {
let errMsg = Utils.getErrorMsg(error); let errMsg = Utils.getErrorMsg(error);
@@ -91,14 +88,9 @@ class Info extends Component {
let { license_mode, license_to, license_expiration, org_count, let { license_mode, license_to, license_expiration, org_count,
repos_count, total_files_count, total_storage, total_devices_count, repos_count, total_files_count, total_storage, total_devices_count,
current_connected_devices_count, license_maxusers, multi_tenancy_enabled, current_connected_devices_count, license_maxusers, multi_tenancy_enabled,
active_users_count, users_count, groups_count } = this.state.sysInfo; active_users_count, users_count, groups_count, with_license } = this.state.sysInfo;
let { loading, errorMsg, with_license } = this.state; let { loading, errorMsg } = this.state;
if (loading) {
return <Loading />;
} else if (errorMsg) {
return <p className="error text-center">{errorMsg}</p>;
} else {
return ( return (
<Fragment> <Fragment>
<div className="main-panel-north border-left-show"> <div className="main-panel-north border-left-show">
@@ -115,6 +107,9 @@ class Info extends Component {
<h3 className="sf-heading">{gettext('Info')}</h3> <h3 className="sf-heading">{gettext('Info')}</h3>
</div> </div>
<div className="cur-view-content"> <div className="cur-view-content">
{loading && <Loading />}
{errorMsg && <p className="error text-center mt-4">{errorMsg}</p>}
{(!loading && !errorMsg) &&
<dl> <dl>
<dt>{gettext('System Info')}</dt> <dt>{gettext('System Info')}</dt>
{isPro ? {isPro ?
@@ -165,6 +160,7 @@ class Info extends Component {
</Fragment> </Fragment>
} }
</dl> </dl>
}
</div> </div>
</div> </div>
</div> </div>
@@ -172,6 +168,5 @@ class Info extends Component {
); );
} }
} }
}
export default Info; export default Info;