Skip to content

Commit e67a1ec

Browse files
author
Bernhard Schmitt
committed
Add option to show completed tasks
1 parent c020940 commit e67a1ec

File tree

6 files changed

+69
-2
lines changed

6 files changed

+69
-2
lines changed

Classes/Application/Controller/BitzerController.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,24 @@ final class BitzerController extends ModuleController
5757

5858
private \DateInterval $upcomingInterval;
5959

60+
private bool $showCompletedTasks;
61+
6062
public function __construct(
6163
Bitzer $bitzer,
6264
Schedule $schedule,
6365
AgentRepository $agentRepository,
6466
Translator $translator,
6567
TaskClassNameRepository $taskClassNameRepository,
66-
string $upcomingInterval
68+
string $upcomingInterval,
69+
bool $showCompletedTasks
6770
) {
6871
$this->bitzer = $bitzer;
6972
$this->schedule = $schedule;
7073
$this->agentRepository = $agentRepository;
7174
$this->translator = $translator;
7275
$this->taskClassNameRepository = $taskClassNameRepository;
7376
$this->upcomingInterval = new \DateInterval($upcomingInterval);
77+
$this->showCompletedTasks = $showCompletedTasks;
7478
}
7579

7680
public function indexAction(array $module = []): void
@@ -164,6 +168,7 @@ public function myScheduleAction(): void
164168
$this->view->setFusionPath('mySchedule');
165169
$this->view->assignMultiple([
166170
'groupedTasks' => $groupedTasks,
171+
'completedTasks' => $this->showCompletedTasks ? $this->schedule->findCompleted(null, $agents) : null,
167172
'labels' => [
168173
'task.scheduledTime.label' => $this->getLabel('task.scheduledTime.label'),
169174
'task.actionStatus.label' => $this->getLabel('task.actionStatus.label'),

Classes/Domain/Task/Schedule.php

+32
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,38 @@ final public function findPastDueDueAndUpcoming(\DateInterval $upcomingInterval,
144144
return $groupedTasks;
145145
}
146146

147+
/**
148+
* @throws DbalException
149+
* @throws DriverException
150+
*/
151+
final public function findCompleted(?TaskClassName $taskClassName = null, ?Agents $agents = null): Tasks
152+
{
153+
$query = 'SELECT * FROM ' . self::TABLE_NAME . '
154+
WHERE actionstatus = :actionStatusType';
155+
$parameters = [
156+
'actionStatusType' => ActionStatusType::TYPE_COMPLETED
157+
];
158+
if ($taskClassName) {
159+
$query .= ' AND classname = :taskClassName';
160+
$params['taskClassName'] = $taskClassName->getValue();
161+
}
162+
163+
if ($agents) {
164+
$parameters['agentIdentifiers'] = $agents->getIdentifiers();
165+
$types['agentIdentifiers'] = Connection::PARAM_STR_ARRAY;
166+
$query .= ' AND agent IN (:agentIdentifiers)';
167+
}
168+
$query .= ' ORDER BY scheduledtime ASC';
169+
170+
$rawDataSet = $this->databaseConnection->executeQuery(
171+
$query,
172+
$parameters,
173+
$types
174+
)->fetchAllAssociative();
175+
176+
return $this->createTasksFromTableRows($rawDataSet);
177+
}
178+
147179
/**
148180
* @throws DriverException
149181
* @throws DbalException

Configuration/Objects.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
arguments:
1818
6:
1919
setting: 'Sitegeist.Bitzer.upcomingInterval'
20+
7:
21+
setting: 'Sitegeist.Bitzer.mySchedule.showCompletedTasks'

Configuration/Settings.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ Sitegeist:
44
factories: [] # Here task factories can be registered as $taskClassName: $taskFactoryClassName
55
constraintCheckPlugins: [] # Here constraint check plugins registered as $taskClassName: {$taskFactoryClassName: $active}
66
taskAutoGenerationEnabled: true # Plugins may auto generate tasks on node events if this is enabled
7+
mySchedule:
8+
showCompletedTasks: false
79
fusion:
8-
autoInclude: [] # Here auto included fusion roots can be configured as $packageKey: $active
10+
autoInclude: [] # Here auto included fusion roots can be configured as $packageKey: $active

Resources/Private/Fusion/Application/MySchedule.fusion

+25
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ prototype(Sitegeist.Bitzer:Application.MySchedule) < prototype(Neos.Fusion:Compo
2020
<Sitegeist.Bitzer:MyScheduleTable @if.hasPastDueTasks={props.groupedTasks.pastDue} tasks={props.groupedTasks.pastDue} groupIdentifier="pastDue" />
2121
<Sitegeist.Bitzer:MyScheduleTable @if.hasDueTasks={props.groupedTasks.due} tasks={props.groupedTasks.due} groupIdentifier="due" />
2222
<Sitegeist.Bitzer:MyScheduleTable @if.hasUpcomingTasks={props.groupedTasks.upcoming} tasks={props.groupedTasks.upcoming} groupIdentifier="upcoming" />
23+
<Sitegeist.Bitzer:CompletedTable @if.hasCompletedTasks={props.completedTasks} tasks={props.completedTasks} />
2324
</tbody>
2425
</table>
2526
<Sitegeist.Bitzer:ToggleScript />`
@@ -57,3 +58,27 @@ prototype(Sitegeist.Bitzer:MyScheduleTable) < prototype(Neos.Fusion:Component) {
5758
</tr>
5859
</Neos.Fusion:Collection>`
5960
}
61+
62+
prototype(Sitegeist.Bitzer:CompletedTable) < prototype(Neos.Fusion:Component) {
63+
tasks = ${[]}
64+
65+
renderer = afx`
66+
<tr class="neos-folder">
67+
<td class="neos-priority1" colspan="7">{q(labels).get('actionStatusType.https://schema.org/CompletedActionStatus.label')}</td>
68+
<td class="neos-priority1 neos-aRight">
69+
<i class="fold-toggle icon-white fas fa-chevron-up" data-toggle={'fold-tasks_completed'}></i>
70+
</td>
71+
</tr>
72+
<Neos.Fusion:Collection collection={props.tasks} itemName="task">
73+
<tr class={'fold-tasks_completed'} style="display: table-row">
74+
<td><i class={'fas fa-' + task.image + ' icon-white'}></i></td>
75+
<td>{Date.format(task.scheduledTime, 'Y-m-d H:i')}</td>
76+
<td></td>
77+
<td>{task.shortType}</td>
78+
<td>{task.description}</td>
79+
<td>{task.agent.label}</td>
80+
<td>{task.object.label}</td>
81+
<td></td>
82+
</tr>
83+
</Neos.Fusion:Collection>`
84+
}

Resources/Private/Fusion/Root.fusion

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ index = Sitegeist.Bitzer:Application.Index {
77

88
mySchedule = Sitegeist.Bitzer:Application.MySchedule {
99
groupedTasks = ${groupedTasks}
10+
completedTasks = ${completedTasks}
1011
}
1112

1213
schedule = Sitegeist.Bitzer:Application.Schedule {

0 commit comments

Comments
 (0)