diff options
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/projectconf.html | 81 | ||||
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 26 |
2 files changed, 92 insertions, 15 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/projectconf.html b/bitbake/lib/toaster/toastergui/templates/projectconf.html index 774e9ea417..c994f31bbc 100644 --- a/bitbake/lib/toaster/toastergui/templates/projectconf.html +++ b/bitbake/lib/toaster/toastergui/templates/projectconf.html | |||
@@ -14,6 +14,7 @@ | |||
14 | <div style="padding-left:19px;"> | 14 | <div style="padding-left:19px;"> |
15 | 15 | ||
16 | <dl class="dl-vertical"> | 16 | <dl class="dl-vertical"> |
17 | {% if distro_defined %} | ||
17 | <dt> | 18 | <dt> |
18 | <span class="js-config-var-name js-config-var-managed-name">DISTRO</span> | 19 | <span class="js-config-var-name js-config-var-managed-name">DISTRO</span> |
19 | <i class="icon-question-sign get-help" title="The short name of the distribution. If the variable is blank, meta/conf/distro/defaultsetup.conf will be used. <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-DISTRO' target='_blank'>Read more in the manual</a>"></i> | 20 | <i class="icon-question-sign get-help" title="The short name of the distribution. If the variable is blank, meta/conf/distro/defaultsetup.conf will be used. <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-DISTRO' target='_blank'>Read more in the manual</a>"></i> |
@@ -32,6 +33,9 @@ | |||
32 | </div> | 33 | </div> |
33 | </form> | 34 | </form> |
34 | </dd> | 35 | </dd> |
36 | {% endif %} | ||
37 | |||
38 | {% if fstypes_defined %} | ||
35 | <dt> | 39 | <dt> |
36 | <span class="js-config-var-name js-config-var-managed-name">IMAGE_FSTYPES</span> | 40 | <span class="js-config-var-name js-config-var-managed-name">IMAGE_FSTYPES</span> |
37 | <i class="icon-question-sign get-help" title="Formats of root file system images that you want to have created <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-IMAGE_FSTYPES' target='_blank'>Read more in the manual</a>"></i> | 41 | <i class="icon-question-sign get-help" title="Formats of root file system images that you want to have created <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-IMAGE_FSTYPES' target='_blank'>Read more in the manual</a>"></i> |
@@ -47,6 +51,9 @@ | |||
47 | <button id="cancel-change-image_fstypes" type="button" class="btn btn-link">Cancel</button> | 51 | <button id="cancel-change-image_fstypes" type="button" class="btn btn-link">Cancel</button> |
48 | </form> | 52 | </form> |
49 | </dd> | 53 | </dd> |
54 | {% endif %} | ||
55 | |||
56 | {% if image_install_append_defined %} | ||
50 | <dt> | 57 | <dt> |
51 | <span class="js-config-var-name js-config-var-managed-name">IMAGE_INSTALL_append</span> | 58 | <span class="js-config-var-name js-config-var-managed-name">IMAGE_INSTALL_append</span> |
52 | <i class="icon-question-sign get-help" title="Specifies additional packages to install into an image. If your build creates more than one image, the packages will be installed in <strong>all of them</strong> <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-IMAGE_INSTALL' target='_blank'>Read more in the manual</a>"></i> | 59 | <i class="icon-question-sign get-help" title="Specifies additional packages to install into an image. If your build creates more than one image, the packages will be installed in <strong>all of them</strong> <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-IMAGE_INSTALL' target='_blank'>Read more in the manual</a>"></i> |
@@ -66,6 +73,9 @@ | |||
66 | </div> | 73 | </div> |
67 | </form> | 74 | </form> |
68 | </dd> | 75 | </dd> |
76 | {% endif %} | ||
77 | |||
78 | {% if package_classes_defined %} | ||
69 | <dt> | 79 | <dt> |
70 | <span class="js-config-var-name js-config-var-managed-name">PACKAGE_CLASSES</span> | 80 | <span class="js-config-var-name js-config-var-managed-name">PACKAGE_CLASSES</span> |
71 | <i class="icon-question-sign get-help" title="Specifies the package manager to use when packaging data <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-PACKAGE_CLASSES' target='_blank'>Read more in the manual</a>"></i> | 81 | <i class="icon-question-sign get-help" title="Specifies the package manager to use when packaging data <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-PACKAGE_CLASSES' target='_blank'>Read more in the manual</a>"></i> |
@@ -99,6 +109,9 @@ | |||
99 | </div> | 109 | </div> |
100 | </form> | 110 | </form> |
101 | </dd> | 111 | </dd> |
112 | {% endif %} | ||
113 | |||
114 | {% if sdk_machine_defined %} | ||
102 | <dt> | 115 | <dt> |
103 | <span class="js-config-var-name js-config-var-managed-name">SDKMACHINE</span> | 116 | <span class="js-config-var-name js-config-var-managed-name">SDKMACHINE</span> |
104 | <i class="icon-question-sign get-help" title="Specifies the architecture (i.e. i686 or x86_64) for which to build SDK and ADT items <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-SDKMACHINE' target='_blank'>Read more in the manual</a>"></i> | 117 | <i class="icon-question-sign get-help" title="Specifies the architecture (i.e. i686 or x86_64) for which to build SDK and ADT items <br /><a href='http://www.yoctoproject.org/docs/1.6.1/ref-manual/ref-manual.html#var-SDKMACHINE' target='_blank'>Read more in the manual</a>"></i> |
@@ -121,6 +134,7 @@ | |||
121 | </div> | 134 | </div> |
122 | </form> | 135 | </form> |
123 | </dd> | 136 | </dd> |
137 | {% endif %} | ||
124 | 138 | ||
125 | </dl> | 139 | </dl> |
126 | 140 | ||
@@ -137,7 +151,7 @@ | |||
137 | <input type="hidden" class="js-config-blacklist-name" value="{{b}}"> | 151 | <input type="hidden" class="js-config-blacklist-name" value="{{b}}"> |
138 | {% endfor %} | 152 | {% endfor %} |
139 | {% for b in vars_managed %} | 153 | {% for b in vars_managed %} |
140 | <input type="hidden" class="js-config-var-managed-name" value="{{b}}"> | 154 | <input type="hidden" class="js-config-managed-name" value="{{b}}"> |
141 | {% endfor %} | 155 | {% endfor %} |
142 | 156 | ||
143 | <div class="row-fluid"> | 157 | <div class="row-fluid"> |
@@ -187,6 +201,9 @@ | |||
187 | 201 | ||
188 | <script> | 202 | <script> |
189 | 203 | ||
204 | // global variables | ||
205 | var do_reload=false; | ||
206 | |||
190 | // validate new variable name | 207 | // validate new variable name |
191 | function validate_new_variable() { | 208 | function validate_new_variable() { |
192 | var variable = $("input#variable").val(); | 209 | var variable = $("input#variable").val(); |
@@ -210,6 +227,13 @@ | |||
210 | } | 227 | } |
211 | } | 228 | } |
212 | 229 | ||
230 | var managed_configvars = document.getElementsByClassName('js-config-managed-name'); | ||
231 | for (var i = 0, length = managed_configvars.length; i < length; i++) { | ||
232 | if (managed_configvars[i].value.toUpperCase() == variable.toUpperCase()) { | ||
233 | error_msg = "You cannot set this variable here. Please set it in the <a href=\"{% url 'project' project.id %}\">project main page</a>"; | ||
234 | } | ||
235 | } | ||
236 | |||
213 | var bad_chars = /[^a-zA-Z0-9\-_]/.test(variable); | 237 | var bad_chars = /[^a-zA-Z0-9\-_]/.test(variable); |
214 | var has_spaces = (0 <= variable.indexOf(" ")); | 238 | var has_spaces = (0 <= variable.indexOf(" ")); |
215 | var only_spaces = (0 < variable.length) && (0 == variable.trim().length); | 239 | var only_spaces = (0 < variable.length) && (0 == variable.trim().length); |
@@ -223,16 +247,22 @@ | |||
223 | } | 247 | } |
224 | 248 | ||
225 | if ("" != error_msg) { | 249 | if ("" != error_msg) { |
226 | $('#new-variable-error-message').text(error_msg); | 250 | $('#new-variable-error-message').html(error_msg); |
227 | $(".save").attr("disabled","disabled"); | 251 | $(".save").attr("disabled","disabled"); |
228 | 252 | ||
253 | // add one (and only one) error class append | ||
229 | var d = document.getElementById("add-configvar-name-div"); | 254 | var d = document.getElementById("add-configvar-name-div"); |
230 | d.className = d.className + " control-group error"; | 255 | d.className = d.className.replace(" error",""); |
256 | d.className = d.className + " error"; | ||
231 | 257 | ||
232 | return false; | 258 | return false; |
259 | } else if (0 == variable.length) { | ||
260 | $(".save").attr("disabled","disabled"); | ||
261 | return false; | ||
233 | } | 262 | } |
263 | |||
234 | var d = document.getElementById("add-configvar-name-div"); | 264 | var d = document.getElementById("add-configvar-name-div"); |
235 | d.className = d.className.replace(" control-group error",""); | 265 | d.className = d.className.replace(" error",""); |
236 | 266 | ||
237 | // now set the "Save" enablement if 'value' also passes | 267 | // now set the "Save" enablement if 'value' also passes |
238 | if (value.trim().length > 0) { | 268 | if (value.trim().length > 0) { |
@@ -264,14 +294,16 @@ | |||
264 | $('#distro-error-message').text(error_msg); | 294 | $('#distro-error-message').text(error_msg); |
265 | $("#apply-change-distro").attr("disabled","disabled"); | 295 | $("#apply-change-distro").attr("disabled","disabled"); |
266 | 296 | ||
297 | // add one (and only one) error class append | ||
267 | var d = document.getElementById("edit-distro-name-div"); | 298 | var d = document.getElementById("edit-distro-name-div"); |
268 | d.className = d.className + " control-group error"; | 299 | d.className = d.className.replace(" error",""); |
300 | d.className = d.className + " error"; | ||
269 | 301 | ||
270 | return false; | 302 | return false; |
271 | } | 303 | } |
272 | 304 | ||
273 | var d = document.getElementById("edit-distro-name-div"); | 305 | var d = document.getElementById("edit-distro-name-div"); |
274 | d.className = d.className.replace(" control-group error",""); | 306 | d.className = d.className.replace(" error",""); |
275 | $("#apply-change-distro").removeAttr("disabled"); | 307 | $("#apply-change-distro").removeAttr("disabled"); |
276 | return true; | 308 | return true; |
277 | } | 309 | } |
@@ -421,7 +453,14 @@ | |||
421 | alert("error on request:\n" + data.error); | 453 | alert("error on request:\n" + data.error); |
422 | return; | 454 | return; |
423 | } | 455 | } |
424 | onEditPageUpdate(data); | 456 | |
457 | // delayed page reload? | ||
458 | if (do_reload) { | ||
459 | do_reload=false; | ||
460 | location.reload(true); | ||
461 | } else { | ||
462 | onEditPageUpdate(data); | ||
463 | } | ||
425 | } | 464 | } |
426 | 465 | ||
427 | function onEditAjaxError(jqXHR, textstatus, error) { | 466 | function onEditAjaxError(jqXHR, textstatus, error) { |
@@ -454,6 +493,7 @@ | |||
454 | // Register handlers for static elements | 493 | // Register handlers for static elements |
455 | // | 494 | // |
456 | 495 | ||
496 | {% if distro_defined %} | ||
457 | // change distro variable | 497 | // change distro variable |
458 | $('#change-distro-icon').click(function() { | 498 | $('#change-distro-icon').click(function() { |
459 | $('#change-distro-icon, #distro').hide(); | 499 | $('#change-distro-icon, #distro').hide(); |
@@ -468,7 +508,7 @@ | |||
468 | // reset any dangling error state | 508 | // reset any dangling error state |
469 | $('#distro-error-message').text(""); | 509 | $('#distro-error-message').text(""); |
470 | var d = document.getElementById("edit-distro-name-div"); | 510 | var d = document.getElementById("edit-distro-name-div"); |
471 | d.className = d.className.replace(" control-group error",""); | 511 | d.className = d.className.replace(" error",""); |
472 | }); | 512 | }); |
473 | }); | 513 | }); |
474 | 514 | ||
@@ -486,11 +526,12 @@ | |||
486 | $('#distro, #change-distro-icon').show(); | 526 | $('#distro, #change-distro-icon').show(); |
487 | }); | 527 | }); |
488 | }); | 528 | }); |
529 | {% endif %} | ||
489 | 530 | ||
490 | // init IMAGE_FSTYPES trash icon | ||
491 | setDeleteTooltip($('#delete-image_install-icon')); | ||
492 | 531 | ||
532 | {% if fstypes_defined %} | ||
493 | // change IMAGE_FSTYPES variable | 533 | // change IMAGE_FSTYPES variable |
534 | |||
494 | $('#change-image_fstypes-icon').click(function() { | 535 | $('#change-image_fstypes-icon').click(function() { |
495 | $('#change-image_fstypes-icon, #image_fstypes').hide(); | 536 | $('#change-image_fstypes-icon, #image_fstypes').hide(); |
496 | $("#change-image_fstypes-form").slideDown(); | 537 | $("#change-image_fstypes-form").slideDown(); |
@@ -525,7 +566,6 @@ | |||
525 | $("input#filter-image_fstypes").val(""); | 566 | $("input#filter-image_fstypes").val(""); |
526 | }); | 567 | }); |
527 | 568 | ||
528 | |||
529 | $('#cancel-change-image_fstypes').click(function(){ | 569 | $('#cancel-change-image_fstypes').click(function(){ |
530 | $("#change-image_fstypes-form").slideUp(function() { | 570 | $("#change-image_fstypes-form").slideUp(function() { |
531 | $('#image_fstypes, #change-image_fstypes-icon').show(); | 571 | $('#image_fstypes, #change-image_fstypes-icon').show(); |
@@ -570,8 +610,14 @@ | |||
570 | $('#image_fstypes, #change-image_fstypes-icon').show(); | 610 | $('#image_fstypes, #change-image_fstypes-icon').show(); |
571 | }); | 611 | }); |
572 | }); | 612 | }); |
613 | {% endif %} | ||
573 | 614 | ||
574 | 615 | ||
616 | {% if image_install_append_defined %} | ||
617 | |||
618 | // init IMAGE_INSTALL_append trash icon | ||
619 | setDeleteTooltip($('#delete-image_install-icon')); | ||
620 | |||
575 | // change IMAGE_INSTALL_append variable | 621 | // change IMAGE_INSTALL_append variable |
576 | $('#change-image_install-icon').click(function() { | 622 | $('#change-image_install-icon').click(function() { |
577 | // preset the edit value | 623 | // preset the edit value |
@@ -630,8 +676,10 @@ | |||
630 | $('#image_install').parent().fadeIn(1000); | 676 | $('#image_install').parent().fadeIn(1000); |
631 | }); | 677 | }); |
632 | }); | 678 | }); |
679 | {% endif %} | ||
633 | 680 | ||
634 | 681 | ||
682 | {% if package_classes_defined %} | ||
635 | // change PACKAGE_CLASSES variable | 683 | // change PACKAGE_CLASSES variable |
636 | $('#change-package_classes-icon').click(function() { | 684 | $('#change-package_classes-icon').click(function() { |
637 | $('#change-package_classes-icon, #package_classes').hide(); | 685 | $('#change-package_classes-icon, #package_classes').hide(); |
@@ -695,8 +743,10 @@ | |||
695 | $('#package_classes, #change-package_classes-icon').show(); | 743 | $('#package_classes, #change-package_classes-icon').show(); |
696 | }); | 744 | }); |
697 | }); | 745 | }); |
746 | {% endif %} | ||
698 | 747 | ||
699 | 748 | ||
749 | {% if sdk_machine_defined %} | ||
700 | // change SDKMACHINE variable | 750 | // change SDKMACHINE variable |
701 | $('#change-sdkmachine-icon').click(function() { | 751 | $('#change-sdkmachine-icon').click(function() { |
702 | var current_value = document.getElementById("sdkmachine").innerHTML; | 752 | var current_value = document.getElementById("sdkmachine").innerHTML; |
@@ -734,6 +784,7 @@ | |||
734 | }); | 784 | }); |
735 | 785 | ||
736 | }); | 786 | }); |
787 | {% endif %} | ||
737 | 788 | ||
738 | 789 | ||
739 | // add new variable | 790 | // add new variable |
@@ -746,6 +797,14 @@ | |||
746 | // clear the previous values | 797 | // clear the previous values |
747 | $("input#variable").val(""); | 798 | $("input#variable").val(""); |
748 | $("input#value").val(""); | 799 | $("input#value").val(""); |
800 | // Disable add button | ||
801 | $(".save").attr("disabled","disabled"); | ||
802 | |||
803 | // Reload page if admin-removed core managed value is manually added back in | ||
804 | if (0 <= " DISTRO IMAGE_FSTYPES IMAGE_INSTALL_append PACKAGE_CLASSES SDKMACHINE ".indexOf( " "+variable+" " )) { | ||
805 | // delayed reload to avoid race condition with postEditAjaxRequest | ||
806 | do_reload=true; | ||
807 | } | ||
749 | }); | 808 | }); |
750 | 809 | ||
751 | // validate new variable name and value | 810 | // validate new variable name and value |
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index ed27ca0ac9..df893483c6 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2418,11 +2418,17 @@ if toastermain.settings.MANAGED: | |||
2418 | t=request.POST['configvarDel'].strip() | 2418 | t=request.POST['configvarDel'].strip() |
2419 | pt = ProjectVariable.objects.get(pk = int(t)).delete() | 2419 | pt = ProjectVariable.objects.get(pk = int(t)).delete() |
2420 | 2420 | ||
2421 | # return all project settings | 2421 | # return all project settings, filter out blacklist and elsewhere-managed variables |
2422 | vars_managed,vars_fstypes,vars_blacklist = get_project_configvars_context() | 2422 | vars_managed,vars_fstypes,vars_blacklist = get_project_configvars_context() |
2423 | configvars_query = ProjectVariable.objects.filter(project_id = pid).all() | ||
2424 | for var in vars_managed: | ||
2425 | configvars_query = configvars_query.exclude(name = var) | ||
2426 | for var in vars_blacklist: | ||
2427 | configvars_query = configvars_query.exclude(name = var) | ||
2428 | |||
2423 | return_data = { | 2429 | return_data = { |
2424 | "error": "ok", | 2430 | "error": "ok", |
2425 | 'configvars' : map(lambda x: (x.name, x.value, x.pk), ProjectVariable.objects.filter(project_id = pid).all()), | 2431 | 'configvars' : map(lambda x: (x.name, x.value, x.pk), configvars_query), |
2426 | } | 2432 | } |
2427 | try: | 2433 | try: |
2428 | return_data['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value, | 2434 | return_data['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value, |
@@ -2899,7 +2905,7 @@ if toastermain.settings.MANAGED: | |||
2899 | def get_project_configvars_context(): | 2905 | def get_project_configvars_context(): |
2900 | # Vars managed outside of this view | 2906 | # Vars managed outside of this view |
2901 | vars_managed = { | 2907 | vars_managed = { |
2902 | 'MACHINE' | 2908 | 'MACHINE', 'BBLAYERS' |
2903 | } | 2909 | } |
2904 | 2910 | ||
2905 | vars_blacklist = { | 2911 | vars_blacklist = { |
@@ -2926,9 +2932,16 @@ if toastermain.settings.MANAGED: | |||
2926 | except Project.DoesNotExist: | 2932 | except Project.DoesNotExist: |
2927 | return HttpResponseNotFound("<h1>Project id " + pid + " is unavailable</h1>") | 2933 | return HttpResponseNotFound("<h1>Project id " + pid + " is unavailable</h1>") |
2928 | 2934 | ||
2935 | # remove blacklist and externally managed varaibles from this list | ||
2929 | vars_managed,vars_fstypes,vars_blacklist = get_project_configvars_context() | 2936 | vars_managed,vars_fstypes,vars_blacklist = get_project_configvars_context() |
2937 | configvars = ProjectVariable.objects.filter(project_id = pid).all() | ||
2938 | for var in vars_managed: | ||
2939 | configvars = configvars.exclude(name = var) | ||
2940 | for var in vars_blacklist: | ||
2941 | configvars = configvars.exclude(name = var) | ||
2942 | |||
2930 | context = { | 2943 | context = { |
2931 | 'configvars': ProjectVariable.objects.filter(project_id = pid).all(), | 2944 | 'configvars': configvars, |
2932 | 'vars_managed': vars_managed, | 2945 | 'vars_managed': vars_managed, |
2933 | 'vars_fstypes': vars_fstypes, | 2946 | 'vars_fstypes': vars_fstypes, |
2934 | 'vars_blacklist': vars_blacklist, | 2947 | 'vars_blacklist': vars_blacklist, |
@@ -2936,22 +2949,27 @@ if toastermain.settings.MANAGED: | |||
2936 | 2949 | ||
2937 | try: | 2950 | try: |
2938 | context['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value | 2951 | context['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value |
2952 | context['distro_defined'] = "1" | ||
2939 | except ProjectVariable.DoesNotExist: | 2953 | except ProjectVariable.DoesNotExist: |
2940 | pass | 2954 | pass |
2941 | try: | 2955 | try: |
2942 | context['fstypes'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_FSTYPES").value | 2956 | context['fstypes'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_FSTYPES").value |
2957 | context['fstypes_defined'] = "1" | ||
2943 | except ProjectVariable.DoesNotExist: | 2958 | except ProjectVariable.DoesNotExist: |
2944 | pass | 2959 | pass |
2945 | try: | 2960 | try: |
2946 | context['image_install_append'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_INSTALL_append").value | 2961 | context['image_install_append'] = ProjectVariable.objects.get(project = prj, name = "IMAGE_INSTALL_append").value |
2962 | context['image_install_append_defined'] = "1" | ||
2947 | except ProjectVariable.DoesNotExist: | 2963 | except ProjectVariable.DoesNotExist: |
2948 | pass | 2964 | pass |
2949 | try: | 2965 | try: |
2950 | context['package_classes'] = ProjectVariable.objects.get(project = prj, name = "PACKAGE_CLASSES").value | 2966 | context['package_classes'] = ProjectVariable.objects.get(project = prj, name = "PACKAGE_CLASSES").value |
2967 | context['package_classes_defined'] = "1" | ||
2951 | except ProjectVariable.DoesNotExist: | 2968 | except ProjectVariable.DoesNotExist: |
2952 | pass | 2969 | pass |
2953 | try: | 2970 | try: |
2954 | context['sdk_machine'] = ProjectVariable.objects.get(project = prj, name = "SDKMACHINE").value | 2971 | context['sdk_machine'] = ProjectVariable.objects.get(project = prj, name = "SDKMACHINE").value |
2972 | context['sdk_machine_defined'] = "1" | ||
2955 | except ProjectVariable.DoesNotExist: | 2973 | except ProjectVariable.DoesNotExist: |
2956 | pass | 2974 | pass |
2957 | 2975 | ||