remove syncstatus leftovers

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2025-06-24 15:44:12 +02:00
parent 031456629b
commit 9b13922fc2
6 changed files with 0 additions and 513 deletions

View File

@ -1,157 +0,0 @@
import type { Meta, StoryObj } from "@storybook/web-components";
import { html } from "lit";
import { LogLevelEnum, SyncStatus, SystemTaskStatusEnum } from "@goauthentik/api";
import "./SyncStatusCard";
const metadata: Meta<SyncStatus> = {
title: "Elements/<ak-sync-status-card>",
component: "ak-sync-status-card",
};
export default metadata;
export const Running: StoryObj = {
args: {
status: {
isRunning: true,
tasks: [],
} as SyncStatus,
},
// @ts-ignore
render: ({ status }: SyncStatus) => {
return html` <div style="background-color: #f0f0f0; padding: 1rem;">
<ak-sync-status-card
.fetch=${async () => {
return status;
}}
></ak-sync-status-card>
</div>`;
},
};
export const SingleTask: StoryObj = {
args: {
status: {
isRunning: false,
tasks: [
{
uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b",
name: "Single task",
fullName: "foo:bar:baz",
status: SystemTaskStatusEnum.Successful,
messages: [
{
logger: "foo",
event: "bar",
attributes: {
foo: "bar",
},
timestamp: new Date(),
logLevel: LogLevelEnum.Info,
},
],
description: "foo",
startTimestamp: new Date(),
finishTimestamp: new Date(),
duration: 0,
},
],
} as SyncStatus,
},
// @ts-ignore
render: ({ status }: SyncStatus) => {
return html` <div style="background-color: #f0f0f0; padding: 1rem;">
<ak-sync-status-card
.fetch=${async () => {
return status;
}}
></ak-sync-status-card>
</div>`;
},
};
export const MultipleTasks: StoryObj = {
args: {
status: {
isRunning: false,
tasks: [
{
uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b",
name: "Single task",
fullName: "foo:bar:baz",
status: SystemTaskStatusEnum.Successful,
messages: [
{
logger: "foo",
event: "bar",
attributes: {
foo: "bar",
},
timestamp: new Date(),
logLevel: LogLevelEnum.Info,
},
],
description: "foo",
startTimestamp: new Date(),
finishTimestamp: new Date(),
duration: 0,
},
{
uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b",
name: "Single task",
fullName: "foo:bar:baz",
status: SystemTaskStatusEnum.Successful,
messages: [
{
logger: "foo",
event: "bar",
attributes: {
foo: "bar",
},
timestamp: new Date(),
logLevel: LogLevelEnum.Info,
},
],
description: "foo",
startTimestamp: new Date(),
finishTimestamp: new Date(),
duration: 0,
},
{
uuid: "9ff42169-8249-4b67-ae3d-e455d822de2b",
name: "Single task",
fullName: "foo:bar:baz",
status: SystemTaskStatusEnum.Successful,
messages: [
{
logger: "foo",
event: "bar",
attributes: {
foo: "bar",
},
timestamp: new Date(),
logLevel: LogLevelEnum.Info,
},
],
description: "foo",
startTimestamp: new Date(),
finishTimestamp: new Date(),
duration: 0,
},
],
} as SyncStatus,
},
// @ts-ignore
render: ({ status }: SyncStatus) => {
return html` <div style="background-color: #f0f0f0; padding: 1rem;">
<ak-sync-status-card
.fetch=${async () => {
return status;
}}
></ak-sync-status-card>
</div>`;
},
};

View File

@ -1,112 +0,0 @@
import { EVENT_REFRESH } from "@goauthentik/common/constants";
import "@goauthentik/components/ak-status-label";
import { AKElement } from "@goauthentik/elements/Base";
import "@goauthentik/elements/EmptyState";
import "@goauthentik/elements/buttons/ActionButton";
import "@goauthentik/elements/events/LogViewer";
import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFCard from "@patternfly/patternfly/components/Card/card.css";
import PFTable from "@patternfly/patternfly/components/Table/table.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { SyncStatus } from "@goauthentik/api";
@customElement("ak-sync-status-card")
export class SyncStatusCard extends AKElement {
@state()
syncState?: SyncStatus;
@state()
loading = false;
@property({ attribute: false })
fetch!: () => Promise<SyncStatus>;
@property({ attribute: false })
triggerSync!: () => Promise<unknown>;
static get styles(): CSSResult[] {
return [PFBase, PFButton, PFCard, PFTable];
}
firstUpdated() {
this.loading = true;
this.fetch().then((status) => {
this.syncState = status;
this.loading = false;
});
}
renderSyncStatus(): TemplateResult {
if (this.loading) {
return html`<ak-empty-state loading></ak-empty-state>`;
}
if (!this.syncState) {
return html`${msg("No sync status.")}`;
}
if (this.syncState.isRunning) {
return html`${msg("Sync currently running.")}`;
}
return html`${msg("No synchronization currently running.")}`;
}
render(): TemplateResult {
return html`<div class="pf-c-card">
<div class="pf-c-card__header">
<div class="pf-c-card__actions">
<button
class="pf-c-button pf-m-plain"
type="button"
@click=${() => {
this.fetch();
}}
>
<i class="fa fa-sync"></i>
</button>
</div>
<div class="pf-c-card__title">${msg("Sync status")}</div>
</div>
<div class="pf-c-card__body">${this.renderSyncStatus()}</div>
<div class="pf-c-card__footer">
<ak-action-button
class="pf-m-secondary"
?disabled=${this.syncState?.isRunning}
.apiRequest=${() => {
if (this.syncState) {
// This is a bit of a UX cheat, we set isRunning to true to disable the button
// and change the text even before we hear back from the backend
this.syncState = {
...this.syncState,
isRunning: true,
};
}
this.triggerSync().then(() => {
this.dispatchEvent(
new CustomEvent(EVENT_REFRESH, {
bubbles: true,
composed: true,
}),
);
this.firstUpdated();
});
}}
>
${this.syncState?.isRunning
? msg("Sync currently running")
: msg("Run sync again")}
</ak-action-button>
</div>
</div>`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ak-sync-status-card": SyncStatusCard;
}
}