Commit e655ed8a by Bence Dányi

firewall_gui: hostgroup details page added

parent d10a77d8
...@@ -108,6 +108,7 @@ urlpatterns = patterns('', ...@@ -108,6 +108,7 @@ urlpatterns = patterns('',
url(r'^firewall/hosts/(?P<id>\d+)/$', 'firewall_gui.views.show_host'), url(r'^firewall/hosts/(?P<id>\d+)/$', 'firewall_gui.views.show_host'),
url(r'^firewall/vlans/(?P<id>\d+)/$', 'firewall_gui.views.show_vlan'), url(r'^firewall/vlans/(?P<id>\d+)/$', 'firewall_gui.views.show_vlan'),
url(r'^firewall/vlangroups/(?P<id>\d+)/$', 'firewall_gui.views.show_vlangroup'), url(r'^firewall/vlangroups/(?P<id>\d+)/$', 'firewall_gui.views.show_vlangroup'),
url(r'^firewall/hostgroups/(?P<id>\d+)/$', 'firewall_gui.views.show_hostgroup'),
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', 'host', 'vlan', 'vlangroup']; var entityControllers = ['rule', 'host', 'vlan', 'vlangroup', 'hostgroup'];
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) {
......
<form class="form-horizontal">
<div class="span5">
<div class="control-group">
<label class="control-label" for="ID">ID</label>
<div class="controls">
<input class="input-mini" type="text" id="ID" placeholder="ID" value="{{entity.id}}" disabled="disabled">
</div>
</div>
<div class="control-group">
<label class="control-label" for="created_at">Created at</label>
<div class="controls">
<input class="input" type="text" id="created_at" ng-model="entity.created_at" disabled="disabled">
</div>
</div>
<div class="control-group">
<label class="control-label" for="modified_at">Modified at</label>
<div class="controls">
<input class="input" type="text" id="modified_at" ng-model="entity.modified_at" disabled="disabled">
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input type="text" id="name" ng-model="entity.name" />
</div>
</div>
</div>
<div class="span5">
<div class="control-group">
<label class="control-label" for="owner">Owner</label>
<div class="controls">
<input type="text" autocomplete="off" id="owner" ng-model="entity.owner.name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
<textarea rows="4" id="description" ng-model="entity.description">
</textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn">Save (nem működik!)</button>
</div>
</div>
</div>
</form>
<div class="span12">
<h3>Rules belonging to this hostgroup</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Direction</th>
<th>Protocol</th>
<th>Accept</th>
<th>NAT</th>
<th colspan="2">Owner</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="rule in entity.rules">
<td>{{rule.direction}}</td>
<td>{{rule.proto}}</td>
<td>{{rule.accept}}</td>
<td>{{rule.nat}}</td>
<td>{{rule.owner.name}}</td>
<td>
<a class="btn" href="#/rules/{{rule.id}}/">Edit</a>
<a class="btn btn-danger" href="#/rules/{{rule.id}}/delete/">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
...@@ -353,6 +353,32 @@ def show_vlangroup(request, id): ...@@ -353,6 +353,32 @@ def show_vlangroup(request, id):
} }
return HttpResponse(json.dumps(group), content_type='application/json') return HttpResponse(json.dumps(group), content_type='application/json')
def show_hostgroup(request, id):
group = get_object_or_404(Group, id=id)
group = {
'id': group.id,
'name': group.name,
'description': group.description,
'owner': {
'id': group.owner.id,
'name': str(group.owner),
},
'created_at': group.created_at.isoformat(),
'modified_at': group.modified_at.isoformat(),
'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 group.rules.all()]
}
return HttpResponse(json.dumps(group), content_type='application/json')
def autocomplete_vlan(request): def autocomplete_vlan(request):
return HttpResponse(json.dumps([{ return HttpResponse(json.dumps([{
......
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