base.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {% extends 'generic/object.html' %}
  2. {% load buttons %}
  3. {% load static %}
  4. {% load helpers %}
  5. {% load plugins %}
  6. {% block breadcrumbs %}
  7. {{ block.super }}
  8. <li class="breadcrumb-item"><a href="{% url 'dcim:device_list' %}?site_id={{ object.site.pk }}">{{ object.site }}</a></li>
  9. {% if object.parent_bay %}
  10. <li class="breadcrumb-item"><a href="{% url 'dcim:device' pk=object.parent_bay.device.pk %}">{{ object.parent_bay.device }}</a></li>
  11. <li class="breadcrumb-item">{{ object.parent_bay }}</li>
  12. {% endif %}
  13. {% endblock %}
  14. {% block extra_controls %}
  15. {% if perms.dcim.change_device %}
  16. <div class="dropdown">
  17. <button id="add-device-components" type="button" class="btn btn-sm btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  18. <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add Components
  19. </button>
  20. <ul class="dropdown-menu" aria-labeled-by="add-device-components">
  21. {% if perms.dcim.add_consoleport %}
  22. <li>
  23. <a class="dropdown-item" href="{% url 'dcim:consoleport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">
  24. Console Ports
  25. </a>
  26. </li>
  27. {% endif %}
  28. {% if perms.dcim.add_consoleserverport %}
  29. <li>
  30. <a class="dropdown-item" href="{% url 'dcim:consoleserverport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">
  31. Console Server Ports
  32. </a>
  33. </li>
  34. {% endif %}
  35. {% if perms.dcim.add_powerport %}
  36. <li>
  37. <a class="dropdown-item" href="{% url 'dcim:powerport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">
  38. Power Ports
  39. </a>
  40. </li>
  41. {% endif %}
  42. {% if perms.dcim.add_poweroutlet %}
  43. <li>
  44. <a class="dropdown-item" href="{% url 'dcim:poweroutlet_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">
  45. Power Outlets
  46. </a>
  47. </li>
  48. {% endif %}
  49. {% if perms.dcim.add_interface %}
  50. <li>
  51. <a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">
  52. Interfaces
  53. </a>
  54. </li>
  55. {% endif %}
  56. {% if perms.dcim.add_frontport %}
  57. <li>
  58. <a class="dropdown-item" href="{% url 'dcim:frontport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">
  59. Front Ports
  60. </a>
  61. </li>
  62. {% endif %}
  63. {% if perms.dcim.add_rearport %}
  64. <li>
  65. <a class="dropdown-item" href="{% url 'dcim:rearport_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">
  66. Rear Ports
  67. </a>
  68. </li>
  69. {% endif %}
  70. {% if perms.dcim.add_devicebay %}
  71. <li>
  72. <a class="dropdown-item" href="{% url 'dcim:devicebay_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_devicebays' pk=object.pk %}">
  73. Device Bays
  74. </a>
  75. </li>
  76. {% endif %}
  77. {% if perms.dcim.add_inventoryitem %}
  78. <li>
  79. <a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ object.pk }}&return_url={% url 'dcim:device_inventory' pk=object.pk %}">
  80. Inventory Items
  81. </a>
  82. </li>
  83. {% endif %}
  84. </ul>
  85. </div>
  86. {% endif %}
  87. {% endblock %}
  88. {% block tab_items %}
  89. <li role="presentation" class="nav-item">
  90. <a href="{% url 'dcim:device' pk=object.pk %}" class="nav-link{% if active_tab == 'device' %} active{% endif %}">
  91. Device
  92. </a>
  93. </li>
  94. {% with tab_name='interfaces' interface_count=object.interfaces_count %}
  95. {% if active_tab == tab_name or interface_count %}
  96. <li role="presentation" class="nav-item">
  97. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_interfaces' pk=object.pk %}">Interfaces {% badge interface_count %}</a>
  98. </li>
  99. {% endif %}
  100. {% endwith %}
  101. {% with tab_name='front-ports' frontport_count=object.frontports.count %}
  102. {% if active_tab == tab_name or frontport_count %}
  103. <li role="presentation" class="nav-item">
  104. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_frontports' pk=object.pk %}">Front Ports {% badge frontport_count %}</a>
  105. </li>
  106. {% endif %}
  107. {% endwith %}
  108. {% with tab_name='rear-ports' rearport_count=object.rearports.count %}
  109. {% if active_tab == tab_name or rearport_count %}
  110. <li role="presentation" class="nav-item">
  111. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_rearports' pk=object.pk %}">Rear Ports {% badge rearport_count %}</a>
  112. </li>
  113. {% endif %}
  114. {% endwith %}
  115. {% with tab_name='console-ports' consoleport_count=object.consoleports.count %}
  116. {% if active_tab == tab_name or consoleport_count %}
  117. <li role="presentation" class="nav-item">
  118. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_consoleports' pk=object.pk %}">Console Ports {% badge consoleport_count %}</a>
  119. </li>
  120. {% endif %}
  121. {% endwith %}
  122. {% with tab_name='console-server-ports' consoleserverport_count=object.consoleserverports.count %}
  123. {% if active_tab == tab_name or consoleserverport_count %}
  124. <li role="presentation" class="nav-item">
  125. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_consoleserverports' pk=object.pk %}">Console Server Ports {% badge consoleserverport_count %}</a>
  126. </li>
  127. {% endif %}
  128. {% endwith %}
  129. {% with tab_name='power-ports' powerport_count=object.powerports.count %}
  130. {% if active_tab == tab_name or powerport_count %}
  131. <li role="presentation" class="nav-item">
  132. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_powerports' pk=object.pk %}">Power Ports {% badge powerport_count %}</a>
  133. </li>
  134. {% endif %}
  135. {% endwith %}
  136. {% with tab_name='power-outlets' poweroutlet_count=object.poweroutlets.count %}
  137. {% if active_tab == tab_name or poweroutlet_count %}
  138. <li role="presentation" class="nav-item">
  139. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_poweroutlets' pk=object.pk %}">Power Outlets {% badge poweroutlet_count %}</a>
  140. </li>
  141. {% endif %}
  142. {% endwith %}
  143. {% with tab_name='device-bays' devicebay_count=object.devicebays.count %}
  144. {% if active_tab == tab_name or devicebay_count %}
  145. <li role="presentation" class="nav-item">
  146. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_devicebays' pk=object.pk %}">Device Bays {% badge devicebay_count %}</a>
  147. </li>
  148. {% endif %}
  149. {% endwith %}
  150. {% with tab_name='inventory-items' inventoryitem_count=object.inventoryitems.count %}
  151. {% if active_tab == tab_name or inventoryitem_count %}
  152. <li role="presentation" class="nav-item">
  153. <a class="nav-link {% if active_tab == tab_name %} active{% endif %}" href="{% url 'dcim:device_inventory' pk=object.pk %}">Inventory {% badge inventoryitem_count %}</a>
  154. </li>
  155. {% endif %}
  156. {% endwith %}
  157. {% if perms.dcim.napalm_read_device and object.status == 'active' and object.primary_ip and object.platform.napalm_driver %}
  158. {# NAPALM-enabled tabs #}
  159. <li role="presentation" class="nav-item">
  160. <a class="nav-link{% if active_tab == 'status' %} active{% endif %}" href="{% url 'dcim:device_status' pk=object.pk %}">
  161. Status
  162. </a>
  163. </li>
  164. <li role="presentation" class="nav-item">
  165. <a class="nav-link{% if active_tab == 'lldp-neighbors' %} active{% endif %}" href="{% url 'dcim:device_lldp_neighbors' pk=object.pk %}">
  166. LLDP Neighbors
  167. </a>
  168. </li>
  169. <li role="presentation" class="nav-item">
  170. <a class="nav-link{% if active_tab == 'config' %} active{% endif %}" href="{% url 'dcim:device_config' pk=object.pk %}">
  171. Configuration
  172. </a>
  173. </li>
  174. {% endif %}
  175. {% if perms.extras.view_configcontext %}
  176. <li role="presentation" class="nav-item">
  177. <a href="{% url 'dcim:device_configcontext' pk=object.pk %}" class="nav-link{% if active_tab == 'config-context' %} active{% endif %}">
  178. Config Context
  179. </a>
  180. </li>
  181. {% endif %}
  182. {% endblock %}