From f45a5a5de8ee8e7b014a780aa45b37774a4b06a1 Mon Sep 17 00:00:00 2001 From: "Belal, Awais" Date: Wed, 5 Apr 2017 00:12:48 -0700 Subject: [PATCH] bitbake: toaster: toastergui: implement machine name validation Valid machine names cannot include spaces anywhere in the name and doing so will result in a build failure. This implements a mechanism to alert the user against such a misconfiguration and does not allow input of such machine names. [YOCTO #8721] (Bitbake rev: 6fb642935a3787659aa316ca906025d2d87964cf) Signed-off-by: Awais Belal Signed-off-by: David Reyna Signed-off-by: Richard Purdie --- .../toaster/toastergui/static/js/projectpage.js | 17 +++++++++++++++++ .../toaster/toastergui/templates/project.html | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js index 4536703649..21adf816c6 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js @@ -12,6 +12,8 @@ function projectPageInit(ctx) { var machineChangeFormToggle = $("#change-machine-toggle"); var machineNameTitle = $("#project-machine-name"); var machineChangeCancel = $("#cancel-machine-change"); + var machineInputForm = $("#machine-input-form"); + var invalidMachineNameHelp = $("#invalid-machine-name-help"); var freqBuildBtn = $("#freq-build-btn"); var freqBuildList = $("#freq-build-list"); @@ -208,8 +210,23 @@ function projectPageInit(ctx) { /* Change machine functionality */ + machineChangeInput.keyup(function(){ + if ($(this).val().indexOf(' ') >= 0) { + machineChangeBtn.attr("disabled", "disabled"); + invalidMachineNameHelp.show(); + machineInputForm.addClass('has-error'); + } else { + machineChangeBtn.removeAttr("disabled"); + invalidMachineNameHelp.hide(); + machineInputForm.removeClass('has-error'); + } + }); machineChangeFormToggle.click(function(){ + machineChangeInput.val(machineNameTitle.text()); + machineChangeBtn.removeAttr("disabled"); + invalidMachineNameHelp.hide(); + machineInputForm.removeClass('has-error'); machineForm.slideDown(); machineNameTitle.hide(); $(this).hide(); diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index 5abe241305..ab7e665b64 100644 --- a/bitbake/lib/toaster/toastergui/templates/project.html +++ b/bitbake/lib/toaster/toastergui/templates/project.html @@ -67,11 +67,12 @@