replication.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* vim: set expandtab sw=4 ts=4 sts=4: */
  2. /**
  3. * for server_replication.php
  4. *
  5. */
  6. var random_server_id = Math.floor(Math.random() * 10000000);
  7. var conf_prefix = 'server-id=' + random_server_id + '\nlog_bin=mysql-bin\nlog_error=mysql-bin.err\n';
  8. function update_config () {
  9. var conf_ignore = 'binlog_ignore_db=';
  10. var conf_do = 'binlog_do_db=';
  11. var database_list = '';
  12. if ($('#db_select option:selected').size() === 0) {
  13. $('#rep').text(conf_prefix);
  14. } else if ($('#db_type option:selected').val() === 'all') {
  15. $('#db_select option:selected').each(function () {
  16. database_list += conf_ignore + $(this).val() + '\n';
  17. });
  18. $('#rep').text(conf_prefix + database_list);
  19. } else {
  20. $('#db_select option:selected').each(function () {
  21. database_list += conf_do + $(this).val() + '\n';
  22. });
  23. $('#rep').text(conf_prefix + database_list);
  24. }
  25. }
  26. /**
  27. * Unbind all event handlers before tearing down a page
  28. */
  29. AJAX.registerTeardown('replication.js', function () {
  30. $('#db_type').off('change');
  31. $('#db_select').off('change');
  32. $('#master_status_href').off('click');
  33. $('#master_slaves_href').off('click');
  34. $('#slave_status_href').off('click');
  35. $('#slave_control_href').off('click');
  36. $('#slave_errormanagement_href').off('click');
  37. $('#slave_synchronization_href').off('click');
  38. $('#db_reset_href').off('click');
  39. $('#db_select_href').off('click');
  40. $('#reset_slave').off('click');
  41. });
  42. AJAX.registerOnload('replication.js', function () {
  43. $('#rep').text(conf_prefix);
  44. $('#db_type').change(update_config);
  45. $('#db_select').change(update_config);
  46. $('#master_status_href').click(function () {
  47. $('#replication_master_section').toggle();
  48. });
  49. $('#master_slaves_href').click(function () {
  50. $('#replication_slaves_section').toggle();
  51. });
  52. $('#slave_status_href').click(function () {
  53. $('#replication_slave_section').toggle();
  54. });
  55. $('#slave_control_href').click(function () {
  56. $('#slave_control_gui').toggle();
  57. });
  58. $('#slave_errormanagement_href').click(function () {
  59. $('#slave_errormanagement_gui').toggle();
  60. });
  61. $('#slave_synchronization_href').click(function () {
  62. $('#slave_synchronization_gui').toggle();
  63. });
  64. $('#db_reset_href').click(function () {
  65. $('#db_select option:selected').prop('selected', false);
  66. $('#db_select').trigger('change');
  67. });
  68. $('#db_select_href').click(function () {
  69. $('#db_select option').prop('selected', true);
  70. $('#db_select').trigger('change');
  71. });
  72. $('#reset_slave').click(function (e) {
  73. e.preventDefault();
  74. var $anchor = $(this);
  75. var question = PMA_messages.strResetSlaveWarning;
  76. $anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
  77. PMA_ajaxShowMessage();
  78. AJAX.source = $anchor;
  79. var params = getJSConfirmCommonParam({
  80. 'ajax_page_request': true,
  81. 'ajax_request': true
  82. }, $anchor.getPostData());
  83. $.post(url, params, AJAX.responseHandler);
  84. });
  85. });
  86. });