* rework event volume Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * the rest of the owl Signed-off-by: Jens Langhammer <jens@goauthentik.io> * client-side data padding Signed-off-by: Jens Langhammer <jens@goauthentik.io> * I love deleting code Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix clamping Signed-off-by: Jens Langhammer <jens@goauthentik.io> * chunk it Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add event-to-color map Signed-off-by: Jens Langhammer <jens@goauthentik.io> * sync colours Signed-off-by: Jens Langhammer <jens@goauthentik.io> * switch colours Signed-off-by: Jens Langhammer <jens@goauthentik.io> * heatmap? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * Revert "heatmap?" This reverts commitc1f549a18b. * Revert "Revert "heatmap?"" This reverts commit6d6175b96b. * Revert "Revert "Revert "heatmap?""" This reverts commit3717903f12. * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { EventChart } from "#elements/charts/EventChart";
|
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { ChartData, ChartDataset } from "chart.js";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { customElement } from "lit/decorators.js";
|
|
|
|
import { EventActions, EventVolume, EventsApi } from "@goauthentik/api";
|
|
|
|
@customElement("ak-charts-admin-login-authorization")
|
|
export class AdminLoginAuthorizeChart extends EventChart {
|
|
async apiRequest(): Promise<EventVolume[]> {
|
|
return new EventsApi(DEFAULT_CONFIG).eventsEventsVolumeList({
|
|
actions: [
|
|
EventActions.AuthorizeApplication,
|
|
EventActions.Login,
|
|
EventActions.LoginFailed,
|
|
],
|
|
});
|
|
}
|
|
|
|
getChartData(data: EventVolume[]): ChartData {
|
|
const optsMap = new Map<EventActions, Partial<ChartDataset>>();
|
|
optsMap.set(EventActions.AuthorizeApplication, {
|
|
label: msg("Authorizations"),
|
|
spanGaps: true,
|
|
fill: "origin",
|
|
cubicInterpolationMode: "monotone",
|
|
tension: 0.4,
|
|
});
|
|
optsMap.set(EventActions.Login, {
|
|
label: msg("Successful Logins"),
|
|
spanGaps: true,
|
|
fill: "origin",
|
|
cubicInterpolationMode: "monotone",
|
|
tension: 0.4,
|
|
});
|
|
optsMap.set(EventActions.LoginFailed, {
|
|
label: msg("Failed Logins"),
|
|
spanGaps: true,
|
|
fill: "origin",
|
|
cubicInterpolationMode: "monotone",
|
|
tension: 0.4,
|
|
});
|
|
return this.eventVolume(data, {
|
|
optsMap: optsMap,
|
|
padToDays: 7,
|
|
});
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-charts-admin-login-authorization": AdminLoginAuthorizeChart;
|
|
}
|
|
}
|