admin.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright (c) 2016 ownCloud Inc
  3. *
  4. * @author Lukas Reschke <lukas@owncloud.com>
  5. *
  6. * This file is licensed under the Affero General Public License version 3
  7. * or later.
  8. *
  9. * See the COPYING-README file.
  10. *
  11. */
  12. /**
  13. * Creates a new authentication token and loads the updater URL
  14. */
  15. var loginToken = '';
  16. $(document).ready(function(){
  17. $('#oca_updatenotification_button').click(function() {
  18. // Load the new token
  19. $.ajax({
  20. url: OC.generateUrl('/apps/updatenotification/credentials')
  21. }).success(function(data) {
  22. loginToken = data;
  23. $.ajax({
  24. url: OC.webroot+'/updater/',
  25. headers: {
  26. 'X-Updater-Auth': loginToken
  27. },
  28. method: 'POST',
  29. success: function(data){
  30. if(data !== 'false') {
  31. var body = $('body');
  32. $('head').remove();
  33. body.html(data);
  34. body.removeAttr('id');
  35. body.attr('id', 'body-settings');
  36. }
  37. },
  38. error: function(){
  39. OC.Notification.showTemporary(t('updatenotification', 'Could not start updater, please try the manual update'));
  40. $('#oca_updatenotification_button').addClass('hidden');
  41. $('#oca_updatenotification_section .button').removeClass('hidden');
  42. }
  43. });
  44. });
  45. });
  46. $('#release-channel').change(function() {
  47. var newChannel = $('#release-channel').find(":selected").val();
  48. if (newChannel === 'git' || newChannel === 'daily') {
  49. $('#oca_updatenotification_groups em').removeClass('hidden');
  50. } else {
  51. $('#oca_updatenotification_groups em').addClass('hidden');
  52. }
  53. $.post(
  54. OC.generateUrl('/apps/updatenotification/channel'),
  55. {
  56. 'channel': newChannel
  57. },
  58. function(data){
  59. OC.msg.finishedAction('#channel_save_msg', data);
  60. }
  61. );
  62. });
  63. var $notificationTargetGroups = $('#oca_updatenotification_groups_list');
  64. OC.Settings.setupGroupsSelect($notificationTargetGroups);
  65. $notificationTargetGroups.change(function(ev) {
  66. var groups = ev.val || [];
  67. groups = JSON.stringify(groups);
  68. OCP.AppConfig.setValue('updatenotification', 'notify_groups', groups);
  69. });
  70. });