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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
565ee8ef
authored
Apr 26, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: generic list controller for any list
parent
30a6c788
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
75 deletions
+36
-75
firewall_gui/static/js/project.js
+36
-75
No files found.
firewall_gui/static/js/project.js
View file @
565ee8ef
...
@@ -2,10 +2,10 @@ var module = angular.module('firewall', []).config(
...
@@ -2,10 +2,10 @@ var module = angular.module('firewall', []).config(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
[
'$routeProvider'
,
function
(
$routeProvider
)
{
$routeProvider
.
when
(
'/rules/'
,
{
$routeProvider
.
when
(
'/rules/'
,
{
templateUrl
:
'/static/partials/rule-list.html'
,
templateUrl
:
'/static/partials/rule-list.html'
,
controller
:
RuleListCtrl
controller
:
ListController
(
'/firewall/rules/'
)
}).
when
(
'/hosts/'
,
{
}).
when
(
'/hosts/'
,
{
templateUrl
:
'/static/partials/host-list.html'
,
templateUrl
:
'/static/partials/host-list.html'
,
controller
:
HostListCtrl
controller
:
ListController
(
'/firewall/hosts/'
)
}).
}).
otherwise
({
otherwise
({
redirectTo
:
'/rules/'
redirectTo
:
'/rules/'
...
@@ -30,80 +30,41 @@ function matchAnything(obj, query) {
...
@@ -30,80 +30,41 @@ function matchAnything(obj, query) {
return
false
;
return
false
;
}
}
function
RuleListCtrl
(
$scope
,
$http
)
{
function
ListController
(
url
)
{
$scope
.
page
=
1
;
return
function
(
$scope
,
$http
)
{
var
rules
=
[];
$scope
.
page
=
1
;
var
pageSize
=
10
;
var
rules
=
[];
var
itemCount
=
0
;
var
pageSize
=
10
;
$scope
.
getPage
=
function
()
{
var
itemCount
=
0
;
var
res
=
[];
$scope
.
getPage
=
function
()
{
if
(
$scope
.
query
)
{
var
res
=
[];
for
(
var
i
in
rules
)
{
if
(
$scope
.
query
)
{
var
rule
=
rules
[
i
];
for
(
var
i
in
rules
)
{
if
(
matchAnything
(
rule
,
$scope
.
query
))
{
var
rule
=
rules
[
i
];
res
.
push
(
rule
);
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/rules/'
).
success
(
function
success
(
data
)
{
console
.
log
(
'foo'
);
rules
=
data
;
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
data
.
length
/
pageSize
));
console
.
log
(
$scope
.
pages
);
});
}
function
HostListCtrl
(
$scope
,
$http
)
{
}
else
{
$scope
.
page
=
1
;
res
=
rules
;
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
);
}
}
}
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
res
.
length
/
pageSize
));
}
else
{
$scope
.
page
=
Math
.
min
(
$scope
.
page
,
$scope
.
pages
.
length
);
res
=
rules
;
return
res
.
slice
((
$scope
.
page
-
1
)
*
pageSize
,
$scope
.
page
*
pageSize
);
}
};
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
res
.
length
/
pageSize
));
$scope
.
setPage
=
function
(
page
)
{
$scope
.
page
=
Math
.
min
(
$scope
.
page
,
$scope
.
pages
.
length
);
$scope
.
page
=
page
;
return
res
.
slice
((
$scope
.
page
-
1
)
*
pageSize
,
$scope
.
page
*
pageSize
);
};
};
$scope
.
nextPage
=
function
()
{
$scope
.
setPage
=
function
(
page
)
{
$scope
.
page
=
Math
.
min
(
$scope
.
page
+
1
,
$scope
.
pages
.
length
);
$scope
.
page
=
page
;
};
};
$scope
.
prevPage
=
function
()
{
$scope
.
nextPage
=
function
()
{
$scope
.
page
=
Math
.
max
(
$scope
.
page
-
1
,
1
);
$scope
.
page
=
Math
.
min
(
$scope
.
page
+
1
,
$scope
.
pages
.
length
);
};
};
$http
.
get
(
url
).
success
(
function
success
(
data
)
{
$scope
.
prevPage
=
function
()
{
rules
=
data
;
$scope
.
page
=
Math
.
max
(
$scope
.
page
-
1
,
1
);
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
data
.
length
/
pageSize
));
};
});
$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
);
});
}
}
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