summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/customrecipe.js50
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerBtn.js13
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/newcustomimage.js49
3 files changed, 112 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
new file mode 100644
index 0000000000..4f6b304dd6
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
@@ -0,0 +1,50 @@
1"use strict";
2
3function customRecipePageInit(ctx) {
4
5 var urlParams = libtoaster.parseUrlParams();
6
7 (function notificationRequest(){
8 if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new'){
9 $("#image-created-notification").show();
10 }
11 })();
12
13 $("#recipeselection").on('table-done', function(e, total, tableParams){
14 /* Table is done so now setup the click handler for the package buttons */
15 $(".add-rm-package-btn").click(function(e){
16 e.preventDefault();
17 addRemovePackage($(this), tableParams);
18 });
19 });
20
21 function addRemovePackage(pkgBtn, tableParams){
22 var pkgBtnData = pkgBtn.data();
23 var method;
24 var buttonToShow;
25
26 if (pkgBtnData.directive == 'add') {
27 method = 'PUT';
28 buttonToShow = '#package-rm-btn-' + pkgBtnData.package;
29 } else if (pkgBtnData.directive == 'remove') {
30 method = 'DELETE';
31 buttonToShow = '#package-add-btn-' + pkgBtnData.package;
32 } else {
33 throw("Unknown package directive: should be add or remove");
34 }
35
36 $.ajax({
37 type: method,
38 url: pkgBtnData.packageUrl,
39 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
40 success: function(data){
41 /* Invalidate the Add | Rm package table's current cache */
42 tableParams.nocache = true;
43 $.get(ctx.tableApiUrl, tableParams);
44 /* Swap the buttons around */
45 pkgBtn.hide();
46 $(buttonToShow).show();
47 }
48 });
49 }
50}
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
index a0509f9aa3..da0241c62b 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
@@ -68,6 +68,19 @@ function layerBtnsInit(ctx) {
68 }); 68 });
69 }); 69 });
70 70
71
72 $(".customise-btn").unbind('click');
73 $(".customise-btn").click(function(e){
74 e.preventDefault();
75 var imgCustomModal = $("#new-custom-image-modal");
76
77 if (imgCustomModal.length == 0)
78 throw("Modal new-custom-image not found");
79
80 imgCustomModal.data('recipe', $(this).data('recipe'));
81 imgCustomModal.modal('show');
82 });
83
71 /* Setup the initial state of the buttons */ 84 /* Setup the initial state of the buttons */
72 85
73 for (var i in ctx.projectLayers){ 86 for (var i in ctx.projectLayers){
diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js
new file mode 100644
index 0000000000..935b21ede8
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js
@@ -0,0 +1,49 @@
1"use strict";
2
3function newCustomImagePageInit(ctx){
4
5 var newCustomImgBtn = $("#create-new-custom-image-btn");
6 var imgCustomModal = $("#new-custom-image-modal");
7
8 newCustomImgBtn.click(function(e){
9 e.preventDefault();
10
11 var name = imgCustomModal.find('input').val();
12 var baseRecipeId = imgCustomModal.data('recipe');
13
14 if (name.length > 0) {
15 createCustomRecipe(name, baseRecipeId);
16 imgCustomModal.modal('hide');
17 } else {
18 console.warn("TODO No name supplied");
19 }
20 });
21
22 function createCustomRecipe(name, baseRecipeId){
23 var data = {
24 'name' : name,
25 'project' : libtoaster.ctx.projectId,
26 'base' : baseRecipeId,
27 };
28
29 $.ajax({
30 type: "POST",
31 url: ctx.xhrCustomRecipeUrl,
32 data: data,
33 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
34 success: function (ret) {
35 if (ret.error !== "ok") {
36 console.warn(ret.error);
37 } else {
38 window.location.replace(ret.url + '?notify=new');
39 }
40 },
41 error: function (ret) {
42 console.warn("Call failed");
43 console.warn(ret);
44 }
45 });
46 }
47
48
49}