Commit 07811494 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Check for invalid name on rename

parent b48e4d3c
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment