show tasks/schedules for outpost service connections
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
		| @ -84,7 +84,7 @@ def controller_for_outpost(outpost: Outpost) -> type[BaseController] | None: | |||||||
|     return None |     return None | ||||||
|  |  | ||||||
|  |  | ||||||
| @actor(description=_("Update cached state of a service connection.")) | @actor(description=_("Update cached state of service connection.")) | ||||||
| def outpost_service_connection_monitor(connection_pk: Any): | def outpost_service_connection_monitor(connection_pk: Any): | ||||||
|     """Update cached state of a service connection""" |     """Update cached state of a service connection""" | ||||||
|     connection: OutpostServiceConnection = ( |     connection: OutpostServiceConnection = ( | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _ | |||||||
| from django_dramatiq_postgres.models import ScheduleBase | from django_dramatiq_postgres.models import ScheduleBase | ||||||
|  |  | ||||||
| from authentik.lib.models import SerializerModel | from authentik.lib.models import SerializerModel | ||||||
|  | from authentik.tasks.models import TasksModel | ||||||
| from authentik.tasks.schedules.lib import ScheduleSpec | from authentik.tasks.schedules.lib import ScheduleSpec | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -36,7 +37,7 @@ class Schedule(SerializerModel, ScheduleBase): | |||||||
|         return ScheduleSerializer |         return ScheduleSerializer | ||||||
|  |  | ||||||
|  |  | ||||||
| class ScheduledModel(models.Model): | class ScheduledModel(TasksModel, models.Model): | ||||||
|     schedules = GenericRelation( |     schedules = GenericRelation( | ||||||
|         Schedule, content_type_field="rel_obj_content_type", object_id_field="rel_obj_id" |         Schedule, content_type_field="rel_obj_content_type", object_id_field="rel_obj_id" | ||||||
|     ) |     ) | ||||||
| @ -51,7 +52,11 @@ class ScheduledModel(models.Model): | |||||||
|                 return True |                 return True | ||||||
|             return any(is_scheduled_model(klass) for klass in klass.__bases__) |             return any(is_scheduled_model(klass) for klass in klass.__bases__) | ||||||
|  |  | ||||||
|         return [model for model in apps.get_models() if is_scheduled_model(model)] |         return [ | ||||||
|  |             model | ||||||
|  |             for model in apps.get_models() | ||||||
|  |             if is_scheduled_model(model) and not model.__subclasses__() | ||||||
|  |         ] | ||||||
|  |  | ||||||
|     @property |     @property | ||||||
|     def schedule_specs(self) -> list[ScheduleSpec]: |     def schedule_specs(self) -> list[ScheduleSpec]: | ||||||
|  | |||||||
| @ -3,9 +3,12 @@ import "@goauthentik/admin/outposts/ServiceConnectionDockerForm"; | |||||||
| import "@goauthentik/admin/outposts/ServiceConnectionKubernetesForm"; | import "@goauthentik/admin/outposts/ServiceConnectionKubernetesForm"; | ||||||
| import "@goauthentik/admin/outposts/ServiceConnectionWizard"; | import "@goauthentik/admin/outposts/ServiceConnectionWizard"; | ||||||
| import "@goauthentik/admin/rbac/ObjectPermissionModal"; | import "@goauthentik/admin/rbac/ObjectPermissionModal"; | ||||||
|  | import "@goauthentik/admin/system-tasks/ScheduleList"; | ||||||
|  | import "@goauthentik/admin/system-tasks/TaskList"; | ||||||
| import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||||||
| import "@goauthentik/components/ak-status-label"; | import "@goauthentik/components/ak-status-label"; | ||||||
| import { PFColor } from "@goauthentik/elements/Label"; | import { PFColor } from "@goauthentik/elements/Label"; | ||||||
|  | import "@goauthentik/elements/Tabs"; | ||||||
| import "@goauthentik/elements/buttons/SpinnerButton"; | import "@goauthentik/elements/buttons/SpinnerButton"; | ||||||
| import "@goauthentik/elements/forms/DeleteBulkForm"; | import "@goauthentik/elements/forms/DeleteBulkForm"; | ||||||
| import "@goauthentik/elements/forms/ModalForm"; | import "@goauthentik/elements/forms/ModalForm"; | ||||||
| @ -40,6 +43,7 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     checkbox = true; |     checkbox = true; | ||||||
|  |     expandable = true; | ||||||
|     clearOnRefresh = true; |     clearOnRefresh = true; | ||||||
|  |  | ||||||
|     async apiEndpoint(): Promise<PaginatedResponse<ServiceConnection>> { |     async apiEndpoint(): Promise<PaginatedResponse<ServiceConnection>> { | ||||||
| @ -109,6 +113,52 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio | |||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     renderExpanded(item: ServiceConnection): TemplateResult { | ||||||
|  |         const [appLabel, modelName] = item.metaModelName.split("."); | ||||||
|  |         return html` <td role="cell" colspan="5"> | ||||||
|  |             <div class="pf-c-table__expandable-row-content"> | ||||||
|  |                 <div class="pf-c-content"> | ||||||
|  |                     <ak-tabs> | ||||||
|  |                         <section | ||||||
|  |                             slot="page-schedules" | ||||||
|  |                             data-tab-title="${msg("Schedules")}" | ||||||
|  |                             class="pf-c-page__main-section pf-m-no-padding-mobile" | ||||||
|  |                         > | ||||||
|  |                             <div class="pf-l-grid pf-m-gutter"> | ||||||
|  |                                 <div | ||||||
|  |                                     class="pf-l-grid__item pf-m-12-col pf-m-12-col-on-xl pf-m-12-col-on-2xl" | ||||||
|  |                                 > | ||||||
|  |                                     <ak-schedule-list | ||||||
|  |                                         .relObjAppLabel=${appLabel} | ||||||
|  |                                         .relObjModel=${modelName} | ||||||
|  |                                         .relObjId="${item.pk}" | ||||||
|  |                                     ></ak-schedule-list> | ||||||
|  |                                 </div> | ||||||
|  |                             </div> | ||||||
|  |                         </section> | ||||||
|  |                         <section | ||||||
|  |                             slot="page-tasks" | ||||||
|  |                             data-tab-title="${msg("Tasks")}" | ||||||
|  |                             class="pf-c-page__main-section pf-m-no-padding-mobile" | ||||||
|  |                         > | ||||||
|  |                             <div class="pf-l-grid pf-m-gutter"> | ||||||
|  |                                 <div | ||||||
|  |                                     class="pf-l-grid__item pf-m-12-col pf-m-12-col-on-xl pf-m-12-col-on-2xl" | ||||||
|  |                                 > | ||||||
|  |                                     <ak-task-list | ||||||
|  |                                         .relObjAppLabel=${appLabel} | ||||||
|  |                                         .relObjModel=${modelName} | ||||||
|  |                                         .relObjId="${item.pk}" | ||||||
|  |                                     ></ak-task-list> | ||||||
|  |                                 </div> | ||||||
|  |                             </div> | ||||||
|  |                         </section> | ||||||
|  |                     </ak-tabs> | ||||||
|  |                 </div> | ||||||
|  |             </div> | ||||||
|  |         </td>`; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     renderToolbarSelected(): TemplateResult { |     renderToolbarSelected(): TemplateResult { | ||||||
|         const disabled = this.selectedElements.length < 1; |         const disabled = this.selectedElements.length < 1; | ||||||
|         return html`<ak-forms-delete-bulk |         return html`<ak-forms-delete-bulk | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Marc 'risson' Schmitt
					Marc 'risson' Schmitt