2021-09-21 09:19:26 +00:00
|
|
|
import { customElement, property } from "lit/decorators";
|
2021-08-15 19:32:28 +00:00
|
|
|
import { Coordinate, CoreApi } from "@goauthentik/api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { AKChart } from "./Chart";
|
2021-05-05 20:15:11 +00:00
|
|
|
import { ChartData } from "chart.js";
|
2021-03-08 10:14:00 +00:00
|
|
|
|
|
|
|
@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: [
|
|
|
|
{
|
|
|
|
label: "Authorizations",
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|