From 2de01a68eb6a9ca74384957c674928944c235269 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Mon, 18 May 2015 20:08:28 +0100 Subject: bitbake: toaster: Port layerdetails to ToasterTables This ports the layerdetails page to using ToasterTables Also some whitespace and strict clean ups in the existing layerdetails js and html template. (Bitbake rev: 8ce35f81631e31539aeb82f8a85abbb3312e5097) Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- .../toaster/toastergui/static/js/layerdetails.js | 70 ++++++++++++++++------ 1 file changed, 52 insertions(+), 18 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/static/js/layerdetails.js') diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index 3c4d632563..3746ea26e3 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js @@ -1,4 +1,4 @@ -"use strict" +"use strict"; function layerDetailsPageInit (ctx) { @@ -54,7 +54,7 @@ function layerDetailsPageInit (ctx) { /* Add dependency layer button click handler */ layerDepBtn.click(function(){ - if (currentLayerDepSelection == undefined) + if (currentLayerDepSelection === undefined) return; addRemoveDep(currentLayerDepSelection.id, true, function(){ @@ -122,13 +122,6 @@ function layerDetailsPageInit (ctx) { }); }); - $(".build-target-btn").click(function(){ - /* fire a build */ - var target = $(this).data('target-name'); - libtoaster.startABuild(ctx.projectBuildUrl, libtoaster.ctx.projectId, target, null, null); - window.location.replace(libtoaster.ctx.projectPageUrl); - }); - function defaultAddBtnText(){ var text = " Add the "+ctx.layerVersion.name+" layer to your project"; addRmLayerBtn.text(text); @@ -155,9 +148,48 @@ function layerDetailsPageInit (ctx) { } } - window.location.hash = "targets"; + window.location.hash = "recipes"; } + $("#recipestable").on('table-done', function(e, total, tableParams){ + ctx.numTargets = total; + + if (total === 0 && !tableParams.search) { + $("#no-recipes-yet").show(); + } else { + $("#no-recipes-yet").hide(); + } + + $("#targets-tab").removeClass("muted"); + if (window.location.hash === "#recipes"){ + /* re run the machinesTabShow to update the text */ + targetsTabShow(); + } + + $(".build-target-btn").unbind('click'); + $(".build-target-btn").click(function(){ + /* fire a build */ + var target = $(this).data('target-name'); + libtoaster.startABuild(ctx.projectBuildUrl, libtoaster.ctx.projectId, target, null, null); + window.location.replace(libtoaster.ctx.projectPageUrl); + }); + }); + + $("#machinestable").on('table-done', function(e, total, tableParams){ + ctx.numMachines = total; + + if (total === 0 && !tableParams.search) + $("#no-machines-yet").show(); + else + $("#no-machines-yet").hide(); + + $("#machines-tab").removeClass("muted"); + if (window.location.hash === "#machines"){ + /* re run the machinesTabShow to update the text */ + machinesTabShow(); + } + }); + $("#targets-tab").on('show', targetsTabShow); function machinesTabShow(){ @@ -187,7 +219,7 @@ function layerDetailsPageInit (ctx) { /* Enables the Build target and Select Machine buttons and switches the * add/remove button */ - function setLayerInCurrentPrj(added, depsList) { + function setLayerInCurrentPrj(added) { ctx.layerVersion.inCurrentPrj = added; if (added){ @@ -224,18 +256,20 @@ function layerDetailsPageInit (ctx) { } } - $("#dismiss-alert").click(function(){ $(this).parent().hide() }); + $("#dismiss-alert").click(function(){ + $(this).parent().fadeOut(); + }); /* Add or remove this layer from the project */ addRmLayerBtn.click(function() { - var add = ($(this).data('directive') === "add") + var add = ($(this).data('directive') === "add"); libtoaster.addRmLayer(ctx.layerVersion, add, function (layersList){ var alertMsg = $("#alert-msg"); alertMsg.html(libtoaster.makeLayerAddRmAlertMsg(ctx.layerVersion, layersList, add)); - setLayerInCurrentPrj(add, layersList); + setLayerInCurrentPrj(add); $("#alert-area").show(); }); @@ -250,9 +284,9 @@ function layerDetailsPageInit (ctx) { * from. */ var entryElement = mParent.find("input"); - if (entryElement.length == 0) + if (entryElement.length === 0) entryElement = mParent.find("textarea"); - if (entryElement.length == 0) { + if (entryElement.length === 0) { console.warn("Could not find element to get data from for this change"); return; } @@ -293,7 +327,7 @@ function layerDetailsPageInit (ctx) { /* Disable the change button when we have no data in the input */ $("dl input, dl textarea").on("input",function() { - if ($(this).val().length == 0) + if ($(this).val().length === 0) $(this).parent().children(".change-btn").attr("disabled", "disabled"); else $(this).parent().children(".change-btn").removeAttr("disabled"); @@ -322,7 +356,7 @@ function layerDetailsPageInit (ctx) { }); /* Hide the right column if it contains no information */ - if ($("dl.item-info").children(':visible').length == 0) { + if ($("dl.item-info").children(':visible').length === 0) { $("dl.item-info").parent().hide(); } -- cgit v1.2.3-54-g00ecf