Merge pull request 'issue-96: Fix TaskStatus' (#104) from issue-96 into master
Reviewed-on: #104
This commit is contained in:
commit
13df4ac6fa
12
frontend/package-lock.json
generated
12
frontend/package-lock.json
generated
@ -7220,9 +7220,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.15.3",
|
"version": "1.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||||
"integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
|
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -8103,9 +8103,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ip": {
|
"node_modules/ip": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
|
||||||
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==",
|
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/ipaddr.js": {
|
"node_modules/ipaddr.js": {
|
||||||
|
@ -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 [checked]="task.finished" [contentEditable]="false" disableRipple="true" (click)="$event.preventDefault()"></mat-checkbox>
|
<mat-checkbox [checked]="task.finished" [contentEditable]="false" (click)="$event.preventDefault()"></mat-checkbox>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="status">
|
<ng-container matColumnDef="status">
|
||||||
|
@ -9,6 +9,7 @@ import {MatDialog} from "@angular/material/dialog";
|
|||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {ClearTaskDialogComponent, ClearTaskDialogData} from "../clear-task-dialog/clear-task-dialog.component";
|
import {ClearTaskDialogComponent, ClearTaskDialogData} from "../clear-task-dialog/clear-task-dialog.component";
|
||||||
import * as moment from "moment/moment";
|
import * as moment from "moment/moment";
|
||||||
|
import {TaskStatus, TaskStatusService} from "../task-status.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-task-dashboard',
|
selector: 'app-task-dashboard',
|
||||||
@ -39,7 +40,8 @@ export class TaskDashboardComponent implements OnChanges{
|
|||||||
|
|
||||||
constructor(private taskService: TaskService,
|
constructor(private taskService: TaskService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private snackbar: MatSnackBar) {
|
private snackbar: MatSnackBar,
|
||||||
|
public taskStatusService: TaskStatusService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,13 +55,8 @@ export class TaskDashboardComponent implements OnChanges{
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStatusOfTask(task: TaskEntityInfo) {
|
getStatusOfTask(task: TaskEntityInfo) {
|
||||||
if(moment(task.deadline, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isBefore(moment())) {
|
const taskStatus = this.taskStatusService.computeTaskStatus(task);
|
||||||
return "🔴";
|
return this.taskStatusService.convertTaskStatusToColor(taskStatus);
|
||||||
} else if(task.finishable && !task.hasPlannedSchedules){
|
|
||||||
return "🟠";
|
|
||||||
} else {
|
|
||||||
return "🟢";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTask(deletedTask: TaskEntityInfo) {
|
deleteTask(deletedTask: TaskEntityInfo) {
|
||||||
@ -108,4 +105,6 @@ export class TaskDashboardComponent implements OnChanges{
|
|||||||
data.push(task)
|
data.push(task)
|
||||||
this.datasource.data = data;
|
this.datasource.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly TaskStatus = TaskStatus;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import {TaskEditorComponent} from "../task-editor/task-editor.component";
|
|||||||
import {TaskEditorData} from "../task-editor/TaskEditorData";
|
import {TaskEditorData} from "../task-editor/TaskEditorData";
|
||||||
import * as moment from "moment";
|
import * as moment from "moment";
|
||||||
import {ScheduleDashboardComponent} from "../../schedules/schedule-dashboard/schedule-dashboard.component";
|
import {ScheduleDashboardComponent} from "../../schedules/schedule-dashboard/schedule-dashboard.component";
|
||||||
|
import {TaskStatusService} from "../task-status.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-task-detail-overview',
|
selector: 'app-task-detail-overview',
|
||||||
@ -53,7 +54,8 @@ export class TaskDetailOverviewComponent implements OnInit {
|
|||||||
private taskService: TaskService,
|
private taskService: TaskService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private scheduleService: ScheduleService,
|
private scheduleService: ScheduleService,
|
||||||
private router: Router) {
|
private router: Router,
|
||||||
|
private taskStatusService: TaskStatusService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -102,13 +104,8 @@ export class TaskDetailOverviewComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStatusOfTask(task: TaskEntityInfo ) {
|
getStatusOfTask(task: TaskEntityInfo ) {
|
||||||
if(moment(task.deadline, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isBefore(moment())) {
|
const taskStatus = this.taskStatusService.computeTaskStatus(task);
|
||||||
return "🔴";
|
return this.taskStatusService.convertTaskStatusToColor(taskStatus);
|
||||||
} else if(this.schedules.length == 0 && this.schedulesLoaded){
|
|
||||||
return "🟠";
|
|
||||||
} else {
|
|
||||||
return "🟢";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calcProgress() {
|
calcProgress() {
|
||||||
|
16
frontend/src/app/tasks/task-status.service.spec.ts
Normal file
16
frontend/src/app/tasks/task-status.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { TaskStatusService } from './task-status.service';
|
||||||
|
|
||||||
|
describe('TaskStatusService', () => {
|
||||||
|
let service: TaskStatusService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(TaskStatusService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
38
frontend/src/app/tasks/task-status.service.ts
Normal file
38
frontend/src/app/tasks/task-status.service.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {TaskEntityInfo} from "../../api";
|
||||||
|
import * as moment from "moment";
|
||||||
|
|
||||||
|
export enum TaskStatus {
|
||||||
|
OK,
|
||||||
|
WARNING,
|
||||||
|
ATTENTION,
|
||||||
|
DEAD
|
||||||
|
}
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class TaskStatusService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
computeTaskStatus(task: TaskEntityInfo): TaskStatus {
|
||||||
|
if(!task.finished && task.deadline != null && moment(task.deadline, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isBefore(moment())) {
|
||||||
|
return TaskStatus.DEAD;
|
||||||
|
} else if(!task.finished && task.deadline != null && !task.hasPlannedSchedules) {
|
||||||
|
return TaskStatus.ATTENTION
|
||||||
|
} else if(!task.finished && !task.hasPlannedSchedules) {
|
||||||
|
return TaskStatus.WARNING
|
||||||
|
} else {
|
||||||
|
return TaskStatus.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
convertTaskStatusToColor(taskStatus: TaskStatus) {
|
||||||
|
switch (taskStatus) {
|
||||||
|
case TaskStatus.OK: return "🟢";
|
||||||
|
case TaskStatus.WARNING: return "🟠";
|
||||||
|
case TaskStatus.ATTENTION: return "🔴";
|
||||||
|
case TaskStatus.DEAD: return "⚫";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user