diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-20 00:34:43 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-28 17:28:10 +0200 |
commit | 4d6a21a3795355a4e94d60dcc468db81fdc4a47e (patch) | |
tree | b7aaade242066a8527732b9f1fa9627f20fb89fa | |
parent | 8ec53608b0b1f6fad1569933bc05b723bd2bd2fc (diff) | |
download | nextcloud-server-4d6a21a3795355a4e94d60dcc468db81fdc4a47e.tar.gz nextcloud-server-4d6a21a3795355a4e94d60dcc468db81fdc4a47e.zip |
refactor(core): Make AJAX cron script work without jQuery
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | core/Listener/BeforeTemplateRenderedListener.php | 2 | ||||
-rw-r--r-- | core/js/backgroundjobs.js | 13 | ||||
-rw-r--r-- | core/js/public/publicpage.js | 1 | ||||
-rw-r--r-- | core/src/ajax-cron.ts | 18 | ||||
-rw-r--r-- | webpack.modules.js | 1 |
5 files changed, 20 insertions, 15 deletions
diff --git a/core/Listener/BeforeTemplateRenderedListener.php b/core/Listener/BeforeTemplateRenderedListener.php index 0eff924d1f8..664138518e0 100644 --- a/core/Listener/BeforeTemplateRenderedListener.php +++ b/core/Listener/BeforeTemplateRenderedListener.php @@ -54,7 +54,7 @@ class BeforeTemplateRenderedListener implements IEventListener { // If installed and background job is set to ajax, add dedicated script if ($this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { - Util::addScript('core', 'backgroundjobs'); + Util::addScript('core', 'ajax-cron'); } } } diff --git a/core/js/backgroundjobs.js b/core/js/backgroundjobs.js deleted file mode 100644 index ec5ae24d262..00000000000 --- a/core/js/backgroundjobs.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2012 Jakob Sack owncloud@jakobsack.de - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -// start worker once page has loaded -window.addEventListener('DOMContentLoaded', function(){ - $.get( OC.getRootPath()+'/cron.php' ); - - $('.section .icon-info').tooltip({ - placement: 'right' - }); -}); diff --git a/core/js/public/publicpage.js b/core/js/public/publicpage.js index af473045413..340fb56d9f1 100644 --- a/core/js/public/publicpage.js +++ b/core/js/public/publicpage.js @@ -14,7 +14,6 @@ window.addEventListener('DOMContentLoaded', function () { $('#remote_address').focus(); }); - $(document).mouseup(function(e) { var toggle = $('#body-public').find('.header-right .menutoggle'); var container = toggle.next('.popovermenu'); diff --git a/core/src/ajax-cron.ts b/core/src/ajax-cron.ts new file mode 100644 index 00000000000..d903a3596ea --- /dev/null +++ b/core/src/ajax-cron.ts @@ -0,0 +1,18 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { getRootUrl } from '@nextcloud/router' +import logger from './logger' + +window.addEventListener('DOMContentLoaded', async () => { + // When the page is loaded send GET to the cron endpoint to trigger background jobs + try { + logger.debug('Running web cron') + await window.fetch(`${getRootUrl()}/cron.php`) + logger.debug('Web cron successfull') + } catch (e) { + logger.debug('Running web cron failed', { error: e }) + } +}) diff --git a/webpack.modules.js b/webpack.modules.js index 28c9946d65e..d13ad284bab 100644 --- a/webpack.modules.js +++ b/webpack.modules.js @@ -11,6 +11,7 @@ module.exports = { init: path.join(__dirname, 'apps/comments/src', 'init.ts'), }, core: { + 'ajax-cron': path.join(__dirname, 'core/src', 'ajax-cron.ts'), files_client: path.join(__dirname, 'core/src', 'files/client.js'), files_fileinfo: path.join(__dirname, 'core/src', 'files/fileinfo.js'), install: path.join(__dirname, 'core/src', 'install.js'), |