| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  | {% extends '_base.html' %} | 
					
						
							| 
									
										
										
										
											2018-02-02 16:12:57 -05:00
										 |  |  | {% load buttons %} | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | {% block content %} | 
					
						
							|  |  |  | <div class="pull-right"> | 
					
						
							|  |  |  |     {% if perms.dcim.add_device %} | 
					
						
							| 
									
										
										
										
											2018-02-02 16:12:57 -05:00
										 |  |  |         {% add_button 'dcim:device_add' %} | 
					
						
							|  |  |  |         {% import_button 'dcim:device_import' %} | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  |     {% endif %} | 
					
						
							| 
									
										
										
										
											2018-02-02 16:12:57 -05:00
										 |  |  |     {% export_button content_type %} | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  | </div> | 
					
						
							| 
									
										
										
										
											2017-08-02 13:15:28 -04:00
										 |  |  | <h1>{% block title %}Devices{% endblock %}</h1> | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  | <div class="row"> | 
					
						
							|  |  |  | 	<div class="col-md-9"> | 
					
						
							| 
									
										
										
										
											2016-05-19 16:36:48 -04:00
										 |  |  |         {% include 'dcim/inc/device_table.html' with bulk_edit_url='dcim:device_bulk_edit' bulk_delete_url='dcim:device_bulk_delete' %} | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  |     </div> | 
					
						
							|  |  |  |     <div class="col-md-3"> | 
					
						
							| 
									
										
										
										
											2016-07-29 12:51:23 -04:00
										 |  |  | 		{% include 'inc/search_panel.html' %} | 
					
						
							| 
									
										
										
										
											2018-05-18 15:43:21 -04:00
										 |  |  | 		{% include 'inc/tags_panel.html' %} | 
					
						
							| 
									
										
										
										
											2016-03-01 11:23:03 -05:00
										 |  |  |     </div> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | {% endblock %} | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | {% block javascript %} | 
					
						
							|  |  |  | <script type="text/javascript"> | 
					
						
							|  |  |  | $(document).ready(function() { | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     var site_list = $('#id_site'); | 
					
						
							|  |  |  |     var rack_group_list = $('#id_rack_group_id'); | 
					
						
							|  |  |  |     var rack_list = $('#id_rack_id'); | 
					
						
							|  |  |  |     var manufacturer_list = $('#id_manufacturer_id'); | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  |     var model_list = $('#id_device_type_id'); | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Update device type options based on selected manufacturer | 
					
						
							|  |  |  |     manufacturer_list.change(function() { | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  |         var selected_manufacturers = $(this).val(); | 
					
						
							|  |  |  |         if (selected_manufacturers) { | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  |             model_list.empty(); | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  |             $.ajax({ | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  |                 url: netbox_api_path + 'dcim/device-types/?limit=500&manufacturer_id=' + selected_manufacturers.join('&manufacturer_id='), | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  |                 dataType: 'json', | 
					
						
							|  |  |  |                 success: function (response, status) { | 
					
						
							| 
									
										
										
										
											2017-05-12 22:20:21 -04:00
										 |  |  |                     $.each(response["results"], function (index, device_type) { | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  |                         var option = $("<option></option>").attr("value", device_type.id).text(device_type.model + " (" + device_type.instance_count + ")"); | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  |                         model_list.append(option); | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Update rack group and rack options based on selected site | 
					
						
							|  |  |  |     site_list.change(function() { | 
					
						
							|  |  |  |         var selected_sites = $(this).val(); | 
					
						
							|  |  |  |         if (selected_sites) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // Update rack group options | 
					
						
							|  |  |  |             rack_group_list.empty(); | 
					
						
							|  |  |  |             $.ajax({ | 
					
						
							|  |  |  |                 url: netbox_api_path + 'dcim/rack-groups/?limit=500&site=' + selected_sites.join('&site='), | 
					
						
							|  |  |  |                 dataType: 'json', | 
					
						
							|  |  |  |                 success: function (response, status) { | 
					
						
							|  |  |  |                     $.each(response["results"], function (index, group) { | 
					
						
							|  |  |  |                         var option = $("<option></option>").attr("value", group.id).text(group.name); | 
					
						
							|  |  |  |                         rack_group_list.append(option); | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // Update rack options | 
					
						
							|  |  |  |             rack_list.empty(); | 
					
						
							| 
									
										
										
										
											2017-05-18 14:27:07 -04:00
										 |  |  |             rack_list.append($("<option></option>").attr("value", "0").text("None")); | 
					
						
							| 
									
										
										
										
											2017-05-12 22:41:27 -04:00
										 |  |  |             $.ajax({ | 
					
						
							|  |  |  |                 url: netbox_api_path + 'dcim/racks/?limit=500&site=' + selected_sites.join('&site='), | 
					
						
							|  |  |  |                 dataType: 'json', | 
					
						
							|  |  |  |                 success: function (response, status) { | 
					
						
							|  |  |  |                     $.each(response["results"], function (index, rack) { | 
					
						
							|  |  |  |                         var option = $("<option></option>").attr("value", rack.id).text(rack.display_name); | 
					
						
							|  |  |  |                         rack_list.append(option); | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Update rack options based on selected rack group | 
					
						
							|  |  |  |     rack_group_list.change(function() { | 
					
						
							|  |  |  |         var selected_rack_groups = $(this).val(); | 
					
						
							|  |  |  |         if (selected_rack_groups) { | 
					
						
							|  |  |  |             rack_list.empty(); | 
					
						
							|  |  |  |             $.ajax({ | 
					
						
							|  |  |  |                 url: netbox_api_path + 'dcim/racks/?limit=500&group_id=' + selected_rack_groups.join('&group_id='), | 
					
						
							|  |  |  |                 dataType: 'json', | 
					
						
							|  |  |  |                 success: function (response, status) { | 
					
						
							|  |  |  |                     $.each(response["results"], function (index, rack) { | 
					
						
							|  |  |  |                         var option = $("<option></option>").attr("value", rack.id).text(rack.display_name); | 
					
						
							|  |  |  |                         rack_list.append(option); | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 10:53:59 -05:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | {% endblock %} |