device.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. {% extends '_base.html' %}
  2. {% load static from staticfiles %}
  3. {% load helpers %}
  4. {% block title %}{{ device }}{% endblock %}
  5. {% block content %}
  6. {% include 'dcim/inc/device_header.html' with active_tab='info' %}
  7. <div class="row">
  8. <div class="col-md-6">
  9. <div class="panel panel-default">
  10. <div class="panel-heading">
  11. <strong>Device</strong>
  12. </div>
  13. <table class="table table-hover panel-body attr-table">
  14. <tr>
  15. <td>Site</td>
  16. <td>
  17. {% if device.site.region %}
  18. <a href="{{ device.site.region.get_absolute_url }}">{{ device.site.region }}</a>
  19. <i class="fa fa-angle-right"></i>
  20. {% endif %}
  21. <a href="{% url 'dcim:site' slug=device.site.slug %}">{{ device.site }}</a>
  22. </td>
  23. </tr>
  24. <tr>
  25. <td>Rack</td>
  26. <td>
  27. {% if device.rack %}
  28. {% if device.rack.group %}
  29. <a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group }}</a>
  30. <i class="fa fa-angle-right"></i>
  31. {% endif %}
  32. <a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a>
  33. {% else %}
  34. <span class="text-muted">None</span>
  35. {% endif %}
  36. </td>
  37. </tr>
  38. <tr>
  39. <td>Position</td>
  40. <td>
  41. {% if device.parent_bay %}
  42. {% with device.parent_bay.device as parent %}
  43. <a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay }}
  44. {% if parent.position %}
  45. (U{{ parent.position }} / {{ parent.get_face_display }})
  46. {% endif %}
  47. {% endwith %}
  48. {% elif device.rack and device.position %}
  49. <span>U{{ device.position }} / {{ device.get_face_display }}</span>
  50. {% elif device.rack and device.device_type.u_height %}
  51. <span class="label label-warning">Not racked</span>
  52. {% else %}
  53. <span class="text-muted">N/A</span>
  54. {% endif %}
  55. </td>
  56. </tr>
  57. <tr>
  58. <td>Tenant</td>
  59. <td>
  60. {% if device.tenant %}
  61. {% if device.tenant.group %}
  62. <a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group }}</a>
  63. <i class="fa fa-angle-right"></i>
  64. {% endif %}
  65. <a href="{{ device.tenant.get_absolute_url }}">{{ device.tenant }}</a>
  66. {% else %}
  67. <span class="text-muted">None</span>
  68. {% endif %}
  69. </td>
  70. </tr>
  71. <tr>
  72. <td>Device Type</td>
  73. <td>
  74. <span><a href="{% url 'dcim:devicetype' pk=device.device_type.pk %}">{{ device.device_type.full_name }}</a> ({{ device.device_type.u_height }}U)</span>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td>Serial Number</td>
  79. <td>
  80. {% if device.serial %}
  81. <span>{{ device.serial }}</span>
  82. {% else %}
  83. <span class="text-muted">N/A</span>
  84. {% endif %}
  85. </td>
  86. </tr>
  87. <tr>
  88. <td>Asset Tag</td>
  89. <td>
  90. {% if device.asset_tag %}
  91. <span>{{ device.asset_tag }}</span>
  92. {% else %}
  93. <span class="text-muted">N/A</span>
  94. {% endif %}
  95. </td>
  96. </tr>
  97. </table>
  98. </div>
  99. <div class="panel panel-default">
  100. <div class="panel-heading">
  101. <strong>Management</strong>
  102. </div>
  103. <table class="table table-hover panel-body attr-table">
  104. <tr>
  105. <td>Role</td>
  106. <td>
  107. <a href="{{ device.device_role.get_absolute_url }}">{{ device.device_role }}</a>
  108. </td>
  109. </tr>
  110. <tr>
  111. <td>Platform</td>
  112. <td>
  113. {% if device.platform %}
  114. <span>{{ device.platform }}</span>
  115. {% else %}
  116. <span class="text-muted">None</span>
  117. {% endif %}
  118. </td>
  119. </tr>
  120. <tr>
  121. <td>Status</td>
  122. <td>
  123. <span class="label label-{{ device.get_status_class }}">{{ device.get_status_display }}</span>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td>Primary IPv4</td>
  128. <td>
  129. {% if device.primary_ip4 %}
  130. <a href="{% url 'ipam:ipaddress' pk=device.primary_ip4.pk %}">{{ device.primary_ip4.address.ip }}</a>
  131. {% if device.primary_ip4.nat_inside %}
  132. <span>(NAT for {{ device.primary_ip4.nat_inside.address.ip }})</span>
  133. {% elif device.primary_ip4.nat_outside %}
  134. <span>(NAT: {{ device.primary_ip4.nat_outside.address.ip }})</span>
  135. {% endif %}
  136. {% else %}
  137. <span class="text-muted">N/A</span>
  138. {% endif %}
  139. </td>
  140. </tr>
  141. <tr>
  142. <td>Primary IPv6</td>
  143. <td>
  144. {% if device.primary_ip6 %}
  145. <a href="{% url 'ipam:ipaddress' pk=device.primary_ip6.pk %}">{{ device.primary_ip6.address.ip }}</a>
  146. {% if device.primary_ip6.nat_inside %}
  147. <span>(NAT for {{ device.primary_ip6.nat_inside.address.ip }})</span>
  148. {% elif device.primary_ip6.nat_outside %}
  149. <span>(NAT: {{ device.primary_ip6.nat_outside.address.ip }})</span>
  150. {% endif %}
  151. {% else %}
  152. <span class="text-muted">N/A</span>
  153. {% endif %}
  154. </td>
  155. </tr>
  156. {% if device.cluster %}
  157. <tr>
  158. <td>Cluster</td>
  159. <td>
  160. {% if device.cluster.group %}
  161. <a href="{{ device.cluster.group.get_absolute_url }}">{{ device.cluster.group }}</a>
  162. <i class="fa fa-angle-right"></i>
  163. {% endif %}
  164. <a href="{{ device.cluster.get_absolute_url }}">{{ device.cluster }}</a>
  165. </td>
  166. </tr>
  167. {% endif %}
  168. </table>
  169. </div>
  170. {% with device.get_custom_fields as custom_fields %}
  171. {% include 'inc/custom_fields_panel.html' %}
  172. {% endwith %}
  173. <div class="panel panel-default">
  174. <div class="panel-heading">
  175. <strong>Comments</strong>
  176. </div>
  177. <div class="panel-body">
  178. {% if device.comments %}
  179. {{ device.comments|gfm }}
  180. {% else %}
  181. <span class="text-muted">None</span>
  182. {% endif %}
  183. </div>
  184. </div>
  185. </div>
  186. <div class="col-md-6">
  187. <div class="panel panel-default">
  188. <div class="panel-heading">
  189. <strong>Console / Power</strong>
  190. </div>
  191. <table class="table table-hover panel-body component-list">
  192. {% for cp in console_ports %}
  193. {% include 'dcim/inc/consoleport.html' %}
  194. {% empty %}
  195. {% if device.device_type.console_port_templates.exists %}
  196. <tr>
  197. <td colspan="6" class="alert-warning">
  198. <i class="fa fa-fw fa-warning"></i> No console ports defined
  199. {% if perms.dcim.add_consoleport %}
  200. <a href="{% url 'dcim:consoleport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
  201. {% endif %}
  202. </td>
  203. </tr>
  204. {% endif %}
  205. {% endfor %}
  206. {% for pp in power_ports %}
  207. {% include 'dcim/inc/powerport.html' %}
  208. {% empty %}
  209. {% if device.device_type.power_port_templates.exists %}
  210. <tr>
  211. <td colspan="6" class="alert-warning">
  212. <i class="fa fa-fw fa-warning"></i> No power ports defined
  213. {% if perms.dcim.add_powerport %}
  214. <a href="{% url 'dcim:powerport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
  215. {% endif %}
  216. </td>
  217. </tr>
  218. {% endif %}
  219. {% endfor %}
  220. </table>
  221. {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %}
  222. <div class="panel-footer text-right">
  223. {% if perms.dcim.add_consoleport %}
  224. <a href="{% url 'dcim:consoleport_add' pk=device.pk %}" class="btn btn-xs btn-primary">
  225. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console port
  226. </a>
  227. {% endif %}
  228. {% if perms.dcim.add_powerport %}
  229. <a href="{% url 'dcim:powerport_add' pk=device.pk %}" class="btn btn-xs btn-primary">
  230. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power port
  231. </a>
  232. {% endif %}
  233. </div>
  234. {% endif %}
  235. </div>
  236. {% if request.user.is_authenticated %}
  237. <div class="panel panel-default">
  238. <div class="panel-heading">
  239. <strong>Secrets</strong>
  240. </div>
  241. {% if secrets %}
  242. <table class="table table-hover panel-body">
  243. {% for secret in secrets %}
  244. {% include 'secrets/inc/secret_tr.html' %}
  245. {% endfor %}
  246. </table>
  247. {% else %}
  248. <div class="panel-body text-muted">
  249. None found
  250. </div>
  251. {% endif %}
  252. {% if perms.secrets.add_secret %}
  253. <form id="secret_form">
  254. {% csrf_token %}
  255. </form>
  256. <div class="panel-footer text-right">
  257. <a href="{% url 'dcim:device_addsecret' pk=device.pk %}" class="btn btn-xs btn-primary">
  258. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
  259. Add secret
  260. </a>
  261. </div>
  262. {% endif %}
  263. </div>
  264. {% endif %}
  265. <div class="panel panel-default">
  266. <div class="panel-heading">
  267. <strong>Services</strong>
  268. </div>
  269. {% if services %}
  270. <table class="table table-hover panel-body">
  271. {% for service in services %}
  272. {% include 'ipam/inc/service.html' %}
  273. {% endfor %}
  274. </table>
  275. {% else %}
  276. <div class="panel-body text-muted">
  277. None
  278. </div>
  279. {% endif %}
  280. {% if perms.ipam.add_service %}
  281. <div class="panel-footer text-right">
  282. <a href="{% url 'dcim:device_service_assign' device=device.pk %}" class="btn btn-xs btn-primary">
  283. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Assign service
  284. </a>
  285. </div>
  286. {% endif %}
  287. </div>
  288. <div class="panel panel-default">
  289. <div class="panel-heading">
  290. <strong>Images</strong>
  291. </div>
  292. {% include 'inc/image_attachments.html' with images=device.images.all %}
  293. {% if perms.extras.add_imageattachment %}
  294. <div class="panel-footer text-right">
  295. <a href="{% url 'dcim:device_add_image' object_id=device.pk %}" class="btn btn-primary btn-xs">
  296. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
  297. Attach an image
  298. </a>
  299. </div>
  300. {% endif %}
  301. </div>
  302. <div class="panel panel-default">
  303. <div class="panel-heading">
  304. <strong>Related Devices</strong>
  305. </div>
  306. {% if related_devices %}
  307. <table class="table table-hover panel-body">
  308. {% for rd in related_devices %}
  309. <tr>
  310. <td>
  311. <a href="{% url 'dcim:device' pk=rd.pk %}">{{ rd }}</a>
  312. </td>
  313. <td>
  314. {% if rd.rack %}
  315. <a href="{% url 'dcim:rack' pk=rd.rack.pk %}">Rack {{ rd.rack }}</a>
  316. {% else %}
  317. <span class="text-muted">&mdash;</span>
  318. {% endif %}
  319. </td>
  320. <td>{{ rd.device_type.full_name }}</td>
  321. </tr>
  322. {% endfor %}
  323. </table>
  324. {% else %}
  325. <div class="panel-body text-muted">None found</div>
  326. {% endif %}
  327. </div>
  328. </div>
  329. </div>
  330. <div class="row">
  331. <div class="col-md-12">
  332. {% if device_bays or device.device_type.is_parent_device %}
  333. {% if perms.dcim.delete_devicebay %}
  334. <form method="post" action="{% url 'dcim:devicebay_bulk_delete' pk=device.pk %}">
  335. {% csrf_token %}
  336. {% endif %}
  337. <div class="panel panel-default">
  338. <div class="panel-heading">
  339. <strong>Device Bays</strong>
  340. <div class="pull-right">
  341. {% if perms.dcim.change_devicebay and device_bays|length > 1 %}
  342. <button class="btn btn-default btn-xs toggle">
  343. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  344. </button>
  345. {% endif %}
  346. {% if perms.dcim.add_devicebay and device_bays|length > 10 %}
  347. <a href="{% url 'dcim:devicebay_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  348. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add device bays
  349. </a>
  350. {% endif %}
  351. </div>
  352. </div>
  353. <table class="table table-hover panel-body component-list">
  354. {% for devicebay in device_bays %}
  355. {% include 'dcim/inc/devicebay.html' %}
  356. {% empty %}
  357. <tr>
  358. <td colspan="4">No device bays defined</td>
  359. </tr>
  360. {% endfor %}
  361. </table>
  362. {% if perms.dcim.add_devicebay or perms.dcim.delete_devicebay %}
  363. <div class="panel-footer">
  364. {% if device_bays and perms.dcim.delete_devicebay %}
  365. <button type="submit" class="btn btn-danger btn-xs">
  366. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  367. </button>
  368. {% endif %}
  369. {% if perms.dcim.add_devicebay %}
  370. <div class="pull-right">
  371. <a href="{% url 'dcim:devicebay_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  372. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add device bays
  373. </a>
  374. </div>
  375. <div class="clearfix"></div>
  376. {% endif %}
  377. </div>
  378. {% endif %}
  379. </div>
  380. {% if perms.dcim.delete_devicebay %}
  381. </form>
  382. {% endif %}
  383. {% endif %}
  384. {% if interfaces or device.device_type.is_network_device %}
  385. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  386. <form method="post">
  387. {% csrf_token %}
  388. <input type="hidden" name="device" value="{{ device.pk }}" />
  389. {% endif %}
  390. <div class="panel panel-default">
  391. <div class="panel-heading">
  392. <strong>Interfaces</strong>
  393. <div class="pull-right">
  394. <button class="btn btn-default btn-xs toggle-ips" selected="selected">
  395. <span class="glyphicon glyphicon-check" aria-hidden="true"></span> Show IPs
  396. </button>
  397. {% if perms.dcim.change_interface and interfaces|length > 1 %}
  398. <button class="btn btn-default btn-xs toggle">
  399. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  400. </button>
  401. {% endif %}
  402. {% if perms.dcim.add_interface and interfaces|length > 10 %}
  403. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  404. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  405. </a>
  406. {% endif %}
  407. </div>
  408. </div>
  409. <table id="interfaces_table" class="table table-hover panel-body component-list">
  410. <tr class="table-headings">
  411. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  412. <th></th>
  413. {% endif %}
  414. <th>Name</th>
  415. <th>LAG</th>
  416. <th>Description</th>
  417. <th>MTU</th>
  418. <th>MAC Address</th>
  419. <th colspan="2">Connection</th>
  420. <th></th>
  421. </tr>
  422. {% for iface in interfaces %}
  423. {% include 'dcim/inc/interface.html' %}
  424. {% empty %}
  425. <tr>
  426. <td colspan="8">No interfaces defined</td>
  427. </tr>
  428. {% endfor %}
  429. </table>
  430. {% if perms.dcim.add_interface or perms.dcim.delete_interface %}
  431. <div class="panel-footer">
  432. {% if interfaces and perms.dcim.change_interface %}
  433. <button type="submit" name="_edit" formaction="{% url 'dcim:interface_bulk_edit' pk=device.pk %}" class="btn btn-warning btn-xs">
  434. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
  435. </button>
  436. {% endif %}
  437. {% if interfaces and perms.dcim.delete_interfaceconnection %}
  438. <button type="submit" name="_disconnect" formaction="{% url 'dcim:interface_bulk_disconnect' pk=device.pk %}" class="btn btn-danger btn-xs">
  439. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  440. </button>
  441. {% endif %}
  442. {% if interfaces and perms.dcim.delete_interface %}
  443. <button type="submit" name="_delete" formaction="{% url 'dcim:interface_bulk_delete' pk=device.pk %}" class="btn btn-danger btn-xs">
  444. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  445. </button>
  446. {% endif %}
  447. {% if perms.dcim.add_interface %}
  448. <div class="pull-right">
  449. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  450. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  451. </a>
  452. </div>
  453. <div class="clearfix"></div>
  454. {% endif %}
  455. </div>
  456. {% endif %}
  457. </div>
  458. {% if perms.dcim.delete_interface %}
  459. </form>
  460. {% endif %}
  461. {% endif %}
  462. {% if cs_ports or device.device_type.is_console_server %}
  463. {% if perms.dcim.delete_consoleserverport %}
  464. <form method="post" action="{% url 'dcim:consoleserverport_bulk_delete' pk=device.pk %}">
  465. {% csrf_token %}
  466. {% endif %}
  467. <div class="panel panel-default">
  468. <div class="panel-heading">
  469. <strong>Console Server Ports</strong>
  470. <div class="pull-right">
  471. {% if perms.dcim.change_consoleserverport and cs_ports|length > 1 %}
  472. <button class="btn btn-default btn-xs toggle">
  473. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  474. </button>
  475. {% endif %}
  476. {% if perms.dcim.add_consoleserverport and cs_ports|length > 10 %}
  477. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  478. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  479. </a>
  480. {% endif %}
  481. </div>
  482. </div>
  483. <table class="table table-hover panel-body component-list">
  484. <tr class="table-headings">
  485. {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %}
  486. <th></th>
  487. {% endif %}
  488. <th>Name</th>
  489. <th colspan="2">Connection</th>
  490. <th></th>
  491. </tr>
  492. {% for csp in cs_ports %}
  493. {% include 'dcim/inc/consoleserverport.html' %}
  494. {% empty %}
  495. <tr>
  496. <td colspan="4">No console server ports defined</td>
  497. </tr>
  498. {% endfor %}
  499. </table>
  500. {% if perms.dcim.add_consoleserverport or perms.dcim.delete_consoleserverport %}
  501. <div class="panel-footer">
  502. {% if cs_ports and perms.dcim.change_consoleport %}
  503. <button type="submit" name="_disconnect" formaction="{% url 'dcim:consoleserverport_bulk_disconnect' pk=device.pk %}" class="btn btn-danger btn-xs">
  504. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  505. </button>
  506. {% endif %}
  507. {% if cs_ports and perms.dcim.delete_consoleserverport %}
  508. <button type="submit" class="btn btn-danger btn-xs">
  509. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  510. </button>
  511. {% endif %}
  512. {% if perms.dcim.add_consoleserverport %}
  513. <div class="pull-right">
  514. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  515. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  516. </a>
  517. </div>
  518. <div class="clearfix"></div>
  519. {% endif %}
  520. </div>
  521. {% endif %}
  522. </div>
  523. {% if perms.dcim.delete_consoleserverport %}
  524. </form>
  525. {% endif %}
  526. {% endif %}
  527. {% if power_outlets or device.device_type.is_pdu %}
  528. {% if perms.dcim.delete_poweroutlet %}
  529. <form method="post" action="{% url 'dcim:poweroutlet_bulk_delete' pk=device.pk %}">
  530. {% csrf_token %}
  531. {% endif %}
  532. <div class="panel panel-default">
  533. <div class="panel-heading">
  534. <strong>Power Outlets</strong>
  535. <div class="pull-right">
  536. {% if perms.dcim.change_poweroutlet and power_outlets|length > 1 %}
  537. <button class="btn btn-default btn-xs toggle">
  538. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  539. </button>
  540. {% endif %}
  541. {% if perms.dcim.add_poweroutlet and power_outlets|length > 10 %}
  542. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  543. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  544. </a>
  545. {% endif %}
  546. </div>
  547. </div>
  548. <table class="table table-hover panel-body component-list">
  549. <tr class="table-headings">
  550. {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %}
  551. <th></th>
  552. {% endif %}
  553. <th>Name</th>
  554. <th colspan="2">Connection</th>
  555. <th></th>
  556. </tr>
  557. {% for po in power_outlets %}
  558. {% include 'dcim/inc/poweroutlet.html' %}
  559. {% empty %}
  560. <tr>
  561. <td colspan="4">No power outlets defined</td>
  562. </tr> text-nowrap
  563. {% endfor %}
  564. </table>
  565. {% if perms.dcim.add_poweroutlet or perms.dcim.delete_poweroutlet %}
  566. <div class="panel-footer">
  567. {% if power_outlets and perms.dcim.change_powerport %}
  568. <button type="submit" name="_disconnect" formaction="{% url 'dcim:poweroutlet_bulk_disconnect' pk=device.pk %}" class="btn btn-danger btn-xs">
  569. <span class="glyphicon glyphicon-resize-full" aria-hidden="true"></span> Disconnect
  570. </button>
  571. {% endif %}
  572. {% if power_outlets and perms.dcim.delete_poweroutlet %}
  573. <button type="submit" class="btn btn-danger btn-xs">
  574. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
  575. </button>
  576. {% endif %}
  577. {% if perms.dcim.add_poweroutlet %}
  578. <div class="pull-right">
  579. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  580. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  581. </a>
  582. </div>
  583. <div class="clearfix"></div>
  584. {% endif %}
  585. </div>
  586. {% endif %}
  587. </div>
  588. {% if perms.dcim.delete_poweroutlet %}
  589. </form>
  590. {% endif %}
  591. {% endif %}
  592. </div>
  593. </div>
  594. {% include 'inc/graphs_modal.html' %}
  595. {% include 'secrets/inc/private_key_modal.html' %}
  596. {% endblock %}
  597. {% block javascript %}
  598. <script type="text/javascript">
  599. function toggleConnection(elem, api_url) {
  600. var url = netbox_api_path + api_url + elem.attr('data') + "/";
  601. if (elem.hasClass('connected')) {
  602. $.ajax({
  603. url: url,
  604. method: 'PATCH',
  605. dataType: 'json',
  606. beforeSend: function(xhr, settings) {
  607. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  608. },
  609. data: {
  610. 'connection_status': 'False'
  611. },
  612. context: this,
  613. success: function() {
  614. elem.parents('tr').removeClass('success').addClass('info');
  615. elem.removeClass('connected btn-warning').addClass('btn-success');
  616. elem.attr('title', 'Mark installed');
  617. elem.children('i').removeClass('glyphicon glyphicon-ban-circle').addClass('fa fa-plug')
  618. }
  619. });
  620. } else {
  621. $.ajax({
  622. url: url,
  623. method: 'PATCH',
  624. dataType: 'json',
  625. beforeSend: function(xhr, settings) {
  626. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  627. },
  628. data: {
  629. 'connection_status': 'True'
  630. },
  631. context: this,
  632. success: function() {
  633. elem.parents('tr').removeClass('info').addClass('success');
  634. elem.removeClass('btn-success').addClass('connected btn-warning');
  635. elem.attr('title', 'Mark planned');
  636. elem.children('i').removeClass('fa fa-plug').addClass('glyphicon glyphicon-ban-circle')
  637. }
  638. });
  639. }
  640. return false;
  641. }
  642. $(".consoleport-toggle").click(function() {
  643. return toggleConnection($(this), "dcim/console-ports/");
  644. });
  645. $(".powerport-toggle").click(function() {
  646. return toggleConnection($(this), "dcim/power-ports/");
  647. });
  648. $(".interface-toggle").click(function() {
  649. return toggleConnection($(this), "dcim/interface-connections/");
  650. });
  651. // Toggle the display of IP addresses under interfaces
  652. $('button.toggle-ips').click(function() {
  653. var selected = $(this).attr('selected');
  654. if (selected) {
  655. $('#interfaces_table tr.ipaddress').hide();
  656. } else {
  657. $('#interfaces_table tr.ipaddress').show();
  658. }
  659. $(this).attr('selected', !selected);
  660. $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
  661. return false;
  662. });
  663. </script>
  664. <script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
  665. <script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
  666. {% endblock %}