summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-09-26 13:59:35 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-30 16:52:22 +0100
commit5b23bf083b7adcd7884d58aaf26f23102e6e3f5a (patch)
treee0789662977ed5dbf591afd238befedf41e7b2df /bitbake
parentfbf7e14894f08a803cc3096da6b0143faaa3d43e (diff)
downloadpoky-5b23bf083b7adcd7884d58aaf26f23102e6e3f5a.tar.gz
bitbake: toaster: importlayer Convert success import to new notification system
Use the simpler libtoaster method of showing a notification about successful import of a layer. Also a number of whitespace clean ups. (Bitbake rev: 89d3acbc32eadd2acf90030d8b9703ce193dff0c) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/importlayer.js59
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectpage.js66
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 191b30ffee..570ca3369b 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) {
17 var currentLayerDepSelection; 17 var currentLayerDepSelection;
18 var validLayerName = /^(\w|-)+$/; 18 var validLayerName = /^(\w|-)+$/;
19 19
20 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){ 20 libtoaster.makeTypeahead(layerDepInput,
21 libtoaster.ctx.layersTypeAheadUrl,
22 { include_added: "true" }, function(item){
21 currentLayerDepSelection = item; 23 currentLayerDepSelection = item;
22 }); 24 });
23 25
@@ -95,7 +97,8 @@ function importLayerPageInit (ctx) {
95 97
96 $("#layer-deps-list").append(newLayerDep); 98 $("#layer-deps-list").append(newLayerDep);
97 99
98 libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerdetailurl, function (data){ 100 libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerdetailurl,
101 function (data){
99 /* These are the dependencies of the layer added as a dependency */ 102 /* These are the dependencies of the layer added as a dependency */
100 if (data.list.length > 0) { 103 if (data.list.length > 0) {
101 currentLayerDepSelection.url = currentLayerDepSelection.layerdetailurl; 104 currentLayerDepSelection.url = currentLayerDepSelection.layerdetailurl;
@@ -150,7 +153,9 @@ function importLayerPageInit (ctx) {
150 var body = "<strong>"+layer.name+"</strong>'s dependencies ("+ 153 var body = "<strong>"+layer.name+"</strong>'s dependencies ("+
151 depNames.join(", ")+"</span>) require some layers that are not added to your project. Select the ones you want to add:</p>"; 154 depNames.join(", ")+"</span>) require some layers that are not added to your project. Select the ones you want to add:</p>";
152 155
153 showLayerDepsModal(layer, depDepsArray, title, body, false, function(layerObsList){ 156 showLayerDepsModal(layer,
157 depDepsArray,
158 title, body, false, function(layerObsList){
154 /* Add the accepted layer dependencies' ids to the allDeps array */ 159 /* Add the accepted layer dependencies' ids to the allDeps array */
155 for (var key in layerObsList){ 160 for (var key in layerObsList){
156 allDeps.push(layerObsList[key].id); 161 allDeps.push(layerObsList[key].id);
@@ -191,9 +196,8 @@ function importLayerPageInit (ctx) {
191 if (data.error != "ok") { 196 if (data.error != "ok") {
192 console.log(data.error); 197 console.log(data.error);
193 } else { 198 } else {
194 /* Success layer import now go to the project page */ 199 createImportedNotification(data);
195 $.cookie('layer-imported-alert', JSON.stringify(data), { path: '/'}); 200 window.location.replace(libtoaster.ctx.projectPageUrl);
196 window.location.replace(libtoaster.ctx.projectPageUrl+'?notify=layer-imported');
197 } 201 }
198 }, 202 },
199 error: function (data) { 203 error: function (data) {
@@ -204,6 +208,30 @@ function importLayerPageInit (ctx) {
204 } 208 }
205 }); 209 });
206 210
211 /* Layer imported notification */
212 function createImportedNotification(imported){
213 var message = "Layer imported";
214
215 if (imported.deps_added.length === 0) {
216 message = "You have imported <strong><a class=\"alert-link\" href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a></strong> and added it to your project.";
217 } else {
218
219 var links = "<a href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a>, ";
220
221 imported.deps_added.map (function(item, index){
222 links +='<a href="'+item.layerdetailurl+'">'+item.name+'</a>';
223 /*If we're at the last element we don't want the trailing comma */
224 if (imported.deps_added[index+1] !== undefined)
225 links += ', ';
226 });
227
228 /* Length + 1 here to do deps + the imported layer */
229 message = 'You have imported <strong><a href="'+imported.imported_layer.layerdetailurl+'">'+imported.imported_layer.name+'</a></strong> and added <strong>'+(imported.deps_added.length+1)+'</strong> layers to your project: <strong>'+links+'</strong>';
230 }
231
232 libtoaster.setNotification("layer-imported", message);
233 }
234
207 function enable_import_btn(enabled) { 235 function enable_import_btn(enabled) {
208 var importAndAddHint = $("#import-and-add-hint"); 236 var importAndAddHint = $("#import-and-add-hint");
209 237
@@ -230,10 +258,13 @@ function importLayerPageInit (ctx) {
230 } 258 }
231 259
232 if (valid) { 260 if (valid) {
233 if ($("#local-dir-radio").prop("checked") && localDirPath.val().length > 0) { 261 if ($("#local-dir-radio").prop("checked") &&
262 localDirPath.val().length > 0) {
234 enable_import_btn(true); 263 enable_import_btn(true);
235 } 264 }
236 if ($("#git-repo-radio").prop("checked") && vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) { 265
266 if ($("#git-repo-radio").prop("checked") &&
267 vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
237 enable_import_btn(true); 268 enable_import_btn(true);
238 } 269 }
239 } 270 }
@@ -266,13 +297,13 @@ function importLayerPageInit (ctx) {
266 } 297 }
267 298
268 layerNameInput.on('blur', function() { 299 layerNameInput.on('blur', function() {
269 if (!$(this).val()){ 300 if (!$(this).val()){
270 return; 301 return;
271 } 302 }
272 var name = $(this).val(); 303 var name = $(this).val();
273 304
274 /* Check if the layer name exists */ 305 /* Check if the layer name exists */
275 $.getJSON(libtoaster.ctx.layersTypeAheadUrl, 306 $.getJSON(libtoaster.ctx.layersTypeAheadUrl,
276 { include_added: "true" , search: name, format: "json" }, 307 { include_added: "true" , search: name, format: "json" },
277 function(layer) { 308 function(layer) {
278 if (layer.results.length > 0) { 309 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 7f19c0d7aa..4536703649 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) {
50 $("#delete-project-modal .project-name").text(prjInfo.name); 50 $("#delete-project-modal .project-name").text(prjInfo.name);
51 }); 51 });
52 52
53 (function notificationRequest(){ 53 if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new-project'){
54 54 $("#project-created-notification").show();
55 if (urlParams.hasOwnProperty('notify')){
56 switch (urlParams.notify){
57 case 'new-project':
58 $("#project-created-notification").show();
59 break;
60 case 'layer-imported':
61 layerImportedNotification();
62 break;
63 case 'layer-deleted':
64 layerDeletedNotification();
65 default:
66 break;
67 }
68 }
69 })();
70
71 /* Layer deleted notification */
72 function layerDeletedNotification(){
73 var layer = $.cookie("layer-deleted");
74
75 if (!layer)
76 return;
77
78 var message = "You have deleted <strong>1</strong> layer from your ";
79 message += "project: <strong>" + layer + "</strong>";
80
81 libtoaster.showChangeNotification(message);
82
83 $.removeCookie("layer-deleted", { path: "/"});
84 }
85
86
87 /* Layer imported notification */
88 function layerImportedNotification(){
89 var imported = $.cookie("layer-imported-alert");
90 var message = "Layer imported";
91
92 if (!imported)
93 return;
94 else
95 imported = JSON.parse(imported);
96
97 if (imported.deps_added.length === 0) {
98 message = "You have imported <strong><a class=\"alert-link\" href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a></strong> and added it to your project.";
99 } else {
100
101 var links = "<a href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a>, ";
102
103 imported.deps_added.map (function(item, index){
104 links +='<a href="'+item.layerdetailurl+'">'+item.name+'</a>';
105 /*If we're at the last element we don't want the trailing comma */
106 if (imported.deps_added[index+1] !== undefined)
107 links += ', ';
108 });
109
110 /* Length + 1 here to do deps + the imported layer */
111 message = 'You have imported <strong><a href="'+imported.imported_layer.layerdetailurl+'">'+imported.imported_layer.name+'</a></strong> and added <strong>'+(imported.deps_added.length+1)+'</strong> layers to your project: <strong>'+links+'</strong>';
112 }
113
114 libtoaster.showChangeNotification(message);
115
116 $.removeCookie("layer-imported-alert", { path: "/"});
117 } 55 }
118 56
119 /* Add/Rm layer functionality */ 57 /* Add/Rm layer functionality */