Commit 30a6c788 by Bence Dányi

firewall_gui: HostList controller added

parent d12efa8c
......@@ -68,3 +68,42 @@ function RuleListCtrl($scope, $http) {
console.log($scope.pages);
});
}
function HostListCtrl($scope, $http) {
$scope.page = 1;
var rules = [];
var pageSize = 10;
var itemCount = 0;
$scope.getPage = function() {
var res = [];
if ($scope.query) {
for (var i in rules) {
var rule = rules[i];
if (matchAnything(rule, $scope.query)) {
res.push(rule);
}
}
} else {
res = rules;
}
$scope.pages = range(1, Math.ceil(res.length / pageSize));
$scope.page = Math.min($scope.page, $scope.pages.length);
return res.slice(($scope.page - 1) * pageSize, $scope.page * pageSize);
};
$scope.setPage = function(page) {
$scope.page = page;
};
$scope.nextPage = function() {
$scope.page = Math.min($scope.page + 1, $scope.pages.length);
};
$scope.prevPage = function() {
$scope.page = Math.max($scope.page - 1, 1);
};
$http.get('/firewall/hosts/').success(function success(data) {
console.log('foo');
rules = data;
$scope.pages = range(1, Math.ceil(data.length / pageSize));
console.log($scope.pages);
});
}
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