aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
blob: 16e42b3d278ede813fb154ec4bc59bc52e197f98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";

/* Used for the newcustomimage_modal actions */
function newCustomImageModalInit(){

  var newCustomImgBtn = $("#create-new-custom-image-btn");
  var imgCustomModal = $("#new-custom-image-modal");

  newCustomImgBtn.click(function(e){
    e.preventDefault();

    var name = imgCustomModal.find('input').val();
    var baseRecipeId = imgCustomModal.data('recipe');

    if (name.length > 0) {
      imgCustomModal.modal('hide');
      libtoaster.createCustomRecipe(name, baseRecipeId, function(ret) {
        if (ret.error !== "ok") {
          console.warn(ret.error);
        } else {
          window.location.replace(ret.url + '?notify=new');
        }
      });
    } else {
      console.warn("TODO No name supplied");
    }
  });
}