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:
@ -1,6 +1,16 @@
|
||||
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { Chart, ChartConfiguration, ChartData, ChartOptions, Plugin, Tick } from "chart.js";
|
||||
import {
|
||||
Chart,
|
||||
ChartConfiguration,
|
||||
ChartData,
|
||||
ChartOptions,
|
||||
Filler,
|
||||
LineElement,
|
||||
Plugin,
|
||||
PointElement,
|
||||
Tick,
|
||||
} from "chart.js";
|
||||
import { Legend, Tooltip } from "chart.js";
|
||||
import { BarController, DoughnutController, LineController } from "chart.js";
|
||||
import { ArcElement, BarElement } from "chart.js";
|
||||
@ -14,12 +24,33 @@ import { property } from "lit/decorators.js";
|
||||
|
||||
Chart.register(Legend, Tooltip);
|
||||
Chart.register(LineController, BarController, DoughnutController);
|
||||
Chart.register(ArcElement, BarElement);
|
||||
Chart.register(TimeScale, LinearScale);
|
||||
Chart.register(ArcElement, BarElement, PointElement, LineElement);
|
||||
Chart.register(TimeScale, LinearScale, Filler);
|
||||
|
||||
export const FONT_COLOUR_DARK_MODE = "#fafafa";
|
||||
export const FONT_COLOUR_LIGHT_MODE = "#151515";
|
||||
|
||||
export class RGBAColor {
|
||||
constructor(public r: number, public g: number, public b: number, public a: number = 1) {}
|
||||
toString(): string {
|
||||
return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;
|
||||
}
|
||||
}
|
||||
|
||||
export function getColorFromString(stringInput: string): RGBAColor {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < stringInput.length; i++) {
|
||||
hash = stringInput.charCodeAt(i) + ((hash << 5) - hash);
|
||||
hash = hash & hash;
|
||||
}
|
||||
const rgb = [0, 0, 0];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const value = (hash >> (i * 8)) & 255;
|
||||
rgb[i] = value;
|
||||
}
|
||||
return new RGBAColor(rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
|
||||
export abstract class AKChart<T> extends AKElement {
|
||||
abstract apiRequest(): Promise<T>;
|
||||
abstract getChartData(data: T): ChartData;
|
||||
|
||||
Reference in New Issue
Block a user