Commit 7e62b497 by Bence Dányi

firewall_gui: universal match function added

parent a2ee0bbd
...@@ -16,14 +16,14 @@ function range(a, b) { ...@@ -16,14 +16,14 @@ function range(a, b) {
return res; return res;
} }
function ruleMatch(rule, query) { function matchAnything(obj, query) {
return rule.description.match(query) || for(var i in obj) {
rule.proto && rule.proto.match(query) || var prop = obj[i];
rule.target.name.match(query) || if(typeof prop === 'number' && prop == query) return true;
rule.direction.match(query) || if(typeof prop === 'string' && prop.match(query)) return true;
rule.owner.name.match(query) || if(typeof prop === 'object' && matchAnything(prop, query)) return true;
rule.type.match(query) || }
rule.foreignNetwork.name.match(query); return false;
} }
function RuleListCtrl($scope, $http, $routeParams) { function RuleListCtrl($scope, $http, $routeParams) {
...@@ -36,7 +36,7 @@ function RuleListCtrl($scope, $http, $routeParams) { ...@@ -36,7 +36,7 @@ function RuleListCtrl($scope, $http, $routeParams) {
if ($scope.query) { if ($scope.query) {
for (var i in rules) { for (var i in rules) {
var rule = rules[i]; var rule = rules[i];
if (ruleMatch(rule, $scope.query)) { if (matchAnything(rule, $scope.query)) {
res.push(rule); res.push(rule);
} }
} }
......
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