mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
12175 rack starting unit to svg
This commit is contained in:
parent
ec15336340
commit
ba9ef11522
@ -221,8 +221,8 @@ class RackForm(TenancyForm, NetBoxModelForm):
|
|||||||
model = Rack
|
model = Rack
|
||||||
fields = [
|
fields = [
|
||||||
'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial',
|
'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial',
|
||||||
'asset_tag', 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit',
|
'asset_tag', 'type', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth',
|
||||||
'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,8 +274,8 @@ class Rack(PrimaryModel, WeightMixin):
|
|||||||
Return a list of unit numbers, top to bottom.
|
Return a list of unit numbers, top to bottom.
|
||||||
"""
|
"""
|
||||||
if self.desc_units:
|
if self.desc_units:
|
||||||
return drange(decimal.Decimal(1.0), self.u_height + 1, 0.5)
|
return drange(decimal.Decimal(self.starting_unit), self.u_height + 1, 0.5)
|
||||||
return drange(self.u_height + decimal.Decimal(0.5), 0.5, -0.5)
|
return drange(self.u_height + decimal.Decimal(0.5) + self.starting_unit - 1, 0.5 + self.starting_unit - 1, -0.5)
|
||||||
|
|
||||||
def get_status_color(self):
|
def get_status_color(self):
|
||||||
return RackStatusChoices.colors.get(self.status)
|
return RackStatusChoices.colors.get(self.status)
|
||||||
|
@ -150,9 +150,9 @@ class RackElevationSVG:
|
|||||||
x = self.legend_width + RACK_ELEVATION_BORDER_WIDTH
|
x = self.legend_width + RACK_ELEVATION_BORDER_WIDTH
|
||||||
y = RACK_ELEVATION_BORDER_WIDTH
|
y = RACK_ELEVATION_BORDER_WIDTH
|
||||||
if self.rack.desc_units:
|
if self.rack.desc_units:
|
||||||
y += int((position - 1) * self.unit_height)
|
y += int((position - self.rack.starting_unit) * self.unit_height)
|
||||||
else:
|
else:
|
||||||
y += int((self.rack.u_height - position + 1) * self.unit_height) - int(height * self.unit_height)
|
y += int((self.rack.u_height - position + self.rack.starting_unit) * self.unit_height) - int(height * self.unit_height)
|
||||||
|
|
||||||
return x, y
|
return x, y
|
||||||
|
|
||||||
@ -237,6 +237,7 @@ class RackElevationSVG:
|
|||||||
start_y = ru * self.unit_height + RACK_ELEVATION_BORDER_WIDTH
|
start_y = ru * self.unit_height + RACK_ELEVATION_BORDER_WIDTH
|
||||||
position_coordinates = (self.legend_width / 2, start_y + self.unit_height / 2 + RACK_ELEVATION_BORDER_WIDTH)
|
position_coordinates = (self.legend_width / 2, start_y + self.unit_height / 2 + RACK_ELEVATION_BORDER_WIDTH)
|
||||||
unit = ru + 1 if self.rack.desc_units else self.rack.u_height - ru
|
unit = ru + 1 if self.rack.desc_units else self.rack.u_height - ru
|
||||||
|
unit = unit + self.rack.starting_unit - 1
|
||||||
self.drawing.add(
|
self.drawing.add(
|
||||||
Text(str(unit), position_coordinates, class_='unit')
|
Text(str(unit), position_coordinates, class_='unit')
|
||||||
)
|
)
|
||||||
@ -278,6 +279,7 @@ class RackElevationSVG:
|
|||||||
|
|
||||||
for ru in range(0, self.rack.u_height):
|
for ru in range(0, self.rack.u_height):
|
||||||
unit = ru + 1 if self.rack.desc_units else self.rack.u_height - ru
|
unit = ru + 1 if self.rack.desc_units else self.rack.u_height - ru
|
||||||
|
unit = unit + self.rack.starting_unit - 1
|
||||||
y_offset = RACK_ELEVATION_BORDER_WIDTH + ru * self.unit_height
|
y_offset = RACK_ELEVATION_BORDER_WIDTH + ru * self.unit_height
|
||||||
text_coords = (
|
text_coords = (
|
||||||
x_offset + self.unit_width / 2,
|
x_offset + self.unit_width / 2,
|
||||||
|
@ -101,6 +101,12 @@
|
|||||||
<th scope="row">Height</th>
|
<th scope="row">Height</th>
|
||||||
<td>{{ object.u_height }}U ({% if object.desc_units %}descending{% else %}ascending{% endif %})</td>
|
<td>{{ object.u_height }}U ({% if object.desc_units %}descending{% else %}ascending{% endif %})</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Starting Unit</th>
|
||||||
|
<td>
|
||||||
|
{{ object.starting_unit }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Outer Width</th>
|
<th scope="row">Outer Width</th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% render_field form.mounting_depth %}
|
{% render_field form.mounting_depth %}
|
||||||
{% render_field form.desc_units %}
|
{% render_field form.desc_units %}
|
||||||
|
{% render_field form.starting_unit %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if form.custom_fields %}
|
{% if form.custom_fields %}
|
||||||
|
Loading…
Reference in New Issue
Block a user