Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
07811494
Commit
07811494
authored
Sep 20, 2017
by
Francesc Guasch
Browse files
Check for invalid name on rename
parent
b48e4d3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/js/ravada.js
View file @
07811494
...
...
@@ -127,6 +127,7 @@
function
singleMachinePageC
(
$scope
,
$http
,
$interval
,
request
,
$location
)
{
$scope
.
domain_remove
=
0
;
$scope
.
new_name_invalid
=
false
;
$http
.
get
(
'
/pingbackend.json
'
).
then
(
function
(
response
)
{
$scope
.
pingbe_fail
=
!
response
.
data
;
});
...
...
@@ -155,7 +156,7 @@
$http
.
get
(
'
/
'
+
target
+
'
/
'
+
action
+
'
/
'
+
machineId
+
'
.json
'
);
};
$scope
.
rename
=
function
(
machineId
,
old_name
)
{
if
(
$scope
.
new_name_duplicated
)
return
;
if
(
$scope
.
new_name_duplicated
||
$scope
.
new_name_invalid
)
return
;
$scope
.
rename_requested
=
1
;
$http
.
get
(
'
/machine/rename/
'
+
machineId
+
'
/
'
+
$scope
.
new_name
);
...
...
@@ -165,10 +166,17 @@
};
$scope
.
validate_new_name
=
function
(
old_name
)
{
if
(
old_name
==
$scope
.
new_name
)
{
$scope
.
new_name_duplicated
=
false
;
$scope
.
new_name_duplicated
=
false
;
if
(
!
$scope
.
new_name
||
old_name
==
$scope
.
new_name
)
{
$scope
.
new_name_invalid
=
true
;
return
;
}
var
valid_domain_name
=
/^
[
a-zA-Z
]\w
+$/
;
if
(
!
valid_domain_name
.
test
(
$scope
.
new_name
))
{
$scope
.
new_name_invalid
=
true
;
return
;
}
$scope
.
new_name_invalid
=
false
;
$http
.
get
(
'
/machine/exists/
'
+
$scope
.
new_name
)
.
then
(
duplicated_callback
,
unique_callback
);
function
duplicated_callback
(
response
)
{
...
...
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