diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-12-07 18:42:16 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:19 +0000 |
commit | 4b3c9d61dc0c416d4d277de680604e2f6697e288 (patch) | |
tree | 6e36faa75bfbf317f1083c595b2eb89a1bdad2a9 /bitbake/lib/toaster/toastergui/static | |
parent | b213907afe2b37f66d8fae88af8e5edf50464f04 (diff) | |
download | poky-4b3c9d61dc0c416d4d277de680604e2f6697e288.tar.gz |
bitbake: toaster: customrecipe Add further front end features using new API
This adds some basic package dependency hint modals when you add and
remove a package. It also makes sure that if the CustomImageRecipe has
no current included packages that we go and check this with the server
to see if a relevant build has taken place which will provide this
information.
[YOCTO #8082]
(Bitbake rev: 418f5509e74d46d36a8eb966a245083006e5f4ba)
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.js | 132 |
1 files changed, 118 insertions, 14 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js index 4cd9382b49..33fcb88e94 100644 --- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js | |||
@@ -4,32 +4,129 @@ function customRecipePageInit(ctx) { | |||
4 | 4 | ||
5 | var urlParams = libtoaster.parseUrlParams(); | 5 | var urlParams = libtoaster.parseUrlParams(); |
6 | var customiseTable = $("#selectpackagestable"); | 6 | var customiseTable = $("#selectpackagestable"); |
7 | var addPkgDepsModalBtn = $("#add-package-deps-modal-btn"); | ||
8 | var rmdPkgReverseDepsModalBtn = $("#rm-package-reverse-deps-modal-btn"); | ||
7 | 9 | ||
8 | (function notificationRequest(){ | 10 | if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){ |
9 | if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){ | 11 | $("#image-created-notification").show(); |
10 | $("#image-created-notification").show(); | 12 | } |
11 | } | ||
12 | })(); | ||
13 | 13 | ||
14 | customiseTable.on('table-done', function(e, total, tableParams){ | 14 | customiseTable.on('table-done', function(e, total){ |
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 | addRemovePackage($(this), tableParams); | 18 | var pkgBtnData = $(this).data(); |
19 | |||
20 | checkPackageDeps(pkgBtnData, function(pkgData){ | ||
21 | if (pkgBtnData.directive === 'add'){ | ||
22 | /* If we're adding a package we may need to show the modal to advise | ||
23 | * on dependencies for this package. | ||
24 | */ | ||
25 | if (pkgData.unsatisfied_dependencies.length === 0){ | ||
26 | addRemovePackage(pkgBtnData); | ||
27 | } else { | ||
28 | showPackageDepsModal(pkgBtnData, pkgData); | ||
29 | } | ||
30 | } else if (pkgBtnData.directive === 'remove') { | ||
31 | if (pkgData.reverse_dependencies.length === 0){ | ||
32 | addRemovePackage(pkgBtnData); | ||
33 | } else { | ||
34 | showPackageReverseDepsModal(pkgBtnData, pkgData); | ||
35 | } | ||
36 | } | ||
37 | }); | ||
38 | }); | ||
39 | }); | ||
40 | |||
41 | function checkPackageDeps(pkgBtnData, doneCb){ | ||
42 | $.ajax({ | ||
43 | type: 'GET', | ||
44 | url: pkgBtnData.packageUrl, | ||
45 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
46 | success: function(data){ | ||
47 | if (data.error !== 'ok'){ | ||
48 | console.warn(data.error); | ||
49 | return; | ||
50 | } | ||
51 | doneCb(data); | ||
52 | } | ||
19 | }); | 53 | }); |
54 | } | ||
55 | |||
56 | function showPackageDepsModal(pkgBtnData, pkgData){ | ||
57 | var modal = $("#package-deps-modal"); | ||
58 | var depsList = modal.find("#package-add-dep-list"); | ||
59 | var deps = pkgData.unsatisfied_dependencies; | ||
60 | |||
61 | modal.find(".package-to-add-name").text(pkgBtnData.name); | ||
62 | |||
63 | depsList.text(""); | ||
64 | |||
65 | for (var i in deps){ | ||
66 | var li = $('<li></li>').text(deps[i].name); | ||
67 | li.append($('<span></span>').text(" ("+ | ||
68 | deps[i].size_formatted+")")); | ||
69 | depsList.append(li); | ||
70 | } | ||
71 | |||
72 | modal.find("#package-deps-total-size").text( | ||
73 | pkgData.unsatisfied_dependencies_size_formatted); | ||
74 | |||
75 | addPkgDepsModalBtn.data(pkgBtnData); | ||
76 | modal.modal('show'); | ||
77 | } | ||
78 | |||
79 | addPkgDepsModalBtn.click(function(e){ | ||
80 | e.preventDefault(); | ||
81 | |||
82 | addRemovePackage($(this).data(), null); | ||
83 | }); | ||
84 | |||
85 | function showPackageReverseDepsModal(pkgBtnData, pkgData){ | ||
86 | var modal = $("#package-reverse-deps-modal"); | ||
87 | var depsList = modal.find("#package-reverse-dep-list"); | ||
88 | var deps = pkgData.reverse_dependencies; | ||
89 | |||
90 | modal.find(".package-to-rm-name").text(pkgBtnData.name); | ||
91 | |||
92 | depsList.text(""); | ||
93 | |||
94 | for (var i in deps){ | ||
95 | var li = $('<li></li>').text(deps[i].name); | ||
96 | li.append($('<span></span>').text(" ("+ | ||
97 | deps[i].size_formatted+")")); | ||
98 | depsList.append(li); | ||
99 | } | ||
100 | |||
101 | modal.find("#package-reverse-deps-total-size").text( | ||
102 | pkgData.reverse_dependencies_size_formatted); | ||
103 | |||
104 | rmdPkgReverseDepsModalBtn.data(pkgBtnData); | ||
105 | modal.modal('show'); | ||
106 | } | ||
107 | |||
108 | rmdPkgReverseDepsModalBtn.click(function(e){ | ||
109 | e.preventDefault(); | ||
110 | |||
111 | addRemovePackage($(this).data(), null); | ||
20 | }); | 112 | }); |
21 | 113 | ||
22 | function addRemovePackage(pkgBtn, tableParams){ | 114 | |
23 | var pkgBtnData = pkgBtn.data(); | 115 | function addRemovePackage(pkgBtnData, tableParams){ |
24 | var method; | 116 | var method; |
25 | var msg = "You have "; | 117 | var msg = "You have "; |
26 | 118 | ||
27 | if (pkgBtnData.directive == 'add') { | 119 | var btnCell = $("#package-btn-cell-"+pkgBtnData.package); |
120 | var inlineNotify = btnCell.children(".inline-notification"); | ||
121 | |||
122 | if (pkgBtnData.directive === 'add') { | ||
28 | method = 'PUT'; | 123 | method = 'PUT'; |
29 | msg += "added 1 package to "+ctx.recipe.name+":"; | 124 | msg += "added 1 package to "+ctx.recipe.name+":"; |
30 | } else if (pkgBtnData.directive == 'remove') { | 125 | inlineNotify.text("1 package added"); |
126 | } else if (pkgBtnData.directive === 'remove') { | ||
31 | method = 'DELETE'; | 127 | method = 'DELETE'; |
32 | msg += "removed 1 package from "+ctx.recipe.name+":"; | 128 | msg += "removed 1 package from "+ctx.recipe.name+":"; |
129 | inlineNotify.text("1 package removed"); | ||
33 | } else { | 130 | } else { |
34 | throw("Unknown package directive: should be add or remove"); | 131 | throw("Unknown package directive: should be add or remove"); |
35 | } | 132 | } |
@@ -45,11 +142,18 @@ function customRecipePageInit(ctx) { | |||
45 | console.warn(data.error); | 142 | console.warn(data.error); |
46 | return; | 143 | return; |
47 | } | 144 | } |
48 | /* Reload and Invalidate the Add | Rm package table's current data */ | ||
49 | tableParams.nocache = true; | ||
50 | customiseTable.trigger('reload', [tableParams]); | ||
51 | 145 | ||
52 | libtoaster.showChangeNotification(msg); | 146 | libtoaster.showChangeNotification(msg); |
147 | |||
148 | /* Also do the in-cell notification */ | ||
149 | btnCell.children("button").fadeOut().promise().done(function(){ | ||
150 | inlineNotify.fadeIn().delay(500).fadeOut(function(){ | ||
151 | if (pkgBtnData.directive === 'add') | ||
152 | btnCell.children("button[data-directive=remove]").fadeIn(); | ||
153 | else | ||
154 | btnCell.children("button[data-directive=add]").fadeIn(); | ||
155 | }); | ||
156 | }); | ||
53 | } | 157 | } |
54 | }); | 158 | }); |
55 | } | 159 | } |