Return-Path:
Received: by yocto-www.yoctoproject.org (Postfix, from userid 118)
id 65F18E00D63; Thu, 22 Sep 2016 09:56:38 -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=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,
DKIM_VALID, RCVD_IN_DNSWL_NONE,
RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1
X-Spam-HAM-Report: * 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source
* [209.85.192.177 listed in dnsbl.sorbs.net]
* -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,
no * trust
* [209.85.192.177 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-f177.google.com (mail-pf0-f177.google.com
[209.85.192.177])
by yocto-www.yoctoproject.org (Postfix) with ESMTP id D4FAAE00444
for ; Thu, 22 Sep 2016 09:56:21 -0700 (PDT)
Received: by mail-pf0-f177.google.com with SMTP id z123so32452500pfz.2
for ; Thu, 22 Sep 2016 09:56:21 -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=cVCxDCNCbly65mGf5cCQ1PqzW2/HF0P9yIp2RCW9VGk=;
b=HoiQVBDiMOYCcDPkqbXFB5isj6MdJub8H3GDzksm3/wNog48yUvvNvFx5bV1x2RBm5
d1MdPMwPl3nxz4iqxMnC1qlhKT8Z9x0I7bJpHsgxURxVuUVHo4n3om9WUb6Dyx996gb8
siqVlTrlRnJo+vKznFocbmNH/VNE7z6fNwdrLv5/LP9vISciNbPMcjCQQzv45rKjGOqc
eDJxB3PCZuLet/w/zu9x3QzTNkiS7s32y152zoduq87bgxlQIst87kPCASKbE7KG0kWb
TR69wJdpdZ8546Db5VkHGCiBKELrSBzkoUbDnOlk02dHpm0e6QJIYVq30dtGNwNvbZKn
Q10A==
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=cVCxDCNCbly65mGf5cCQ1PqzW2/HF0P9yIp2RCW9VGk=;
b=PkeFCk4Sf1OrjrBxibvhiOJBWf9E1PiSsT1AMfDMw42A+JqMqH/DULg15kj2Ro5amg
yTK16hZUl78BClfeamf7FznNfizaNYven9gsWOyXAmYAgSrnwE8vuFTZLENlg9OusiV3
qd38D5NobfdDGeQUGVuP446hoBWFPODAzleuTpQ+5DmRTdLRN7mdsBeKNj6aJpX1tYCt
6SUQ7ooS5p40q6bNy0aOEfE6SlICZN+mOUe94vDq48kOwHpWs8vJ49TTEqqvv51663Is
WL1olN+mwCnEC1HtL5C7emB+4LCYCzPjcAcvDby465ydRLnVCW9Or3IhPd0dq3lpEpM4
o+Vg==
X-Gm-Message-State: AE9vXwP0Qg9Knk2QUvJbSQ5YALH7QQdojue3nu413gUxJiBJ6cXi0UDrg/UI6MoRzg4FVpW8
X-Received: by 10.98.89.199 with SMTP id k68mr5032700pfj.72.1474563381078;
Thu, 22 Sep 2016 09:56:21 -0700 (PDT)
Received: from orion.ger.corp.intel.com ([192.55.55.41])
by smtp.gmail.com with ESMTPSA id uj8sm5458889pab.5.2016.09.22.09.56.18
(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
Thu, 22 Sep 2016 09:56:19 -0700 (PDT)
From: Michael Wood
To: toaster@yoctoproject.org
Date: Thu, 22 Sep 2016 17:55:52 +0100
Message-Id: <1474563354-11878-9-git-send-email-michael.g.wood@intel.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1474563354-11878-1-git-send-email-michael.g.wood@intel.com>
References: <1474563354-11878-1-git-send-email-michael.g.wood@intel.com>
Subject: [PATCH 08/10] toaster: importlayer Convert success import to new notification system
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, 22 Sep 2016 16:56:38 -0000
Use the simpler libtoaster method of showing a notification about
successful import of a layer.
Also a number of whitespace clean ups.
Signed-off-by: Michael Wood
---
.../toaster/toastergui/static/js/importlayer.js | 59 ++++++++++++++-----
.../toaster/toastergui/static/js/projectpage.js | 66 +---------------------
2 files changed, 47 insertions(+), 78 deletions(-)
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
index 191b30f..570ca33 100644
--- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js
+++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
@@ -17,7 +17,9 @@ function importLayerPageInit (ctx) {
var currentLayerDepSelection;
var validLayerName = /^(\w|-)+$/;
- libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
+ libtoaster.makeTypeahead(layerDepInput,
+ libtoaster.ctx.layersTypeAheadUrl,
+ { include_added: "true" }, function(item){
currentLayerDepSelection = item;
});
@@ -95,7 +97,8 @@ function importLayerPageInit (ctx) {
$("#layer-deps-list").append(newLayerDep);
- libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerdetailurl, function (data){
+ libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerdetailurl,
+ function (data){
/* These are the dependencies of the layer added as a dependency */
if (data.list.length > 0) {
currentLayerDepSelection.url = currentLayerDepSelection.layerdetailurl;
@@ -150,7 +153,9 @@ function importLayerPageInit (ctx) {
var body = ""+layer.name+"'s dependencies ("+
depNames.join(", ")+") require some layers that are not added to your project. Select the ones you want to add:
";
- showLayerDepsModal(layer, depDepsArray, title, body, false, function(layerObsList){
+ showLayerDepsModal(layer,
+ depDepsArray,
+ title, body, false, function(layerObsList){
/* Add the accepted layer dependencies' ids to the allDeps array */
for (var key in layerObsList){
allDeps.push(layerObsList[key].id);
@@ -191,9 +196,8 @@ function importLayerPageInit (ctx) {
if (data.error != "ok") {
console.log(data.error);
} else {
- /* Success layer import now go to the project page */
- $.cookie('layer-imported-alert', JSON.stringify(data), { path: '/'});
- window.location.replace(libtoaster.ctx.projectPageUrl+'?notify=layer-imported');
+ createImportedNotification(data);
+ window.location.replace(libtoaster.ctx.projectPageUrl);
}
},
error: function (data) {
@@ -204,6 +208,30 @@ function importLayerPageInit (ctx) {
}
});
+ /* Layer imported notification */
+ function createImportedNotification(imported){
+ var message = "Layer imported";
+
+ if (imported.deps_added.length === 0) {
+ message = "You have imported "+imported.imported_layer.name+" and added it to your project.";
+ } else {
+
+ var links = ""+imported.imported_layer.name+", ";
+
+ imported.deps_added.map (function(item, index){
+ links +=''+item.name+'';
+ /*If we're at the last element we don't want the trailing comma */
+ if (imported.deps_added[index+1] !== undefined)
+ links += ', ';
+ });
+
+ /* Length + 1 here to do deps + the imported layer */
+ message = 'You have imported '+imported.imported_layer.name+' and added '+(imported.deps_added.length+1)+' layers to your project: '+links+'';
+ }
+
+ libtoaster.setNotification("layer-imported", message);
+ }
+
function enable_import_btn(enabled) {
var importAndAddHint = $("#import-and-add-hint");
@@ -230,10 +258,13 @@ function importLayerPageInit (ctx) {
}
if (valid) {
- if ($("#local-dir-radio").prop("checked") && localDirPath.val().length > 0) {
+ if ($("#local-dir-radio").prop("checked") &&
+ localDirPath.val().length > 0) {
enable_import_btn(true);
}
- if ($("#git-repo-radio").prop("checked") && vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
+
+ if ($("#git-repo-radio").prop("checked") &&
+ vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
enable_import_btn(true);
}
}
@@ -266,13 +297,13 @@ function importLayerPageInit (ctx) {
}
layerNameInput.on('blur', function() {
- if (!$(this).val()){
- return;
- }
- var name = $(this).val();
+ if (!$(this).val()){
+ return;
+ }
+ var name = $(this).val();
- /* Check if the layer name exists */
- $.getJSON(libtoaster.ctx.layersTypeAheadUrl,
+ /* Check if the layer name exists */
+ $.getJSON(libtoaster.ctx.layersTypeAheadUrl,
{ include_added: "true" , search: name, format: "json" },
function(layer) {
if (layer.results.length > 0) {
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
index 7f19c0d..4536703 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
@@ -50,70 +50,8 @@ function projectPageInit(ctx) {
$("#delete-project-modal .project-name").text(prjInfo.name);
});
- (function notificationRequest(){
-
- if (urlParams.hasOwnProperty('notify')){
- switch (urlParams.notify){
- case 'new-project':
- $("#project-created-notification").show();
- break;
- case 'layer-imported':
- layerImportedNotification();
- break;
- case 'layer-deleted':
- layerDeletedNotification();
- default:
- break;
- }
- }
- })();
-
- /* Layer deleted notification */
- function layerDeletedNotification(){
- var layer = $.cookie("layer-deleted");
-
- if (!layer)
- return;
-
- var message = "You have deleted 1 layer from your ";
- message += "project: " + layer + "";
-
- libtoaster.showChangeNotification(message);
-
- $.removeCookie("layer-deleted", { path: "/"});
- }
-
-
- /* Layer imported notification */
- function layerImportedNotification(){
- var imported = $.cookie("layer-imported-alert");
- var message = "Layer imported";
-
- if (!imported)
- return;
- else
- imported = JSON.parse(imported);
-
- if (imported.deps_added.length === 0) {
- message = "You have imported "+imported.imported_layer.name+" and added it to your project.";
- } else {
-
- var links = ""+imported.imported_layer.name+", ";
-
- imported.deps_added.map (function(item, index){
- links +=''+item.name+'';
- /*If we're at the last element we don't want the trailing comma */
- if (imported.deps_added[index+1] !== undefined)
- links += ', ';
- });
-
- /* Length + 1 here to do deps + the imported layer */
- message = 'You have imported '+imported.imported_layer.name+' and added '+(imported.deps_added.length+1)+' layers to your project: '+links+'';
- }
-
- libtoaster.showChangeNotification(message);
-
- $.removeCookie("layer-imported-alert", { path: "/"});
+ if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new-project'){
+ $("#project-created-notification").show();
}
/* Add/Rm layer functionality */
--
2.7.4