From a373c91d2021086d4dd854986ec149c6fd566933 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Wed, 8 Nov 2023 18:19:14 +0530 Subject: [PATCH 1/4] adds unit to the power port draw #13587 --- netbox/dcim/tables/devices.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 624eb579b13..6467f373bf5 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -466,6 +466,14 @@ class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable): 'args': [Accessor('device_id')], } ) + maximum_draw = tables.TemplateColumn( + template_code='''{% if record.maximum_draw %}{{ record.maximum_draw }} W{% else %}—{% endif %}''', + verbose_name=_('Maximum draw') + ) + allocated_draw = tables.TemplateColumn( + template_code='''{% if record.allocated_draw %}{{ record.allocated_draw }} W{% else %}—{% endif %}''', + verbose_name=_('Allocated draw') + ) tags = columns.TagColumn( url_name='dcim:powerport_list' ) From 92cdf420bbb06c9097cb16a0d531daae08bcb8f3 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Wed, 8 Nov 2023 23:15:22 +0530 Subject: [PATCH 2/4] review changes #13587 --- netbox/dcim/tables/devices.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 6467f373bf5..ac99c93bbd3 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -466,12 +466,12 @@ class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable): 'args': [Accessor('device_id')], } ) - maximum_draw = tables.TemplateColumn( - template_code='''{% if record.maximum_draw %}{{ record.maximum_draw }} W{% else %}—{% endif %}''', + maximum_draw = columns.TemplateColumn( + template_code='''{% if record.maximum_draw %}{{ value }} W{% endif %}''', verbose_name=_('Maximum draw') ) - allocated_draw = tables.TemplateColumn( - template_code='''{% if record.allocated_draw %}{{ record.allocated_draw }} W{% else %}—{% endif %}''', + allocated_draw = columns.TemplateColumn( + template_code='''{% if record.allocated_draw %}{{ value }} W{% endif %}''', verbose_name=_('Allocated draw') ) tags = columns.TagColumn( From da7ef1fbd3125e8b38d0c53ab0e6a60a62daccbe Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Thu, 9 Nov 2023 20:28:50 +0530 Subject: [PATCH 3/4] moved units to header #13587 --- netbox/dcim/tables/devices.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index ac99c93bbd3..83bf62a2c00 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -466,13 +466,11 @@ class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable): 'args': [Accessor('device_id')], } ) - maximum_draw = columns.TemplateColumn( - template_code='''{% if record.maximum_draw %}{{ value }} W{% endif %}''', - verbose_name=_('Maximum draw') + maximum_draw = tables.Column( + verbose_name=_('Maximum draw (watts)') ) - allocated_draw = columns.TemplateColumn( - template_code='''{% if record.allocated_draw %}{{ value }} W{% endif %}''', - verbose_name=_('Allocated draw') + allocated_draw = tables.Column( + verbose_name=_('Allocated draw (watts)') ) tags = columns.TagColumn( url_name='dcim:powerport_list' From e017fb68649ca79674f2702151c1c1128fb1dc2e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 9 Nov 2023 15:01:18 -0500 Subject: [PATCH 4/4] Abbreviate unit for consistency with e.g. PowerFeedTable available_power column --- netbox/dcim/tables/devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 83bf62a2c00..bffbe71f12a 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -467,10 +467,10 @@ class PowerPortTable(ModularDeviceComponentTable, PathEndpointTable): } ) maximum_draw = tables.Column( - verbose_name=_('Maximum draw (watts)') + verbose_name=_('Maximum draw (W)') ) allocated_draw = tables.Column( - verbose_name=_('Allocated draw (watts)') + verbose_name=_('Allocated draw (W)') ) tags = columns.TagColumn( url_name='dcim:powerport_list'