diff --git a/web/src/elements/charts/AdminLoginsChart.ts b/web/src/elements/charts/AdminLoginsChart.ts index 9411597d3..bf0449240 100644 --- a/web/src/elements/charts/AdminLoginsChart.ts +++ b/web/src/elements/charts/AdminLoginsChart.ts @@ -8,7 +8,7 @@ import { DEFAULT_CONFIG } from "../../api/Config"; export class AdminLoginsChart extends AKChart { apiRequest(): Promise { - return new AdminApi(DEFAULT_CONFIG).adminMetricsList(); + return new AdminApi(DEFAULT_CONFIG).adminMetricsList({}); } getDatasets(data: LoginMetrics): Chart.ChartDataSets[] { diff --git a/web/src/elements/charts/UserChart.ts b/web/src/elements/charts/UserChart.ts new file mode 100644 index 000000000..86d4fa113 --- /dev/null +++ b/web/src/elements/charts/UserChart.ts @@ -0,0 +1,52 @@ +import { customElement } from "lit-element"; +import Chart from "chart.js"; +import { CoreApi, UserMetrics } from "authentik-api"; +import { AKChart } from "./Chart"; +import { DEFAULT_CONFIG } from "../../api/Config"; + +@customElement("ak-charts-user") +export class UserChart extends AKChart { + + apiRequest(): Promise { + return new CoreApi(DEFAULT_CONFIG).coreUsersMetrics({}); + } + + getDatasets(data: UserMetrics): Chart.ChartDataSets[] { + return [ + { + label: "Failed Logins", + backgroundColor: "rgba(201, 25, 11, .5)", + spanGaps: true, + data: data.loginsFailedPer1h?.map((cord) => { + return { + x: cord.xCord, + y: cord.yCord, + }; + }), + }, + { + label: "Successful Logins", + backgroundColor: "rgba(189, 229, 184, .5)", + spanGaps: true, + data: data.loginsPer1h?.map((cord) => { + return { + x: cord.xCord, + y: cord.yCord, + }; + }), + }, + { + label: "Application authorizations", + backgroundColor: "rgba(43, 154, 243, .5)", + spanGaps: true, + data: data.loginsPer1h?.map((cord) => { + return { + x: cord.xCord, + y: cord.yCord, + }; + }), + }, + ]; + } + +} diff --git a/web/src/pages/users/UserViewPage.ts b/web/src/pages/users/UserViewPage.ts index dd1d7b513..322b61f63 100644 --- a/web/src/pages/users/UserViewPage.ts +++ b/web/src/pages/users/UserViewPage.ts @@ -20,6 +20,7 @@ import "../../elements/events/ObjectChangelog"; import "../../elements/user/UserConsentList"; import "../../elements/oauth/UserCodeList"; import "../../elements/oauth/UserRefreshList"; +import "../../elements/charts/UserChart"; import { Page } from "../../elements/Page"; import { CoreApi, User } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; @@ -68,8 +69,9 @@ export class UserViewPage extends Page {