Commit 55cd39eb by Bence Dányi

firewall_gui: show rule details RESTful url endpoint added

parent 40c3dccf
...@@ -103,4 +103,6 @@ urlpatterns = patterns('', ...@@ -103,4 +103,6 @@ urlpatterns = patterns('',
url(r'^firewall/domains/$', 'firewall_gui.views.list_domains'), url(r'^firewall/domains/$', 'firewall_gui.views.list_domains'),
url(r'^firewall/records/$', 'firewall_gui.views.list_records'), url(r'^firewall/records/$', 'firewall_gui.views.list_records'),
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'),
) )
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* @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 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) {
...@@ -16,6 +16,13 @@ var module = angular.module('firewall', []).config( ...@@ -16,6 +16,13 @@ var module = angular.module('firewall', []).config(
controller: ListController('/firewall/' + c + 's/') controller: ListController('/firewall/' + c + 's/')
}); });
} }
for (var i in entityControllers) {
var c = entityControllers[i];
$routeProvider.when('/' + c + 's/:id/', {
templateUrl: '/static/partials/' + c + '-edit.html',
controller: EntityController('/firewall/' + c + 's/')
});
}
$routeProvider.otherwise({ $routeProvider.otherwise({
redirectTo: '/rules/' redirectTo: '/rules/'
}); });
...@@ -77,3 +84,15 @@ function ListController(url) { ...@@ -77,3 +84,15 @@ function ListController(url) {
}); });
} }
} }
function EntityController(url) {
console.log('creatin...', url);
return function($scope, $http, $routeParams) {
var id = $routeParams.id;
console.log('foooooo');
$http.get(url + id + '/').success(function success(data) {
console.log(data);
$scope.rule = data;
});
}
}
<form class="form-horizontal">
<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="{{rule.id}}" disabled="disabled">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button type="submit" class="btn">Sign in</button>
</div>
</div>
</form>
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