Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id CA1E3E00BC1; Tue, 8 Dec 2015 13:18:25 -0800 (PST) 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.192.180 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-pf0-f180.google.com (mail-pf0-f180.google.com [209.85.192.180]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 463C3E00B8B for ; Tue, 8 Dec 2015 13:17:58 -0800 (PST) Received: by pfdd184 with SMTP id d184so17927657pfd.3 for ; Tue, 08 Dec 2015 13:17:58 -0800 (PST) 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=o7qMzRTLEJ4ik8UChVtSHmiVunAxvrIEX7t5a1OUDs4=; b=vZh+I1I8Fvlmg5Cn46Jtmjl6nQqTt2ajq+IbqSOtt8i4JbxuQlwhsZSnckbX8TEsEb Tk/0IvN/ND2PghuTa4Cf+YTiNUCg73u0D5a2d5n4qzLuzGGgSjd3jwMKJeEjbjXFyvMU wVIkImllpT0ontIinkKNYZlgyUZ76u70MQEGs1VRvgWPt1mT5fUXP6zcX9zKNuZe5tk1 HNOX1Ds67qRYpbKHCAilT8gJDSmiK9cofZjLXkafbywemqbxa5br0t5xb8xBCdK5DzoR AMRyP/QCXxA9OymsjFyhRk55p/FiJ7r0Cq7prrNwfLXNW6Sj5C5lnKPDv2+wUv7NhLt/ QPWg== 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=o7qMzRTLEJ4ik8UChVtSHmiVunAxvrIEX7t5a1OUDs4=; b=QO+mO9aug8eztaoykXU6YfR+dFs4Rg6012rqCZeyMa0oNE+QrE+6nq4W/N1k/n+YsO lwj7oUIK1bbFMo/9t53sOkGms2aO/4YpQcs6vfL0l87PSoFBYXooeE8pQfNAu/0mgQ/G 9aGjw+hGBNMNuRQDed3DYf4UKWCvaR+ulYdQ46sGUt45FUwibVeYIfEbASDrSSLWBSDr L3p3XYgaIVZ92GUmiOBiaTWjfEMQRlr+kqq6iCXuP3+UTV0g74xtEnOWZcD1DL/kSEK5 OJe6JPrQDL5rUxRaz3Ssxo8IyW/ECBz8kzA33Z/LtpIJB6lFCG+uysBzJEnTWiuVaQF9 p/Rg== X-Gm-Message-State: ALoCoQl/kcINFu2X04IWzd1qwU09W4ulu25Di5LGsf++sgsoW4lajztpYuI0ZnlZ170JBTx/Dni4VI2EHzUKG41icwYKSm9grw== X-Received: by 10.98.75.71 with SMTP id y68mr8008109pfa.75.1449609478738; Tue, 08 Dec 2015 13:17:58 -0800 (PST) Received: from draco.ger.corp.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id v64sm6675766pfi.50.2015.12.08.13.17.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 13:17:57 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Dec 2015 21:16:17 +0000 Message-Id: <1449609380-11073-32-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> References: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 31/34] toaster: customrecipe Add further front end features using new API 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: Tue, 08 Dec 2015 21:18:25 -0000 This adds some basic package dependency hint modals when you add and remove a package. It also makes sure that if the CustomImageRecipe has no current included packages that we go and check this with the server to see if a relevant build has taken place which will provide this information. [YOCTO #8082] Signed-off-by: Michael Wood --- .../toaster/toastergui/static/js/customrecipe.js | 148 +++++++++++++++++++-- .../toaster/toastergui/templates/customrecipe.html | 46 ++++++- .../toastergui/templates/pkg_add_rm_btn.html | 35 ++--- 3 files changed, 196 insertions(+), 33 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js index 4cd9382..2d43ec2 100644 --- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js @@ -4,32 +4,145 @@ function customRecipePageInit(ctx) { var urlParams = libtoaster.parseUrlParams(); var customiseTable = $("#selectpackagestable"); + var addPkgDepsModalBtn = $("#add-package-deps-modal-btn"); + var rmdPkgReverseDepsModalBtn = $("#rm-package-reverse-deps-modal-btn"); - (function notificationRequest(){ - if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){ - $("#image-created-notification").show(); - } - })(); + if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){ + $("#image-created-notification").show(); + } + + /* If the total packages included in this image is 0 we need to + * try updating this recipe + */ + if (ctx.recipe.includedPackagesCount === 0){ + libtoaster.createCustomRecipe(ctx.recipe.name, + ctx.recipe.baseRecipeId, + function(ret){ + /* TODO rather than reload the page just show the table and hide err */ + if (ret.packages > 0){ + window.location.reload(); + } else { + console.warn("Tried again and no packages found for this recipe"); + } + }); + } - customiseTable.on('table-done', function(e, total, tableParams){ + customiseTable.on('table-done', function(e, total){ /* Table is done so now setup the click handler for the package buttons */ $(".add-rm-package-btn").click(function(e){ e.preventDefault(); - addRemovePackage($(this), tableParams); + var pkgBtnData = $(this).data(); + + checkPackageDeps(pkgBtnData, function(pkgData){ + if (pkgBtnData.directive === 'add'){ + /* If we're adding a package we may need to show the modal to advise + * on dependencies for this package. + */ + if (pkgData.unsatisfied_dependencies.length === 0){ + addRemovePackage(pkgBtnData); + } else { + showPackageDepsModal(pkgBtnData, pkgData); + } + } else if (pkgBtnData.directive === 'remove') { + if (pkgData.reverse_dependencies.length === 0){ + addRemovePackage(pkgBtnData); + } else { + showPackageReverseDepsModal(pkgBtnData, pkgData); + } + } + }); + }); + }); + + function checkPackageDeps(pkgBtnData, doneCb){ + $.ajax({ + type: 'GET', + url: pkgBtnData.packageUrl, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function(data){ + if (data.error !== 'ok'){ + console.warn(data.error); + return; + } + doneCb(data); + } }); + } + + function showPackageDepsModal(pkgBtnData, pkgData){ + var modal = $("#package-deps-modal"); + var depsList = modal.find("#package-add-dep-list"); + var deps = pkgData.unsatisfied_dependencies; + + modal.find(".package-to-add-name").text(pkgBtnData.name); + + depsList.text(""); + + for (var i in deps){ + var li = $('
  • ').text(deps[i].depends_on__name); + li.append($('').text(" ("+ + deps[i].depends_on__size_formatted+")")); + depsList.append(li); + } + + modal.find("#package-deps-total-size").text( + pkgData.unsatisfied_dependencies_size_formatted); + + addPkgDepsModalBtn.data(pkgBtnData); + modal.modal('show'); + } + + addPkgDepsModalBtn.click(function(e){ + e.preventDefault(); + + addRemovePackage($(this).data(), null); + }); + + function showPackageReverseDepsModal(pkgBtnData, pkgData){ + var modal = $("#package-reverse-deps-modal"); + var depsList = modal.find("#package-reverse-dep-list"); + var deps = pkgData.reverse_dependencies; + + modal.find(".package-to-rm-name").text(pkgBtnData.name); + + depsList.text(""); + + for (var i in deps){ + var li = $('
  • ').text(deps[i].package__name); + li.append($('').text(" ("+ + deps[i].package__size_formatted+")")); + depsList.append(li); + } + + modal.find("#package-reverse-deps-total-size").text( + pkgData.reverse_dependencies_size_formatted); + + rmdPkgReverseDepsModalBtn.data(pkgBtnData); + modal.modal('show'); + } + + rmdPkgReverseDepsModalBtn.click(function(e){ + e.preventDefault(); + + addRemovePackage($(this).data(), null); }); - function addRemovePackage(pkgBtn, tableParams){ - var pkgBtnData = pkgBtn.data(); + + function addRemovePackage(pkgBtnData, tableParams){ var method; var msg = "You have "; - if (pkgBtnData.directive == 'add') { + var btnCell = $("#package-btn-cell-"+pkgBtnData.package); + var inlineNotify = btnCell.children(".inline-notification"); + + if (pkgBtnData.directive === 'add') { method = 'PUT'; msg += "added 1 package to "+ctx.recipe.name+":"; - } else if (pkgBtnData.directive == 'remove') { + inlineNotify.text("1 package added"); + } else if (pkgBtnData.directive === 'remove') { method = 'DELETE'; msg += "removed 1 package from "+ctx.recipe.name+":"; + inlineNotify.text("1 package removed"); } else { throw("Unknown package directive: should be add or remove"); } @@ -45,11 +158,18 @@ function customRecipePageInit(ctx) { console.warn(data.error); return; } - /* Reload and Invalidate the Add | Rm package table's current data */ - tableParams.nocache = true; - customiseTable.trigger('reload', [tableParams]); libtoaster.showChangeNotification(msg); + + /* Also do the in-cell notification */ + btnCell.children("button").fadeOut().promise().done(function(){ + inlineNotify.fadeIn().delay(500).fadeOut(function(){ + if (pkgBtnData.directive === 'add') + btnCell.children("button[data-directive=remove]").fadeIn(); + else + btnCell.children("button[data-directive=add]").fadeIn(); + }); + }); } }); } diff --git a/bitbake/lib/toaster/toastergui/templates/customrecipe.html b/bitbake/lib/toaster/toastergui/templates/customrecipe.html index 743625c..37e0689 100644 --- a/bitbake/lib/toaster/toastergui/templates/customrecipe.html +++ b/bitbake/lib/toaster/toastergui/templates/customrecipe.html @@ -26,6 +26,8 @@ recipe : { id: {{recipe.pk}}, name: "{{recipe.name}}", + includedPackagesCount: {{recipe.includes_set.count}}, + baseRecipeId: {{recipe.base_recipe.pk}}, } }; @@ -37,6 +39,44 @@ } }); + + + + + + + +
    - {% if recipe.package_set.count == 0 and last_build == None %} + {% if recipe.get_all_packages.count == 0 and last_build == None %}

    Add | Remove packages

    Toaster has no package information for {{recipe.name}}. To generate package information, build {{recipe.name}}

    - +
    {% else %} {# ToasterTable for Adding remove packages #} @@ -103,7 +143,7 @@ Approx. packages included -
    {{recipe.package_set.all.count}}
    +
    {{recipe.get_all_packages.count}}
    Approx. package size diff --git a/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html b/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html index 8723d4e..493456f 100644 --- a/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html +++ b/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html @@ -1,16 +1,19 @@ - +
    + + +
    -- 2.1.4