7699 graphql, tables

This commit is contained in:
Arthur Hanson 2024-10-23 13:16:39 -07:00
parent d19cef4974
commit 7e6bb0e6bc
2 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,4 @@
from typing import Annotated, List
from typing import Annotated, List, Union
import strawberry
import strawberry_django
@ -31,18 +31,25 @@ class ComponentType(NetBoxObjectType):
@strawberry_django.type(
models.Cluster,
fields='__all__',
exclude=('scope_type', 'scope_id', '_location', '_region', '_site', '_sitegroup'),
filters=ClusterFilter
)
class ClusterType(VLANGroupsMixin, NetBoxObjectType):
type: Annotated["ClusterTypeType", strawberry.lazy('virtualization.graphql.types')] | None
group: Annotated["ClusterGroupType", strawberry.lazy('virtualization.graphql.types')] | None
tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')] | None
virtual_machines: List[Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')]]
devices: List[Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]]
@strawberry_django.field
def scope(self) -> Annotated[Union[
Annotated["LocationType", strawberry.lazy('dcim.graphql.types')],
Annotated["RegionType", strawberry.lazy('dcim.graphql.types')],
Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')],
Annotated["SiteType", strawberry.lazy('dcim.graphql.types')],
], strawberry.union("ClusterScopeType")] | None:
return self.scope
@strawberry_django.type(
models.ClusterGroup,

View File

@ -75,7 +75,8 @@ class ClusterTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
)
site = tables.Column(
verbose_name=_('Site'),
linkify=True
linkify=True,
accessor='_site'
)
device_count = columns.LinkedCountColumn(
viewname='dcim:device_list',