diff --git a/web/src/admin/system-tasks/TaskList.ts b/web/src/admin/system-tasks/TaskList.ts
index 222d9b3d50..a4a3fb142d 100644
--- a/web/src/admin/system-tasks/TaskList.ts
+++ b/web/src/admin/system-tasks/TaskList.ts
@@ -1,6 +1,6 @@
+import { formatElapsedTime } from "#common/temporal";
import "@goauthentik/admin/rbac/ObjectPermissionModal";
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
-import { getRelativeTime } from "@goauthentik/common/utils";
import { PFColor } from "@goauthentik/elements/Label";
import "@goauthentik/elements/buttons/SpinnerButton";
import "@goauthentik/elements/events/LogViewer";
@@ -16,7 +16,7 @@ import { customElement, property } from "lit/decorators.js";
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
-import { Schedule, Task, TasksApi, TasksTasksListStateEnum } from "@goauthentik/api";
+import { Task, TasksApi, TasksTasksListStateEnum } from "@goauthentik/api";
@customElement("ak-task-list")
export class TaskList extends Table
{
@@ -24,7 +24,14 @@ export class TaskList extends Table {
clearOnRefresh = true;
@property()
- schedule: Schedule | undefined;
+ relObjAppLabel?: string;
+ @property()
+ relObjModel?: string;
+ @property()
+ relObjId?: string;
+
+ @property()
+ showOnlyStandalone: boolean = true;
searchEnabled(): boolean {
return true;
@@ -38,14 +45,27 @@ export class TaskList extends Table {
}
async apiEndpoint(): Promise> {
- const excludeScheduled = this.schedule === undefined;
+ const relObjIdIsnull =
+ typeof this.relObjId !== "undefined"
+ ? undefined
+ : this.showOnlyStandalone
+ ? true
+ : undefined;
return new TasksApi(DEFAULT_CONFIG).tasksTasksList({
...(await this.defaultEndpointConfig()),
- excludeScheduled: excludeScheduled,
- scheduleUid: this.schedule?.uid,
+ relObjContentTypeAppLabel: this.relObjAppLabel,
+ relObjContentTypeModel: this.relObjModel,
+ relObjId: this.relObjId,
+ relObjIdIsnull,
});
}
+ #toggleShowOnlyStandalone = () => {
+ this.showOnlyStandalone = !this.showOnlyStandalone;
+ this.page = 1;
+ return this.fetch();
+ };
+
columns(): TableColumn[] {
return [
new TableColumn(msg("Task"), "actor_name"),
@@ -56,6 +76,37 @@ export class TaskList extends Table {
];
}
+ renderToolbarAfter(): TemplateResult {
+ console.log("task show standalone");
+ console.log(this.showOnlyStandalone);
+ if (this.relObjId !== undefined) {
+ return html``;
+ }
+ return html`
+ `;
+ }
+
taskState(task: Task): TemplateResult {
switch (task.state) {
case TasksTasksListStateEnum.Queued:
@@ -74,9 +125,9 @@ export class TaskList extends Table {
row(item: Task): TemplateResult[] {
return [
html`${item.actorName}
- ${item.uid}`,
+ ${item.uid.replace(new RegExp("^authentik."), "")}`,
html`${item.queueName}`,
- html`${getRelativeTime(item.mtime)}
+ html`${formatElapsedTime(item.mtime || new Date())}
${item.mtime.toLocaleString()}`,
this.taskState(item),
html``,