Finish task and display finished tasks correctly

This commit is contained in:
Sebastian 2023-10-26 10:02:03 +02:00
parent 80dc508e67
commit bcc9b4760f
5 changed files with 23 additions and 10 deletions

View File

@ -4,10 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix starting schedule and returning active time of schedule after stop"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Remove update spamming in console">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/BasicTaskSchedule.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/BasicTaskSchedule.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/dashboard/active-schedule/active-schedule.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/dashboard/active-schedule/active-schedule.component.ts" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -101,7 +100,7 @@
<workItem from="1698127431684" duration="2039000" /> <workItem from="1698127431684" duration="2039000" />
<workItem from="1698164397550" duration="2329000" /> <workItem from="1698164397550" duration="2329000" />
<workItem from="1698246651541" duration="5106000" /> <workItem from="1698246651541" duration="5106000" />
<workItem from="1698298897364" duration="3234000" /> <workItem from="1698298897364" duration="3634000" />
</task> </task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies"> <task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -199,7 +198,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1698306442833</updated> <updated>1698306442833</updated>
</task> </task>
<option name="localTasksCounter" value="13" /> <task id="LOCAL-00013" summary="Remove update spamming in console">
<option name="closed" value="true" />
<created>1698306889808</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1698306889808</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -220,7 +227,8 @@
<MESSAGE value="Stop and Finish TaskSchedules" /> <MESSAGE value="Stop and Finish TaskSchedules" />
<MESSAGE value="Include TaskScheduleStopResponse" /> <MESSAGE value="Include TaskScheduleStopResponse" />
<MESSAGE value="Fix starting schedule and returning active time of schedule after stop" /> <MESSAGE value="Fix starting schedule and returning active time of schedule after stop" />
<option name="LAST_COMMIT_MESSAGE" value="Fix starting schedule and returning active time of schedule after stop" /> <MESSAGE value="Remove update spamming in console" />
<option name="LAST_COMMIT_MESSAGE" value="Remove update spamming in console" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@ -180,7 +180,7 @@ public class ScheduleController {
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed")); return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
} }
ServiceResult<Integer> stopResult = taskScheduleService.stopSchedule(schedulePermissionResult.getResult()); ServiceResult<Integer> stopResult = taskScheduleService.stopSchedule(schedulePermissionResult.getResult(), finish);
if(stopResult.getExitCode() == ServiceExitCode.INVALID_OPERATION) { if(stopResult.getExitCode() == ServiceExitCode.INVALID_OPERATION) {
return ResponseEntity.status(400).body(new SimpleStatusResponse("failed")); return ResponseEntity.status(400).body(new SimpleStatusResponse("failed"));
} else { } else {

View File

@ -115,7 +115,7 @@ public class TaskScheduleService {
} }
} }
public ServiceResult<Integer> stopSchedule(BasicTaskSchedule taskSchedule) { public ServiceResult<Integer> stopSchedule(BasicTaskSchedule taskSchedule, boolean finish) {
if(taskSchedule.getStartTime() == null || taskSchedule.getFinishedTime() != null) { if(taskSchedule.getStartTime() == null || taskSchedule.getFinishedTime() != null) {
return new ServiceResult<>(ServiceExitCode.INVALID_OPERATION); return new ServiceResult<>(ServiceExitCode.INVALID_OPERATION);
} }
@ -125,6 +125,9 @@ public class TaskScheduleService {
long workTime = (taskSchedule.getTask().getWorkTime() + activeTime); long workTime = (taskSchedule.getTask().getWorkTime() + activeTime);
int workTime_i = (int) (workTime); int workTime_i = (int) (workTime);
taskSchedule.getTask().setWorkTime(workTime_i); taskSchedule.getTask().setWorkTime(workTime_i);
if(finish) {
taskSchedule.getTask().setFinished(true);
}
basicTaskScheduleRepository.save(taskSchedule); basicTaskScheduleRepository.save(taskSchedule);
taskRepository.save(taskSchedule.getTask()); taskRepository.save(taskSchedule.getTask());
return new ServiceResult<>((int) activeTime); return new ServiceResult<>((int) activeTime);

View File

@ -29,7 +29,7 @@
<ng-container matColumnDef="finished"> <ng-container matColumnDef="finished">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Finished </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Finished </th>
<td mat-cell *matCellDef="let task"> <td mat-cell *matCellDef="let task">
<mat-checkbox [value]="task.finished" [contentEditable]="false" disableRipple="true" (click)="$event.preventDefault()"></mat-checkbox> <mat-checkbox [checked]="task.finished" [contentEditable]="false" disableRipple="true" (click)="$event.preventDefault()"></mat-checkbox>
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="status"> <ng-container matColumnDef="status">

View File

@ -22,6 +22,8 @@ export class TaskDashboardComponent implements OnChanges{
this.datasource = new MatTableDataSource<TaskEntityInfo>(resp); this.datasource = new MatTableDataSource<TaskEntityInfo>(resp);
this.datasource.paginator = this.paginator!; this.datasource.paginator = this.paginator!;
this.datasource.sort = this.sort!; this.datasource.sort = this.sort!;
resp.forEach(task => console.log(task))
} }
}) })
} }