mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Hide per-role counts for licensed users
* Hide totals
(cherry picked from commit 05f3161f8e
)
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
parent
ddb6922773
commit
735630f364
@ -1,11 +1,12 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { hot } from 'react-hot-loader';
|
||||
import { connect } from 'react-redux';
|
||||
import { Icon, Tooltip } from '@grafana/ui';
|
||||
import { NavModel } from '@grafana/data';
|
||||
import { StoreState } from 'app/types';
|
||||
import { getNavModel } from 'app/core/selectors/navModel';
|
||||
import { getServerStats, ServerStat } from './state/apis';
|
||||
import Page from 'app/core/components/Page/Page';
|
||||
import { NavModel } from '@grafana/data';
|
||||
import { getServerStats, ServerStat } from './state/apis';
|
||||
|
||||
interface Props {
|
||||
navModel: NavModel;
|
||||
@ -57,7 +58,14 @@ export class ServerStats extends PureComponent<Props, State> {
|
||||
function StatItem(stat: ServerStat) {
|
||||
return (
|
||||
<tr key={stat.name}>
|
||||
<td>{stat.name}</td>
|
||||
<td>
|
||||
{stat.name}{' '}
|
||||
{stat.tooltip && (
|
||||
<Tooltip content={stat.tooltip} placement={'top'}>
|
||||
<Icon name={'info-circle'} />
|
||||
</Tooltip>
|
||||
)}
|
||||
</td>
|
||||
<td>{stat.value}</td>
|
||||
</tr>
|
||||
);
|
||||
|
@ -1,34 +0,0 @@
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
|
||||
export interface ServerStat {
|
||||
name: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export const getServerStats = async (): Promise<ServerStat[]> => {
|
||||
try {
|
||||
const res = await getBackendSrv().get('api/admin/stats');
|
||||
return [
|
||||
{ name: 'Total users', value: res.users },
|
||||
{ name: 'Total admins', value: res.admins },
|
||||
{ name: 'Total editors', value: res.editors },
|
||||
{ name: 'Total viewers', value: res.viewers },
|
||||
{ name: 'Active users (seen last 30 days)', value: res.activeUsers },
|
||||
{ name: 'Active admins (seen last 30 days)', value: res.activeAdmins },
|
||||
{ name: 'Active editors (seen last 30 days)', value: res.activeEditors },
|
||||
{ name: 'Active viewers (seen last 30 days)', value: res.activeViewers },
|
||||
{ name: 'Active sessions', value: res.activeSessions },
|
||||
{ name: 'Total dashboards', value: res.dashboards },
|
||||
{ name: 'Total orgs', value: res.orgs },
|
||||
{ name: 'Total playlists', value: res.playlists },
|
||||
{ name: 'Total snapshots', value: res.snapshots },
|
||||
{ name: 'Total dashboard tags', value: res.tags },
|
||||
{ name: 'Total starred dashboards', value: res.stars },
|
||||
{ name: 'Total alerts', value: res.alerts },
|
||||
{ name: 'Total data sources', value: res.datasources },
|
||||
];
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
58
public/app/features/admin/state/apis.tsx
Normal file
58
public/app/features/admin/state/apis.tsx
Normal file
@ -0,0 +1,58 @@
|
||||
import React from 'react';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { PopoverContent } from '@grafana/ui';
|
||||
import { config } from 'app/core/config';
|
||||
|
||||
export interface ServerStat {
|
||||
name: string;
|
||||
value: number;
|
||||
tooltip?: PopoverContent;
|
||||
}
|
||||
|
||||
const { hasLicense } = config.licenseInfo;
|
||||
|
||||
export const getServerStats = async (): Promise<ServerStat[]> => {
|
||||
try {
|
||||
const res = await getBackendSrv().get('api/admin/stats');
|
||||
return [
|
||||
{ name: 'Total users', value: res.users },
|
||||
...(!hasLicense
|
||||
? [
|
||||
{ name: 'Total admins', value: res.admins },
|
||||
{ name: 'Total editors', value: res.editors },
|
||||
{ name: 'Total viewers', value: res.viewers },
|
||||
]
|
||||
: []),
|
||||
{
|
||||
name: 'Active users (seen last 30 days)',
|
||||
value: res.activeUsers,
|
||||
tooltip: hasLicense
|
||||
? () => (
|
||||
<>
|
||||
For active user count by role, see the <a href="/admin/licensing">Licensing page</a>.
|
||||
</>
|
||||
)
|
||||
: '',
|
||||
},
|
||||
...(!hasLicense
|
||||
? [
|
||||
{ name: 'Active admins (seen last 30 days)', value: res.activeAdmins },
|
||||
{ name: 'Active editors (seen last 30 days)', value: res.activeEditors },
|
||||
{ name: 'Active viewers (seen last 30 days)', value: res.activeViewers },
|
||||
]
|
||||
: []),
|
||||
{ name: 'Active sessions', value: res.activeSessions },
|
||||
{ name: 'Total dashboards', value: res.dashboards },
|
||||
{ name: 'Total orgs', value: res.orgs },
|
||||
{ name: 'Total playlists', value: res.playlists },
|
||||
{ name: 'Total snapshots', value: res.snapshots },
|
||||
{ name: 'Total dashboard tags', value: res.tags },
|
||||
{ name: 'Total starred dashboards', value: res.stars },
|
||||
{ name: 'Total alerts', value: res.alerts },
|
||||
{ name: 'Total data sources', value: res.datasources },
|
||||
];
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user