diff options
author | Michael Wood <michael.g.wood@intel.com> | 2016-01-29 14:38:43 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:21 +0000 |
commit | 998f9af193aec78abaddfbedd7dac161ed9d538d (patch) | |
tree | b955076ede19dd5395d11963e7d490d9f2a43b11 /bitbake | |
parent | 9976e4f169ad39bcbe5ca34c866318d654adaa59 (diff) | |
download | poky-998f9af193aec78abaddfbedd7dac161ed9d538d.tar.gz |
bitbake: toaster: customrecipe Add dependency tracking to package selection
Update the states of the packages in the package selection UI to reflect
whether it's likely that 1st level dependencies for the package will be
also added.
(Bitbake rev: 119569d83c3fb1d1bd162624819b3f9c63a791c4)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
4 files changed, 80 insertions, 31 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js index 33fcb88e94..a1fe4862e5 100644 --- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js | |||
@@ -15,33 +15,33 @@ function customRecipePageInit(ctx) { | |||
15 | /* Table is done so now setup the click handler for the package buttons */ | 15 | /* Table is done so now setup the click handler for the package buttons */ |
16 | $(".add-rm-package-btn").click(function(e){ | 16 | $(".add-rm-package-btn").click(function(e){ |
17 | e.preventDefault(); | 17 | e.preventDefault(); |
18 | var pkgBtnData = $(this).data(); | 18 | var targetPkg = $(this).data(); |
19 | 19 | ||
20 | checkPackageDeps(pkgBtnData, function(pkgData){ | 20 | checkPackageDeps(targetPkg, function(pkgData){ |
21 | if (pkgBtnData.directive === 'add'){ | 21 | if (targetPkg.directive === 'add'){ |
22 | /* If we're adding a package we may need to show the modal to advise | 22 | /* If we're adding a package we may need to show the modal to advise |
23 | * on dependencies for this package. | 23 | * on dependencies for this package. |
24 | */ | 24 | */ |
25 | if (pkgData.unsatisfied_dependencies.length === 0){ | 25 | if (pkgData.unsatisfied_dependencies.length === 0){ |
26 | addRemovePackage(pkgBtnData); | 26 | addRemovePackage(targetPkg); |
27 | } else { | 27 | } else { |
28 | showPackageDepsModal(pkgBtnData, pkgData); | 28 | showPackageDepsModal(targetPkg, pkgData); |
29 | } | 29 | } |
30 | } else if (pkgBtnData.directive === 'remove') { | 30 | } else if (targetPkg.directive === 'remove') { |
31 | if (pkgData.reverse_dependencies.length === 0){ | 31 | if (pkgData.reverse_dependencies.length === 0){ |
32 | addRemovePackage(pkgBtnData); | 32 | addRemovePackage(targetPkg); |
33 | } else { | 33 | } else { |
34 | showPackageReverseDepsModal(pkgBtnData, pkgData); | 34 | showPackageReverseDepsModal(targetPkg, pkgData); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | }); | 37 | }); |
38 | }); | 38 | }); |
39 | }); | 39 | }); |
40 | 40 | ||
41 | function checkPackageDeps(pkgBtnData, doneCb){ | 41 | function checkPackageDeps(targetPkg, doneCb){ |
42 | $.ajax({ | 42 | $.ajax({ |
43 | type: 'GET', | 43 | type: 'GET', |
44 | url: pkgBtnData.packageUrl, | 44 | url: targetPkg.packageUrl, |
45 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 45 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
46 | success: function(data){ | 46 | success: function(data){ |
47 | if (data.error !== 'ok'){ | 47 | if (data.error !== 'ok'){ |
@@ -53,12 +53,12 @@ function customRecipePageInit(ctx) { | |||
53 | }); | 53 | }); |
54 | } | 54 | } |
55 | 55 | ||
56 | function showPackageDepsModal(pkgBtnData, pkgData){ | 56 | function showPackageDepsModal(targetPkg, pkgData){ |
57 | var modal = $("#package-deps-modal"); | 57 | var modal = $("#package-deps-modal"); |
58 | var depsList = modal.find("#package-add-dep-list"); | 58 | var depsList = modal.find("#package-add-dep-list"); |
59 | var deps = pkgData.unsatisfied_dependencies; | 59 | var deps = pkgData.unsatisfied_dependencies; |
60 | 60 | ||
61 | modal.find(".package-to-add-name").text(pkgBtnData.name); | 61 | modal.find(".package-to-add-name").text(targetPkg.name); |
62 | 62 | ||
63 | depsList.text(""); | 63 | depsList.text(""); |
64 | 64 | ||
@@ -72,7 +72,9 @@ function customRecipePageInit(ctx) { | |||
72 | modal.find("#package-deps-total-size").text( | 72 | modal.find("#package-deps-total-size").text( |
73 | pkgData.unsatisfied_dependencies_size_formatted); | 73 | pkgData.unsatisfied_dependencies_size_formatted); |
74 | 74 | ||
75 | addPkgDepsModalBtn.data(pkgBtnData); | 75 | targetPkg.depsAdded = deps; |
76 | |||
77 | addPkgDepsModalBtn.data(targetPkg); | ||
76 | modal.modal('show'); | 78 | modal.modal('show'); |
77 | } | 79 | } |
78 | 80 | ||
@@ -82,12 +84,12 @@ function customRecipePageInit(ctx) { | |||
82 | addRemovePackage($(this).data(), null); | 84 | addRemovePackage($(this).data(), null); |
83 | }); | 85 | }); |
84 | 86 | ||
85 | function showPackageReverseDepsModal(pkgBtnData, pkgData){ | 87 | function showPackageReverseDepsModal(targetPkg, pkgData){ |
86 | var modal = $("#package-reverse-deps-modal"); | 88 | var modal = $("#package-reverse-deps-modal"); |
87 | var depsList = modal.find("#package-reverse-dep-list"); | 89 | var depsList = modal.find("#package-reverse-dep-list"); |
88 | var deps = pkgData.reverse_dependencies; | 90 | var deps = pkgData.reverse_dependencies; |
89 | 91 | ||
90 | modal.find(".package-to-rm-name").text(pkgBtnData.name); | 92 | modal.find(".package-to-rm-name").text(targetPkg.name); |
91 | 93 | ||
92 | depsList.text(""); | 94 | depsList.text(""); |
93 | 95 | ||
@@ -101,7 +103,7 @@ function customRecipePageInit(ctx) { | |||
101 | modal.find("#package-reverse-deps-total-size").text( | 103 | modal.find("#package-reverse-deps-total-size").text( |
102 | pkgData.reverse_dependencies_size_formatted); | 104 | pkgData.reverse_dependencies_size_formatted); |
103 | 105 | ||
104 | rmdPkgReverseDepsModalBtn.data(pkgBtnData); | 106 | rmdPkgReverseDepsModalBtn.data(targetPkg); |
105 | modal.modal('show'); | 107 | modal.modal('show'); |
106 | } | 108 | } |
107 | 109 | ||
@@ -112,30 +114,58 @@ function customRecipePageInit(ctx) { | |||
112 | }); | 114 | }); |
113 | 115 | ||
114 | 116 | ||
115 | function addRemovePackage(pkgBtnData, tableParams){ | 117 | function addRemovePackage(targetPkg, tableParams){ |
116 | var method; | 118 | var method; |
117 | var msg = "You have "; | 119 | var msg = "You have "; |
118 | 120 | ||
119 | var btnCell = $("#package-btn-cell-"+pkgBtnData.package); | 121 | var btnCell = $("#package-btn-cell-" + targetPkg.id); |
120 | var inlineNotify = btnCell.children(".inline-notification"); | 122 | var inlineNotify = btnCell.children(".inline-notification"); |
121 | 123 | ||
122 | if (pkgBtnData.directive === 'add') { | 124 | if (targetPkg.directive === 'add') { |
123 | method = 'PUT'; | 125 | method = 'PUT'; |
124 | msg += "added 1 package to "+ctx.recipe.name+":"; | 126 | /* If the package had dependencies also notify that they were added */ |
125 | inlineNotify.text("1 package added"); | 127 | if (targetPkg.hasOwnProperty('depsAdded') && |
126 | } else if (pkgBtnData.directive === 'remove') { | 128 | targetPkg.depsAdded.length > 0) { |
129 | |||
130 | msg += "added " + (targetPkg.depsAdded.length + 1); | ||
131 | msg += " packages to " + ctx.recipe.name + ": "; | ||
132 | msg += "<strong>" + targetPkg.name + "</strong> and its dependencies"; | ||
133 | |||
134 | for (var i in targetPkg.depsAdded){ | ||
135 | var dep = targetPkg.depsAdded[i]; | ||
136 | |||
137 | msg += " <strong>" + dep.name + "</strong>"; | ||
138 | |||
139 | /* Add any cells currently in view to the list of cells which get | ||
140 | * an inline notification inside them and which change add/rm state | ||
141 | */ | ||
142 | var depBtnCell = $("#package-btn-cell-" + dep.pk); | ||
143 | btnCell = btnCell.add(depBtnCell); | ||
144 | |||
145 | inlineNotify = inlineNotify.add( | ||
146 | depBtnCell.children(".inline-notification")); | ||
147 | } | ||
148 | |||
149 | inlineNotify.text( | ||
150 | (targetPkg.depsAdded.length + 1) + " packages added"); | ||
151 | |||
152 | } else { | ||
153 | msg += ' <strong>' + targetPkg.name + '<strong>'; | ||
154 | inlineNotify.text("1 package added"); | ||
155 | } | ||
156 | |||
157 | } else if (targetPkg.directive === 'remove') { | ||
127 | method = 'DELETE'; | 158 | method = 'DELETE'; |
128 | msg += "removed 1 package from "+ctx.recipe.name+":"; | 159 | msg += "removed 1 package from "+ctx.recipe.name+":"; |
160 | msg += ' <strong>' + targetPkg.name + '<strong>'; | ||
129 | inlineNotify.text("1 package removed"); | 161 | inlineNotify.text("1 package removed"); |
130 | } else { | 162 | } else { |
131 | throw("Unknown package directive: should be add or remove"); | 163 | throw("Unknown package directive: should be add or remove"); |
132 | } | 164 | } |
133 | 165 | ||
134 | msg += ' <strong>' + pkgBtnData.name + '<strong>'; | ||
135 | |||
136 | $.ajax({ | 166 | $.ajax({ |
137 | type: method, | 167 | type: method, |
138 | url: pkgBtnData.packageUrl, | 168 | url: targetPkg.packageUrl, |
139 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 169 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
140 | success: function(data){ | 170 | success: function(data){ |
141 | if (data.error !== 'ok'){ | 171 | if (data.error !== 'ok'){ |
@@ -145,15 +175,29 @@ function customRecipePageInit(ctx) { | |||
145 | 175 | ||
146 | libtoaster.showChangeNotification(msg); | 176 | libtoaster.showChangeNotification(msg); |
147 | 177 | ||
148 | /* Also do the in-cell notification */ | 178 | /* do the in-cell/inline notification to swap buttoms from add to |
179 | * remove | ||
180 | */ | ||
149 | btnCell.children("button").fadeOut().promise().done(function(){ | 181 | btnCell.children("button").fadeOut().promise().done(function(){ |
150 | inlineNotify.fadeIn().delay(500).fadeOut(function(){ | 182 | inlineNotify.fadeIn().delay(500).fadeOut(function(){ |
151 | if (pkgBtnData.directive === 'add') | 183 | if (targetPkg.directive === 'add') |
152 | btnCell.children("button[data-directive=remove]").fadeIn(); | 184 | btnCell.children("button[data-directive=remove]").fadeIn(); |
153 | else | 185 | else |
154 | btnCell.children("button[data-directive=add]").fadeIn(); | 186 | btnCell.children("button[data-directive=add]").fadeIn(); |
155 | }); | 187 | }); |
156 | }); | 188 | }); |
189 | |||
190 | /* Update the total num packages */ | ||
191 | $.ajax({ | ||
192 | type: "GET", | ||
193 | url: ctx.recipe.xhrPackageListUrl, | ||
194 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
195 | success: function(data){ | ||
196 | console.log(data); | ||
197 | $("#total-num-packages").text(data.total); | ||
198 | $("#total-size-packages").text(data.total_size_formatted); | ||
199 | } | ||
200 | }); | ||
157 | } | 201 | } |
158 | }); | 202 | }); |
159 | } | 203 | } |
diff --git a/bitbake/lib/toaster/toastergui/templates/customrecipe.html b/bitbake/lib/toaster/toastergui/templates/customrecipe.html index 4d88be054d..02ca5be1ca 100644 --- a/bitbake/lib/toaster/toastergui/templates/customrecipe.html +++ b/bitbake/lib/toaster/toastergui/templates/customrecipe.html | |||
@@ -28,6 +28,7 @@ | |||
28 | name: "{{recipe.name}}", | 28 | name: "{{recipe.name}}", |
29 | includedPackagesCount: {{recipe.includes_set.count}}, | 29 | includedPackagesCount: {{recipe.includes_set.count}}, |
30 | baseRecipeId: {{recipe.base_recipe.pk}}, | 30 | baseRecipeId: {{recipe.base_recipe.pk}}, |
31 | xhrPackageListUrl: "{% url 'xhr_customrecipe_packages' recipe.pk %}", | ||
31 | } | 32 | } |
32 | }; | 33 | }; |
33 | 34 | ||
@@ -143,12 +144,12 @@ | |||
143 | Approx. packages included | 144 | Approx. packages included |
144 | <i class="icon-question-sign get-help" title="" data-original-title="The number of packages included is based on information from previous builds and from parsing layers, so we can never be sure it is 100% accurate"></i> | 145 | <i class="icon-question-sign get-help" title="" data-original-title="The number of packages included is based on information from previous builds and from parsing layers, so we can never be sure it is 100% accurate"></i> |
145 | </dt> | 146 | </dt> |
146 | <dd class="no-packages">{{recipe.get_all_packages.count}}</dd> | 147 | <dd id="total-num-packages">{{recipe.get_all_packages.count}}</dd> |
147 | <dt> | 148 | <dt> |
148 | Approx. package size | 149 | Approx. package size |
149 | <i class="icon-question-sign get-help" title="" data-original-title="Package size is based on information from previous builds, so we can never be sure it is 100% accurate"></i> | 150 | <i class="icon-question-sign get-help" title="" data-original-title="Package size is based on information from previous builds, so we can never be sure it is 100% accurate"></i> |
150 | </dt> | 151 | </dt> |
151 | <dd>{{approx_pkg_size.size__sum|filtered_filesizeformat}}</dd> | 152 | <dd id="total-size-packages">{{approx_pkg_size.size__sum|filtered_filesizeformat}}</dd> |
152 | {% if last_build %} | 153 | {% if last_build %} |
153 | <dt>Last build</dt> | 154 | <dt>Last build</dt> |
154 | <dd> | 155 | <dd> |
diff --git a/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html b/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html index a3e8546706..0aefc56259 100644 --- a/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html +++ b/bitbake/lib/toaster/toastergui/templates/pkg_add_rm_btn.html | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | <div id="package-btn-cell-{{data.pk}}"> | 14 | <div id="package-btn-cell-{{data.pk}}"> |
15 | <div style="display: none; font-size: 11px; line-height: 1.3;" class="tooltip-inner inline-notification"></div> | 15 | <div style="display: none; font-size: 11px; line-height: 1.3;" class="tooltip-inner inline-notification"></div> |
16 | <button class="btn btn-block btn-danger add-rm-package-btn" data-directive="remove" data-package="{{data.pk}}" data-package-url="{% url 'xhr_customrecipe_packages' extra.recipe_id data.pk %}" data-name="{{data.name}}" style=" | 16 | <button class="btn btn-block btn-danger add-rm-package-btn" data-directive="remove" data-id="{{data.pk}}" data-package-url="{% url 'xhr_customrecipe_packages' extra.recipe_id data.pk %}" data-name="{{data.name}}" style=" |
17 | {% if data.pk not in extra.current_packages %} | 17 | {% if data.pk not in extra.current_packages %} |
18 | display:none | 18 | display:none |
19 | {% endif %} | 19 | {% endif %} |
@@ -21,7 +21,7 @@ | |||
21 | <i class="icon-trash no-tooltip"></i> | 21 | <i class="icon-trash no-tooltip"></i> |
22 | Remove package | 22 | Remove package |
23 | </button> | 23 | </button> |
24 | <button class="btn btn-block add-rm-package-btn" data-directive="add" data-package="{{data.pk}}" data-package-url="{% url 'xhr_customrecipe_packages' extra.recipe_id data.pk %}" data-name="{{data.name}}" style=" | 24 | <button class="btn btn-block add-rm-package-btn" data-directive="add" data-id="{{data.pk}}" data-package-url="{% url 'xhr_customrecipe_packages' extra.recipe_id data.pk %}" data-name="{{data.name}}" style=" |
25 | {% if data.pk in extra.current_packages %} | 25 | {% if data.pk in extra.current_packages %} |
26 | display:none | 26 | display:none |
27 | {% endif %} | 27 | {% endif %} |
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py index 4feeebc14a..4aa64887b7 100644 --- a/bitbake/lib/toaster/toastergui/urls.py +++ b/bitbake/lib/toaster/toastergui/urls.py | |||
@@ -171,6 +171,10 @@ urlpatterns = patterns('toastergui.views', | |||
171 | # image customisation functionality | 171 | # image customisation functionality |
172 | url(r'^xhr_customrecipe/(?P<recipe_id>\d+)/packages/(?P<package_id>\d+|)$', | 172 | url(r'^xhr_customrecipe/(?P<recipe_id>\d+)/packages/(?P<package_id>\d+|)$', |
173 | 'xhr_customrecipe_packages', name='xhr_customrecipe_packages'), | 173 | 'xhr_customrecipe_packages', name='xhr_customrecipe_packages'), |
174 | |||
175 | url(r'^xhr_customrecipe/(?P<recipe_id>\d+)/packages/$', | ||
176 | 'xhr_customrecipe_packages', name='xhr_customrecipe_packages'), | ||
177 | |||
174 | url(r'^xhr_customrecipe/(?P<recipe_id>\d+)$', 'xhr_customrecipe_id', | 178 | url(r'^xhr_customrecipe/(?P<recipe_id>\d+)$', 'xhr_customrecipe_id', |
175 | name='xhr_customrecipe_id'), | 179 | name='xhr_customrecipe_id'), |
176 | url(r'^xhr_customrecipe/', 'xhr_customrecipe', | 180 | url(r'^xhr_customrecipe/', 'xhr_customrecipe', |