summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-01-29 14:38:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:29:21 +0000
commit998f9af193aec78abaddfbedd7dac161ed9d538d (patch)
treeb955076ede19dd5395d11963e7d490d9f2a43b11 /bitbake/lib/toaster/toastergui/static
parent9976e4f169ad39bcbe5ca34c866318d654adaa59 (diff)
downloadpoky-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/lib/toaster/toastergui/static')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/customrecipe.js98
1 files changed, 71 insertions, 27 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 }