diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/layerdetails.js')
| -rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/layerdetails.js | 90 |
1 files changed, 18 insertions, 72 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index 3b6423f7f4..3c4d632563 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js | |||
| @@ -41,7 +41,7 @@ function layerDetailsPageInit (ctx) { | |||
| 41 | }); | 41 | }); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | function layerRemoveClick() { | 44 | function layerDepRemoveClick() { |
| 45 | var toRemove = $(this).parent().data('layer-id'); | 45 | var toRemove = $(this).parent().data('layer-id'); |
| 46 | var layerDepItem = $(this); | 46 | var layerDepItem = $(this); |
| 47 | 47 | ||
| @@ -71,7 +71,7 @@ function layerDetailsPageInit (ctx) { | |||
| 71 | 71 | ||
| 72 | /* Connect up the tash icon */ | 72 | /* Connect up the tash icon */ |
| 73 | var trashItem = newLayerDep.children("span"); | 73 | var trashItem = newLayerDep.children("span"); |
| 74 | trashItem.click(layerRemoveClick); | 74 | trashItem.click(layerDepRemoveClick); |
| 75 | 75 | ||
| 76 | layerDepsList.append(newLayerDep); | 76 | layerDepsList.append(newLayerDep); |
| 77 | /* Clear the current selection */ | 77 | /* Clear the current selection */ |
| @@ -129,13 +129,6 @@ function layerDetailsPageInit (ctx) { | |||
| 129 | window.location.replace(libtoaster.ctx.projectPageUrl); | 129 | window.location.replace(libtoaster.ctx.projectPageUrl); |
| 130 | }); | 130 | }); |
| 131 | 131 | ||
| 132 | $(".select-machine-btn").click(function(){ | ||
| 133 | var data = { machineName : $(this).data('machine-name') }; | ||
| 134 | libtoaster.editCurrentProject(data, function (){ | ||
| 135 | window.location.replace(libtoaster.ctx.projectPageUrl+"#/machineselected"); | ||
| 136 | }, null); | ||
| 137 | }); | ||
| 138 | |||
| 139 | function defaultAddBtnText(){ | 132 | function defaultAddBtnText(){ |
| 140 | var text = " Add the "+ctx.layerVersion.name+" layer to your project"; | 133 | var text = " Add the "+ctx.layerVersion.name+" layer to your project"; |
| 141 | addRmLayerBtn.text(text); | 134 | addRmLayerBtn.text(text); |
| @@ -196,9 +189,6 @@ function layerDetailsPageInit (ctx) { | |||
| 196 | */ | 189 | */ |
| 197 | function setLayerInCurrentPrj(added, depsList) { | 190 | function setLayerInCurrentPrj(added, depsList) { |
| 198 | ctx.layerVersion.inCurrentPrj = added; | 191 | ctx.layerVersion.inCurrentPrj = added; |
| 199 | var alertMsg = $("#alert-msg"); | ||
| 200 | /* Reset alert message */ | ||
| 201 | alertMsg.text(""); | ||
| 202 | 192 | ||
| 203 | if (added){ | 193 | if (added){ |
| 204 | /* enable and switch all the button states */ | 194 | /* enable and switch all the button states */ |
| @@ -209,25 +199,6 @@ function layerDetailsPageInit (ctx) { | |||
| 209 | addRmLayerBtn.text(" Delete the "+ctx.layerVersion.name+" layer from your project"); | 199 | addRmLayerBtn.text(" Delete the "+ctx.layerVersion.name+" layer from your project"); |
| 210 | addRmLayerBtn.prepend("<span class=\"icon-trash\"></span>"); | 200 | addRmLayerBtn.prepend("<span class=\"icon-trash\"></span>"); |
| 211 | 201 | ||
| 212 | if (depsList) { | ||
| 213 | alertMsg.append("You have added <strong>"+(depsList.length+1)+"</strong> layers to <a id=\"project-affected-name\"></a>: <span id=\"layer-affected-name\"></span> and its dependencies "); | ||
| 214 | |||
| 215 | /* Build the layer deps list */ | ||
| 216 | depsList.map(function(layer, i){ | ||
| 217 | var link = $("<a></a>"); | ||
| 218 | |||
| 219 | link.attr("href", layer.layerdetailurl); | ||
| 220 | link.text(layer.name); | ||
| 221 | link.tooltip({title: layer.tooltip}); | ||
| 222 | |||
| 223 | if (i != 0) | ||
| 224 | alertMsg.append(", "); | ||
| 225 | |||
| 226 | alertMsg.append(link); | ||
| 227 | }); | ||
| 228 | } else { | ||
| 229 | alertMsg.append("You have added <strong>1</strong> layer to <a id=\"project-affected-name\"></a>: <span id=\"layer-affected-name\"></span>"); | ||
| 230 | } | ||
| 231 | } else { | 202 | } else { |
| 232 | /* disable and switch all the button states */ | 203 | /* disable and switch all the button states */ |
| 233 | $(".build-target-btn").attr("disabled","disabled"); | 204 | $(".build-target-btn").attr("disabled","disabled"); |
| @@ -250,53 +221,24 @@ function layerDetailsPageInit (ctx) { | |||
| 250 | defaultAddBtnText(); | 221 | defaultAddBtnText(); |
| 251 | break; | 222 | break; |
| 252 | } | 223 | } |
| 253 | |||
| 254 | alertMsg.append("You have deleted <strong>1</strong> layer from <a id=\"project-affected-name\"></a>: <strong id=\"layer-affected-name\"></strong>"); | ||
| 255 | } | 224 | } |
| 256 | |||
| 257 | alertMsg.children("#layer-affected-name").text(ctx.layerVersion.name); | ||
| 258 | alertMsg.children("#project-affected-name").text(libtoaster.ctx.projectName); | ||
| 259 | alertMsg.children("#project-affected-name").attr("href", libtoaster.ctx.projectPageUrl); | ||
| 260 | $("#alert-area").show(); | ||
| 261 | } | 225 | } |
| 262 | 226 | ||
| 263 | $("#dismiss-alert").click(function(){ $(this).parent().hide() }); | 227 | $("#dismiss-alert").click(function(){ $(this).parent().hide() }); |
| 264 | 228 | ||
| 265 | /* Add or remove this layer from the project */ | 229 | /* Add or remove this layer from the project */ |
| 266 | addRmLayerBtn.click(function() { | 230 | addRmLayerBtn.click(function() { |
| 267 | var directive = $(this).data('directive'); | 231 | |
| 268 | 232 | var add = ($(this).data('directive') === "add") | |
| 269 | if (directive == 'add') { | 233 | |
| 270 | /* If adding get the deps for this layer */ | 234 | libtoaster.addRmLayer(ctx.layerVersion, add, function (layersList){ |
| 271 | libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, ctx.layerVersion.id, function (data) { | 235 | var alertMsg = $("#alert-msg"); |
| 272 | /* got result for dependencies */ | 236 | alertMsg.html(libtoaster.makeLayerAddRmAlertMsg(ctx.layerVersion, layersList, add)); |
| 273 | if (data.list.length == 0){ | 237 | |
| 274 | var editData = { layerAdd : ctx.layerVersion.id }; | 238 | setLayerInCurrentPrj(add, layersList); |
| 275 | libtoaster.editCurrentProject(editData, function() { | 239 | |
| 276 | setLayerInCurrentPrj(true); | 240 | $("#alert-area").show(); |
| 277 | }); | 241 | }); |
| 278 | return; | ||
| 279 | } else { | ||
| 280 | /* The add deps will include this layer so no need to add it | ||
| 281 | * separately. | ||
| 282 | */ | ||
| 283 | show_layer_deps_modal(ctx.projectId, ctx.layerVersion, data.list, null, null, true, function () { | ||
| 284 | /* Success add deps and layer */ | ||
| 285 | setLayerInCurrentPrj(true, data.list); | ||
| 286 | }); | ||
| 287 | } | ||
| 288 | }, null); | ||
| 289 | } else if (directive == 'remove') { | ||
| 290 | var editData = { layerDel : ctx.layerVersion.id }; | ||
| 291 | |||
| 292 | libtoaster.editCurrentProject(editData, function () { | ||
| 293 | /* Success removed layer */ | ||
| 294 | //window.location.reload(); | ||
| 295 | setLayerInCurrentPrj(false); | ||
| 296 | }, function () { | ||
| 297 | console.warn ("Removing layer from project failed"); | ||
| 298 | }); | ||
| 299 | } | ||
| 300 | }); | 242 | }); |
| 301 | 243 | ||
| 302 | /* Handler for all of the Change buttons */ | 244 | /* Handler for all of the Change buttons */ |
| @@ -395,8 +337,12 @@ function layerDetailsPageInit (ctx) { | |||
| 395 | $(this).parents("form").submit(); | 337 | $(this).parents("form").submit(); |
| 396 | }); | 338 | }); |
| 397 | 339 | ||
| 340 | $(".select-machine-btn").click(function(e){ | ||
| 341 | if ($(this).attr("disabled") === "disabled") | ||
| 342 | e.preventDefault(); | ||
| 343 | }); | ||
| 398 | 344 | ||
| 399 | layerDepsList.find(".icon-trash").click(layerRemoveClick); | 345 | layerDepsList.find(".icon-trash").click(layerDepRemoveClick); |
| 400 | layerDepsList.find("a").tooltip(); | 346 | layerDepsList.find("a").tooltip(); |
| 401 | $(".icon-trash").tooltip(); | 347 | $(".icon-trash").tooltip(); |
| 402 | $(".commit").tooltip(); | 348 | $(".commit").tooltip(); |
