template_code.py 37 KB

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