mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-14559: cloudstack 3.0 UI - VM Wizard - last step - screen doesn't change, but user-entered VM name will be passed as hostname and displayname to deployVirtualMachine API. Add validation of user-entered name field to match naming rule of hostname.
This commit is contained in:
parent
d7f4d5d4ec
commit
b7b77cea5c
@ -496,8 +496,10 @@
|
||||
}
|
||||
|
||||
var displayname = args.data.displayname;
|
||||
if(displayname != null && displayname.length > 0)
|
||||
if(displayname != null && displayname.length > 0) {
|
||||
array1.push("&displayname="+todb(displayname));
|
||||
array1.push("&name="+todb(displayname));
|
||||
}
|
||||
|
||||
var group = args.data.groupname;
|
||||
if (group != null && group.length > 0)
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
// Automatically generated by addcopyright.py at 04/02/2012
|
||||
var g_mySession = null;
|
||||
var g_sessionKey = null;
|
||||
var g_role = null; // roles - root, domain-admin, ro-admin, user
|
||||
@ -197,6 +197,20 @@ function isValidJsonString(str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
cloudStack.validate = {
|
||||
vmHostName: function(args) {
|
||||
// 1 ~ 63 characters long
|
||||
// ASCII letters 'a' through 'z' (case-insensitive), digits '0' through '9', hyphen ('-')
|
||||
// must start with a letter
|
||||
// must end with a letter or a digit (must not end with a hyphen)
|
||||
var regexp = /^[a-z]{1}[a-z0-9\-]{0,61}[a-z0-9]{0,1}$/;
|
||||
var b = regexp.test(args); //true or false
|
||||
if(b == false)
|
||||
cloudStack.dialog.notice({ message: 'Instance name can not be longer than 63 characters. Only ASCII letters a~z, digits 0~9, hyphen are allowed. Must start with a letter and end with a letter or a digit.' });
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
cloudStack.preFilter = {
|
||||
createTemplate: function(args) {
|
||||
if(isAdmin()) {
|
||||
|
||||
@ -641,6 +641,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
//step 6 - review (spcifiy displyname, group as well)
|
||||
if ($activeStep.hasClass('review')) {
|
||||
if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) {
|
||||
//validate
|
||||
var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val());
|
||||
if(b == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$form.valid()) {
|
||||
if ($form.find('input.error:visible, select.error:visible').size()) {
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user