Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C2F5DE00DFA; Thu, 18 Aug 2016 11:49:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.50 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 3DB41E00DF2 for ; Thu, 18 Aug 2016 11:49:24 -0700 (PDT) Received: by mail-pa0-f50.google.com with SMTP id pp5so8507601pac.3 for ; Thu, 18 Aug 2016 11:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9XGXksJigXQ6X8wnN9yns5Gpo0EM8FMQ/8EDyQej+Y4=; b=R16XMG+chs6SeLBSKmvl9oZIDYnGgWYdBIGAAU8Axc9HBuJCfo56Esnx40tIiA6P3S /RJ1wrJOThV2msbV6nOFxEaIl/bk3ML53vqHAVqzW9dveCUviOpofDvsPfMjIVib8Aud mjWU9WHPj2EAC49xmLB0abcKTcoPyVL+JBD+SGAeA3OzdPUERThwAopi4I8XPd+eJQjl oWINOQAwKKlRv6NYSktzs4K7Bh8Uo/nQOAbglNyOkV3IuHduRRGR/U86SSRd4hevUwx8 pAeiD8Y94Plt86WoRsfKysgxAH96brBL4UUpcAYcSnvZPsWiF0GMv+WUv6zXS++LyFPR tz+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9XGXksJigXQ6X8wnN9yns5Gpo0EM8FMQ/8EDyQej+Y4=; b=SjtkmEu50siFQQju2xvwFigpKFGanKJfSIqLLKflZ8JgJF6f4+/pH9JKeCY/452K+N 8m4q3ZUhJUOLvOAQ2BxYAEDezQ3e1g489F50QJzhmpJ1/UQ8T5DsyIy3I73yzVW3/RL7 zvx/4HbAy969B/XtA+0fMxd91wQh2sYZ/tSpyA2uGf38YNvDPivFYeGVF6afMaUQL7KR 53LrAHHXlExAr/Ncpc7pgqhaweks4ljGklT278XXG7d2uW9Y1qxzXmxlk9VqiJvWR1bX Uy4NuRIejBlM5f422ZNf5JwNJ7TZJZsUWAfdpKDYG7Ie3/6K9Dq7K5MNAaO0HRrpbOUt +y4g== X-Gm-Message-State: AEkoousVWF6a4qBN5GjMXKkU9SE/TzVDWWabkJCpN+DXfaYaAuCcIAQfa0A3MZPuDoRjw0WO X-Received: by 10.66.132.11 with SMTP id oq11mr6663386pab.4.1471546164498; Thu, 18 Aug 2016 11:49:24 -0700 (PDT) Received: from orion.ger.corp.intel.com (fmdmzpr02-ext.fm.intel.com. [192.55.55.37]) by smtp.gmail.com with ESMTPSA id w64sm496095pfb.93.2016.08.18.11.49.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Aug 2016 11:49:23 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 18 Aug 2016 19:49:07 +0100 Message-Id: <1471546154-20891-3-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471546154-20891-1-git-send-email-michael.g.wood@intel.com> References: <1471546154-20891-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v2 2/9] toaster: layerdetails js changes for switching layers X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2016 18:49:26 -0000 From: Sujith H 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 --- .../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