-
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathchange_form.html
More file actions
115 lines (110 loc) · 3.36 KB
/
change_form.html
File metadata and controls
115 lines (110 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{% extends "admin/change_form.html" %}
{% load i18n admin_urls %}
{% load static %}
{% block object-tools-items %}
{% if has_change_permission %}
<li>
<a href="{% url 'admin:ipam_export_subnet' original.id %}">
{% trans 'Export Subnet' %}
</a>
</li>
{% endif %}
{% if has_add_permission %}
<li>
<a href="{% url 'admin:ipam_import_subnet' %}">
{% trans 'Import Addresses into Subnet' %}
</a>
</li>
{% endif %}
{{ block.super }}
{% endblock %}
{% block after_related_objects %}
{% if original and not is_popup %}
<h2>{% trans 'Network Hierarchical View' %}</h2>
<div id="jstree"></div>
<div id="graph"></div>
<h3 class="subnet-visual">{% trans 'Subnet Visual Display' %}</h3>
<div class="subnet-visual">
<form onsubmit="return false">
<input id="goto-input" onkeypress="return event.keyCode != 13;" placeholder="Jump to" />
<input id="goto-button" type="button" value="Go" />
</form>
<ul id="invalid-address" class="errorlist" style="display:none;">
<li>{% trans 'Address not valid for subnet' %}</li>
</ul>
</div>
<section id="subnet-visual" class="subnet-visual{% if original.subnet.version == 6 %} ipv6{% endif %}">
</section>
{% endif %}
{% endblock %}
{% block admin_change_form_document_ready %}
{{ block.super }}
{% if original and not is_popup %}
<script type="text/javascript">
var current_subnet = '{{ original.pk }}';
var ipAddUrl = '{% url ipaddress_add_url %}'
var ipChangeUrl = '{% url ipaddress_change_url "1234" %}'
var hasSubnetChangePermission = {{ has_change_permission|yesno:"true,false" }};
django.jQuery(document).ready(function () {
initHostsInfiniteScroll(django.jQuery, current_subnet, ipAddUrl, ipChangeUrl, {{ ip_uuid| safe}})
});
// Nested Subnet Tree
subnet_tree = [];
subnet_tree.push(
{% for subnet_queryset in subnet_tree %}
{% for subnet_item in subnet_queryset %}
{
subnet_id: "{{ subnet_item.pk }}",
subnet_tree_item: "{{ subnet_item.subnet }} ({{ subnet_item.name }})",
master_subnet: "{{ subnet_item.master_subnet }}",
url: "{% url subnet_change_url subnet_item.pk %}",
},
{% endfor %}
{% endfor %}
);
subnet_tree[0]['master_subnet'] = "jstree";
for (item in subnet_tree) {
var parent_element = document.getElementById(subnet_tree[item]["master_subnet"]),
subnet_list = document.createElement("ul"),
subnet_item = document.createElement("li"),
subnet_href = document.createElement("a"),
subnet_node = document.createTextNode(subnet_tree[item]["subnet_tree_item"]);
subnet_item.id = subnet_tree[item]["subnet_id"];
subnet_href.href = subnet_tree[item]["url"];
subnet_list.appendChild(subnet_item);
subnet_item.appendChild(subnet_href);
subnet_href.appendChild(subnet_node);
parent_element.appendChild(subnet_list);
}
// Ipam Graph / Visual
var data = [],
layout = {},
vals = {{ values| safe }}
vals[1] = Number(vals[1]);
data = [
{
values: {{ values| safe }},
labels: {{ labels| safe }},
text: vals,
type: 'pie',
hoverinfo: 'label+text',
textinfo: 'percent',
marker: {
colors: [
'rgba(149, 10, 10, 1)',
'rgba(20, 102, 26, 1)'
]
},
textfont: {
size: 18,
color: '#FFF',
}
}
];
layout = {
title: '{% trans "Subnet Freespace Display" %}'
};
Plotly.newPlot('graph', data, layout);
</script>
{% endif %}
{% endblock %}