2021-09-21 09:31:37 +00:00
|
|
|
import { ChartData } from "chart.js";
|
|
|
|
|
2021-10-01 12:06:32 +00:00
|
|
|
import { t } from "@lingui/macro";
|
|
|
|
|
2021-09-21 09:19:26 +00:00
|
|
|
import { customElement, property } from "lit/decorators";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-08-15 19:32:28 +00:00
|
|
|
import { Coordinate, CoreApi } from "@goauthentik/api";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { AKChart } from "./Chart";
|
|
|
|
|
|
|
|
@customElement("ak-charts-application-authorize")
|
|
|
|
export class ApplicationAuthorizeChart extends AKChart<Coordinate[]> {
|
|
|
|
@property()
|
|
|
|
applicationSlug!: string;
|
|
|
|
|
|
|
|
apiRequest(): Promise<Coordinate[]> {
|
2021-08-03 15:52:21 +00:00
|
|
|
return new CoreApi(DEFAULT_CONFIG).coreApplicationsMetricsList({
|
|
|
|
slug: this.applicationSlug,
|
|
|
|
});
|
2021-03-08 10:14:00 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 20:15:11 +00:00
|
|
|
getChartData(data: Coordinate[]): ChartData {
|
|
|
|
return {
|
|
|
|
datasets: [
|
|
|
|
{
|
2021-10-01 12:06:32 +00:00
|
|
|
label: t`Authorizations`,
|
2021-05-05 20:15:11 +00:00
|
|
|
backgroundColor: "rgba(189, 229, 184, .5)",
|
|
|
|
spanGaps: true,
|
2021-08-03 15:52:21 +00:00
|
|
|
data:
|
|
|
|
data.map((cord) => {
|
|
|
|
return {
|
|
|
|
x: cord.xCord || 0,
|
|
|
|
y: cord.yCord || 0,
|
|
|
|
};
|
|
|
|
}) || [],
|
2021-05-05 20:15:11 +00:00
|
|
|
},
|
2021-08-03 15:52:21 +00:00
|
|
|
],
|
2021-05-05 20:15:11 +00:00
|
|
|
};
|
2021-03-08 10:14:00 +00:00
|
|
|
}
|
|
|
|
}
|