Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d6ff97a0
authored
Apr 26, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: angularjs controller updated
parent
ac9284e1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
3 deletions
+53
-3
firewall_gui/static/js/project.js
+53
-3
No files found.
firewall_gui/static/js/project.js
View file @
d6ff97a0
angular
.
module
(
'firewall'
,
[]).
config
(
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
$routeProvider
.
when
(
'/rules/'
,
{
templateUrl
:
'/static/partials/rule-list.html'
,
...
...
@@ -9,8 +9,58 @@ angular.module('firewall', []).config(
});
}]);
function
RuleListCtrl
(
$scope
,
$http
)
{
function
range
(
a
,
b
)
{
var
res
=
[];
do
res
.
push
(
a
++
);
while
(
a
<
b
)
return
res
;
}
function
ruleMatch
(
rule
,
query
)
{
return
rule
.
description
.
match
(
query
)
||
rule
.
proto
&&
rule
.
proto
.
match
(
query
)
||
rule
.
target
.
name
.
match
(
query
)
||
rule
.
direction
.
match
(
query
)
||
rule
.
owner
.
name
.
match
(
query
)
||
rule
.
type
.
match
(
query
)
||
rule
.
foreignNetwork
.
name
.
match
(
query
);
}
function
RuleListCtrl
(
$scope
,
$http
,
$routeParams
)
{
$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
(
ruleMatch
(
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/rules/'
).
success
(
function
success
(
data
)
{
$scope
.
rules
=
data
;
console
.
log
(
'foo'
);
rules
=
data
;
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
data
.
length
/
pageSize
));
console
.
log
(
$scope
.
pages
);
});
}
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