Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 6904DE00D03; Thu, 18 Aug 2016 02:42:31 -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: * -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 * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.173 listed in list.dnswl.org] Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 8362AE00CE7 for ; Thu, 18 Aug 2016 02:42:28 -0700 (PDT) Received: by mail-pf0-f173.google.com with SMTP id x72so5246536pfd.2 for ; Thu, 18 Aug 2016 02:42:28 -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=TPxTLzomhRFhhRu07J9icTmx/Jc1LXXGwTwoSbvwEkW0viP+SEoupqY0jjuWQ7tDw9 Xva0D1mQzCtxjkfp5I+WCkT5x43/KY+EKuGltyn9KCCQvkk8PdSt5Bj0PVN9OJjnDKvW +/JwIxP6moqMceziMgw5wjRJ7zF2WKgXLUtdqmaonjWfCeBrkxW4qZ+9Yb5DOvvA6NqQ slnjBbw60P05KlhEurWgGnZpDkc85q2vnQ1FSIR4K+6qBCCSSZTYfpoBmp1RKtRVmlOw hEMKLKKgkILaby0tAFy+fyeYP3AiYGi2kuLbr0XveuRQIclRk3D6K6NAH7OE9RXyoRrz VXZQ== 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=TKryPfUKeS+JZT7zNmUmi5H3vEVgY6/IKzISC0j+bHFSKRqq2gcGaohiFt6oT/qAry okPsZsGnNpiWUPacEo59/2/6AEgXNyV2RNfA3K2kUf9+fdHAmJhndCUOkzePP1eHporV DMu5qxty/b7BIbxVunCqhTVNm0kyuNKaB0H0E74CbrkwimJq/EZDS6RaZWOwFXw6Y7CH Rlh8Gr+8m6s9qDD3kezZFhRBXVt4wsotOdDK6s4CCmAlE50zAmAkKqc8JX+CHkSHaaIa cfFWlOt+siaO1H2kYYoU8bMjT6Hlen3aXwRVgEFtCmxtS7yXHJC3eXj8qcGcXy75EqNW jIhw== X-Gm-Message-State: AEkoouty4ubqqt62Qnsa2MO781vjPnEvEAUv0ejYCspKXXHMEutCibfR0NanM0PpzRf/bhyB X-Received: by 10.98.85.134 with SMTP id j128mr2472038pfb.6.1471513347487; Thu, 18 Aug 2016 02:42:27 -0700 (PDT) Received: from orion.ger.corp.intel.com ([192.55.54.44]) by smtp.gmail.com with ESMTPSA id e10sm2517365pay.39.2016.08.18.02.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Aug 2016 02:42:27 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 18 Aug 2016 10:42:11 +0100 Message-Id: <1471513336-13789-3-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471513336-13789-1-git-send-email-michael.g.wood@intel.com> References: <1471513336-13789-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 2/7] 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 09:42:31 -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