From b070be1c41cd4c5f0454f6b45c2140651b16c98b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 29 Mar 2021 14:55:17 -0400 Subject: [PATCH] Closes #5425: Create separate tabs for VMs and devices under the cluster view --- docs/release-notes/version-2.11.md | 1 + netbox/templates/virtualization/cluster.html | 178 +++++++----------- .../virtualization/cluster/base.html | 55 ++++++ .../virtualization/cluster/devices.html | 25 +++ .../cluster/virtual_machines.html | 15 ++ .../virtualization/virtualmachine/base.html | 5 + netbox/virtualization/tests/test_views.py | 16 +- netbox/virtualization/urls.py | 2 + netbox/virtualization/views.py | 28 ++- 9 files changed, 214 insertions(+), 111 deletions(-) create mode 100644 netbox/templates/virtualization/cluster/base.html create mode 100644 netbox/templates/virtualization/cluster/devices.html create mode 100644 netbox/templates/virtualization/cluster/virtual_machines.html diff --git a/docs/release-notes/version-2.11.md b/docs/release-notes/version-2.11.md index 1e1b906aa..6500e36e3 100644 --- a/docs/release-notes/version-2.11.md +++ b/docs/release-notes/version-2.11.md @@ -87,6 +87,7 @@ A new Cloud model has been introduced to represent the boundary of a network tha * [#5370](https://github.com/netbox-community/netbox/issues/5370) - Extend custom field support to organizational models * [#5375](https://github.com/netbox-community/netbox/issues/5375) - Add `speed` attribute to console port models * [#5401](https://github.com/netbox-community/netbox/issues/5401) - Extend custom field support to device component models +* [#5425](https://github.com/netbox-community/netbox/issues/5425) - Create separate tabs for VMs and devices under the cluster view * [#5451](https://github.com/netbox-community/netbox/issues/5451) - Add support for multiple-selection custom fields * [#5608](https://github.com/netbox-community/netbox/issues/5608) - Add REST API endpoint for custom links * [#5610](https://github.com/netbox-community/netbox/issues/5610) - Add REST API endpoint for webhooks diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index c065d52e1..e21e82eed 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -1,117 +1,81 @@ -{% extends 'generic/object.html' %} -{% load buttons %} -{% load custom_links %} +{% extends 'virtualization/cluster/base.html' %} {% load helpers %} {% load plugins %} -{% block breadcrumbs %} -
  • {{ object.type }}
  • - {% if object.group %} -
  • {{ object.group }}
  • - {% endif %} -
  • {{ object }}
  • -{% endblock %} - {% block content %}
    -
    -
    -
    - Cluster -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Name{{ object.name }}
    Type{{ object.type }}
    Group - {% if object.group %} - {{ object.group }} - {% else %} - None - {% endif %} -
    Tenant - {% if object.tenant %} - {{ object.tenant }} - {% else %} - None - {% endif %} -
    Site - {% if object.site %} - {{ object.site }} - {% else %} - None - {% endif %} -
    Virtual Machines{{ object.virtual_machines.count }}
    -
    - {% include 'inc/custom_fields_panel.html' %} - {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='virtualization:cluster_list' %} -
    -
    - Comments -
    -
    - {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
    -
    - {% plugin_left_page object %} +
    +
    +
    + Cluster +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Name{{ object.name }}
    Type{{ object.type }}
    Group + {% if object.group %} + {{ object.group }} + {% else %} + None + {% endif %} +
    Tenant + {% if object.tenant %} + {{ object.tenant }} + {% else %} + None + {% endif %} +
    Site + {% if object.site %} + {{ object.site }} + {% else %} + None + {% endif %} +
    Virtual Machines{{ object.virtual_machines.count }}
    -
    -
    -
    - Host Devices -
    - {% if perms.virtualization.change_cluster %} -
    - {% csrf_token %} - {% endif %} - {% include 'responsive_table.html' with table=device_table %} - {% if perms.virtualization.change_cluster %} - -
    - {% endif %} -
    - {% plugin_right_page object %} -
    + {% include 'inc/custom_fields_panel.html' %} +
    +
    + {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='virtualization:cluster_list' %} +
    +
    + Comments +
    +
    + {% if object.comments %} + {{ object.comments|render_markdown }} + {% else %} + None + {% endif %} +
    +
    + {% plugin_left_page object %} +
    -
    - {% plugin_full_width_page object %} -
    +
    + {% plugin_full_width_page object %} +
    {% endblock %} diff --git a/netbox/templates/virtualization/cluster/base.html b/netbox/templates/virtualization/cluster/base.html new file mode 100644 index 000000000..3e90eb17d --- /dev/null +++ b/netbox/templates/virtualization/cluster/base.html @@ -0,0 +1,55 @@ +{% extends 'generic/object.html' %} +{% load buttons %} +{% load helpers %} +{% load custom_links %} +{% load plugins %} + +{% block breadcrumbs %} +
  • {{ object.type }}
  • + {% if object.group %} +
  • {{ object.group }}
  • + {% endif %} +
  • {{ object }}
  • +{% endblock %} + +{% block buttons %} + {% if perms.virtualization.change_cluster and perms.virtualization.add_virtualmachine %} + + Add Virtual Machine + + {% endif %} + {% if perms.virtualization.change_cluster %} + + Assign Device + + {% endif %} + {{ block.super }} +{% endblock %} + +{% block tabs %} + +{% endblock %} diff --git a/netbox/templates/virtualization/cluster/devices.html b/netbox/templates/virtualization/cluster/devices.html new file mode 100644 index 000000000..f0de81e39 --- /dev/null +++ b/netbox/templates/virtualization/cluster/devices.html @@ -0,0 +1,25 @@ +{% extends 'virtualization/cluster/base.html' %} +{% load helpers %} + +{% block content %} +
    +
    +
    +
    + Host Devices +
    +
    + {% csrf_token %} + {% include 'responsive_table.html' with table=devices_table %} + {% if perms.virtualization.change_cluster %} + + {% endif %} +
    +
    +
    +
    +{% endblock %} diff --git a/netbox/templates/virtualization/cluster/virtual_machines.html b/netbox/templates/virtualization/cluster/virtual_machines.html new file mode 100644 index 000000000..5c8902bc7 --- /dev/null +++ b/netbox/templates/virtualization/cluster/virtual_machines.html @@ -0,0 +1,15 @@ +{% extends 'virtualization/cluster/base.html' %} +{% load helpers %} + +{% block content %} +
    +
    +
    +
    + Virtual Machines +
    + {% include 'responsive_table.html' with table=virtualmachines_table %} +
    +
    +
    +{% endblock %} diff --git a/netbox/templates/virtualization/virtualmachine/base.html b/netbox/templates/virtualization/virtualmachine/base.html index 00212aadd..88f7da1de 100644 --- a/netbox/templates/virtualization/virtualmachine/base.html +++ b/netbox/templates/virtualization/virtualmachine/base.html @@ -36,6 +36,11 @@ Config Context {% endif %} + {% if perms.extras.view_journalentry %} + + {% endif %} {% if perms.extras.view_objectchange %}