2020-12-29 10:34:23 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import Column from '../ui/components/column';
|
2020-12-29 20:17:03 -08:00
|
|
|
import RegistrationModePicker from './components/registration_mode_picker';
|
2020-12-29 10:34:23 -08:00
|
|
|
import { parseVersion } from 'soapbox/utils/features';
|
2021-03-30 15:28:36 -07:00
|
|
|
import sourceCode from 'soapbox/utils/code';
|
2020-12-29 10:34:23 -08:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
heading: { id: 'column.admin.dashboard', defaultMessage: 'Dashboard' },
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
instance: state.get('instance'),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
@injectIntl
|
|
|
|
class Dashboard extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
instance: ImmutablePropTypes.map.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { intl, instance } = this.props;
|
|
|
|
const v = parseVersion(instance.get('version'));
|
2021-04-22 19:00:28 -07:00
|
|
|
const userCount = instance.getIn(['stats', 'user_count']);
|
2021-04-22 18:23:54 -07:00
|
|
|
const mau = instance.getIn(['pleroma', 'stats', 'mau']);
|
2021-04-22 19:00:28 -07:00
|
|
|
const retention = (userCount && mau) ? Math.round(mau / userCount * 100) : null;
|
2020-12-29 10:34:23 -08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Column icon='tachometer' heading={intl.formatMessage(messages.heading)} backBtnSlim>
|
|
|
|
<div className='dashcounters'>
|
2021-04-22 19:00:28 -07:00
|
|
|
{mau && <div className='dashcounter'>
|
|
|
|
<div>
|
|
|
|
<div className='dashcounter__num'>
|
|
|
|
<FormattedNumber value={mau} />
|
|
|
|
</div>
|
|
|
|
<div className='dashcounter__label'>
|
|
|
|
<FormattedMessage id='admin.dashcounters.mau_label' defaultMessage='monthly active users' />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashcounter'>
|
2020-12-29 10:44:29 -08:00
|
|
|
<a href='/pleroma/admin/#/users/index' target='_blank'>
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashcounter__num'>
|
2021-04-22 19:00:28 -07:00
|
|
|
<FormattedNumber value={userCount} />
|
2020-12-29 10:34:23 -08:00
|
|
|
</div>
|
|
|
|
<div className='dashcounter__label'>
|
2021-04-22 19:00:28 -07:00
|
|
|
<FormattedMessage id='admin.dashcounters.user_count_label' defaultMessage='total users' />
|
2020-12-29 10:34:23 -08:00
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-04-22 19:00:28 -07:00
|
|
|
{retention && <div className='dashcounter'>
|
|
|
|
<div>
|
|
|
|
<div className='dashcounter__num'>
|
|
|
|
{retention}%
|
|
|
|
</div>
|
|
|
|
<div className='dashcounter__label'>
|
|
|
|
<FormattedMessage id='admin.dashcounters.retention_label' defaultMessage='user retention' />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashcounter'>
|
2020-12-29 10:44:29 -08:00
|
|
|
<a href='/pleroma/admin/#/statuses/index' target='_blank'>
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashcounter__num'>
|
|
|
|
<FormattedNumber value={instance.getIn(['stats', 'status_count'])} />
|
|
|
|
</div>
|
|
|
|
<div className='dashcounter__label'>
|
|
|
|
<FormattedMessage id='admin.dashcounters.status_count_label' defaultMessage='posts' />
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div className='dashcounter'>
|
2020-12-30 15:57:49 -08:00
|
|
|
<div>
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashcounter__num'>
|
2020-12-30 15:57:49 -08:00
|
|
|
<FormattedNumber value={instance.getIn(['stats', 'domain_count'])} />
|
2020-12-29 10:34:23 -08:00
|
|
|
</div>
|
|
|
|
<div className='dashcounter__label'>
|
2020-12-30 15:57:49 -08:00
|
|
|
<FormattedMessage id='admin.dashcounters.domain_count_label' defaultMessage='peers' />
|
2020-12-29 10:34:23 -08:00
|
|
|
</div>
|
2020-12-30 15:57:49 -08:00
|
|
|
</div>
|
2020-12-29 10:34:23 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-29 20:17:03 -08:00
|
|
|
<RegistrationModePicker />
|
2020-12-29 10:34:23 -08:00
|
|
|
<div className='dashwidgets'>
|
2020-12-29 21:25:07 -08:00
|
|
|
<div className='dashwidget'>
|
2020-12-29 10:34:23 -08:00
|
|
|
<h4><FormattedMessage id='admin.dashwidgets.software_header' defaultMessage='Software' /></h4>
|
|
|
|
<ul>
|
2021-03-30 15:28:36 -07:00
|
|
|
<li>Soapbox FE <span className='pull-right'>{sourceCode.version}</span></li>
|
2020-12-29 21:25:07 -08:00
|
|
|
<li>{v.software} <span className='pull-right'>{v.version}</span></li>
|
2020-12-29 10:34:23 -08:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|