admin: add authorisations metric (#3811)
add authorizations metric Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -3,6 +3,7 @@ import "@goauthentik/admin/admin-overview/cards/AdminStatusCard";
|
||||
import "@goauthentik/admin/admin-overview/cards/SystemStatusCard";
|
||||
import "@goauthentik/admin/admin-overview/cards/VersionStatusCard";
|
||||
import "@goauthentik/admin/admin-overview/cards/WorkerStatusCard";
|
||||
import "@goauthentik/admin/admin-overview/charts/AdminLoginAuthorizeChart";
|
||||
import "@goauthentik/admin/admin-overview/charts/FlowStatusChart";
|
||||
import "@goauthentik/admin/admin-overview/charts/GroupCountStatusChart";
|
||||
import "@goauthentik/admin/admin-overview/charts/LDAPSyncStatusChart";
|
||||
@ -13,7 +14,6 @@ import { me } from "@goauthentik/common/users";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/PageHeader";
|
||||
import "@goauthentik/elements/cards/AggregatePromiseCard";
|
||||
import "@goauthentik/elements/charts/AdminLoginsChart";
|
||||
import { paramURL } from "@goauthentik/elements/router/RouterOutlet";
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
@ -189,9 +189,9 @@ export class AdminOverviewPage extends AKElement {
|
||||
>
|
||||
<ak-aggregate-card
|
||||
icon="pf-icon pf-icon-server"
|
||||
header=${t`Logins over the last 24 hours`}
|
||||
header=${t`Logins and authorizations over the last 24 hours`}
|
||||
>
|
||||
<ak-charts-admin-login></ak-charts-admin-login>
|
||||
<ak-charts-admin-login-authorization></ak-charts-admin-login-authorization>
|
||||
</ak-aggregate-card>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { AKChart, RGBAColor } from "@goauthentik/elements/charts/Chart";
|
||||
import { ChartData } from "chart.js";
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { customElement } from "lit/decorators.js";
|
||||
|
||||
import { AdminApi, LoginMetrics } from "@goauthentik/api";
|
||||
|
||||
@customElement("ak-charts-admin-login-authorization")
|
||||
export class AdminLoginAuthorizeChart extends AKChart<LoginMetrics> {
|
||||
apiRequest(): Promise<LoginMetrics> {
|
||||
return new AdminApi(DEFAULT_CONFIG).adminMetricsRetrieve();
|
||||
}
|
||||
|
||||
getChartData(data: LoginMetrics): ChartData {
|
||||
return {
|
||||
datasets: [
|
||||
{
|
||||
label: t`Authorizations`,
|
||||
backgroundColor: new RGBAColor(43, 154, 243, 0.5).toString(),
|
||||
borderColor: new RGBAColor(43, 154, 243, 1).toString(),
|
||||
spanGaps: true,
|
||||
fill: "origin",
|
||||
cubicInterpolationMode: "monotone",
|
||||
tension: 0.4,
|
||||
data: data.authorizationsPer1h.map((cord) => {
|
||||
return {
|
||||
x: cord.xCord,
|
||||
y: cord.yCord,
|
||||
};
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: t`Failed Logins`,
|
||||
backgroundColor: new RGBAColor(201, 24, 11, 0.5).toString(),
|
||||
borderColor: new RGBAColor(201, 24, 11, 1).toString(),
|
||||
spanGaps: true,
|
||||
fill: "origin",
|
||||
cubicInterpolationMode: "monotone",
|
||||
tension: 0.4,
|
||||
data: data.loginsFailedPer1h.map((cord) => {
|
||||
return {
|
||||
x: cord.xCord,
|
||||
y: cord.yCord,
|
||||
};
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: t`Successful Logins`,
|
||||
backgroundColor: new RGBAColor(62, 134, 53, 0.5).toString(),
|
||||
borderColor: new RGBAColor(62, 134, 53, 1).toString(),
|
||||
spanGaps: true,
|
||||
fill: "origin",
|
||||
cubicInterpolationMode: "monotone",
|
||||
tension: 0.4,
|
||||
data: data.loginsPer1h.map((cord) => {
|
||||
return {
|
||||
x: cord.xCord,
|
||||
y: cord.yCord,
|
||||
};
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user