Commit 0da1ad15 by Bence Dányi

firewall_gui: typeahead added

parent 6e156b87
......@@ -119,6 +119,23 @@ function EntityController(url) {
$http.get(url + id + '/').success(function success(data) {
console.log(data);
$scope.rule = data;
$('#targetName').typeahead({
source: function(query, process) {
$.ajax({
url: '/firewall/autocomplete/' + data.target.type + '/',
type: 'post',
data: 'name=' + query,
success: function autocompleteSuccess(data) {
process(data.map(function(obj) {
return obj.name;
}));
}
});
},
matcher: function() {
return true;
}
});
});
}
}
......@@ -6,9 +6,28 @@
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<label class="control-label" for="targetType">Target type</label>
<div class="controls">
<input type="password" id="inputPassword" placeholder="Password">
<select id="targetType">
<option value="vlan">Vlan</option>
<option value="vlangroup">VlanGroup</option>
<option value="host">Host</option>
<option value="hostgroup">HostGroup</option>
<option value="firewall">Firewall</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="targetName">Target</label>
<div class="controls">
<input type="text" data-provide="typeahead" autocomplete="off" id="targetName" value="{{rule.target.name}}" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="direction">Direction</label>
<div class="controls">
<select id="direction" ng-options="choice[0] as choice[1] for choice in rule.direction.choices" ng-model="rule.direction.value">
</select>
</div>
</div>
<div class="control-group">
......
......@@ -264,7 +264,7 @@ def autocomplete_hostgroup(request):
def autocomplete_host(request):
return HttpResponse(json.dumps([{
'id': host.id,
'name': host.name
'name': host.hostname
} for host in Host.objects.filter(hostname__icontains=request.POST['name'])[:5]]), content_type='application/json')
def autocomplete_firewall(request):
......
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