diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static')
9 files changed, 271 insertions, 182 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/css/default.css b/bitbake/lib/toaster/toastergui/static/css/default.css index 7ee1251529..bc3d63e6b9 100644 --- a/bitbake/lib/toaster/toastergui/static/css/default.css +++ b/bitbake/lib/toaster/toastergui/static/css/default.css | |||
@@ -158,7 +158,7 @@ select { width: auto; } | |||
158 | .project-name .label > a { color: #fff; font-weight: normal; } | 158 | .project-name .label > a { color: #fff; font-weight: normal; } |
159 | 159 | ||
160 | /* Remove bottom margin for forms inside modal dialogs */ | 160 | /* Remove bottom margin for forms inside modal dialogs */ |
161 | #dependencies_modal_form { margin-bottom: 0px; } | 161 | #dependencies-modal-form { margin-bottom: 0px; } |
162 | 162 | ||
163 | /* Configuration styles */ | 163 | /* Configuration styles */ |
164 | .icon-trash { color: #B94A48; font-size: 16px; padding-left: 5px; } | 164 | .icon-trash { color: #B94A48; font-size: 16px; padding-left: 5px; } |
diff --git a/bitbake/lib/toaster/toastergui/static/html/layer_deps_modal.html b/bitbake/lib/toaster/toastergui/static/html/layer_deps_modal.html new file mode 100644 index 0000000000..e1dba4358d --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/html/layer_deps_modal.html | |||
@@ -0,0 +1,17 @@ | |||
1 | <div id="dependencies-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="false"> | ||
2 | <form id="dependencies-modal-form"> | ||
3 | <div class="modal-header"> | ||
4 | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button> | ||
5 | <h3><span id="title"></span> dependencies</h3> | ||
6 | </div> | ||
7 | <div class="modal-body"> | ||
8 | <p id="body-text"> <strong id="layer-name"></strong> depends on some layers that are not added to your project. Select the ones you want to add:</p> | ||
9 | <ul class="unstyled" id="dependencies-list"> | ||
10 | </ul> | ||
11 | </div> | ||
12 | <div class="modal-footer"> | ||
13 | <button class="btn btn-primary" type="submit">Add layers</button> | ||
14 | <button class="btn" type="reset" data-dismiss="modal">Cancel</button> | ||
15 | </div> | ||
16 | </form> | ||
17 | </div> | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index ec1cc19e90..875cc342b8 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js | |||
@@ -117,10 +117,10 @@ function importLayerPageInit (ctx) { | |||
117 | var body = "<strong>"+layer.name+"</strong>'s dependencies ("+ | 117 | var body = "<strong>"+layer.name+"</strong>'s dependencies ("+ |
118 | depNames.join(", ")+"</span>) require some layers that are not added to your project. Select the ones you want to add:</p>"; | 118 | depNames.join(", ")+"</span>) require some layers that are not added to your project. Select the ones you want to add:</p>"; |
119 | 119 | ||
120 | show_layer_deps_modal(ctx.projectId, layer, depDepsArray, title, body, false, function(selected){ | 120 | showLayerDepsModal(layer, depDepsArray, title, body, false, function(layerObsList){ |
121 | /* Add the accepted dependencies to the allDeps array */ | 121 | /* Add the accepted layer dependencies' ids to the allDeps array */ |
122 | if (selected.length > 0){ | 122 | for (var key in layerObsList){ |
123 | allDeps = allDeps.concat (selected); | 123 | allDeps.push(layerObsList[key].id); |
124 | } | 124 | } |
125 | import_and_add (); | 125 | import_and_add (); |
126 | }); | 126 | }); |
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js new file mode 100644 index 0000000000..6a1d4b1606 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js | |||
@@ -0,0 +1,63 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | function layerBtnsInit(ctx) { | ||
4 | |||
5 | $(".layerbtn").click(function (){ | ||
6 | var layerObj = $(this).data("layer"); | ||
7 | var add = ($(this).data('directive') === "add"); | ||
8 | var thisBtn = $(this); | ||
9 | |||
10 | libtoaster.addRmLayer(layerObj, add, function (layerDepsList){ | ||
11 | var alertMsg = $("#alert-msg"); | ||
12 | alertMsg.html(libtoaster.makeLayerAddRmAlertMsg(layerObj, layerDepsList, add)); | ||
13 | |||
14 | /* In-cell notification */ | ||
15 | var notification = $('<div id="temp-inline-notify" style="display: none; font-size: 11px; line-height: 1.3;" class="tooltip-inner"></div>'); | ||
16 | thisBtn.parent().append(notification); | ||
17 | |||
18 | if (add){ | ||
19 | if (layerDepsList.length > 0) | ||
20 | notification.text(String(layerDepsList.length + 1) + " layers added"); | ||
21 | else | ||
22 | notification.text("1 layer added"); | ||
23 | |||
24 | var layerBtnsFadeOut = $(); | ||
25 | var layerExistsBtnFadeIn = $(); | ||
26 | |||
27 | layerBtnsFadeOut = layerBtnsFadeOut.add(".layer-add-" + layerObj.id); | ||
28 | layerExistsBtnFadeIn = layerExistsBtnFadeIn.add(".layer-exists-" + layerObj.id); | ||
29 | |||
30 | for (var i in layerDepsList){ | ||
31 | layerBtnsFadeOut = layerBtnsFadeOut.add(".layer-add-" + layerDepsList[i].id); | ||
32 | layerExistsBtnFadeIn = layerExistsBtnFadeIn.add(".layer-exists-" + layerDepsList[i].id); | ||
33 | } | ||
34 | |||
35 | layerBtnsFadeOut.fadeOut().promise().done(function(){ | ||
36 | notification.fadeIn().delay(500).fadeOut(function(){ | ||
37 | /* Fade in the buttons */ | ||
38 | layerExistsBtnFadeIn.fadeIn(); | ||
39 | notification.remove(); | ||
40 | }); | ||
41 | }); | ||
42 | } else { | ||
43 | notification.text("1 layer deleted"); | ||
44 | /* Deleting a layer we only hanlde the one button */ | ||
45 | thisBtn.fadeOut(function(){ | ||
46 | notification.fadeIn().delay(500).fadeOut(function(){ | ||
47 | $(".layer-add-" + layerObj.id).fadeIn(); | ||
48 | notification.remove(); | ||
49 | }); | ||
50 | }); | ||
51 | } | ||
52 | |||
53 | $("#zone1alerts, #zone1alerts *").fadeIn(); | ||
54 | }); | ||
55 | }); | ||
56 | |||
57 | /* Setup the initial state of the buttons */ | ||
58 | |||
59 | for (var i in ctx.projectLayers){ | ||
60 | $(".layer-exists-" + ctx.projectLayers[i]).show(); | ||
61 | $(".layer-add-" + ctx.projectLayers[i]).hide(); | ||
62 | } | ||
63 | } | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerDepsModal.js b/bitbake/lib/toaster/toastergui/static/js/layerDepsModal.js new file mode 100644 index 0000000000..825f9dccd5 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/layerDepsModal.js | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * layer: Object representing the parent layer { id: .. name: ... url } | ||
3 | * dependencies: array of dependency layer objects { id: .. name: ..} | ||
4 | * title: optional override for title | ||
5 | * body: optional override for body | ||
6 | * addToProject: Whether to add layers to project on accept | ||
7 | * successAdd: function to run on success | ||
8 | */ | ||
9 | function showLayerDepsModal(layer, dependencies, title, body, addToProject, successAdd) { | ||
10 | |||
11 | if ($("#dependencies-modal").length === 0) { | ||
12 | $.get(libtoaster.ctx.htmlUrl + "/layer_deps_modal.html", function(html){ | ||
13 | $("body").append(html); | ||
14 | setupModal(); | ||
15 | }); | ||
16 | } else { | ||
17 | setupModal(); | ||
18 | } | ||
19 | |||
20 | function setupModal(){ | ||
21 | |||
22 | if (title) { | ||
23 | $('#dependencies-modal #title').text(title); | ||
24 | } else { | ||
25 | $('#dependencies-modal #title').text(layer.name); | ||
26 | } | ||
27 | |||
28 | if (body) { | ||
29 | $("#dependencies-modal #body-text").html(body); | ||
30 | } else { | ||
31 | $("#dependencies-modal #layer-name").text(layer.name); | ||
32 | } | ||
33 | |||
34 | var deplistHtml = ""; | ||
35 | for (var i = 0; i < dependencies.length; i++) { | ||
36 | deplistHtml += "<li><label class=\"checkbox\"><input name=\"dependencies\" value=\""; | ||
37 | deplistHtml += dependencies[i].id; | ||
38 | deplistHtml +="\" type=\"checkbox\" checked=\"checked\"/>"; | ||
39 | deplistHtml += dependencies[i].name; | ||
40 | deplistHtml += "</label></li>"; | ||
41 | } | ||
42 | $('#dependencies-list').html(deplistHtml); | ||
43 | |||
44 | $("#dependencies-modal").data("deps", dependencies); | ||
45 | |||
46 | $('#dependencies-modal').modal('show'); | ||
47 | |||
48 | /* Discard the old submission function */ | ||
49 | $("#dependencies-modal-form").unbind('submit'); | ||
50 | |||
51 | $("#dependencies-modal-form").submit(function (e) { | ||
52 | e.preventDefault(); | ||
53 | var selectedLayerIds = []; | ||
54 | var selectedLayers = []; | ||
55 | |||
56 | $("input[name='dependencies']:checked").each(function () { | ||
57 | selectedLayerIds.push(parseInt($(this).val())); | ||
58 | }); | ||
59 | |||
60 | /* -1 is a special dummy Id which we use when the layer isn't yet in the | ||
61 | * system, normally we would add the current layer to the selection. | ||
62 | */ | ||
63 | if (layer.id != -1) | ||
64 | selectedLayerIds.push(layer.id); | ||
65 | |||
66 | /* Find the selected layer objects from our original list */ | ||
67 | for (var i = 0; i < selectedLayerIds.length; i++) { | ||
68 | for (var j = 0; j < dependencies.length; j++) { | ||
69 | if (dependencies[j].id == selectedLayerIds[i]) { | ||
70 | selectedLayers.push(dependencies[j]); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | if (addToProject) { | ||
76 | libtoaster.editCurrentProject({ 'layerAdd': selectedLayerIds.join(",") }, function () { | ||
77 | if (successAdd) { | ||
78 | successAdd(selectedLayers); | ||
79 | } | ||
80 | }, function () { | ||
81 | console.warn("Adding layers to project failed"); | ||
82 | }); | ||
83 | } else { | ||
84 | successAdd(selectedLayers); | ||
85 | } | ||
86 | |||
87 | $('#dependencies-modal').modal('hide'); | ||
88 | }); | ||
89 | } | ||
90 | } | ||
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(); |
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'); |
diff --git a/bitbake/lib/toaster/toastergui/static/js/machines.js b/bitbake/lib/toaster/toastergui/static/js/machines.js deleted file mode 100644 index fbcafc26b5..0000000000 --- a/bitbake/lib/toaster/toastergui/static/js/machines.js +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | "use strict" | ||
2 | |||
3 | function machinesPageInit (ctx) { | ||
4 | |||
5 | |||
6 | function setLayerInCurrentPrj(addLayerBtn, depsList){ | ||
7 | var alertMsg = $("#alert-msg"); | ||
8 | |||
9 | $(".select-or-add").each(function(){ | ||
10 | /* If we have added a layer it may also enable other machines so search | ||
11 | * for other machines that have that layer and enable them */ | ||
12 | var selectMachineBtn = $(this).children(".select-machine-btn"); | ||
13 | var otherAddLayerBtns = $(this).children(".add-layer"); | ||
14 | |||
15 | if (addLayerBtn.data('layer-version-id') == selectMachineBtn.data('layer-version-id')) { | ||
16 | otherAddLayerBtns.fadeOut(function(){ | ||
17 | selectMachineBtn.fadeIn(); | ||
18 | }); | ||
19 | } | ||
20 | }); | ||
21 | |||
22 | /* Reset alert message */ | ||
23 | alertMsg.text(""); | ||
24 | |||
25 | /* If we have added layer dependencies */ | ||
26 | if (depsList) { | ||
27 | 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 "); | ||
28 | |||
29 | /* Build the layer deps list */ | ||
30 | depsList.map(function(layer, i){ | ||
31 | var link = $("<a></a>"); | ||
32 | |||
33 | link.attr("href", layer.layerdetailurl); | ||
34 | link.text(layer.name); | ||
35 | link.tooltip({title: layer.tooltip}); | ||
36 | |||
37 | if (i != 0) | ||
38 | alertMsg.append(", "); | ||
39 | |||
40 | alertMsg.append(link); | ||
41 | }); | ||
42 | } else { | ||
43 | alertMsg.append("You have added <strong>1</strong> layer to <a id=\"project-affected-name\"></a>: <strong id=\"layer-affected-name\"></strong>"); | ||
44 | } | ||
45 | |||
46 | var layerName = addLayerBtn.data('layer-name'); | ||
47 | alertMsg.children("#layer-affected-name").text(layerName); | ||
48 | alertMsg.children("#project-affected-name").text(libtoaster.ctx.projectName).attr('href', libtoaster.ctx.projectPageUrl); | ||
49 | |||
50 | $("#alert-area").show(); | ||
51 | } | ||
52 | |||
53 | $("#dismiss-alert").click(function(){ $(this).parent().hide() }); | ||
54 | |||
55 | /* Add or remove this layer from the project */ | ||
56 | $(".add-layer").click(function() { | ||
57 | var btn = $(this); | ||
58 | /* If adding get the deps for this layer */ | ||
59 | var layer = { | ||
60 | id : $(this).data('layer-version-id'), | ||
61 | name : $(this).data('layer-name'), | ||
62 | }; | ||
63 | |||
64 | libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, layer.id, function (data) { | ||
65 | /* got result for dependencies */ | ||
66 | if (data.list.length == 0){ | ||
67 | var editData = { layerAdd : layer.id }; | ||
68 | libtoaster.editCurrentProject(editData, function() { | ||
69 | setLayerInCurrentPrj(btn); | ||
70 | }); | ||
71 | return; | ||
72 | } else { | ||
73 | /* The add deps will include this layer so no need to add it | ||
74 | * separately. | ||
75 | */ | ||
76 | show_layer_deps_modal(ctx.projectId, layer, data.list, null, null, true, function () { | ||
77 | /* Success add deps and layer */ | ||
78 | setLayerInCurrentPrj(btn, data.list); | ||
79 | }); | ||
80 | } | ||
81 | }, null); | ||
82 | }); | ||
83 | |||
84 | $(".select-machine-btn").click(function(){ | ||
85 | var data = { machineName : $(this).data('machine-name') }; | ||
86 | libtoaster.editCurrentProject(data, function (){ | ||
87 | window.location.replace(libtoaster.ctx.projectPageUrl+"#/machineselected"); | ||
88 | }, null); | ||
89 | }); | ||
90 | |||
91 | $("#show-all-btn").click(function(){ | ||
92 | $("#search").val("") | ||
93 | $("#searchform").submit(); | ||
94 | }); | ||
95 | } | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index 1fd4a54f57..43436c5e69 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js | |||
@@ -713,15 +713,6 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
713 | "\">select recipes</a> you want to build.", "alert-success"); | 713 | "\">select recipes</a> you want to build.", "alert-success"); |
714 | }); | 714 | }); |
715 | 715 | ||
716 | _cmdExecuteWithParam("/machineselected", function () { | ||
717 | $scope.displayAlert($scope.zone2alerts, "You have changed the machine to: <strong>" + $scope.machine.name + "</strong>", "alert-info"); | ||
718 | var machineDistro = angular.element("#machine-distro"); | ||
719 | |||
720 | angular.element("html, body").animate({ scrollTop: machineDistro.position().top }, 700).promise().done(function() { | ||
721 | $animate.addClass(machineDistro, "machines-highlight"); | ||
722 | }); | ||
723 | }); | ||
724 | |||
725 | _cmdExecuteWithParam("/layerimported", function () { | 716 | _cmdExecuteWithParam("/layerimported", function () { |
726 | var imported = $cookieStore.get("layer-imported-alert"); | 717 | var imported = $cookieStore.get("layer-imported-alert"); |
727 | var text; | 718 | var text; |