Commit 2810e1e2 by Bence Dányi

firewall_gui: host details page added

parent ed82dac9
...@@ -105,6 +105,7 @@ urlpatterns = patterns('', ...@@ -105,6 +105,7 @@ urlpatterns = patterns('',
url(r'^firewall/blacklists/$', 'firewall_gui.views.list_blacklists'), url(r'^firewall/blacklists/$', 'firewall_gui.views.list_blacklists'),
url(r'^firewall/rules/(?P<id>\d+)/$', 'firewall_gui.views.show_rule'), url(r'^firewall/rules/(?P<id>\d+)/$', 'firewall_gui.views.show_rule'),
url(r'^firewall/hosts/(?P<id>\d+)/$', 'firewall_gui.views.show_host'),
url(r'^firewall/autocomplete/vlan/$', 'firewall_gui.views.autocomplete_vlan'), url(r'^firewall/autocomplete/vlan/$', 'firewall_gui.views.autocomplete_vlan'),
url(r'^firewall/autocomplete/vlangroup/$', 'firewall_gui.views.autocomplete_vlangroup'), url(r'^firewall/autocomplete/vlangroup/$', 'firewall_gui.views.autocomplete_vlangroup'),
......
...@@ -34,7 +34,7 @@ $.ajaxSetup({ ...@@ -34,7 +34,7 @@ $.ajaxSetup({
* @type {Array} * @type {Array}
*/ */
var listControllers = ['rule', 'host', 'vlan', 'vlangroup', 'hostgroup', 'firewall', 'domain', 'record', 'blacklist']; var listControllers = ['rule', 'host', 'vlan', 'vlangroup', 'hostgroup', 'firewall', 'domain', 'record', 'blacklist'];
var entityControllers = ['rule']; var entityControllers = ['rule', 'host'];
var module = angular.module('firewall', []).config( var module = angular.module('firewall', []).config(
['$routeProvider', function($routeProvider) { ['$routeProvider', function($routeProvider) {
for (var i in listControllers) { for (var i in listControllers) {
......
...@@ -243,6 +243,49 @@ def show_rule(request, id): ...@@ -243,6 +243,49 @@ def show_rule(request, id):
} }
return HttpResponse(json.dumps(rule), content_type='application/json') return HttpResponse(json.dumps(rule), content_type='application/json')
def show_host(request, id):
host = get_object_or_404(Host, id=id)
host = {
'id': host.id,
'reverse': host.reverse,
'name': host.hostname,
'mac': host.mac,
'ipv4': host.ipv4,
'ipv6': host.ipv6,
'pub_ipv4' : host.pub_ipv4,
'shared_ip': host.shared_ip,
'description': host.description,
'comment': host.comment,
'location': host.location,
'vlan': {
'name': host.vlan.name,
'id': host.vlan.id
},
'owner': {
'name': str(host.owner),
'id': host.owner.id
},
'created_at': host.created_at.isoformat(),
'modified_at': host.modified_at.isoformat(),
'groups': [{
'name': group.name,
'id': group.id,
} for group in host.groups.all()],
'rules': [{
'id': rule.id,
'direction': rule.get_direction_display(),
'proto': rule.proto,
'owner': {
'id': rule.owner.id,
'name': str(rule.owner),
},
'accept': rule.accept,
'nat': rule.nat
} for rule in host.rules.all()]
}
return HttpResponse(json.dumps(host), content_type='application/json')
def autocomplete_vlan(request): def autocomplete_vlan(request):
return HttpResponse(json.dumps([{ return HttpResponse(json.dumps([{
'id': vlan.id, 'id': vlan.id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment