1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

183 lines
6.8 KiB
HTML
Raw Normal View History

2016-03-01 11:23:03 -05:00
{% extends '_base.html' %}
{% load render_table from django_tables2 %}
{% load helpers %}
{% block title %}{{ site }}{% endblock %}
{% block content %}
<div class="pull-right">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#graphs_modal" data-site="{{ site.name }}" data-id="{{ site.id }}" title="Show graphs">
<i class="glyphicon glyphicon-signal" aria-hidden="true"></i>
Graphs
</button>
{% if perms.dcim.change_site %}
<a href="{% url 'dcim:site_edit' slug=site.slug %}" class="btn btn-warning">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit this site
</a>
{% endif %}
{% if perms.dcim.delete_site %}
<a href="{% url 'dcim:site_delete' slug=site.slug %}" class="btn btn-danger">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
Delete this site
</a>
{% endif %}
</div>
<h1>{{ site.name }}</h1>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Details</strong>
</div>
<table class="table table-hover panel-body">
<tr>
<td>Facility</td>
<td>{{ site.facility }}</td>
</tr>
<tr>
<td>AS Number</td>
<td>{{ site.asn }}</td>
</tr>
<tr>
<td>Physical Address</td>
<td>
{% if site.physical_address %}
<div class="pull-right">
<a href="http://maps.google.com/?q={{ site.physical_address|oneline }}" target="_blank" class="btn btn-primary btn-xs">
<i class="glyphicon glyphicon-map-marker"></i> Map it
</a>
</div>
{% endif %}
<span>{{ site.physical_address|linebreaksbr }}</span>
</td>
</tr>
<tr>
<td>Shipping Address</td>
<td>
{% if site.shipping_address %}
<span>{{ site.shipping_address|linebreaksbr }}</span>
{% else %}
<span class="text-muted">See physical address</span>
{% endif %}
</td>
</tr>
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<strong>Comments</strong>
</div>
<div class="panel-body">
{% if site.comments %}
{{ site.comments|gfm }}
{% else %}
<span class="text-muted">None</span>
{% endif %}
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Stats</strong>
</div>
<table class="table table-hover panel-body">
<tr>
<td>Racks</td>
<td>
<a href="{% url 'dcim:rack_list' %}?site={{ site.slug }}">{{ stats.rack_count }}</a>
</td>
</tr>
<tr>
<td>Devices</td>
<td>
<a href="{% url 'dcim:device_list' %}?site={{ site.slug }}">{{ stats.device_count }}</a>
</td>
</tr>
<tr>
<td>Prefixes</td>
<td>
<a href="{% url 'ipam:prefix_list' %}?site={{ site.slug }}">{{ stats.prefix_count }}</a>
</td>
</tr>
<tr>
<td>VLANs</td>
<td>
<a href="{% url 'ipam:vlan_list' %}?site={{ site.slug }}">{{ stats.vlan_count }}</a>
</td>
</tr>
<tr>
<td>Circuits</td>
<td>
<a href="{% url 'circuits:circuit_list' %}?site={{ site.slug }}">{{ stats.circuit_count }}</a>
</td>
</tr>
</table>
</div>
2016-04-08 14:57:54 -04:00
<div class="panel panel-default">
<div class="panel-heading">
<strong>Topology Maps</strong>
</div>
{% if topology_maps %}
<table class="table table-hover panel-body">
{% for tm in topology_maps %}
<tr>
<td><a href="{% url 'dcim-api:topology_map' slug=tm.slug %}" target="_blank">{{ tm }}</a></td>
<td>{{ tm.description }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<div class="panel-body text-muted">
None
</div>
{% endif %}
</div>
2016-03-01 11:23:03 -05:00
</div>
</div>
<div class="modal fade" id="graphs_modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="graphs_modal_title">Modal title</h4>
</div>
<div class="modal-body"></div>
</div>
</div>
</div>
{% endblock %}
{% block javascript %}
<script type="text/javascript">
$('#graphs_modal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var site = button.data('site');
var site_id = button.data('id');
var modal_title = $(this).find('.modal-title');
var modal_body = $(this).find('.modal-body');
modal_title.text(site);
modal_body.empty();
$.ajax({
url: "/api/dcim/sites/" + site_id + "/graphs/",
dataType: 'json',
success: function(json) {
$.each(json, function(i, graph) {
// Build in a 500ms delay per graph to avoid hammering the server
setTimeout(function() {
modal_body.append('<h4 class="text-center">' + graph.name + '</h4>');
if (graph.link) {
modal_body.append('<a href="' + graph.link + '"><img src="' + graph.embed_url + '" /></a>');
} else {
modal_body.append('<img src="' + graph.embed_url + '" />');
}
}, i*500);
})
}
});
});
</script>
{% endblock %}