diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-04-21 11:59:37 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-08 17:42:06 +0100 |
commit | bec5d164717c6987f81d47d75942e94538649dad (patch) | |
tree | 189574b0de84b2f7ebc83fd3c0230be35d28f997 /bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |
parent | a4cfca604b2c5ab35baf69c2070afa0087842b68 (diff) | |
download | poky-bec5d164717c6987f81d47d75942e94538649dad.tar.gz |
bitbake: toaster: Refactor and expand layer add remove mechanism
We have multiple pages which have buttons to add and remove layers this
patch adds functionality to libtoaster to abstract this and implements
it in the pages affected. We handle loading and showing the dependencies
dialog here too and generating the notification messages.
Also implemented is using the selectmachine api from the projectapp to
avoid having to handle this in each page that allows selecting machines.
A small number of jshint issues, help text and the machine page name
have also been fixed.
(Bitbake rev: ae7a656ba7fc6f4356b57aa309a9b6d035e51d2e)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/libtoaster.js')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 9257f735db..1cf1693dde 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
@@ -114,7 +114,7 @@ var libtoaster = (function (){ | |||
114 | error: function (_data) { | 114 | error: function (_data) { |
115 | console.warn("Call failed"); | 115 | console.warn("Call failed"); |
116 | console.warn(_data); | 116 | console.warn(_data); |
117 | if (onfail) onfail(data); | 117 | if (onfail) onfail(_data); |
118 | } | 118 | } |
119 | }); | 119 | }); |
120 | } | 120 | } |
@@ -219,6 +219,76 @@ var libtoaster = (function (){ | |||
219 | return str; | 219 | return str; |
220 | } | 220 | } |
221 | 221 | ||
222 | function _addRmLayer(layerObj, add, doneCb){ | ||
223 | if (add === true) { | ||
224 | /* If adding get the deps for this layer */ | ||
225 | libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, | ||
226 | layerObj.id, | ||
227 | function (layers) { | ||
228 | |||
229 | /* got result for dependencies */ | ||
230 | if (layers.list.length === 0){ | ||
231 | var editData = { layerAdd : layerObj.id }; | ||
232 | libtoaster.editCurrentProject(editData, function() { | ||
233 | doneCb([]); | ||
234 | }); | ||
235 | return; | ||
236 | } else { | ||
237 | try { | ||
238 | showLayerDepsModal(layerObj, layers.list, null, null, true, doneCb); | ||
239 | } catch (e) { | ||
240 | $.getScript(libtoaster.ctx.jsUrl + "layerDepsModal.js", function(){ | ||
241 | showLayerDepsModal(layerObj, layers.list, null, null, true, doneCb); | ||
242 | }, function(){ | ||
243 | console.warn("Failed to load layerDepsModal"); | ||
244 | }); | ||
245 | } | ||
246 | } | ||
247 | }, null); | ||
248 | } else if (add === false) { | ||
249 | var editData = { layerDel : layerObj.id }; | ||
250 | |||
251 | libtoaster.editCurrentProject(editData, function () { | ||
252 | doneCb([]); | ||
253 | }, function () { | ||
254 | console.warn ("Removing layer from project failed"); | ||
255 | doneCb(null); | ||
256 | }); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | function _makeLayerAddRmAlertMsg(layer, layerDepsList, add) { | ||
261 | var alertMsg; | ||
262 | |||
263 | if (layerDepsList.length > 0 && add === true) { | ||
264 | alertMsg = $("<span>You have added <strong>"+(layerDepsList.length+1)+"</strong> layers to <a id=\"project-affected-name\"></a>: <span id=\"layer-affected-name\"></span> and its dependencies </span>"); | ||
265 | |||
266 | /* Build the layer deps list */ | ||
267 | layerDepsList.map(function(layer, i){ | ||
268 | var link = $("<a></a>"); | ||
269 | |||
270 | link.attr("href", layer.layerdetailurl); | ||
271 | link.text(layer.name); | ||
272 | link.tooltip({title: layer.tooltip}); | ||
273 | |||
274 | if (i !== 0) | ||
275 | alertMsg.append(", "); | ||
276 | |||
277 | alertMsg.append(link); | ||
278 | }); | ||
279 | } else if (layerDepsList.length === 0 && add === true) { | ||
280 | alertMsg = $("<span>You have added <strong>1</strong> layer to <a id=\"project-affected-name\"></a>: <span id=\"layer-affected-name\"></span></span>"); | ||
281 | } else if (add === false) { | ||
282 | alertMsg = $("<span>You have deleted <strong>1</strong> layer from <a id=\"project-affected-name\"></a>: <strong id=\"layer-affected-name\"></strong></span>"); | ||
283 | } | ||
284 | |||
285 | alertMsg.children("#layer-affected-name").text(layer.name); | ||
286 | alertMsg.children("#project-affected-name").text(libtoaster.ctx.projectName); | ||
287 | alertMsg.children("#project-affected-name").attr("href", libtoaster.ctx.projectPageUrl); | ||
288 | |||
289 | return alertMsg.html(); | ||
290 | } | ||
291 | |||
222 | 292 | ||
223 | return { | 293 | return { |
224 | reload_params : reload_params, | 294 | reload_params : reload_params, |
@@ -231,6 +301,8 @@ var libtoaster = (function (){ | |||
231 | debug: false, | 301 | debug: false, |
232 | parseUrlParams : _parseUrlParams, | 302 | parseUrlParams : _parseUrlParams, |
233 | dumpsUrlParams : _dumpsUrlParams, | 303 | dumpsUrlParams : _dumpsUrlParams, |
304 | addRmLayer : _addRmLayer, | ||
305 | makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg, | ||
234 | }; | 306 | }; |
235 | })(); | 307 | })(); |
236 | 308 | ||
@@ -394,6 +466,11 @@ $(document).ready(function() { | |||
394 | $('#collapse-exceptions').toggleClass('in'); | 466 | $('#collapse-exceptions').toggleClass('in'); |
395 | }); | 467 | }); |
396 | 468 | ||
469 | |||
470 | $("#hide-alert").click(function(){ | ||
471 | $(this).parent().fadeOut(); | ||
472 | }); | ||
473 | |||
397 | //show warnings section when requested from the previous page | 474 | //show warnings section when requested from the previous page |
398 | if (location.href.search('#warnings') > -1) { | 475 | if (location.href.search('#warnings') > -1) { |
399 | $('#collapse-warnings').addClass('in'); | 476 | $('#collapse-warnings').addClass('in'); |