All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elliot Smith <elliot.smith@intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 2/9] toaster: layerdetails js changes for switching layers
Date: Mon, 22 Aug 2016 16:42:29 +0100	[thread overview]
Message-ID: <1471880556-9232-2-git-send-email-elliot.smith@intel.com> (raw)
In-Reply-To: <1471880556-9232-1-git-send-email-elliot.smith@intel.com>

From: Sujith H <sujith.h@gmail.com>

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]

Signed-off-by: Sujith H <sujith.h@gmail.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
 .../toaster/toastergui/static/js/layerdetails.js   | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)

diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
index 0d4240b..2ff8e59 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) {
   var targetTab = $("#targets-tab");
   var machineTab = $("#machines-tab");
   var detailsTab = $("#details-tab");
+  var editLayerSource = $("#edit-layer-source");
 
   /* setup the dependencies typeahead */
   libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
@@ -423,4 +424,101 @@ function layerDetailsPageInit (ctx) {
   $(".glyphicon-trash").tooltip();
   $(".commit").tooltip();
 
+  editLayerSource.click(function() {
+    // Kindly bring the git layers imported from layerindex to normal page and not this new page :(
+    $(this).hide();
+    $("#save-changes-for-switch").attr("disabled", "disabled");
+
+    $("#git-repo-info", "#directory-info").hide();
+    $("#edit-layer-source-form").fadeIn();
+    if ($("#layer-dir-path-in-details").val() == "") {
+      //Local dir path is empty...
+      $("#repo").prop("checked", true);
+      $("#layer-git").fadeIn();
+      $("#layer-dir").hide();
+    } else {
+      $("#layer-git").hide();
+      $("#layer-dir").fadeIn();
+    }
+  });
+
+  $('input:radio[name="source-location"]').change(function() {
+    if ($('input[name=source-location]:checked').val() == "repo") {
+      $("#layer-git").fadeIn();
+      $("#layer-dir").hide();
+	if ($("#layer-git-repo-url").val().length === 0 && $("#layer-git-ref").val().length === 0) {
+	    $("#save-changes-for-switch").attr("disabled", "disabled");
+	}
+    } else {
+      $("#layer-dir").fadeIn();
+      $("#layer-git").hide();
+    }
+  });
+
+  $("#layer-dir-path-in-details").keyup(function() {
+    $("#save-changes-for-switch").removeAttr("disabled");
+  });
+
+  $("#layer-git-repo-url").keyup(function() {
+    if ($("#layer-git-repo-url").val().length > 0 && $("#layer-git-ref").val().length > 0) {
+      $("#save-changes-for-switch").removeAttr("disabled");
+    }
+  });
+
+  $("#layer-git-ref").keyup(function() {
+    if ($("#layer-git-repo-url").val().length > 0 && $("#layer-git-ref").val().length > 0) {
+      $("#save-changes-for-switch").removeAttr("disabled");
+    }
+  });
+
+  $('#cancel-changes-for-switch').click(function() {
+    editLayerSource.show();
+    $("#git-repo-info", "#directory-info").fadeIn();
+    $("#edit-layer-source-form").fadeOut();
+
+    if ($("#layer-dir-path-in-details").val().length) {
+      $("#dir").prop("checked", true);
+      $("#layer-git").fadeOut();
+      $("#layer-dir").fadeIn();
+    } else {
+      $("#layer-git").fadeIn();
+      $("#layer-dir").fadeOut();
+    }
+  });
+
+  $('#save-changes-for-switch').click(function() {
+
+    var layerData = {
+      vcs_url: $('#layer-git-repo-url').val(),
+      commit: $('#layer-git-ref').val(),
+      dirpath: $('#layer-subdir').val(),
+      local_source_dir: $('#layer-dir-path-in-details').val(),
+    };
+
+    if ($('input[name=source-location]:checked').val() == "repo") {
+      layerData.local_source_dir = "";
+    } else {
+      layerData.vcs_url = "";
+      layerData.git_ref = "";
+    }
+
+    $.ajax({
+        type: "POST",
+        url: ctx.xhrUpdateLayerUrl,
+        data: layerData,
+        headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
+        success: function (data) {
+          if (data.error != "ok") {
+            console.warn(data.error);
+          } else {
+            /* success layer property changed */
+            window.location.reload();
+          }
+        },
+        error: function (data) {
+          console.warn("Call failed");
+          console.warn(data);
+        }
+    });
+  });
 }
-- 
2.7.4



  reply	other threads:[~2016-08-22 15:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 15:42 [PATCH 1/9] toaster: add switch of git and not-git layers imported Elliot Smith
2016-08-22 15:42 ` Elliot Smith [this message]
2016-08-22 15:42 ` [PATCH 3/9] toaster: update api to include local_source_dir Elliot Smith
2016-08-22 15:42 ` [PATCH 4/9] toaster: layerdetails clean ups after integrating local layer changes Elliot Smith
2016-08-22 15:42 ` [PATCH 5/9] toaster: Fix oe-core fixture Elliot Smith
2016-08-22 15:42 ` [PATCH 6/9] toaster: Move Custom image recipe rest api to api file Elliot Smith
2016-08-22 15:42 ` [PATCH 7/9] toaster: tests Add selenium test layer source switching layer details page Elliot Smith
2016-08-22 15:42 ` [PATCH 8/9] toaster: Allow git information to be null for BRLayer Elliot Smith
2016-09-16 11:00   ` sujith h
2016-08-22 15:42 ` [PATCH 9/9] toaster: localhostbecontroller Remove git assumption Elliot Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471880556-9232-2-git-send-email-elliot.smith@intel.com \
    --to=elliot.smith@intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.