template_code.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. LINKTERMINATION = """
  2. {% if value %}
  3. {% if value.parent_object %}
  4. <a href="{{ value.parent_object.get_absolute_url }}">{{ value.parent_object }}</a>
  5. <i class="mdi mdi-chevron-right"></i>
  6. {% endif %}
  7. <a href="{{ value.get_absolute_url }}">{{ value }}</a>
  8. {% endif %}
  9. """
  10. CABLE_LENGTH = """
  11. {% load helpers %}
  12. {% if record.length %}{{ record.length|simplify_decimal }} {{ record.length_unit }}{% endif %}
  13. """
  14. CABLE_TERMINATION = """
  15. {{ value|join:", " }}
  16. """
  17. CABLE_TERMINATION_PARENT = """
  18. {% with value.0 as termination %}
  19. {% if termination.device %}
  20. <a href="{{ termination.device.get_absolute_url }}">{{ termination.device }}</a>
  21. {% elif termination.circuit %}
  22. <a href="{{ termination.circuit.get_absolute_url }}">{{ termination.circuit }}</a>
  23. {% elif termination.power_panel %}
  24. <a href="{{ termination.power_panel.get_absolute_url }}">{{ termination.power_panel }}</a>
  25. {% endif %}
  26. {% endwith %}
  27. """
  28. DEVICE_LINK = """
  29. <a href="{% url 'dcim:device' pk=record.pk %}">
  30. {{ record.name|default:'<span class="badge bg-info">Unnamed device</span>' }}
  31. </a>
  32. """
  33. DEVICEBAY_STATUS = """
  34. {% if record.installed_device_id %}
  35. <span class="badge bg-{{ record.installed_device.get_status_color }}">
  36. {{ record.installed_device.get_status_display }}
  37. </span>
  38. {% else %}
  39. <span class="badge bg-secondary">Vacant</span>
  40. {% endif %}
  41. """
  42. INTERFACE_IPADDRESSES = """
  43. <div class="table-badge-group">
  44. {% for ip in record.ip_addresses.all %}
  45. {% if ip.status != 'active' %}
  46. <a href="{{ ip.get_absolute_url }}" class="table-badge badge bg-{{ ip.get_status_color }}" data-bs-toggle="tooltip" data-bs-placement="left" title="{{ ip.get_status_display }}">{{ ip }}</a>
  47. {% else %}
  48. <a href="{{ ip.get_absolute_url }}" class="table-badge">{{ ip }}</a>
  49. {% endif %}
  50. {% endfor %}
  51. </div>
  52. """
  53. INTERFACE_FHRPGROUPS = """
  54. <div class="table-badge-group">
  55. {% for assignment in value.all %}
  56. <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.get_protocol_display }}: {{ assignment.group.group_id }}</a>
  57. {% endfor %}
  58. </div>
  59. """
  60. INTERFACE_TAGGED_VLANS = """
  61. {% if record.mode == 'tagged' %}
  62. {% for vlan in record.tagged_vlans.all %}
  63. <a href="{{ vlan.get_absolute_url }}">{{ vlan }}</a><br />
  64. {% endfor %}
  65. {% elif record.mode == 'tagged-all' %}
  66. All
  67. {% endif %}
  68. """
  69. INTERFACE_WIRELESS_LANS = """
  70. {% for wlan in record.wireless_lans.all %}
  71. <a href="{{ wlan.get_absolute_url }}">{{ wlan }}</a><br />
  72. {% endfor %}
  73. """
  74. POWERFEED_CABLE = """
  75. <a href="{{ value.get_absolute_url }}">{{ value }}</a>
  76. <a href="{% url 'dcim:powerfeed_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace">
  77. <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
  78. </a>
  79. """
  80. POWERFEED_CABLETERMINATION = """
  81. <a href="{{ value.parent_object.get_absolute_url }}">{{ value.parent_object }}</a>
  82. <i class="mdi mdi-chevron-right"></i>
  83. <a href="{{ value.get_absolute_url }}">{{ value }}</a>
  84. """
  85. LOCATION_BUTTONS = """
  86. <a href="{% url 'dcim:rack_elevation_list' %}?site={{ record.site.slug }}&location_id={{ record.pk }}" class="btn btn-sm btn-primary" title="View elevations">
  87. <i class="mdi mdi-server"></i>
  88. </a>
  89. """
  90. #
  91. # Device component templatebuttons
  92. #
  93. MODULAR_COMPONENT_TEMPLATE_BUTTONS = """
  94. {% load helpers %}
  95. {% if perms.dcim.add_inventoryitemtemplate %}
  96. <a href="{% url 'dcim:inventoryitemtemplate_add' %}?device_type={{ record.device_type_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={{ request.path }}" title="Add inventory item" class="btn btn-primary btn-sm">
  97. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  98. </a>
  99. {% endif %}
  100. """
  101. #
  102. # Device component buttons
  103. #
  104. CONSOLEPORT_BUTTONS = """
  105. {% if perms.dcim.add_inventoryitem %}
  106. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
  107. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  108. </a>
  109. {% endif %}
  110. {% if record.cable %}
  111. <a href="{% url 'dcim:consoleport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  112. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  113. {% if perms.dcim.delete_cable %}
  114. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleports' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  115. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  116. </a>
  117. {% endif %}
  118. {% elif perms.dcim.add_cable %}
  119. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  120. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  121. <span class="dropdown">
  122. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  123. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  124. </button>
  125. <ul class="dropdown-menu dropdown-menu-end">
  126. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Console Server Port</a></li>
  127. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Front Port</a></li>
  128. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Rear Port</a></li>
  129. </ul>
  130. </span>
  131. {% else %}
  132. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  133. {% endif %}
  134. """
  135. CONSOLESERVERPORT_BUTTONS = """
  136. {% if perms.dcim.add_inventoryitem %}
  137. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
  138. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  139. </a>
  140. {% endif %}
  141. {% if record.cable %}
  142. <a href="{% url 'dcim:consoleserverport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  143. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  144. {% if perms.dcim.delete_cable %}
  145. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  146. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  147. </a>
  148. {% endif %}
  149. {% elif perms.dcim.add_cable %}
  150. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  151. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  152. <span class="dropdown">
  153. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  154. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  155. </button>
  156. <ul class="dropdown-menu dropdown-menu-end">
  157. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Console Port</a></li>
  158. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Front Port</a></li>
  159. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Rear Port</a></li>
  160. </ul>
  161. </span>
  162. {% else %}
  163. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  164. {% endif %}
  165. """
  166. POWERPORT_BUTTONS = """
  167. {% if perms.dcim.add_inventoryitem %}
  168. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
  169. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  170. </a>
  171. {% endif %}
  172. {% if record.cable %}
  173. <a href="{% url 'dcim:powerport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  174. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  175. {% if perms.dcim.delete_cable %}
  176. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  177. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  178. </a>
  179. {% endif %}
  180. {% elif perms.dcim.add_cable %}
  181. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  182. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  183. <span class="dropdown">
  184. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  185. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  186. </button>
  187. <ul class="dropdown-menu dropdown-menu-end">
  188. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.poweroutlet&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Outlet</a></li>
  189. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerfeed&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Feed</a></li>
  190. </ul>
  191. </span>
  192. {% else %}
  193. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  194. {% endif %}
  195. """
  196. POWEROUTLET_BUTTONS = """
  197. {% if perms.dcim.add_inventoryitem %}
  198. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
  199. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  200. </a>
  201. {% endif %}
  202. {% if record.cable %}
  203. <a href="{% url 'dcim:poweroutlet_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  204. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  205. {% if perms.dcim.delete_cable %}
  206. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  207. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  208. </a>
  209. {% endif %}
  210. {% elif perms.dcim.add_cable %}
  211. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  212. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  213. {% if not record.mark_connected %}
  214. <a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.poweroutlet&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerport&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" title="Connect" class="btn btn-success btn-sm">
  215. <i class="mdi mdi-ethernet-cable" aria-hidden="true"></i>
  216. </a>
  217. {% else %}
  218. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  219. {% endif %}
  220. {% endif %}
  221. """
  222. INTERFACE_BUTTONS = """
  223. {% if perms.ipam.add_ipaddress or perms.dcim.add_inventoryitem %}
  224. <span class="dropdown">
  225. <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Add">
  226. <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
  227. </button>
  228. <ul class="dropdown-menu dropdown-menu-end">
  229. {% if perms.ipam.add_ipaddress %}
  230. <li><a class="dropdown-item" href="{% url 'ipam:ipaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">IP Address</a></li>
  231. {% endif %}
  232. {% if perms.dcim.add_inventoryitem %}
  233. <li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
  234. {% endif %}
  235. </ul>
  236. </span>
  237. {% endif %}
  238. {% if record.link %}
  239. <a href="{% url 'dcim:interface_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  240. {% endif %}
  241. {% if record.cable %}
  242. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  243. {% if perms.dcim.delete_cable %}
  244. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  245. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  246. </a>
  247. {% endif %}
  248. {% elif record.wireless_link %}
  249. {% if perms.wireless.delete_wirelesslink %}
  250. <a href="{% url 'wireless:wirelesslink_delete' pk=record.wireless_link.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Delete wireless link" class="btn btn-danger btn-sm">
  251. <i class="mdi mdi-wifi-off" aria-hidden="true"></i>
  252. </a>
  253. {% endif %}
  254. {% elif record.is_wired and perms.dcim.add_cable %}
  255. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  256. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  257. {% if not record.mark_connected %}
  258. <span class="dropdown">
  259. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Connect cable">
  260. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  261. </button>
  262. <ul class="dropdown-menu dropdown-menu-end">
  263. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Interface</a></li>
  264. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Front Port</a></li>
  265. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Rear Port</a></li>
  266. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Circuit Termination</a></li>
  267. </ul>
  268. </span>
  269. {% else %}
  270. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  271. {% endif %}
  272. {% elif record.is_wireless and perms.wireless.add_wirelesslink %}
  273. <a href="{% url 'wireless:wirelesslink_add' %}?site_a={{ record.device.site.pk }}&location_a={{ record.device.location.pk }}&device_a={{ record.device.pk }}&interface_a={{ record.pk }}&site_b={{ record.device.site.pk }}&location_b={{ record.device.location.pk }}" class="btn btn-success btn-sm">
  274. <span class="mdi mdi-wifi-plus" aria-hidden="true"></span>
  275. </a>
  276. {% endif %}
  277. """
  278. FRONTPORT_BUTTONS = """
  279. {% if perms.dcim.add_inventoryitem %}
  280. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
  281. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  282. </a>
  283. {% endif %}
  284. {% if record.cable %}
  285. <a href="{% url 'dcim:frontport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  286. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  287. {% if perms.dcim.delete_cable %}
  288. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_frontports' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  289. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  290. </a>
  291. {% endif %}
  292. {% elif perms.dcim.add_cable %}
  293. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  294. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  295. {% if not record.mark_connected %}
  296. <span class="dropdown">
  297. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  298. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  299. </button>
  300. <ul class="dropdown-menu dropdown-menu-end">
  301. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Interface</a></li>
  302. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Server Port</a></li>
  303. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Port</a></li>
  304. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Front Port</a></li>
  305. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Rear Port</a></li>
  306. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Circuit Termination</a></li>
  307. </ul>
  308. </span>
  309. {% else %}
  310. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  311. {% endif %}
  312. {% endif %}
  313. """
  314. REARPORT_BUTTONS = """
  315. {% if perms.dcim.add_inventoryitem %}
  316. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device.pk }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
  317. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  318. </a>
  319. {% endif %}
  320. {% if record.cable %}
  321. <a href="{% url 'dcim:rearport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
  322. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  323. {% if perms.dcim.delete_cable %}
  324. <a href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_rearports' pk=object.pk %}" title="Remove cable" class="btn btn-danger btn-sm">
  325. <i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i>
  326. </a>
  327. {% endif %}
  328. {% elif perms.dcim.add_cable %}
  329. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  330. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  331. {% if not record.mark_connected %}
  332. <span class="dropdown">
  333. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  334. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  335. </button>
  336. <ul class="dropdown-menu dropdown-menu-end">
  337. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Interface</a></li>
  338. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Server Port</a></li>
  339. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Port</a></li>
  340. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Front Port</a></li>
  341. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Rear Port</a></li>
  342. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuitterminations&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Circuit Termination</a></li>
  343. </ul>
  344. </span>
  345. {% else %}
  346. <a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  347. {% endif %}
  348. {% endif %}
  349. """
  350. DEVICEBAY_BUTTONS = """
  351. {% if perms.dcim.change_devicebay %}
  352. {% if record.installed_device %}
  353. <a href="{% url 'dcim:devicebay_depopulate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-danger btn-sm">
  354. <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove device"></i>
  355. </a>
  356. {% else %}
  357. <a href="{% url 'dcim:devicebay_populate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-success btn-sm">
  358. <i class="mdi mdi-server-plus" aria-hidden="true" title="Install device"></i>
  359. </a>
  360. {% endif %}
  361. {% endif %}
  362. """
  363. MODULEBAY_BUTTONS = """
  364. {% if perms.dcim.add_module %}
  365. {% if record.installed_module %}
  366. <a href="{% url 'dcim:module_delete' pk=record.installed_module.pk %}?return_url={% url 'dcim:device_modulebays' pk=object.pk %}" class="btn btn-danger btn-sm">
  367. <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove module"></i>
  368. </a>
  369. {% else %}
  370. <a href="{% url 'dcim:module_add' %}?device={{ record.device.pk }}&module_bay={{ record.pk }}&return_url={% url 'dcim:device_modulebays' pk=object.pk %}" class="btn btn-success btn-sm">
  371. <i class="mdi mdi-server-plus" aria-hidden="true" title="Install module"></i>
  372. </a>
  373. {% endif %}
  374. {% endif %}
  375. """