device.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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. <input type="hidden" name="device" value="{{ device.pk }}" />
  398. {% endif %}
  399. <div class="panel panel-default">
  400. <div class="panel-heading">
  401. <strong>Interfaces</strong>
  402. <div class="pull-right">
  403. {% if perms.dcim.change_interface and interfaces|length > 1 %}
  404. <button class="btn btn-default btn-xs toggle">
  405. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  406. </button>
  407. {% endif %}
  408. {% if perms.dcim.add_interface and interfaces|length > 10 %}
  409. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  410. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  411. </a>
  412. {% endif %}
  413. </div>
  414. </div>
  415. <table class="table table-hover panel-body">
  416. {% for iface in interfaces %}
  417. {% include 'dcim/inc/interface.html' with selectable=True %}
  418. {% empty %}
  419. <tr>
  420. <td colspan="4">No interfaces defined</td>
  421. </tr>
  422. {% endfor %}
  423. </table>
  424. {% if perms.dcim.add_interface or perms.dcim.delete_interface %}
  425. <div class="panel-footer">
  426. {% if interfaces and perms.dcim.change_interface %}
  427. <button type="submit" name="_edit" formaction="{% url 'dcim:interface_bulk_edit' pk=device.pk %}" class="btn btn-warning btn-xs">
  428. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit selected
  429. </button>
  430. {% endif %}
  431. {% if interfaces and perms.dcim.delete_interface %}
  432. <button type="submit" name="_delete" formaction="{% url 'dcim:interface_bulk_delete' pk=device.pk %}" class="btn btn-danger btn-xs">
  433. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  434. </button>
  435. {% endif %}
  436. {% if perms.dcim.add_interface %}
  437. <div class="pull-right">
  438. <a href="{% url 'dcim:interface_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  439. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add interfaces
  440. </a>
  441. </div>
  442. <div class="clearfix"></div>
  443. {% endif %}
  444. </div>
  445. {% endif %}
  446. </div>
  447. {% if perms.dcim.delete_interface %}
  448. </form>
  449. {% endif %}
  450. {% endif %}
  451. {% if cs_ports or device.device_type.is_console_server %}
  452. {% if perms.dcim.delete_consoleserverport %}
  453. <form method="post" action="{% url 'dcim:consoleserverport_bulk_delete' pk=device.pk %}">
  454. {% csrf_token %}
  455. {% endif %}
  456. <div class="panel panel-default">
  457. <div class="panel-heading">
  458. <strong>Console Server Ports</strong>
  459. <div class="pull-right">
  460. {% if perms.dcim.change_consoleserverport and cs_ports|length > 1 %}
  461. <button class="btn btn-default btn-xs toggle">
  462. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  463. </button>
  464. {% endif %}
  465. {% if perms.dcim.add_consoleserverport and cs_ports|length > 10 %}
  466. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  467. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  468. </a>
  469. {% endif %}
  470. </div>
  471. </div>
  472. <table class="table table-hover panel-body">
  473. {% for csp in cs_ports %}
  474. {% include 'dcim/inc/consoleserverport.html' with selectable=True %}
  475. {% empty %}
  476. <tr>
  477. <td colspan="4">No console server ports defined</td>
  478. </tr>
  479. {% endfor %}
  480. </table>
  481. {% if perms.dcim.add_consoleserverport or perms.dcim.delete_consoleserverport %}
  482. <div class="panel-footer">
  483. {% if cs_ports and perms.dcim.delete_consoleserverport %}
  484. <button type="submit" class="btn btn-danger btn-xs">
  485. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  486. </button>
  487. {% endif %}
  488. {% if perms.dcim.add_consoleserverport %}
  489. <div class="pull-right">
  490. <a href="{% url 'dcim:consoleserverport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  491. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add console server ports
  492. </a>
  493. </div>
  494. <div class="clearfix"></div>
  495. {% endif %}
  496. </div>
  497. {% endif %}
  498. </div>
  499. {% if perms.dcim.delete_consoleserverport %}
  500. </form>
  501. {% endif %}
  502. {% endif %}
  503. {% if power_outlets or device.device_type.is_pdu %}
  504. {% if perms.dcim.delete_poweroutlet %}
  505. <form method="post" action="{% url 'dcim:poweroutlet_bulk_delete' pk=device.pk %}">
  506. {% csrf_token %}
  507. {% endif %}
  508. <div class="panel panel-default">
  509. <div class="panel-heading">
  510. <strong>Power Outlets</strong>
  511. <div class="pull-right">
  512. {% if perms.dcim.change_poweroutlet and cs_ports|length > 1 %}
  513. <button class="btn btn-default btn-xs toggle">
  514. <span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span> Select all
  515. </button>
  516. {% endif %}
  517. {% if perms.dcim.add_poweroutlet and power_outlets|length > 10 %}
  518. <a href="{% url 'dcim:poweroutlet_add' pk=device.pk %}" class="btn btn-primary btn-xs">
  519. <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add power outlets
  520. </a>
  521. {% endif %}
  522. </div>
  523. </div>
  524. <table class="table table-hover panel-body">
  525. {% for po in power_outlets %}
  526. {% include 'dcim/inc/poweroutlet.html' with selectable=True %}
  527. {% empty %}
  528. <tr>
  529. <td colspan="4">No power outlets defined</td>
  530. </tr>
  531. {% endfor %}
  532. </table>
  533. {% if perms.dcim.add_poweroutlet or perms.dcim.delete_poweroutlet %}
  534. <div class="panel-footer">
  535. {% if power_outlets and perms.dcim.delete_poweroutlet %}
  536. <button type="submit" class="btn btn-danger btn-xs">
  537. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete selected
  538. </button>
  539. {% endif %}
  540. {% if perms.dcim.add_poweroutlet %}
  541. <div class="pull-right">
  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. </div>
  546. <div class="clearfix"></div>
  547. {% endif %}
  548. </div>
  549. {% endif %}
  550. </div>
  551. {% if perms.dcim.delete_poweroutlet %}
  552. </form>
  553. {% endif %}
  554. {% endif %}
  555. </div>
  556. </div>
  557. {% include 'inc/graphs_modal.html' %}
  558. {% include 'secrets/inc/private_key_modal.html' %}
  559. {% endblock %}
  560. {% block javascript %}
  561. <script type="text/javascript">
  562. function toggleConnection(elem, api_url) {
  563. var url = netbox_api_path + api_url + elem.attr('data') + "/";
  564. if (elem.hasClass('connected')) {
  565. $.ajax({
  566. url: url,
  567. method: 'PATCH',
  568. dataType: 'json',
  569. beforeSend: function(xhr, settings) {
  570. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  571. },
  572. data: {
  573. 'connection_status': 'False'
  574. },
  575. context: this,
  576. success: function() {
  577. elem.parents('tr').removeClass('success').addClass('info');
  578. elem.removeClass('connected btn-warning').addClass('btn-success');
  579. elem.attr('title', 'Mark connected');
  580. elem.children('i').removeClass('glyphicon glyphicon-ban-circle').addClass('fa fa-plug')
  581. }
  582. });
  583. } else {
  584. $.ajax({
  585. url: url,
  586. method: 'PATCH',
  587. dataType: 'json',
  588. beforeSend: function(xhr, settings) {
  589. xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
  590. },
  591. data: {
  592. 'connection_status': 'True'
  593. },
  594. context: this,
  595. success: function() {
  596. elem.parents('tr').removeClass('info').addClass('success');
  597. elem.removeClass('btn-success').addClass('connected btn-warning');
  598. elem.attr('title', 'Mark disconnected');
  599. elem.children('i').removeClass('fa fa-plug').addClass('glyphicon glyphicon-ban-circle')
  600. }
  601. });
  602. }
  603. return false;
  604. }
  605. $(".consoleport-toggle").click(function() {
  606. return toggleConnection($(this), "dcim/console-ports/");
  607. });
  608. $(".powerport-toggle").click(function() {
  609. return toggleConnection($(this), "dcim/power-ports/");
  610. });
  611. $(".interface-toggle").click(function() {
  612. return toggleConnection($(this), "dcim/interface-connections/");
  613. });
  614. </script>
  615. <script src="{% static 'js/graphs.js' %}"></script>
  616. <script src="{% static 'js/secrets.js' %}"></script>
  617. {% endblock %}