summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorSujith H <sujith.h@gmail.com>2016-08-22 16:42:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-02 18:09:49 +0100
commitfa48ca677c75d01cebe4e5d6519ed71c588fd93d (patch)
treea40d1a9272c5ead2176d292bd337314a5c952320 /bitbake/lib/toaster
parentd9b5d11664e849a7cbb1894062f45017a1c5998c (diff)
downloadpoky-fa48ca677c75d01cebe4e5d6519ed71c588fd93d.tar.gz
bitbake: toaster: layerdetails js changes for switching layers
This patch helps to implement the switching of layers between directories and git repositories. Specifically selection of git and local directory. Also enabling form to view the selection. [YOCTO #9913] (Bitbake rev: 5c20834691f1b65cfc4a0c4ec12958f86b34bbeb) Signed-off-by: Sujith H <sujith.h@gmail.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerdetails.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
index 0d4240b354..2ff8e598a9 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
@@ -10,6 +10,7 @@ function layerDetailsPageInit (ctx) {
10 var targetTab = $("#targets-tab"); 10 var targetTab = $("#targets-tab");
11 var machineTab = $("#machines-tab"); 11 var machineTab = $("#machines-tab");
12 var detailsTab = $("#details-tab"); 12 var detailsTab = $("#details-tab");
13 var editLayerSource = $("#edit-layer-source");
13 14
14 /* setup the dependencies typeahead */ 15 /* setup the dependencies typeahead */
15 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ 16 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
@@ -423,4 +424,101 @@ function layerDetailsPageInit (ctx) {
423 $(".glyphicon-trash").tooltip(); 424 $(".glyphicon-trash").tooltip();
424 $(".commit").tooltip(); 425 $(".commit").tooltip();
425 426
427 editLayerSource.click(function() {
428 // Kindly bring the git layers imported from layerindex to normal page and not this new page :(
429 $(this).hide();
430 $("#save-changes-for-switch").attr("disabled", "disabled");
431
432 $("#git-repo-info", "#directory-info").hide();
433 $("#edit-layer-source-form").fadeIn();
434 if ($("#layer-dir-path-in-details").val() == "") {
435 //Local dir path is empty...
436 $("#repo").prop("checked", true);
437 $("#layer-git").fadeIn();
438 $("#layer-dir").hide();
439 } else {
440 $("#layer-git").hide();
441 $("#layer-dir").fadeIn();
442 }
443 });
444
445 $('input:radio[name="source-location"]').change(function() {
446 if ($('input[name=source-location]:checked').val() == "repo") {
447 $("#layer-git").fadeIn();
448 $("#layer-dir").hide();
449 if ($("#layer-git-repo-url").val().length === 0 && $("#layer-git-ref").val().length === 0) {
450 $("#save-changes-for-switch").attr("disabled", "disabled");
451 }
452 } else {
453 $("#layer-dir").fadeIn();
454 $("#layer-git").hide();
455 }
456 });
457
458 $("#layer-dir-path-in-details").keyup(function() {
459 $("#save-changes-for-switch").removeAttr("disabled");
460 });
461
462 $("#layer-git-repo-url").keyup(function() {
463 if ($("#layer-git-repo-url").val().length > 0 && $("#layer-git-ref").val().length > 0) {
464 $("#save-changes-for-switch").removeAttr("disabled");
465 }
466 });
467
468 $("#layer-git-ref").keyup(function() {
469 if ($("#layer-git-repo-url").val().length > 0 && $("#layer-git-ref").val().length > 0) {
470 $("#save-changes-for-switch").removeAttr("disabled");
471 }
472 });
473
474 $('#cancel-changes-for-switch').click(function() {
475 editLayerSource.show();
476 $("#git-repo-info", "#directory-info").fadeIn();
477 $("#edit-layer-source-form").fadeOut();
478
479 if ($("#layer-dir-path-in-details").val().length) {
480 $("#dir").prop("checked", true);
481 $("#layer-git").fadeOut();
482 $("#layer-dir").fadeIn();
483 } else {
484 $("#layer-git").fadeIn();
485 $("#layer-dir").fadeOut();
486 }
487 });
488
489 $('#save-changes-for-switch').click(function() {
490
491 var layerData = {
492 vcs_url: $('#layer-git-repo-url').val(),
493 commit: $('#layer-git-ref').val(),
494 dirpath: $('#layer-subdir').val(),
495 local_source_dir: $('#layer-dir-path-in-details').val(),
496 };
497
498 if ($('input[name=source-location]:checked').val() == "repo") {
499 layerData.local_source_dir = "";
500 } else {
501 layerData.vcs_url = "";
502 layerData.git_ref = "";
503 }
504
505 $.ajax({
506 type: "POST",
507 url: ctx.xhrUpdateLayerUrl,
508 data: layerData,
509 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
510 success: function (data) {
511 if (data.error != "ok") {
512 console.warn(data.error);
513 } else {
514 /* success layer property changed */
515 window.location.reload();
516 }
517 },
518 error: function (data) {
519 console.warn("Call failed");
520 console.warn(data);
521 }
522 });
523 });
426} 524}