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
a0cbce65
authored
May 08, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: generic entity/listcontrollers
parent
7514d52f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
51 deletions
+71
-51
firewall_gui/static/js/project.js
+71
-51
No files found.
firewall_gui/static/js/project.js
View file @
a0cbce65
...
@@ -33,22 +33,72 @@ $.ajaxSetup({
...
@@ -33,22 +33,72 @@ $.ajaxSetup({
* and the `/static/partials/rule-list.html` template will be used.
* and the `/static/partials/rule-list.html` template will be used.
* @type {Array}
* @type {Array}
*/
*/
var
listControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
,
'firewall'
,
'domain'
,
'record'
,
'blacklist'
];
var
controllers
=
{
var
entityControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
];
rule
:
function
(
$scope
)
{
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
$
(
'#targetName'
).
typeahead
({
[
'$routeProvider'
,
function
(
$routeProvider
)
{
source
:
function
(
query
,
process
)
{
for
(
var
i
in
listControllers
)
{
$
.
ajax
({
var
c
=
listControllers
[
i
];
url
:
'/firewall/autocomplete/'
+
data
.
target
.
type
+
'/'
,
$routeProvider
.
when
(
'/'
+
c
+
's/'
,
{
type
:
'post'
,
templateUrl
:
'/static/partials/'
+
c
+
'-list.html'
,
data
:
'name='
+
query
,
controller
:
ListController
(
'/firewall/'
+
c
+
's/'
)
success
:
function
autocompleteSuccess
(
data
)
{
process
(
data
.
map
(
function
(
obj
)
{
return
obj
.
name
;
}));
}
});
});
},
matcher
:
function
()
{
return
true
;
}
}
for
(
var
i
in
entityControllers
)
{
});
var
c
=
entityControllers
[
i
];
},
$routeProvider
.
when
(
'/'
+
c
+
's/:id/'
,
{
host
:
function
(
$scope
)
{
templateUrl
:
'/static/partials/'
+
c
+
'-edit.html'
,
$scope
.
addHostGroup
=
function
(
group
)
{
controller
:
EntityController
(
'/firewall/'
+
c
+
's/'
)
for
(
var
i
in
$scope
.
entity
.
groups
)
{
var
group_
=
$scope
.
entity
.
groups
[
i
];
if
(
group_
.
name
==
group
&&
group_
.
__destroyed
)
{
group_
.
__destroyed
=
false
;
return
;
}
else
if
(
group_
.
name
==
group
)
{
return
;
}
}
console
.
log
(
'2foooo'
);
$scope
.
entity
.
groups
.
push
({
name
:
group
,
__created
:
true
,
})
}
$scope
.
removeHostGroup
=
function
(
group
)
{
console
.
log
(
group
);
for
(
var
i
in
$scope
.
entity
.
groups
)
{
var
group_
=
$scope
.
entity
.
groups
[
i
];
if
(
group_
.
name
==
group
.
name
)
{
group_
.
__destroyed
=
true
;
return
;
}
}
}
},
vlan
:
function
()
{},
vlangroup
:
function
()
{},
hostgroup
:
function
()
{},
firewall
:
function
()
{},
domain
:
function
()
{},
record
:
function
()
{},
blacklist
:
function
()
{},
}
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
for
(
var
controller
in
controllers
)
{
var
init
=
controllers
[
controller
];
$routeProvider
.
when
(
'/'
+
controller
+
's/'
,
{
templateUrl
:
'/static/partials/'
+
controller
+
'-list.html'
,
controller
:
ListController
(
'/firewall/'
+
controller
+
's/'
)
}).
when
(
'/'
+
controller
+
's/:id/'
,
{
templateUrl
:
'/static/partials/'
+
controller
+
'-edit.html'
,
controller
:
EntityController
(
'/firewall/'
+
controller
+
's/'
,
init
)
});
});
}
}
$routeProvider
.
otherwise
({
$routeProvider
.
otherwise
({
...
@@ -113,48 +163,18 @@ function ListController(url) {
...
@@ -113,48 +163,18 @@ function ListController(url) {
}
}
}
}
function
EntityController
(
url
)
{
function
EntityController
(
url
,
init
)
{
return
function
(
$scope
,
$http
,
$routeParams
)
{
return
function
(
$scope
,
$http
,
$routeParams
)
{
init
(
$scope
);
var
id
=
$routeParams
.
id
;
var
id
=
$routeParams
.
id
;
$scope
.
destroyed
=
function
(
item
)
{
return
!
item
.
__destroyed
;
}
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
console
.
log
(
data
);
$scope
.
entity
=
data
;
$scope
.
entity
=
data
;
$
(
'#targetName'
).
typeahead
({
source
:
function
(
query
,
process
)
{
$
.
ajax
({
url
:
'/firewall/autocomplete/'
+
data
.
target
.
type
+
'/'
,
type
:
'post'
,
data
:
'name='
+
query
,
success
:
function
autocompleteSuccess
(
data
)
{
process
(
data
.
map
(
function
(
obj
)
{
return
obj
.
name
;
}));
}
});
},
matcher
:
function
()
{
return
true
;
}
});
$
(
'#foreignNetwork'
).
typeahead
({
source
:
function
(
query
,
process
)
{
$
.
ajax
({
url
:
'/firewall/autocomplete/vlangroup/'
,
type
:
'post'
,
data
:
'name='
+
query
,
success
:
function
autocompleteSuccess
(
data
)
{
process
(
data
.
map
(
function
(
obj
)
{
return
obj
.
name
;
}));
}
});
},
matcher
:
function
()
{
return
true
;
}
});
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
].
forEach
(
function
(
t
)
{
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
].
forEach
(
function
(
t
)
{
$
(
'
#
'
+
t
).
typeahead
({
$
(
'
.
'
+
t
).
typeahead
({
source
:
function
(
query
,
process
)
{
source
:
function
(
query
,
process
)
{
$
.
ajax
({
$
.
ajax
({
url
:
'/firewall/autocomplete/'
+
t
+
'/'
,
url
:
'/firewall/autocomplete/'
+
t
+
'/'
,
...
...
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