You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. export function initInstall() {
  2. if ($('.install').length === 0) {
  3. return;
  4. }
  5. if ($('#db_host').val() === '') {
  6. $('#db_host').val('127.0.0.1:3306');
  7. $('#db_user').val('gitea');
  8. $('#db_name').val('gitea');
  9. }
  10. // Database type change detection.
  11. $('#db_type').on('change', function () {
  12. const sqliteDefault = 'data/gitea.db';
  13. const tidbDefault = 'data/gitea_tidb';
  14. const dbType = $(this).val();
  15. if (dbType === 'SQLite3') {
  16. $('#sql_settings').hide();
  17. $('#pgsql_settings').hide();
  18. $('#mysql_settings').hide();
  19. $('#sqlite_settings').show();
  20. if (dbType === 'SQLite3' && $('#db_path').val() === tidbDefault) {
  21. $('#db_path').val(sqliteDefault);
  22. }
  23. return;
  24. }
  25. const dbDefaults = {
  26. MySQL: '127.0.0.1:3306',
  27. PostgreSQL: '127.0.0.1:5432',
  28. MSSQL: '127.0.0.1:1433'
  29. };
  30. $('#sqlite_settings').hide();
  31. $('#sql_settings').show();
  32. $('#pgsql_settings').toggle(dbType === 'PostgreSQL');
  33. $('#mysql_settings').toggle(dbType === 'MySQL');
  34. $.each(dbDefaults, (_type, defaultHost) => {
  35. if ($('#db_host').val() === defaultHost) {
  36. $('#db_host').val(dbDefaults[dbType]);
  37. return false;
  38. }
  39. });
  40. });
  41. // TODO: better handling of exclusive relations.
  42. $('#offline-mode input').on('change', function () {
  43. if ($(this).is(':checked')) {
  44. $('#disable-gravatar').checkbox('check');
  45. $('#federated-avatar-lookup').checkbox('uncheck');
  46. }
  47. });
  48. $('#disable-gravatar input').on('change', function () {
  49. if ($(this).is(':checked')) {
  50. $('#federated-avatar-lookup').checkbox('uncheck');
  51. } else {
  52. $('#offline-mode').checkbox('uncheck');
  53. }
  54. });
  55. $('#federated-avatar-lookup input').on('change', function () {
  56. if ($(this).is(':checked')) {
  57. $('#disable-gravatar').checkbox('uncheck');
  58. $('#offline-mode').checkbox('uncheck');
  59. }
  60. });
  61. $('#enable-openid-signin input').on('change', function () {
  62. if ($(this).is(':checked')) {
  63. if (!$('#disable-registration input').is(':checked')) {
  64. $('#enable-openid-signup').checkbox('check');
  65. }
  66. } else {
  67. $('#enable-openid-signup').checkbox('uncheck');
  68. }
  69. });
  70. $('#disable-registration input').on('change', function () {
  71. if ($(this).is(':checked')) {
  72. $('#enable-captcha').checkbox('uncheck');
  73. $('#enable-openid-signup').checkbox('uncheck');
  74. } else {
  75. $('#enable-openid-signup').checkbox('check');
  76. }
  77. });
  78. $('#enable-captcha input').on('change', function () {
  79. if ($(this).is(':checked')) {
  80. $('#disable-registration').checkbox('uncheck');
  81. }
  82. });
  83. }