Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions wcfsetup/install/files/acp/js/WCF.ACP.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,110 +16,6 @@ WCF.ACP = { };
*/
WCF.ACP.Application = { };

/**
* Namespace for ACP cronjob management.
*/
WCF.ACP.Cronjob = { };

/**
* Handles the manual execution of cronjobs.
*/
WCF.ACP.Cronjob.ExecutionHandler = Class.extend({
/**
* notification object
* @var WCF.System.Notification
*/
_notification: null,

/**
* action proxy
* @var WCF.Action.Proxy
*/
_proxy: null,

/**
* Initializes WCF.ACP.Cronjob.ExecutionHandler object.
*/
init: function() {
this._proxy = new WCF.Action.Proxy({
success: $.proxy(this._success, this)
});

$('.jsCronjobRow .jsExecuteButton').click($.proxy(this._click, this));

this._notification = new WCF.System.Notification(WCF.Language.get('wcf.global.success'), 'success');
},

/**
* Handles a click on an execute button.
*
* @param object event
*/
_click: function(event) {
this._proxy.setOption('data', {
actionName: 'execute',
className: 'wcf\\data\\cronjob\\CronjobAction',
objectIDs: [ $(event.target).data('objectID') ]
});

this._proxy.sendRequest();
},

/**
* Handles successful cronjob execution.
*
* @param object data
* @param string textStatus
* @param jQuery jqXHR
*/
_success: function(data, textStatus, jqXHR) {
$('.jsCronjobRow').each($.proxy(function(index, row) {
var $button = $(row).find('.jsExecuteButton');
var $objectID = ($button).data('objectID');

if (WCF.inArray($objectID, data.objectIDs)) {
if (data.returnValues[$objectID]) {
// insert feedback here
$(row).find('td.columnNextExec').html(data.returnValues[$objectID].formatted);
$(row).wcfHighlight();
}

this._notification.show();

return false;
}
}, this));
}
});

/**
* Handles the cronjob log list.
*/
WCF.ACP.Cronjob.LogList = Class.extend({
/**
* Initializes WCF.ACP.Cronjob.LogList object.
*/
init: function() {
// bind event listener to delete cronjob log button
$('.jsCronjobLogDelete').click(function() {
WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.cronjob.log.clear.confirm'), function(action) {
if (action == 'confirm') {
new WCF.Action.Proxy({
autoSend: true,
data: {
actionName: 'clearAll',
className: 'wcf\\data\\cronjob\\log\\CronjobLogAction'
},
success: function() {
window.location.reload();
}
});
}
});
});
}
});

/**
* Namespace for ACP package management.
*/
Expand Down
118 changes: 4 additions & 114 deletions wcfsetup/install/files/acp/templates/cronjobList.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{include file='header' pageTitle='wcf.acp.cronjob.list'}

<script data-relocate="true">
$(function() {
new WCF.ACP.Cronjob.ExecutionHandler();
});
</script>

<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.cronjob.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
<h1 class="contentTitle">{lang}wcf.acp.cronjob.list{/lang}</h1>
<p class="contentHeaderDescription">{lang}wcf.acp.cronjob.subtitle{/lang}</p>
</div>

Expand All @@ -21,112 +15,8 @@
</nav>
</header>

{hascontent}
<div class="paginationTop">
{content}{pages print=true assign=pagesLinks controller="CronjobList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
</div>
{/hascontent}

{hascontent}
<div class="section tabularBox">
<table class="table jsObjectActionContainer" data-object-action-class-name="wcf\data\cronjob\CronjobAction">
<thead>
<tr>
<th class="columnID columnCronjobID{if $sortField == 'cronjobID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='CronjobList'}pageNo={@$pageNo}&sortField=cronjobID&sortOrder={if $sortField == 'cronjobID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnText columnExpression"><span>{lang}wcf.acp.cronjob.expression{/lang}</span></th>
<th class="columnText columnDescription{if $sortField == 'descriptionI18n'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobList'}pageNo={@$pageNo}&sortField=descriptionI18n&sortOrder={if $sortField == 'descriptionI18n' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.description{/lang}</a></th>
<th class="columnText columnPackage{if $sortField == 'packageID'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobList'}pageNo={@$pageNo}&sortField=packageID&sortOrder={if $sortField == 'packageID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.package.name{/lang}</a></th>
<th class="columnDate columnNextExec{if $sortField == 'nextExec'} active {@$sortOrder}{/if}"><a href="{link controller='CronjobList'}pageNo={@$pageNo}&sortField=nextExec&sortOrder={if $sortField == 'nextExec' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.cronjob.nextExec{/lang}</a></th>

{event name='columnHeads'}
</tr>
</thead>

<tbody class="jsReloadPageWhenEmpty">
{content}
{foreach from=$objects item=cronjob}
<tr class="jsCronjobRow jsObjectActionObject" data-object-id="{@$cronjob->getObjectID()}">
<td class="columnIcon">
<button type="button" class="jsExecuteButton jsTooltip" title="{lang}wcf.acp.cronjob.execute{/lang}" data-object-id="{@$cronjob->cronjobID}">
{icon name='play'}
</button>

{if $cronjob->canBeDisabled()}
{objectAction action="toggle" isDisabled=$cronjob->isDisabled}
{else}
{if !$cronjob->isDisabled}
<span class="disabled" title="{lang}wcf.global.button.disable{/lang}">
{icon name='square-check'}
</span>
{else}
<span class="disabled" title="{lang}wcf.global.button.enable{/lang}">
{icon name='square'}
</span>
{/if}
{/if}

{if $cronjob->isEditable()}
<a href="{link controller='CronjobEdit' id=$cronjob->cronjobID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip">{icon name='pencil'}</a>
{else}
<span class="disabled" title="{lang}wcf.global.button.edit{/lang}">
{icon name='pencil'}
</span>
{/if}
{if $cronjob->isDeletable()}
{objectAction action="delete" objectTitle=$cronjob->getDescription()}
{else}
<span class="disabled" title="{lang}wcf.global.button.delete{/lang}">
{icon name='xmark'}
</span>
{/if}

{event name='rowButtons'}
</td>
<td class="columnID">{@$cronjob->cronjobID}</td>
<td class="columnText columnExpression">
<kbd>{$cronjob->getExpression()}</kbd>
</td>
<td class="columnText columnDescription">
{if $cronjob->isEditable()}
<a title="{lang}wcf.acp.cronjob.edit{/lang}" href="{link controller='CronjobEdit' id=$cronjob->cronjobID}{/link}">{$cronjob->getDescription()}</a>
{else}
{$cronjob->getDescription()}
{/if}
</td>
<td class="columnText columnPackage">
{$cronjob->getPackage()}
</td>
<td class="columnDate columnNextExec">
{if !$cronjob->isDisabled && $cronjob->nextExec != 1}
{@$cronjob->nextExec|plainTime}
{/if}
</td>

{event name='columns'}
</tr>
{/foreach}
{/content}
</tbody>
</table>
</div>
{hascontentelse}
<woltlab-core-notice type="info">{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
{/hascontent}

<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{@$pagesLinks}{/content}
</div>
{/hascontent}

<nav class="contentFooterNavigation">
<ul>
<li><a href="{link controller='CronjobAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.cronjob.add{/lang}</span></a></li>

{event name='contentFooterNavigation'}
</ul>
</nav>
</footer>
<div class="section">
{unsafe:$gridView->render()}
</div>

{include file='footer'}
50 changes: 11 additions & 39 deletions wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

namespace wcf\acp\page;

use wcf\data\cronjob\I18nCronjobList;
use wcf\page\SortablePage;
use wcf\page\AbstractGridViewPage;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\admin\CronjobGridView;

/**
* Shows information about configured cron jobs.
*
* @author Alexander Ebert
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @author Olaf Braun, Alexander Ebert
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*
* @property I18nCronjobList $objectList
* @property CronjobGridView $gridView
*/
class CronjobListPage extends SortablePage
class CronjobListPage extends AbstractGridViewPage
{
/**
* @inheritDoc
Expand All @@ -26,38 +27,9 @@ class CronjobListPage extends SortablePage
*/
public $neededPermissions = ['admin.management.canManageCronjob'];

/**
* @inheritDoc
*/
public $defaultSortField = 'descriptionI18n';

/**
* @inheritDoc
*/
public $itemsPerPage = 100;

/**
* @inheritDoc
*/
public $validSortFields = [
'cronjobID',
'nextExec',
'descriptionI18n',
'packageID',
];

/**
* @inheritDoc
*/
public $objectListClassName = I18nCronjobList::class;

/**
* @inheritDoc
*/
public function initObjectList()
#[\Override]
protected function createGridViewController(): AbstractGridView
{
parent::initObjectList();

$this->sqlOrderBy = "cronjob." . $this->sortField . " " . $this->sortOrder;
return new CronjobGridView();
}
}
4 changes: 4 additions & 0 deletions wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ static function (\wcf\event\endpoint\ControllerCollecting $event) {
$event->register(new \wcf\system\endpoint\controller\core\users\ranks\DeleteUserRank());
$event->register(new \wcf\system\endpoint\controller\core\interactions\GetBulkContextMenuOptions());
$event->register(new \wcf\system\endpoint\controller\core\interactions\GetContextMenuOptions());
$event->register(new \wcf\system\endpoint\controller\core\cronjobs\EnableCronjob());
$event->register(new \wcf\system\endpoint\controller\core\cronjobs\DisableCronjob());
$event->register(new \wcf\system\endpoint\controller\core\cronjobs\DeleteCronjob());
$event->register(new \wcf\system\endpoint\controller\core\cronjobs\ExecuteCronjob());
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\gridView\admin;

use wcf\event\IPsr14Event;
use wcf\system\gridView\admin\CronjobGridView;

/**
* Indicates that the cronjob grid view has been initialized.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class CronjobGridViewInitialized implements IPsr14Event
{
public function __construct(public readonly CronjobGridView $gridView)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\admin\CronjobInteractions;

/**
* Indicates that the provider for cronjob interactions is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class CronjobInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly CronjobInteractions $provider)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\bulk\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\bulk\admin\CronjobBulkInteractions;

/**
* Indicates that the provider for cronjob bulk interactions is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class CronjobBulkInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly CronjobBulkInteractions $provider)
{
}
}
Loading