device.html 29 KB

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