device.html 31 KB

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