device.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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>Related Devices</strong>
  330. </div>
  331. {% if related_devices %}
  332. <table class="table table-hover panel-body">
  333. {% for rd in related_devices %}
  334. <tr>
  335. <td>
  336. <a href="{% url 'dcim:device' pk=rd.pk %}">{{ rd }}</a>
  337. </td>
  338. <td>
  339. {% if rd.rack %}
  340. <a href="{% url 'dcim:rack' pk=rd.rack.pk %}">Rack {{ rd.rack }}</a>
  341. {% else %}
  342. <span class="text-muted">&mdash;</span>
  343. {% endif %}
  344. </td>
  345. <td>{{ rd.device_type.full_name }}</td>
  346. </tr>
  347. {% endfor %}
  348. </table>
  349. {% else %}
  350. <div class="panel-body text-muted">None found</div>
  351. {% endif %}
  352. </div>
  353. </div>
  354. <div class="col-md-7 col-lg-6">
  355. {% if device_bays or device.device_type.is_parent_device %}
  356. {% if perms.dcim.delete_devicebay %}
  357. <form method="post" action="{% url 'dcim:devicebay_bulk_delete' pk=device.pk %}">
  358. {% csrf_token %}
  359. {% endif %}
  360. <div class="panel panel-default">
  361. <div class="panel-heading">
  362. <strong>Device Bays</strong>
  363. <div class="pull-right">
  364. {% if perms.dcim.change_devicebay and device_bays|length > 1 %}
  365. <button class="btn btn-default btn-xs toggle">
  366. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  367. </button>
  368. {% endif %}
  369. {% if perms.dcim.add_devicebay and device_bays|length > 10 %}
  370. <a href="{% url 'dcim:devicebay_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  371. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add device bays
  372. </a>
  373. {% endif %}
  374. </div>
  375. </div>
  376. <table class="table table-hover panel-body">
  377. {% for devicebay in device_bays %}
  378. {% include 'dcim/inc/devicebay.html' with selectable=True %}
  379. {% empty %}
  380. <tr>
  381. <td colspan="4">No device bays defined</td>
  382. </tr>
  383. {% endfor %}
  384. </table>
  385. {% if perms.dcim.add_devicebay or perms.dcim.delete_devicebay %}
  386. <div class="panel-footer">
  387. {% if device_bays and perms.dcim.delete_devicebay %}
  388. <button type="submit" class="btn btn-danger btn-xs">
  389. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  390. </button>
  391. {% endif %}
  392. {% if perms.dcim.add_devicebay %}
  393. <div class="pull-right">
  394. <a href="{% url 'dcim:devicebay_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  395. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add device bays
  396. </a>
  397. </div>
  398. <div class="clearfix"></div>
  399. {% endif %}
  400. </div>
  401. {% endif %}
  402. </div>
  403. {% if perms.dcim.delete_devicebay %}
  404. </form>
  405. {% endif %}
  406. {% endif %}
  407. {% if interfaces or device.device_type.is_network_device %}
  408. {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
  409. <form method="post">
  410. {% csrf_token %}
  411. <input type="hidden" name="device" value="{{ device.pk }}" />
  412. {% endif %}
  413. <div class="panel panel-default">
  414. <div class="panel-heading">
  415. <strong>Interfaces</strong>
  416. <div class="pull-right">
  417. {% if perms.dcim.change_interface and interfaces|length > 1 %}
  418. <button class="btn btn-default btn-xs toggle">
  419. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  420. </button>
  421. {% endif %}
  422. {% if perms.dcim.add_interface and interfaces|length > 10 %}
  423. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  424. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  425. </a>
  426. {% endif %}
  427. </div>
  428. </div>
  429. <table class="table table-hover panel-body">
  430. {% for iface in interfaces %}
  431. {% include 'dcim/inc/interface.html' with selectable=True %}
  432. {% empty %}
  433. <tr>
  434. <td colspan="4">No interfaces defined</td>
  435. </tr>
  436. {% endfor %}
  437. </table>
  438. {% if perms.dcim.add_interface or perms.dcim.delete_interface %}
  439. <div class="panel-footer">
  440. {% if interfaces and perms.dcim.change_interface %}
  441. <button type="submit" name="_edit" formaction="{% url 'dcim:interface_bulk_edit' pk=device.pk %}" class="btn btn-warning btn-xs">
  442. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit selected
  443. </button>
  444. {% endif %}
  445. {% if interfaces and perms.dcim.delete_interface %}
  446. <button type="submit" name="_delete" formaction="{% url 'dcim:interface_bulk_delete' pk=device.pk %}" class="btn btn-danger btn-xs">
  447. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  448. </button>
  449. {% endif %}
  450. {% if perms.dcim.add_interface %}
  451. <div class="pull-right">
  452. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  453. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  454. </a>
  455. </div>
  456. <div class="clearfix"></div>
  457. {% endif %}
  458. </div>
  459. {% endif %}
  460. </div>
  461. {% if perms.dcim.delete_interface %}
  462. </form>
  463. {% endif %}
  464. {% endif %}
  465. {% if cs_ports or device.device_type.is_console_server %}
  466. {% if perms.dcim.delete_consoleserverport %}
  467. <form method="post" action="{% url 'dcim:consoleserverport_bulk_delete' pk=device.pk %}">
  468. {% csrf_token %}
  469. {% endif %}
  470. <div class="panel panel-default">
  471. <div class="panel-heading">
  472. <strong>Console Server Ports</strong>
  473. <div class="pull-right">
  474. {% if perms.dcim.change_consoleserverport and cs_ports|length > 1 %}
  475. <button class="btn btn-default btn-xs toggle">
  476. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  477. </button>
  478. {% endif %}
  479. {% if perms.dcim.add_consoleserverport and cs_ports|length > 10 %}
  480. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  481. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  482. </a>
  483. {% endif %}
  484. </div>
  485. </div>
  486. <table class="table table-hover panel-body">
  487. {% for csp in cs_ports %}
  488. {% include 'dcim/inc/consoleserverport.html' with selectable=True %}
  489. {% empty %}
  490. <tr>
  491. <td colspan="4">No console server ports defined</td>
  492. </tr>
  493. {% endfor %}
  494. </table>
  495. {% if perms.dcim.add_consoleserverport or perms.dcim.delete_consoleserverport %}
  496. <div class="panel-footer">
  497. {% if cs_ports and perms.dcim.delete_consoleserverport %}
  498. <button type="submit" class="btn btn-danger btn-xs">
  499. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  500. </button>
  501. {% endif %}
  502. {% if perms.dcim.add_consoleserverport %}
  503. <div class="pull-right">
  504. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  505. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  506. </a>
  507. </div>
  508. <div class="clearfix"></div>
  509. {% endif %}
  510. </div>
  511. {% endif %}
  512. </div>
  513. {% if perms.dcim.delete_consoleserverport %}
  514. </form>
  515. {% endif %}
  516. {% endif %}
  517. {% if power_outlets or device.device_type.is_pdu %}
  518. {% if perms.dcim.delete_poweroutlet %}
  519. <form method="post" action="{% url 'dcim:poweroutlet_bulk_delete' pk=device.pk %}">
  520. {% csrf_token %}
  521. {% endif %}
  522. <div class="panel panel-default">
  523. <div class="panel-heading">
  524. <strong>Power Outlets</strong>
  525. <div class="pull-right">
  526. {% if perms.dcim.change_poweroutlet and cs_ports|length > 1 %}
  527. <button class="btn btn-default btn-xs toggle">
  528. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  529. </button>
  530. {% endif %}
  531. {% if perms.dcim.add_poweroutlet and power_outlets|length > 10 %}
  532. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  533. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  534. </a>
  535. {% endif %}
  536. </div>
  537. </div>
  538. <table class="table table-hover panel-body">
  539. {% for po in power_outlets %}
  540. {% include 'dcim/inc/poweroutlet.html' with selectable=True %}
  541. {% empty %}
  542. <tr>
  543. <td colspan="4">No power outlets defined</td>
  544. </tr>
  545. {% endfor %}
  546. </table>
  547. {% if perms.dcim.add_poweroutlet or perms.dcim.delete_poweroutlet %}
  548. <div class="panel-footer">
  549. {% if power_outlets and perms.dcim.delete_poweroutlet %}
  550. <button type="submit" class="btn btn-danger btn-xs">
  551. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  552. </button>
  553. {% endif %}
  554. {% if perms.dcim.add_poweroutlet %}
  555. <div class="pull-right">
  556. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  557. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  558. </a>
  559. </div>
  560. <div class="clearfix"></div>
  561. {% endif %}
  562. </div>
  563. {% endif %}
  564. </div>
  565. {% if perms.dcim.delete_poweroutlet %}
  566. </form>
  567. {% endif %}
  568. {% endif %}
  569. </div>
  570. </div>
  571. {% include 'inc/graphs_modal.html' %}
  572. {% include 'secrets/inc/private_key_modal.html' %}
  573. {% endblock %}
  574. {% block javascript %}
  575. <script type="text/javascript">
  576. function toggleConnection(elem, api_url) {
  577. var url = netbox_api_path + api_url + elem.attr('data') + "/";
  578. if (elem.hasClass('connected')) {
  579. $.ajax({
  580. url: url,
  581. method: 'PATCH',
  582. dataType: 'json',
  583. beforeSend: function(xhr, settings) {
  584. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  585. },
  586. data: {
  587. 'connection_status': 'False'
  588. },
  589. context: this,
  590. success: function() {
  591. elem.parents('tr').removeClass('success').addClass('info');
  592. elem.removeClass('connected btn-warning').addClass('btn-success');
  593. elem.attr('title', 'Mark connected');
  594. elem.children('i').removeClass('glyphicon glyphicon-ban-circle').addClass('fa fa-plug')
  595. }
  596. });
  597. } else {
  598. $.ajax({
  599. url: url,
  600. method: 'PATCH',
  601. dataType: 'json',
  602. beforeSend: function(xhr, settings) {
  603. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  604. },
  605. data: {
  606. 'connection_status': 'True'
  607. },
  608. context: this,
  609. success: function() {
  610. elem.parents('tr').removeClass('info').addClass('success');
  611. elem.removeClass('btn-success').addClass('connected btn-warning');
  612. elem.attr('title', 'Mark disconnected');
  613. elem.children('i').removeClass('fa fa-plug').addClass('glyphicon glyphicon-ban-circle')
  614. }
  615. });
  616. }
  617. return false;
  618. }
  619. $(".consoleport-toggle").click(function() {
  620. return toggleConnection($(this), "dcim/console-ports/");
  621. });
  622. $(".powerport-toggle").click(function() {
  623. return toggleConnection($(this), "dcim/power-ports/");
  624. });
  625. $(".interface-toggle").click(function() {
  626. return toggleConnection($(this), "dcim/interface-connections/");
  627. });
  628. </script>
  629. <script src="{% static 'js/graphs.js' %}"></script>
  630. <script src="{% static 'js/secrets.js' %}"></script>
  631. {% endblock %}