Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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({
* and the `/static/partials/rule-list.html` template will be used.
* @type {Array}
*/
var
listControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
,
'firewall'
,
'domain'
,
'record'
,
'blacklist'
];
var
entityControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
];
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
for
(
var
i
in
listControllers
)
{
var
c
=
listControllers
[
i
];
$routeProvider
.
when
(
'/'
+
c
+
's/'
,
{
templateUrl
:
'/static/partials/'
+
c
+
'-list.html'
,
controller
:
ListController
(
'/firewall/'
+
c
+
's/'
)
var
controllers
=
{
rule
:
function
(
$scope
)
{
$
(
'#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
;
}
for
(
var
i
in
entityControllers
)
{
var
c
=
entityControllers
[
i
];
$routeProvider
.
when
(
'/'
+
c
+
's/:id/'
,
{
templateUrl
:
'/static/partials/'
+
c
+
'-edit.html'
,
controller
:
EntityController
(
'/firewall/'
+
c
+
's/'
)
});
},
host
:
function
(
$scope
)
{
$scope
.
addHostGroup
=
function
(
group
)
{
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
({
...
...
@@ -113,48 +163,18 @@ function ListController(url) {
}
}
function
EntityController
(
url
)
{
function
EntityController
(
url
,
init
)
{
return
function
(
$scope
,
$http
,
$routeParams
)
{
init
(
$scope
);
var
id
=
$routeParams
.
id
;
$scope
.
destroyed
=
function
(
item
)
{
return
!
item
.
__destroyed
;
}
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
console
.
log
(
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
)
{
$
(
'
#
'
+
t
).
typeahead
({
$
(
'
.
'
+
t
).
typeahead
({
source
:
function
(
query
,
process
)
{
$
.
ajax
({
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