diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/newcustomimage.js')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/newcustomimage.js | 49 |
1 files changed, 49 insertions, 0 deletions
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 | |||
3 | function 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 | } | ||