Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
type="list"
label="JGLOBAL_SORT_BY"
class="js-select-submit-on-change"
default="a.title ASC"
default="a.next_execution ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
Expand All @@ -59,6 +59,8 @@
<option value="j.type_title DESC">COM_SCHEDULER_TASK_TYPE_DESC</option>
<option value="a.last_execution ASC">COM_SCHEDULER_LAST_RUN_ASC</option>
<option value="a.last_execution DESC">COM_SCHEDULER_LAST_RUN_DESC</option>
<option value="a.next_execution ASC">COM_SCHEDULER_NEXT_RUN_ASC</option>
<option value="a.next_execution DESC">COM_SCHEDULER_NEXT_RUN_DESC</option>
<option value="a.priority ASC">COM_SCHEDULER_TASK_PRIORITY_ASC</option>
<option value="a.priority DESC">COM_SCHEDULER_TASK_PRIORITY_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
Expand Down
17 changes: 14 additions & 3 deletions administrator/components/com_scheduler/src/Model/TasksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static function (TaskOption $taskOption): string {
$multiOrdering = $this->state->get('list.multi_ordering');

if (!$multiOrdering || !\is_array($multiOrdering)) {
$orderCol = $this->state->get('list.ordering', 'a.title');
$orderCol = $this->state->get('list.ordering', 'a.next_execution');
$orderDir = $this->state->get('list.direction', 'asc');

// Type title ordering is handled exceptionally in _getList()
Expand Down Expand Up @@ -366,7 +366,7 @@ static function (TaskOption $taskOption): string {
protected function _getList($query, $limitstart = 0, $limit = 0): array
{
// Get stuff from the model state
$listOrder = $this->getState('list.ordering', 'a.title');
$listOrder = $this->getState('list.ordering', 'a.next_execution');
$listDirectionN = strtolower($this->getState('list.direction', 'asc')) === 'desc' ? -1 : 1;

// Set limit parameters and get object list
Expand Down Expand Up @@ -433,7 +433,7 @@ private function attachTaskOptions(array $items): void
* @return void
* @since 4.1.0
*/
protected function populateState($ordering = 'a.title', $direction = 'ASC'): void
protected function populateState($ordering = 'a.next_execution', $direction = 'ASC'): void
{
// Call the parent method
parent::populateState($ordering, $direction);
Expand Down Expand Up @@ -468,4 +468,15 @@ public function hasDueTasks(Date $time): bool
// False if we don't have due tasks, or we have locked tasks
return $taskDetails && $taskDetails->due_count && !$taskDetails->locked_count;
}

/**
* Check if we have right now any enabled due tasks and no locked tasks.
*
* @return boolean
* @since __DEPLOY_VERSION__
*/
public function getHasDueTasks()
{
return $this->hasDueTasks(Factory::getDate('now', 'UTC'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function display($tpl = null): void
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->hasDueTasks = $this->get('hasDueTasks');

if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('empty_state');
Expand Down
16 changes: 16 additions & 0 deletions administrator/components/com_scheduler/tmpl/tasks/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
$saveOrderingUrl = 'index.php?option=com_scheduler&task=tasks.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
HTMLHelper::_('draggablelist.draggable');
}

// When there are due Tasks show that information to the user
if ($this->hasDueTasks === true) {
$app->enqueueMessage(Text::_('COM_SCHEDULER_MSG_DUETASKS'), 'warning');
}

?>

<form action="<?php echo Route::_('index.php?option=com_scheduler&view=tasks'); ?>" method="post" name="adminForm"
Expand Down Expand Up @@ -129,6 +135,11 @@ class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_LAST_RUN_DATE', 'a.last_execution', $listDirn, $listOrder) ?>
</th>

<!-- Next runs -->
<th scope="col" class="d-none d-lg-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_NEXT_RUN_DATE', 'a.next_execution', $listDirn, $listOrder) ?>
</th>

<!-- Test task -->
<th scope="col" class="d-none d-md-table-cell">
<?php echo Text::_('COM_SCHEDULER_TEST_TASK'); ?>
Expand Down Expand Up @@ -239,6 +250,11 @@ class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="
<?php echo $item->last_execution ? HTMLHelper::_('date', $item->last_execution, 'DATE_FORMAT_LC5') : '-'; ?>
</td>

<!-- Next run date -->
<td class="small d-none d-lg-table-cell">
<?php echo $item->next_execution ? HTMLHelper::_('date', $item->next_execution, 'DATE_FORMAT_LC5') : Text::_('COM_SCHEDULER_NEXT_RUN_MANUAL'); ?>
</td>

<!-- Test task -->
<td class="small d-none d-md-table-cell">
<button type="button" class="btn btn-sm btn-warning" <?php echo $item->state < 0 ? 'disabled' : ''; ?>
Expand Down
5 changes: 5 additions & 0 deletions administrator/language/en-GB/com_scheduler.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ COM_SCHEDULER_MANAGER_TASKS="Scheduled Tasks"
COM_SCHEDULER_MANAGER_TASK_EDIT="Edit Task"
COM_SCHEDULER_MANAGER_TASK_NEW="New Task"
COM_SCHEDULER_MANAGER_TOOLTIP_TASK_FAILING="Task failed. Exit code: %1$d"
COM_SCHEDULER_NEXT_RUN_ASC="Next Run ascending"
COM_SCHEDULER_NEXT_RUN_DATE="Next Run Date"
COM_SCHEDULER_NEXT_RUN_DESC="Next Run descending"
COM_SCHEDULER_NEXT_RUN_MANUAL="Manual"
COM_SCHEDULER_MSG_DUETASKS="There is at least one due task which should have already run. Please make sure that at least one cron scheduler is enabled and running."
COM_SCHEDULER_MSG_MANAGE_NO_TASK_PLUGINS="There are no task types matching your query."
COM_SCHEDULER_NEW_TASK="New Task"
COM_SCHEDULER_N_ITEMS_CHECKED_IN_1="Task checked in."
Expand Down