admin.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. $(document).ready(function(){
  2. var params = OC.Util.History.parseUrlQuery();
  3. // Hack to add a trusted domain
  4. if (params.trustDomain) {
  5. OC.dialogs.confirm(t('settings', 'Are you really sure you want add "{domain}" as trusted domain?',
  6. {domain: params.trustDomain}),
  7. t('settings', 'Add trusted domain'), function(answer) {
  8. if(answer) {
  9. $.ajax({
  10. type: 'POST',
  11. url: OC.generateUrl('settings/admin/security/trustedDomains'),
  12. data: { newTrustedDomain: params.trustDomain }
  13. }).done(function() {
  14. window.location.replace(OC.generateUrl('settings/admin'));
  15. });
  16. }
  17. });
  18. }
  19. $('#excludedGroups').each(function (index, element) {
  20. OC.Settings.setupGroupsSelect($(element));
  21. $(element).change(function(ev) {
  22. var groups = ev.val || [];
  23. if (groups.length > 0) {
  24. groups = ev.val.join(','); // FIXME: make this JSON
  25. } else {
  26. groups = '';
  27. }
  28. OC.AppConfig.setValue('core', $(this).attr('name'), groups);
  29. });
  30. });
  31. $('#loglevel').change(function(){
  32. $.post(OC.generateUrl('/settings/admin/log/level'), {level: $(this).val()},function(){
  33. OC.Log.reload();
  34. } );
  35. });
  36. $('#backgroundjobs span.crondate').tipsy({fade: true, gravity: 's', live: true});
  37. $('#backgroundjobs input').change(function(){
  38. if($(this).attr('checked')){
  39. var mode = $(this).val();
  40. if (mode === 'ajax' || mode === 'webcron' || mode === 'cron') {
  41. OC.AppConfig.setValue('core', 'backgroundjobs_mode', mode);
  42. }
  43. }
  44. });
  45. $('#shareAPIEnabled').change(function() {
  46. $('#shareAPI p:not(#enable)').toggleClass('hidden', !this.checked);
  47. });
  48. $('#encryptionEnabled').change(function() {
  49. $('#encryptionAPI div#selectEncryptionModules').toggleClass('hidden');
  50. });
  51. $('#encryptionAPI input').change(function() {
  52. var value = $(this).val();
  53. if ($(this).attr('type') === 'checkbox') {
  54. if (this.checked) {
  55. value = 'yes';
  56. } else {
  57. value = 'no';
  58. }
  59. }
  60. OC.AppConfig.setValue('core', $(this).attr('name'), value);
  61. });
  62. $('#shareAPI input:not(#excludedGroups)').change(function() {
  63. var value = $(this).val();
  64. if ($(this).attr('type') === 'checkbox') {
  65. if (this.checked) {
  66. value = 'yes';
  67. } else {
  68. value = 'no';
  69. }
  70. }
  71. OC.AppConfig.setValue('core', $(this).attr('name'), value);
  72. });
  73. $('#shareapiDefaultExpireDate').change(function() {
  74. $("#setDefaultExpireDate").toggleClass('hidden', !this.checked);
  75. });
  76. $('#allowLinks').change(function() {
  77. $("#publicLinkSettings").toggleClass('hidden', !this.checked);
  78. $('#setDefaultExpireDate').toggleClass('hidden', !(this.checked && $('#shareapiDefaultExpireDate')[0].checked));
  79. });
  80. $('#mail_smtpauth').change(function() {
  81. if (!this.checked) {
  82. $('#mail_credentials').addClass('hidden');
  83. } else {
  84. $('#mail_credentials').removeClass('hidden');
  85. }
  86. });
  87. $('#mail_smtpmode').change(function() {
  88. if ($(this).val() !== 'smtp') {
  89. $('#setting_smtpauth').addClass('hidden');
  90. $('#setting_smtphost').addClass('hidden');
  91. $('#mail_smtpsecure_label').addClass('hidden');
  92. $('#mail_smtpsecure').addClass('hidden');
  93. $('#mail_credentials').addClass('hidden');
  94. } else {
  95. $('#setting_smtpauth').removeClass('hidden');
  96. $('#setting_smtphost').removeClass('hidden');
  97. $('#mail_smtpsecure_label').removeClass('hidden');
  98. $('#mail_smtpsecure').removeClass('hidden');
  99. if ($('#mail_smtpauth').attr('checked')) {
  100. $('#mail_credentials').removeClass('hidden');
  101. }
  102. }
  103. });
  104. $('#mail_general_settings_form').change(function(){
  105. OC.msg.startSaving('#mail_settings_msg');
  106. var post = $( "#mail_general_settings_form" ).serialize();
  107. $.post(OC.generateUrl('/settings/admin/mailsettings'), post, function(data){
  108. OC.msg.finishedSaving('#mail_settings_msg', data);
  109. });
  110. });
  111. $('#mail_credentials_settings_submit').click(function(){
  112. OC.msg.startSaving('#mail_settings_msg');
  113. var post = $( "#mail_credentials_settings" ).serialize();
  114. $.post(OC.generateUrl('/settings/admin/mailsettings/credentials'), post, function(data){
  115. OC.msg.finishedSaving('#mail_settings_msg', data);
  116. });
  117. });
  118. $('#sendtestemail').click(function(event){
  119. event.preventDefault();
  120. OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending...'));
  121. $.post(OC.generateUrl('/settings/admin/mailtest'), '', function(data){
  122. OC.msg.finishedAction('#sendtestmail_msg', data);
  123. });
  124. });
  125. $('#shareapiExcludeGroups').change(function() {
  126. $("#selectExcludedGroups").toggleClass('hidden', !this.checked);
  127. });
  128. // run setup checks then gather error messages
  129. $.when(
  130. OC.SetupChecks.checkWebDAV(),
  131. OC.SetupChecks.checkSetup(),
  132. OC.SetupChecks.checkGeneric()
  133. ).then(function(check1, check2, check3) {
  134. var errors = [].concat(check1, check2, check3);
  135. var $el = $('#postsetupchecks');
  136. var $errorsEl;
  137. $el.find('.loading').addClass('hidden');
  138. if (errors.length === 0) {
  139. } else {
  140. $errorsEl = $el.find('.errors');
  141. for (var i = 0; i < errors.length; i++ ) {
  142. $errorsEl.append('<li>' + errors[i] + '</li>');
  143. }
  144. $errorsEl.removeClass('hidden');
  145. $el.find('.hint').removeClass('hidden');
  146. }
  147. });
  148. });