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
07bacf6f
authored
May 09, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: client-side validation feedback
parent
e9a40a29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
10 deletions
+39
-10
firewall_gui/static/js/project.js
+25
-2
firewall_gui/static/partials/rule-edit.html
+14
-8
No files found.
firewall_gui/static/js/project.js
View file @
07bacf6f
...
...
@@ -236,6 +236,7 @@ function EntityController(url, init) {
return
function
(
$scope
,
$http
,
$routeParams
)
{
init
(
$scope
);
var
id
=
$routeParams
.
id
;
$scope
.
errors
=
{};
/**
* Generic filter for collections
*
...
...
@@ -246,15 +247,37 @@ function EntityController(url, init) {
$scope
.
destroyed
=
function
(
item
)
{
return
!
item
.
__destroyed
;
}
$scope
.
hasError
=
function
(
name
)
{
return
$scope
.
errors
[
name
]
?
'error'
:
null
;
}
$scope
.
getError
=
function
(
name
)
{
return
$scope
.
errors
[
name
]
?
$scope
.
errors
[
name
]
:
''
;
}
$scope
.
save
=
function
()
{
console
.
log
(
$scope
.
entity
);
console
.
log
(
JSON
.
stringify
(
$scope
.
entity
));
$scope
.
errors
=
{};
$
.
ajax
({
url
:
url
+
'save/'
,
type
:
'post'
,
data
:
JSON
.
stringify
(
$scope
.
entity
),
success
:
function
(
data
)
{
console
.
log
(
data
);
$scope
.
$apply
(
function
(){
$scope
.
errors
=
{};
})
}
}).
error
(
function
(
data
){
try
{
data
=
JSON
.
parse
(
data
.
responseText
);
var
newErrors
=
{};
for
(
var
i
in
data
)
{
var
id
=
$
(
'#'
+
i
).
length
?
i
:
'targetName'
;
newErrors
[
id
]
=
data
[
i
];
}
$scope
.
$apply
(
function
(){
$scope
.
errors
=
newErrors
;
})
}
catch
(
ex
)
{
}
})
}
...
...
firewall_gui/static/partials/rule-edit.html
View file @
07bacf6f
...
...
@@ -30,10 +30,11 @@
</select>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('targetName')"
>
<label
class=
"control-label"
for=
"targetName"
>
Target
</label>
<div
class=
"controls"
>
<input
type=
"text"
data-provide=
"typeahead"
autocomplete=
"off"
id=
"targetName"
ng-model=
"entity.target.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('targetName')"
></span>
</div>
</div>
<div
class=
"control-group"
>
...
...
@@ -51,16 +52,18 @@
</select>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('owner')"
>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"owner"
ng-model=
"entity.owner.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('owner')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
for=
"foreign
N
etwork"
>
Foreign network
</label>
<div
class=
"control-group"
ng-class=
"hasError('foreign_network')"
>
<label
class=
"control-label"
for=
"foreign
_n
etwork"
>
Foreign network
</label>
<div
class=
"controls"
>
<input
type=
"text"
data-provide=
"typeahead"
autocomplete=
"off"
id=
"foreignNetwork"
class=
"vlangroup"
ng-model=
"entity.foreignNetwork.name"
/>
<input
type=
"text"
data-provide=
"typeahead"
autocomplete=
"off"
id=
"foreign_network"
class=
"vlangroup"
ng-model=
"entity.foreignNetwork.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('foreign_network')"
></span>
</div>
</div>
</div>
...
...
@@ -86,22 +89,25 @@
</label>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('dport')"
>
<label
class=
"control-label"
for=
"dport"
>
Destination port
</label>
<div
class=
"controls"
>
<input
class=
"input-mini"
type=
"number"
id=
"dport"
ng-model=
"entity.dport"
>
<span
class=
"help-inline"
ng-bind=
"getError('dport')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('nat_dport')"
>
<label
class=
"control-label"
for=
"nat_dport"
>
NAT Destination port
</label>
<div
class=
"controls"
>
<input
class=
"input-mini"
type=
"number"
id=
"nat_dport"
ng-model=
"entity.nat_dport"
>
<span
class=
"help-inline"
ng-bind=
"getError('nat_dport')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('sport')"
>
<label
class=
"control-label"
for=
"sport"
>
Source port
</label>
<div
class=
"controls"
>
<input
class=
"input-mini"
type=
"number"
id=
"sport"
ng-model=
"entity.sport"
>
<span
class=
"help-inline"
ng-bind=
"getError('sport')"
></span>
</div>
</div>
<div
class=
"control-group"
>
...
...
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