summaryrefslogtreecommitdiff
path: root/lib/toaster/toastergui/static/js/customrecipe.js
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-09-28 21:45:24 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 13:44:48 +0100
commit543586462b66434741f47f2884b4ccdeda5397b5 (patch)
tree75d02763dbf675f1d3274a5a4251fbbf8cce2b1c /lib/toaster/toastergui/static/js/customrecipe.js
parent4e5472e9ba6850081baa9d56fabc4ddb1aa24846 (diff)
downloadbitbake-543586462b66434741f47f2884b4ccdeda5397b5.zip
toaster: Add Image customisation frontend feature
Add the Image customisation front end feature to Toaster. Caveat - This feature is currently in development and should not be enabled by default. 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 'lib/toaster/toastergui/static/js/customrecipe.js')
-rw-r--r--lib/toaster/toastergui/static/js/customrecipe.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/toaster/toastergui/static/js/customrecipe.js b/lib/toaster/toastergui/static/js/customrecipe.js
new file mode 100644
index 00000000..4f6b304d
--- /dev/null
+++ b/lib/toaster/toastergui/static/js/customrecipe.js
@@ -0,0 +1,50 @@
+"use strict";
+
+function customRecipePageInit(ctx) {
+
+ var urlParams = libtoaster.parseUrlParams();
+
+ (function notificationRequest(){
+ if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){
+ $("#image-created-notification").show();
+ }
+ })();
+
+ $("#recipeselection").on('table-done', function(e, total, tableParams){
+ /* Table is done so now setup the click handler for the package buttons */
+ $(".add-rm-package-btn").click(function(e){
+ e.preventDefault();
+ addRemovePackage($(this), tableParams);
+ });
+ });
+
+ function addRemovePackage(pkgBtn, tableParams){
+ var pkgBtnData = pkgBtn.data();
+ var method;
+ var buttonToShow;
+
+ if (pkgBtnData.directive == 'add') {
+ method = 'PUT';
+ buttonToShow = '#package-rm-btn-' + pkgBtnData.package;
+ } else if (pkgBtnData.directive == 'remove') {
+ method = 'DELETE';
+ buttonToShow = '#package-add-btn-' + pkgBtnData.package;
+ } else {
+ throw("Unknown package directive: should be add or remove");
+ }
+
+ $.ajax({
+ type: method,
+ url: pkgBtnData.packageUrl,
+ headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
+ success: function(data){
+ /* Invalidate the Add | Rm package table's current cache */
+ tableParams.nocache = true;
+ $.get(ctx.tableApiUrl, tableParams);
+ /* Swap the buttons around */
+ pkgBtn.hide();
+ $(buttonToShow).show();
+ }
+ });
+ }
+}