Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1d8cc180
authored
Apr 29, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: more compact controller generation
parent
fb6cb5ee
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
19 deletions
+15
-19
firewall_gui/static/js/project.js
+15
-19
No files found.
firewall_gui/static/js/project.js
View file @
1d8cc180
/**
* List of firewall collections, keys are RESTful url suffixes,
* values are templates.
* @type {Object}
* List of firewall collections, controllers/routes will be dynamically created from them.
*
* E.g., from the `rule` controller, the RESTful url `/rules/` will be generated,
* and the `/static/partials/rule-list.html` template will be used.
* @type {Array}
*/
var
listControllers
=
{
rules
:
'rule-list'
,
hosts
:
'host-list'
,
vlans
:
'vlan-list'
,
vlangroups
:
'vlangroup-list'
,
hostgroups
:
'hostgroup-list'
,
firewalls
:
'firewall-list'
,
};
var
listControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
,
'firewall'
];
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
for
(
var
i
in
listControllers
)
{
$routeProvider
.
when
(
'/'
+
i
+
'/'
,
{
templateUrl
:
'/static/partials/'
+
listControllers
[
i
]
+
'.html'
,
controller
:
ListController
(
'/firewall/'
+
i
+
'/'
)
for
(
var
i
in
listControllers
)
{
var
c
=
listControllers
[
i
];
$routeProvider
.
when
(
'/'
+
c
+
's/'
,
{
templateUrl
:
'/static/partials/'
+
c
+
'-list.html'
,
controller
:
ListController
(
'/firewall/'
+
c
+
's/'
)
});
}
$routeProvider
.
otherwise
({
...
...
@@ -34,11 +30,11 @@ function range(a, b) {
function
matchAnything
(
obj
,
query
)
{
var
expr
=
new
RegExp
(
query
,
'i'
)
for
(
var
i
in
obj
)
{
for
(
var
i
in
obj
)
{
var
prop
=
obj
[
i
];
if
(
typeof
prop
===
'number'
&&
prop
==
query
)
return
true
;
if
(
typeof
prop
===
'string'
&&
prop
.
match
(
expr
))
return
true
;
if
(
typeof
prop
===
'object'
&&
matchAnything
(
prop
,
query
))
return
true
;
if
(
typeof
prop
===
'number'
&&
prop
==
query
)
return
true
;
if
(
typeof
prop
===
'string'
&&
prop
.
match
(
expr
))
return
true
;
if
(
typeof
prop
===
'object'
&&
matchAnything
(
prop
,
query
))
return
true
;
}
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment