web/admin: fix naming of charts on overview page

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-05-06 13:51:54 +02:00
parent 9538ad5710
commit e401b4e74e
7 changed files with 33 additions and 33 deletions

View File

@ -0,0 +1,68 @@
import { customElement } from "lit-element";
import { CoreApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import { AKChart } from "../../../elements/charts/Chart";
import { t } from "@lingui/macro";
import { ChartOptions, ChartData } from "chart.js";
interface UserMetrics {
count: number;
superusers: number;
}
@customElement("ak-admin-status-chart-user-count")
export class UserCountStatusChart extends AKChart<UserMetrics> {
getChartType(): string {
return "doughnut";
}
getOptions(): ChartOptions {
return {
plugins: {
legend: {
display: false,
},
},
maintainAspectRatio: false,
};
}
async apiRequest(): Promise<UserMetrics> {
const api = new CoreApi(DEFAULT_CONFIG);
const count = (await api.coreUsersList({
pageSize: 1
})).pagination.count;
const superusers = (await api.coreUsersList({
isSuperuser: "true"
})).pagination.count;
this.centerText = count.toString();
return {
count: count - superusers,
superusers,
};
}
getChartData(data: UserMetrics): ChartData {
return {
labels: [
t`Total users`,
t`Superusers`,
],
datasets: [
{
backgroundColor: [
"#2b9af3",
"#3e8635",
],
spanGaps: true,
data: [
data.count,
data.superusers,
],
},
]
};
}
}