mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-18 03:19:51 +03:00
7f0c6ddb5b
* base locale off of ak-element Signed-off-by: Jens Langhammer <jens@goauthentik.io> * revert temp theme fixes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix theme switching Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add basic support for theme-different images Signed-off-by: Jens Langhammer <jens@goauthentik.io> * sort outposts in card Signed-off-by: Jens Langhammer <jens@goauthentik.io> * set default theme based on pre-hydrated brand settings Signed-off-by: Jens Langhammer <jens@goauthentik.io> * activate global theme before root in shadow dom Signed-off-by: Jens Langhammer <jens@goauthentik.io> * logging Signed-off-by: Jens Langhammer <jens@goauthentik.io> * when using _applyTheme, check media matcher Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
83 lines
2.8 KiB
TypeScript
83 lines
2.8 KiB
TypeScript
import { SummarizedSyncStatus } from "@goauthentik/admin/admin-overview/charts/SyncStatusChart";
|
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { AKChart } from "@goauthentik/elements/charts/Chart";
|
|
import "@goauthentik/elements/forms/ConfirmationForm";
|
|
import { ChartData, ChartOptions } from "chart.js";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { customElement } from "lit/decorators.js";
|
|
|
|
import { OutpostsApi } from "@goauthentik/api";
|
|
|
|
@customElement("ak-admin-status-chart-outpost")
|
|
export class OutpostStatusChart extends AKChart<SummarizedSyncStatus[]> {
|
|
getChartType(): string {
|
|
return "doughnut";
|
|
}
|
|
|
|
getOptions(): ChartOptions {
|
|
return {
|
|
plugins: {
|
|
legend: {
|
|
display: false,
|
|
},
|
|
},
|
|
maintainAspectRatio: false,
|
|
};
|
|
}
|
|
|
|
async apiRequest(): Promise<SummarizedSyncStatus[]> {
|
|
const api = new OutpostsApi(DEFAULT_CONFIG);
|
|
const outposts = await api.outpostsInstancesList({});
|
|
const outpostStats: SummarizedSyncStatus[] = [];
|
|
await Promise.all(
|
|
outposts.results.map(async (element) => {
|
|
const health = await api.outpostsInstancesHealthList({
|
|
uuid: element.pk || "",
|
|
});
|
|
const singleStats: SummarizedSyncStatus = {
|
|
unsynced: 0,
|
|
healthy: 0,
|
|
failed: 0,
|
|
total: health.length,
|
|
label: element.name,
|
|
};
|
|
if (health.length === 0) {
|
|
singleStats.unsynced += 1;
|
|
}
|
|
health.forEach((h) => {
|
|
if (h.versionOutdated) {
|
|
singleStats.failed += 1;
|
|
} else {
|
|
singleStats.healthy += 1;
|
|
}
|
|
});
|
|
outpostStats.push(singleStats);
|
|
}),
|
|
);
|
|
this.centerText = outposts.pagination.count.toString();
|
|
outpostStats.sort((a, b) => a.label.localeCompare(b.label));
|
|
return outpostStats;
|
|
}
|
|
|
|
getChartData(data: SummarizedSyncStatus[]): ChartData {
|
|
return {
|
|
labels: [msg("Healthy outposts"), msg("Outdated outposts"), msg("Unhealthy outposts")],
|
|
datasets: data.map((d) => {
|
|
return {
|
|
backgroundColor: ["#3e8635", "#C9190B", "#2b9af3"],
|
|
spanGaps: true,
|
|
data: [d.healthy, d.failed, d.unsynced],
|
|
label: d.label,
|
|
};
|
|
}),
|
|
};
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-admin-status-chart-outpost": OutpostStatusChart;
|
|
}
|
|
}
|