Sha256: 50aead252edae2f18c622780ed9cc445c0c0a521ce19777d8cb1a729dd8fcf80

Contents?: true

Size: 1.9 KB

Versions: 17

Compression:

Stored size: 1.9 KB

Contents

function virt_who_update_listing_mode() {
  var filtering_mode = $('#foreman_virt_who_configure_config_listing_mode').val();
  var whitelist = $('#foreman_virt_who_configure_config_whitelist').parents('div.form-group');
  var blacklist = $('#foreman_virt_who_configure_config_blacklist').parents('div.form-group');

  // UNLIMITED = 0, WHITELIST = 1, BLACKLIST = 2, see config.rb model for the definition
  if (filtering_mode == '0') {
    whitelist.hide();
    blacklist.hide();
  } else if (filtering_mode == '1') {
    whitelist.show();
    blacklist.hide();
  } else if (filtering_mode == '2') {
    whitelist.hide();
    blacklist.show();
  }
}

function virt_who_update_hypervisor_fields() {
  selected_type = $('#foreman_virt_who_configure_config_hypervisor_type').val();
  var element = $('#foreman_virt_who_configure_config_hypervisor_password');
  element.closest('.form-group').toggle(selected_type != 'libvirt');
}

function virt_who_update_credentials_help() {
  selected_type = $(this).val();
  $.each(['hypervisor_server', 'hypervisor_username'], function(index, value) {
    var element = $('#foreman_virt_who_configure_config_' + value);
    var help = element.data("help")[selected_type];
    var inline_help_popover = element.parents('.form-group').find('.help-inline a[rel=popover]');
    if (inline_help_popover[0]) {
      // pre Foreman 1.15
      inline_help_popover.attr('data-content', help);
    } else {
      element.parents('.form-group').find('label a[rel=popover]').attr('data-content', help);
    }
  });
}

$(document).ready(function () {
  virt_who_update_listing_mode();
  virt_who_update_hypervisor_fields();
  $('#foreman_virt_who_configure_config_listing_mode').change(virt_who_update_listing_mode);
  $('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_credentials_help);
  $('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_hypervisor_fields);
});

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_virt_who_configure-0.3.3 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.3.2 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.3.1 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.3.0 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.2.2 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.2.1 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.2.0 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.9 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.8 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.7 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.6 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.5 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.4 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.3 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.2 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.1 app/assets/javascripts/foreman_virt_who_configure/config_edit.js
foreman_virt_who_configure-0.1.0 app/assets/javascripts/foreman_virt_who_configure/config_edit.js