template_code.py 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. LINKTERMINATION = """
  2. {% for termination in value %}
  3. {% if termination.parent_object %}
  4. <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
  5. <i class="mdi mdi-chevron-right"></i>
  6. {% endif %}
  7. <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>{% if not forloop.last %}<br />{% endif %}
  8. {% empty %}
  9. {{ ''|placeholder }}
  10. {% endfor %}
  11. """
  12. INTERFACE_LINKTERMINATION = """
  13. {% load i18n %}
  14. {% if record.is_virtual and record.virtual_circuit_termination %}
  15. {% for termination in record.connected_endpoints %}
  16. <a href="{{ termination.interface.parent_object.get_absolute_url }}">{{ termination.interface.parent_object }}</a>
  17. <i class="mdi mdi-chevron-right"></i>
  18. <a href="{{ termination.interface.get_absolute_url }}">{{ termination.interface }}</a>
  19. {% trans "via" %}
  20. <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
  21. {% if not forloop.last %}<br />{% endif %}
  22. {% endfor %}
  23. {% else %}""" + LINKTERMINATION + """{% endif %}
  24. """
  25. CABLE_LENGTH = """
  26. {% load helpers %}
  27. {% if record.length %}{{ record.length|floatformat:"-2" }} {{ record.length_unit }}{% endif %}
  28. """
  29. WEIGHT = """
  30. {% load helpers %}
  31. {% if value %}{{ value|floatformat:"-2" }} {{ record.weight_unit }}{% endif %}
  32. """
  33. DEVICE_LINK = """
  34. {{ value|default:'<span class="badge text-bg-info">Unnamed device</span>' }}
  35. """
  36. DEVICEBAY_STATUS = """
  37. {% if record.installed_device_id %}
  38. <span class="badge text-bg-{{ record.installed_device.get_status_color }}">
  39. {{ record.installed_device.get_status_display }}
  40. </span>
  41. {% else %}
  42. <span class="badge text-bg-secondary">Vacant</span>
  43. {% endif %}
  44. """
  45. INTERFACE_IPADDRESSES = """
  46. {% if value.count > 3 %}
  47. <a href="{% url 'ipam:ipaddress_list' %}?{{ record|meta:"model_name" }}_id={{ record.pk }}">{{ value.count }}</a>
  48. {% else %}
  49. {% for ip in value.all %}
  50. {% if ip.status != 'active' %}
  51. <a href="{{ ip.get_absolute_url }}" class="badge text-bg-{{ ip.get_status_color }}" data-bs-toggle="tooltip" data-bs-placement="left" title="{{ ip.get_status_display }}">{{ ip }}</a>
  52. {% else %}
  53. <a href="{{ ip.get_absolute_url }}">{{ ip }}</a>
  54. {% endif %}
  55. {% endfor %}
  56. {% endif %}
  57. """
  58. INTERFACE_FHRPGROUPS = """
  59. {% for assignment in value.all %}
  60. <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.get_protocol_display }}: {{ assignment.group.group_id }}</a>
  61. {% endfor %}
  62. """
  63. INTERFACE_TAGGED_VLANS = """
  64. {% load i18n %}
  65. {% if record.mode == 'access' %}
  66. {% elif record.mode == 'tagged-all' %}
  67. {% trans "All" %}
  68. {% else %}
  69. {% if value.count > 3 %}
  70. <a href="{% url 'ipam:vlan_list' %}?{{ record|meta:"model_name" }}_id={{ record.pk }}">{{ value.count }} VLANs</a>
  71. {% else %}
  72. {% for vlan in value.all %}
  73. <a href="{{ vlan.get_absolute_url }}">{{ vlan }}</a><br />
  74. {% endfor %}
  75. {% endif %}
  76. {% endif %}
  77. """
  78. INTERFACE_WIRELESS_LANS = """
  79. {% for wlan in value.all %}
  80. <a href="{{ wlan.get_absolute_url }}">{{ wlan }}</a><br />
  81. {% endfor %}
  82. """
  83. POWERFEED_CABLE = """
  84. <a href="{{ value.get_absolute_url }}">{{ value }}</a>
  85. <a href="{% url 'dcim:powerfeed_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace">
  86. <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
  87. </a>
  88. """
  89. POWERFEED_CABLETERMINATION = """
  90. <a href="{{ value.parent_object.get_absolute_url }}">{{ value.parent_object }}</a>
  91. <i class="mdi mdi-chevron-right"></i>
  92. <a href="{{ value.get_absolute_url }}">{{ value }}</a>
  93. """
  94. LOCATION_BUTTONS = """
  95. <a href="{% url 'dcim:rack_elevation_list' %}?site={{ record.site.slug }}&location_id={{ record.pk }}" class="btn btn-sm btn-primary" title="View elevations">
  96. <i class="mdi mdi-server"></i>
  97. </a>
  98. """
  99. #
  100. # Device component templatebuttons
  101. #
  102. MODULAR_COMPONENT_TEMPLATE_BUTTONS = """
  103. {% load helpers %}
  104. {% if perms.dcim.add_inventoryitemtemplate and record.device_type_id %}
  105. <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">
  106. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  107. </a>
  108. {% endif %}
  109. """
  110. #
  111. # Device component buttons
  112. #
  113. CONSOLEPORT_BUTTONS = """
  114. {% if perms.dcim.add_inventoryitem %}
  115. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  116. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  117. </a>
  118. {% endif %}
  119. {% if record.cable %}
  120. <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>
  121. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  122. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  123. <span class="dropdown">
  124. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  125. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  126. </button>
  127. <ul class="dropdown-menu dropdown-menu-end">
  128. {% if perms.dcim.change_cable %}
  129. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleports' pk=object.pk %}">
  130. <i class="mdi mdi-pencil-outline"></i>
  131. Edit cable
  132. </a>
  133. </li>
  134. {% endif %}
  135. {% if perms.dcim.delete_cable %}
  136. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleports' pk=object.pk %}">
  137. <i class="mdi mdi-trash-can-outline"></i>
  138. Delete cable
  139. </a>
  140. </li>
  141. {% endif %}
  142. </ul>
  143. </span>
  144. {% endif %}
  145. {% elif perms.dcim.add_cable %}
  146. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  147. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  148. <span class="dropdown">
  149. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  150. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  151. </button>
  152. <ul class="dropdown-menu dropdown-menu-end">
  153. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Console Server Port</a></li>
  154. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Front Port</a></li>
  155. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Rear Port</a></li>
  156. </ul>
  157. </span>
  158. {% else %}
  159. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  160. {% endif %}
  161. """
  162. CONSOLESERVERPORT_BUTTONS = """
  163. {% if perms.dcim.add_inventoryitem %}
  164. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  165. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  166. </a>
  167. {% endif %}
  168. {% if record.cable %}
  169. <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>
  170. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  171. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  172. <span class="dropdown">
  173. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  174. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  175. </button>
  176. <ul class="dropdown-menu dropdown-menu-end">
  177. {% if perms.dcim.change_cable %}
  178. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">
  179. <i class="mdi mdi-pencil-outline"></i>
  180. Edit cable
  181. </a>
  182. </li>
  183. {% endif %}
  184. {% if perms.dcim.delete_cable %}
  185. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">
  186. <i class="mdi mdi-trash-can-outline"></i>
  187. Delete cable
  188. </a>
  189. </li>
  190. {% endif %}
  191. </ul>
  192. </span>
  193. {% endif %}
  194. {% elif perms.dcim.add_cable %}
  195. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  196. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  197. <span class="dropdown">
  198. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  199. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  200. </button>
  201. <ul class="dropdown-menu dropdown-menu-end">
  202. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Console Port</a></li>
  203. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Front Port</a></li>
  204. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Rear Port</a></li>
  205. </ul>
  206. </span>
  207. {% else %}
  208. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  209. {% endif %}
  210. """
  211. POWERPORT_BUTTONS = """
  212. {% if perms.dcim.add_inventoryitem %}
  213. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  214. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  215. </a>
  216. {% endif %}
  217. {% if record.cable %}
  218. <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>
  219. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  220. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  221. <span class="dropdown">
  222. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  223. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  224. </button>
  225. <ul class="dropdown-menu dropdown-menu-end">
  226. {% if perms.dcim.change_cable %}
  227. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}">
  228. <i class="mdi mdi-pencil-outline"></i>
  229. Edit cable
  230. </a>
  231. </li>
  232. {% endif %}
  233. {% if perms.dcim.delete_cable %}
  234. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}">
  235. <i class="mdi mdi-trash-can-outline"></i>
  236. Delete cable
  237. </a>
  238. </li>
  239. {% endif %}
  240. </ul>
  241. </span>
  242. {% endif %}
  243. {% elif perms.dcim.add_cable %}
  244. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  245. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  246. <span class="dropdown">
  247. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  248. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  249. </button>
  250. <ul class="dropdown-menu dropdown-menu-end">
  251. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.poweroutlet&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Outlet</a></li>
  252. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerfeed&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Feed</a></li>
  253. </ul>
  254. </span>
  255. {% else %}
  256. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  257. {% endif %}
  258. """
  259. POWEROUTLET_BUTTONS = """
  260. {% if perms.dcim.add_inventoryitem %}
  261. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  262. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  263. </a>
  264. {% endif %}
  265. {% if record.cable %}
  266. <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>
  267. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  268. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  269. <span class="dropdown">
  270. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  271. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  272. </button>
  273. <ul class="dropdown-menu dropdown-menu-end">
  274. {% if perms.dcim.change_cable %}
  275. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">
  276. <i class="mdi mdi-pencil-outline"></i>
  277. Edit cable
  278. </a>
  279. </li>
  280. {% endif %}
  281. {% if perms.dcim.delete_cable %}
  282. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">
  283. <i class="mdi mdi-trash-can-outline"></i>
  284. Delete cable
  285. </a>
  286. </li>
  287. {% endif %}
  288. </ul>
  289. </span>
  290. {% endif %}
  291. {% elif perms.dcim.add_cable %}
  292. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  293. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  294. {% if not record.mark_connected %}
  295. <a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.poweroutlet&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" title="Connect" class="btn btn-success btn-sm">
  296. <i class="mdi mdi-ethernet-cable" aria-hidden="true"></i>
  297. </a>
  298. {% else %}
  299. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  300. {% endif %}
  301. {% endif %}
  302. """
  303. INTERFACE_BUTTONS = """
  304. {% if perms.dcim.change_interface %}
  305. <span class="dropdown">
  306. <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Add">
  307. <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
  308. </button>
  309. <ul class="dropdown-menu dropdown-menu-end">
  310. {% if perms.ipam.add_ipaddress %}
  311. <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>
  312. {% endif %}
  313. {% if perms.dcim.add_macaddress %}
  314. <li><a class="dropdown-item" href="{% url 'dcim:macaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">MAC Address</a></li>
  315. {% endif %}
  316. {% if perms.dcim.add_inventoryitem %}
  317. <li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
  318. {% endif %}
  319. {% if perms.dcim.add_interface %}
  320. <li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ record.device_id }}&parent={{ record.pk }}&name={{ record.name }}.&type=virtual&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Child Interface</a></li>
  321. {% endif %}
  322. {% if perms.vpn.add_l2vpntermination %}
  323. <li><a class="dropdown-item" href="{% url 'vpn:l2vpntermination_add' %}?device={{ object.pk }}&interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">L2VPN Termination</a></li>
  324. {% endif %}
  325. {% if perms.ipam.add_fhrpgroupassignment %}
  326. <li><a class="dropdown-item" href="{% url 'ipam:fhrpgroupassignment_add' %}?interface_type={{ record|content_type_id }}&interface_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Assign FHRP Group</a></li>
  327. {% endif %}
  328. </ul>
  329. </span>
  330. {% endif %}
  331. {% if record.link %}
  332. <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>
  333. {% endif %}
  334. {% if record.cable %}
  335. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  336. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  337. <span class="dropdown">
  338. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  339. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  340. </button>
  341. <ul class="dropdown-menu dropdown-menu-end">
  342. {% if perms.dcim.change_cable %}
  343. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}">
  344. <i class="mdi mdi-pencil-outline"></i>
  345. Edit cable
  346. </a>
  347. </li>
  348. {% endif %}
  349. {% if perms.dcim.delete_cable %}
  350. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}">
  351. <i class="mdi mdi-trash-can-outline"></i>
  352. Delete cable
  353. </a>
  354. </li>
  355. {% endif %}
  356. </ul>
  357. </span>
  358. {% endif %}
  359. {% elif record.wireless_link %}
  360. {% if perms.wireless.delete_wirelesslink %}
  361. <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">
  362. <i class="mdi mdi-wifi-off" aria-hidden="true"></i>
  363. </a>
  364. {% endif %}
  365. {% elif record.type == 'virtual' %}
  366. {% if perms.vpn.add_tunnel and not record.tunnel_termination %}
  367. <a href="{% url 'vpn:tunnel_add' %}?termination1_type=dcim.device&termination1_parent={{ record.device.pk }}&termination1_termination={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Create a tunnel" class="btn btn-success btn-sm">
  368. <i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
  369. </a>
  370. {% elif perms.vpn.delete_tunneltermination and record.tunnel_termination %}
  371. <a href="{% url 'vpn:tunneltermination_delete' pk=record.tunnel_termination.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove tunnel" class="btn btn-danger btn-sm">
  372. <i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
  373. </a>
  374. {% endif %}
  375. {% if perms.circuits.add_virtualcircuittermination and not record.virtual_circuit_termination %}
  376. <a href="{% url 'circuits:virtualcircuittermination_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Terminate a virtual circuit" class="btn btn-success btn-sm">
  377. <i class="mdi mdi-vector-line" aria-hidden="true"></i>
  378. </a>
  379. {% elif perms.circuits.delete_virtualcircuittermination and record.virtual_circuit_termination %}
  380. <a href="{% url 'circuits:virtualcircuittermination_delete' pk=record.virtual_circuit_termination.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove virtual circuit" class="btn btn-danger btn-sm">
  381. <i class="mdi mdi-vector-line" aria-hidden="true"></i>
  382. </a>
  383. {% endif %}
  384. {% elif record.is_wired and perms.dcim.add_cable %}
  385. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  386. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  387. {% if not record.mark_connected %}
  388. <span class="dropdown">
  389. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Connect cable">
  390. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  391. </button>
  392. <ul class="dropdown-menu dropdown-menu-end">
  393. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Interface</a></li>
  394. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Front Port</a></li>
  395. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Rear Port</a></li>
  396. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Circuit Termination</a></li>
  397. </ul>
  398. </span>
  399. {% else %}
  400. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  401. {% endif %}
  402. {% elif record.is_wireless and perms.wireless.add_wirelesslink %}
  403. <a href="{% url 'wireless:wirelesslink_add' %}?site_a={{ record.device.site.pk }}&location_a={{ record.device.location.pk }}&device_a={{ record.device_id }}&interface_a={{ record.pk }}&site_b={{ record.device.site.pk }}&location_b={{ record.device.location.pk }}" class="btn btn-success btn-sm">
  404. <span class="mdi mdi-wifi-plus" aria-hidden="true"></span>
  405. </a>
  406. {% endif %}
  407. """
  408. FRONTPORT_BUTTONS = """
  409. {% if perms.dcim.add_inventoryitem %}
  410. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  411. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  412. </a>
  413. {% endif %}
  414. {% if record.cable %}
  415. <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>
  416. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  417. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  418. <span class="dropdown">
  419. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  420. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  421. </button>
  422. <ul class="dropdown-menu dropdown-menu-end">
  423. {% if perms.dcim.change_cable %}
  424. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_frontports' pk=object.pk %}">
  425. <i class="mdi mdi-pencil-outline"></i>
  426. Edit cable
  427. </a>
  428. </li>
  429. {% endif %}
  430. {% if perms.dcim.delete_cable %}
  431. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_frontports' pk=object.pk %}">
  432. <i class="mdi mdi-trash-can-outline"></i>
  433. Delete cable
  434. </a>
  435. </li>
  436. {% endif %}
  437. </ul>
  438. </span>
  439. {% endif %}
  440. {% elif perms.dcim.add_cable %}
  441. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  442. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  443. {% if not record.mark_connected %}
  444. <span class="dropdown">
  445. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  446. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  447. </button>
  448. <ul class="dropdown-menu dropdown-menu-end">
  449. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Interface</a></li>
  450. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Server Port</a></li>
  451. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Port</a></li>
  452. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Front Port</a></li>
  453. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Rear Port</a></li>
  454. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Circuit Termination</a></li>
  455. </ul>
  456. </span>
  457. {% else %}
  458. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  459. {% endif %}
  460. {% endif %}
  461. """
  462. REARPORT_BUTTONS = """
  463. {% if perms.dcim.add_inventoryitem %}
  464. <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&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">
  465. <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
  466. </a>
  467. {% endif %}
  468. {% if record.cable %}
  469. <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>
  470. {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
  471. {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
  472. <span class="dropdown">
  473. <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  474. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  475. </button>
  476. <ul class="dropdown-menu dropdown-menu-end">
  477. {% if perms.dcim.change_cable %}
  478. <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_rearports' pk=object.pk %}">
  479. <i class="mdi mdi-pencil-outline"></i>
  480. Edit cable
  481. </a>
  482. </li>
  483. {% endif %}
  484. {% if perms.dcim.delete_cable %}
  485. <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_rearports' pk=object.pk %}">
  486. <i class="mdi mdi-trash-can-outline"></i>
  487. Delete cable
  488. </a>
  489. </li>
  490. {% endif %}
  491. </ul>
  492. </span>
  493. {% endif %}
  494. {% elif perms.dcim.add_cable %}
  495. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
  496. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
  497. {% if not record.mark_connected %}
  498. <span class="dropdown">
  499. <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  500. <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
  501. </button>
  502. <ul class="dropdown-menu dropdown-menu-end">
  503. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Interface</a></li>
  504. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Server Port</a></li>
  505. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Port</a></li>
  506. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Front Port</a></li>
  507. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Rear Port</a></li>
  508. <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Circuit Termination</a></li>
  509. </ul>
  510. </span>
  511. {% else %}
  512. <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
  513. {% endif %}
  514. {% endif %}
  515. """
  516. DEVICEBAY_BUTTONS = """
  517. {% if perms.dcim.change_devicebay %}
  518. {% if record.installed_device %}
  519. <a href="{% url 'dcim:devicebay_depopulate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-danger btn-sm">
  520. <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove device"></i>
  521. </a>
  522. {% else %}
  523. <a href="{% url 'dcim:devicebay_populate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-success btn-sm">
  524. <i class="mdi mdi-server-plus" aria-hidden="true" title="Install device"></i>
  525. </a>
  526. {% endif %}
  527. {% endif %}
  528. """
  529. MODULEBAY_BUTTONS = """
  530. {% if perms.dcim.add_module %}
  531. {% if record.installed_module %}
  532. <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">
  533. <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove module"></i>
  534. </a>
  535. {% else %}
  536. <a href="{% url 'dcim:module_add' %}?device={{ record.device_id }}&module_bay={{ record.pk }}&manufacturer={{ object.device_type.manufacturer_id }}&return_url={% url 'dcim:device_modulebays' pk=object.pk %}" class="btn btn-success btn-sm">
  537. <i class="mdi mdi-server-plus" aria-hidden="true" title="Install module"></i>
  538. </a>
  539. {% endif %}
  540. {% endif %}
  541. """