示例#1
0
文件: clone.js 项目: unistra/one
    $('#' + DIALOG_ID + 'Form', dialog).submit(function() {
      var name = $('input[name="image_clone_name"]', this).val();
      var sel_elems = Sunstone.getDataTable(IMAGES_TAB_ID).elements();

      var extra_info = {};

      var targeDS = that.datastoreTable.retrieveResourceTableSelect();
      if (targeDS) {
        extra_info['target_ds'] = targeDS;
      }

      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'] = name + OpenNebulaImage.getName(sel_elems[i]);
          Sunstone.runAction('Image.clone', sel_elems[i], extra_info);
        }
      } else {
        extra_info['name'] = name;
        Sunstone.runAction('Image.clone', sel_elems[0], extra_info)
      }

      Sunstone.getDialog(DIALOG_ID).hide();
      Sunstone.getDialog(DIALOG_ID).reset();
      setTimeout(function() {
        Sunstone.runAction('Image.refresh');
      }, 1500);
      return false;
    });
示例#2
0
文件: clone.js 项目: melehin/one
  function _onShow(dialog) {
    var sel_elems = Sunstone.getDataTable(IMAGES_TAB_ID).elements();
    //show different text depending on how many elements are selected
    if (sel_elems.length > 1) {
      $('.clone_one', dialog).hide();
      $('.clone_several', dialog).show();
      $('input[name="image_clone_name"]', dialog).val('Copy of ');
    } else {
      $('.clone_one', dialog).show();
      $('.clone_several', dialog).hide();
      $('input[name="image_clone_name"]', dialog).val('Copy of ' + OpenNebulaImage.getName(sel_elems[0]));
    };

    $('#image_clone_advanced', dialog).hide();
    this.datastoreTable.resetResourceTableSelect();

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

    return false;
  }