Example #1
0
File: clone.js Project: tinova/one
    $("#" + DIALOG_ID + "Form", context).submit(function() {
      var extra_info;
      var name = $("input[name=\"name\"]", this).val();
      var sel_elems = Sunstone.getDataTable(ONEFLOW_TEMPLATES_TAB_ID).elements();

      if (sel_elems.length > 1) {
        for (var i = 0; i < sel_elems.length; i++) {
          //If we are cloning several images we
          //use the name as prefix
          extra_info = name + OpenNebulaServiceTemplate.getName(sel_elems[i]);
          Sunstone.runAction("ServiceTemplate.clone", sel_elems[i], extra_info);
        }
      } else {
        extra_info = name;
        Sunstone.runAction("ServiceTemplate.clone", sel_elems[0], extra_info);
      }

      Sunstone.getDialog(DIALOG_ID).hide();
      Sunstone.getDialog(DIALOG_ID).reset();
      setTimeout(function() {
        console.log("e");
        Sunstone.runAction("ServiceTemplate.refresh");
      }, 1500);
      return false;
    });
Example #2
0
File: clone.js Project: melehin/one
    $('#' + DIALOG_ID + 'Form', context).submit(function() {
      var extra_info;
      var name = $('input[name="name"]', this).val();
      var sel_elems = Sunstone.getDataTable(ONEFLOW_TEMPLATES_TAB_ID).elements();

      if (!name || !sel_elems.length)
        Notifier.notifyError('A name or prefix is needed!');

      if (sel_elems.length > 1) {
        for (var i = 0; i < sel_elems.length; i++) {
          //If we are cloning several images we
          //use the name as prefix
          extra_info = name + OpenNebulaServiceTemplate.getName(sel_elems[i]);
          Sunstone.runAction('ServiceTemplate.clone', sel_elems[i], extra_info);
        }
      } else {
        extra_info = name;
        Sunstone.runAction('ServiceTemplate.clone', sel_elems[0], extra_info)
      }

      Sunstone.getDialog(DIALOG_ID).hide();
      Sunstone.getDialog(DIALOG_ID).reset();
      setTimeout(function() {
        Sunstone.runAction('ServiceTemplate.refresh');
      }, 1500);
      return false;
    });
Example #3
0
File: clone.js Project: melehin/one
  function _onShow(context) {
    var sel_elems = Sunstone.getDataTable(ONEFLOW_TEMPLATES_TAB_ID).elements();
    //show different text depending on how many elements are selected
    if (sel_elems.length > 1) {
      $('.clone_one', context).hide();
      $('.clone_several', context).show();
      $('input[name="name"]',context).val('Copy of ');
    } else {
      $('.clone_one', context).show();
      $('.clone_several', context).hide();
      $('input[name="name"]', context).val('Copy of ' + OpenNebulaServiceTemplate.getName(sel_elems[0]));
    };

    $("input[name='name']", context).focus();

    return false;
  }