Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 59CEDE01003; Fri, 25 Sep 2015 11:08:09 -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,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.212.181 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id BEAFAE00FF4 for ; Fri, 25 Sep 2015 11:07:53 -0700 (PDT) Received: by wicfx3 with SMTP id fx3so32300544wic.1 for ; Fri, 25 Sep 2015 11:07:53 -0700 (PDT) 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:mime-version:content-type:content-transfer-encoding; bh=g6pP9U/VKrOXdHQcgfUes9UR3p/ToekiViwDVGWY9xo=; b=aIkZ1xGGrBvFWR62KOGlSfppEP8rW8gwce7SSp737TK2zD2LYdGlFpYOhAXfBvMaKY +wMktliBfs91wnRPSj1JfYkyEl0CBwNYAZUDheXJ22NIPY3CGIv6+33OXUmTqdPDkqTk AmfOsvysHi3dvv7V5sUS46BTghJAALiS3DdYyiY0ak8+mLbZuqxgiKQ+yjxuNBC6Va25 Hw6+0jUMbmD4QsUXy6UV0xkXxMiGlxrybK58LbT6oG8YLmz9weI8N87y0Lk2Es4JKHWz 9/X1Ql3na5jId8dZfTJEQ8jtcMC+JzfNprkvWH66SZw3YI5fFo2cvhL0YYCcoTU6OSk5 I0+Q== X-Gm-Message-State: ALoCoQluHwDdPI/UIvX0JiKzKP6NIruqCe6PS+K9MyH7CZE9k5Qx4pvLoMpMpSaucx1VXwXUstrn X-Received: by 10.194.93.35 with SMTP id cr3mr7720250wjb.46.1443204473092; Fri, 25 Sep 2015 11:07:53 -0700 (PDT) Received: from draco.isw.intel.com ([83.217.123.106]) by smtp.gmail.com with ESMTPSA id uq5sm4511789wjc.3.2015.09.25.11.07.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Sep 2015 11:07:52 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 25 Sep 2015 19:07:25 +0100 Message-Id: <1443204452-32244-15-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> References: <1443204452-32244-1-git-send-email-michael.g.wood@intel.com> MIME-Version: 1.0 Subject: [PATCH 14/21] toaster: Add Image customisation frontend feature 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: Fri, 25 Sep 2015 18:08:09 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the Image customisation front end feature to Toaster. Caveat - This feature is currently in development and should not be enabled by default. Signed-off-by: Michael Wood --- .../toaster/toastergui/static/js/customrecipe.js | 50 ++++++++ .../lib/toaster/toastergui/static/js/layerBtn.js | 13 ++ .../toaster/toastergui/static/js/newcustomimage.js | 49 +++++++ .../toastergui/templates/baseprojectpage.html | 7 +- .../toastergui/templates/customise_btn.html | 9 ++ .../toaster/toastergui/templates/customrecipe.html | 142 +++++++++++++++++++++ .../toastergui/templates/newcustomimage.html | 54 ++++++++ .../toastergui/templates/pkg_add_rm_btn.html | 16 +++ .../lib/toaster/toastergui/templates/project.html | 2 +- .../toastergui/templates/projecttopbar.html | 9 +- bitbake/lib/toaster/toastergui/urls.py | 17 ++- bitbake/lib/toaster/toastergui/views.py | 9 ++ 12 files changed, 368 insertions(+), 9 deletions(-) create mode 100644 bitbake/lib/toaster/toastergui/static/js/customrecipe.js create mode 100644 bitbake/lib/toaster/toastergui/static/js/newcustomimage.js create mode 100644 bitbake/lib/toaster/toastergui/templates/customise_btn.html create mode 100644 bitbake/lib/toaster/toastergui/templates/customrecipe.html create mode 100644 bitbake/lib/toaster/toastergui/templates/newcustomimage.html create mode 100644 bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js new file mode 100644 index 0000000..4f6b304 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js @@ -0,0 +1,50 @@ +"use strict"; + +function customRecipePageInit(ctx) { + + var urlParams = libtoaster.parseUrlParams(); + + (function notificationRequest(){ + if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){ + $("#image-created-notification").show(); + } + })(); + + $("#recipeselection").on('table-done', function(e, total, tableParams){ + /* 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); + }); + }); + + function addRemovePackage(pkgBtn, tableParams){ + var pkgBtnData = pkgBtn.data(); + var method; + var buttonToShow; + + if (pkgBtnData.directive == 'add') { + method = 'PUT'; + buttonToShow = '#package-rm-btn-' + pkgBtnData.package; + } else if (pkgBtnData.directive == 'remove') { + method = 'DELETE'; + buttonToShow = '#package-add-btn-' + pkgBtnData.package; + } else { + throw("Unknown package directive: should be add or remove"); + } + + $.ajax({ + type: method, + url: pkgBtnData.packageUrl, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function(data){ + /* Invalidate the Add | Rm package table's current cache */ + tableParams.nocache = true; + $.get(ctx.tableApiUrl, tableParams); + /* Swap the buttons around */ + pkgBtn.hide(); + $(buttonToShow).show(); + } + }); + } +} diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js index a0509f9..da0241c 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js @@ -68,6 +68,19 @@ function layerBtnsInit(ctx) { }); }); + + $(".customise-btn").unbind('click'); + $(".customise-btn").click(function(e){ + e.preventDefault(); + var imgCustomModal = $("#new-custom-image-modal"); + + if (imgCustomModal.length == 0) + throw("Modal new-custom-image not found"); + + imgCustomModal.data('recipe', $(this).data('recipe')); + imgCustomModal.modal('show'); + }); + /* Setup the initial state of the buttons */ for (var i in ctx.projectLayers){ diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js new file mode 100644 index 0000000..935b21e --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js @@ -0,0 +1,49 @@ +"use strict"; + +function newCustomImagePageInit(ctx){ + + var newCustomImgBtn = $("#create-new-custom-image-btn"); + var imgCustomModal = $("#new-custom-image-modal"); + + newCustomImgBtn.click(function(e){ + e.preventDefault(); + + var name = imgCustomModal.find('input').val(); + var baseRecipeId = imgCustomModal.data('recipe'); + + if (name.length > 0) { + createCustomRecipe(name, baseRecipeId); + imgCustomModal.modal('hide'); + } else { + console.warn("TODO No name supplied"); + } + }); + + function createCustomRecipe(name, baseRecipeId){ + var data = { + 'name' : name, + 'project' : libtoaster.ctx.projectId, + 'base' : baseRecipeId, + }; + + $.ajax({ + type: "POST", + url: ctx.xhrCustomRecipeUrl, + data: data, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function (ret) { + if (ret.error !== "ok") { + console.warn(ret.error); + } else { + window.location.replace(ret.url + '?notify=new'); + } + }, + error: function (ret) { + console.warn("Call failed"); + console.warn(ret); + } + }); + } + + +} diff --git a/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html b/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html index 668e0bf..88bf859 100644 --- a/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html +++ b/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html @@ -23,8 +23,11 @@