Add new Tasks and Visualize Tasks

This commit is contained in:
Sebastian 2023-10-22 00:22:35 +02:00
parent 9c871043e5
commit bd56d601a0
12 changed files with 166 additions and 60 deletions

View File

@ -5,9 +5,16 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Datastructure for Tasks"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Datastructure for Tasks">
<change afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/TaskEditorData.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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/TaskController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/TaskController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.css" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.ts" afterDir="false" />
</list> </list>
@ -41,31 +48,31 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"RequestMappingsPanelOrder0": "0", &quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
"RequestMappingsPanelOrder1": "1", &quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
"RequestMappingsPanelWidth0": "75", &quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
"RequestMappingsPanelWidth1": "75", &quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"WebServerToolWindowFactoryState": "false", &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
"git-widget-placeholder": "issue-11-angular-update", &quot;git-widget-placeholder&quot;: &quot;issue-11-angular-update&quot;,
"last_directory_selection": "D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager", &quot;last_directory_selection&quot;: &quot;D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager&quot;,
"last_opened_file_path": "D:/Programmierprojekte/Dicewars/client", &quot;last_opened_file_path&quot;: &quot;D:/Programmierprojekte/Dicewars/client&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"settings.editor.selected.configurable": "preferences.lookFeel", &quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}, },
"keyToStringList": { &quot;keyToStringList&quot;: {
"DatabaseDriversLRU": [ &quot;DatabaseDriversLRU&quot;: [
"mariadb" &quot;mariadb&quot;
] ]
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true"> <configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<module name="demo" /> <module name="demo" />
@ -88,6 +95,7 @@
<workItem from="1696399523081" duration="666000" /> <workItem from="1696399523081" duration="666000" />
<workItem from="1696517800445" duration="3887000" /> <workItem from="1696517800445" duration="3887000" />
<workItem from="1696573678147" duration="111000" /> <workItem from="1696573678147" duration="111000" />
<workItem from="1697923629354" duration="1218000" />
</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" />

View File

@ -51,7 +51,7 @@ public class TaskController {
} }
} }
@PostMapping("/tasks/{taskgroupID}") @PutMapping("/tasks/{taskgroupID}")
public ResponseEntity<?> createTask(@PathVariable long taskgroupID, @RequestBody @Valid TaskFieldInfo taskFieldInfo) { public ResponseEntity<?> createTask(@PathVariable long taskgroupID, @RequestBody @Valid TaskFieldInfo taskFieldInfo) {
PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName()); PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName());
if(!taskgroupPermissionResult.isHasPermissions()) { if(!taskgroupPermissionResult.isHasPermissions()) {

View File

@ -18,6 +18,8 @@ public class TaskEntityInfo {
private boolean overdue; private boolean overdue;
private boolean finished;
public TaskEntityInfo(Task task) { public TaskEntityInfo(Task task) {
this.taskID = task.getTaskID(); this.taskID = task.getTaskID();
this.taskName = task.getTaskName(); this.taskName = task.getTaskName();
@ -25,6 +27,7 @@ public class TaskEntityInfo {
this.startDate = task.getStartDate(); this.startDate = task.getStartDate();
this.deadline = task.getDeadline(); this.deadline = task.getDeadline();
this.overdue = LocalDate.now().isAfter(task.getDeadline()); this.overdue = LocalDate.now().isAfter(task.getDeadline());
this.finished = task.isFinished();
} }
public long getTaskID() { public long getTaskID() {
@ -74,4 +77,12 @@ public class TaskEntityInfo {
public void setOverdue(boolean overdue) { public void setOverdue(boolean overdue) {
this.overdue = overdue; this.overdue = overdue;
} }
public boolean isFinished() {
return finished;
}
public void setFinished(boolean finished) {
this.finished = finished;
}
} }

View File

@ -22,12 +22,15 @@ public class Task {
private int eta; private int eta;
private boolean finished;
public Task(Taskgroup taskgroup, String taskName, LocalDate startDate, LocalDate deadline, int eta) { public Task(Taskgroup taskgroup, String taskName, LocalDate startDate, LocalDate deadline, int eta) {
this.taskgroup = taskgroup; this.taskgroup = taskgroup;
this.taskName = taskName; this.taskName = taskName;
this.startDate = startDate; this.startDate = startDate;
this.deadline = deadline; this.deadline = deadline;
this.eta = eta; this.eta = eta;
this.finished = false;
} }
public Task() { public Task() {
@ -76,4 +79,16 @@ public class Task {
public void setEta(int eta) { public void setEta(int eta) {
this.eta = eta; this.eta = eta;
} }
public void finish() {
this.finished = true;
}
public boolean isFinished() {
return finished;
}
public void setFinished(boolean finished) {
this.finished = finished;
}
} }

View File

@ -2597,9 +2597,9 @@
} }
}, },
"node_modules/@babel/traverse": { "node_modules/@babel/traverse": {
"version": "7.23.0", "version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
"integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==", "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.22.13", "@babel/code-frame": "^7.22.13",

View File

@ -47,6 +47,10 @@ import {MatCardModule} from "@angular/material/card";
import {MatListModule} from "@angular/material/list"; import {MatListModule} from "@angular/material/list";
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule} from "@angular/material/core"; import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule} from "@angular/material/core";
import {MatMomentDateModule, MomentDateModule} from "@angular/material-moment-adapter"; import {MatMomentDateModule, MomentDateModule} from "@angular/material-moment-adapter";
import { TaskDashboardComponent } from './tasks/task-dashboard/task-dashboard.component';
import {MatSlideToggleModule} from "@angular/material/slide-toggle";
import {MatSortModule} from "@angular/material/sort";
import {MatPaginatorModule} from "@angular/material/paginator";
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -67,36 +71,40 @@ import {MatMomentDateModule, MomentDateModule} from "@angular/material-moment-ad
TaskgroupDashboardComponent, TaskgroupDashboardComponent,
TaskgroupCreationComponent, TaskgroupCreationComponent,
TaskgroupDeletionComponent, TaskgroupDeletionComponent,
TaskEditorComponent TaskEditorComponent,
TaskDashboardComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ApiModule,
HttpClientModule,
BrowserAnimationsModule,
MatToolbarModule,
MatButtonModule,
MatIconModule,
MatDialogModule,
MatFormFieldModule,
MatInputModule,
MatProgressSpinnerModule,
MatSnackBarModule,
MatMenuModule,
MatTabsModule,
MatTableModule,
MatCheckboxModule,
MatCardModule,
ReactiveFormsModule,
MatListModule,
MatDatepickerModule,
MatInputModule,
MatDatepickerModule,
MatMomentDateModule,
FormsModule,
MatSlideToggleModule,
MatSortModule,
MatPaginatorModule
], ],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ApiModule,
HttpClientModule,
BrowserAnimationsModule,
MatToolbarModule,
MatButtonModule,
MatIconModule,
MatDialogModule,
MatFormFieldModule,
MatInputModule,
MatProgressSpinnerModule,
MatSnackBarModule,
MatMenuModule,
MatTabsModule,
MatTableModule,
MatCheckboxModule,
MatCardModule,
ReactiveFormsModule,
MatListModule,
MatDatepickerModule,
MatInputModule,
MatDatepickerModule,
MatMomentDateModule,
FormsModule
],
providers: [ providers: [
HttpClientModule, HttpClientModule,
/* /*

View File

@ -45,3 +45,9 @@
background-color: #6e6e6e; background-color: #6e6e6e;
color: white; color: white;
} }
#task-dashboard-container {
width: 100%;
margin-top: 20px;
}

View File

@ -15,8 +15,16 @@
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
<div>
<mat-card style="width: 100%">
<mat-card-content>
<app-task-dashboard [taskgroupID]="taskgroupID"></app-task-dashboard>
</mat-card-content>
</mat-card>
<div style="width: 100%">
<button id="addTaskBtn" mat-raised-button color="primary" (click)="openTaskCreation()">Create New Task</button> <button id="addTaskBtn" mat-raised-button color="primary" (click)="openTaskCreation()">Create New Task</button>
<button id="addTaskgroupBtn" mat-raised-button color="primary" (click)="openTaskgroupCreation()">Create new Taskgroup</button> <button id="addTaskgroupBtn" mat-raised-button color="primary" (click)="openTaskgroupCreation()">Create new Taskgroup</button>
</div> </div>
</div> </div>

View File

@ -5,6 +5,7 @@ import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deletion.component"; import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deletion.component";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {TaskEditorComponent} from "../../tasks/task-editor/task-editor.component"; import {TaskEditorComponent} from "../../tasks/task-editor/task-editor.component";
import {TaskEditorData} from "../../tasks/task-editor/TaskEditorData";
@Component({ @Component({
selector: 'app-taskgroup-dashboard', selector: 'app-taskgroup-dashboard',
@ -68,6 +69,10 @@ export class TaskgroupDashboardComponent implements OnInit {
} }
openTaskCreation() { openTaskCreation() {
const dialogRef = this.dialog.open(TaskEditorComponent, {minWidth: "400px"}) const editorData: TaskEditorData = {
task: undefined,
taskgroupID: this.taskgroupID
}
const dialogRef = this.dialog.open(TaskEditorComponent, {data: editorData, minWidth: "400px"})
} }
} }

View File

@ -0,0 +1,6 @@
import {TaskEntityInfo} from "../../../api";
export interface TaskEditorData {
taskgroupID: number;
task: TaskEntityInfo | undefined
}

View File

@ -24,3 +24,8 @@
<mat-datepicker #deadlinepicker></mat-datepicker> <mat-datepicker #deadlinepicker></mat-datepicker>
</mat-form-field> </mat-form-field>
</div> </div>
<div mat-dialog-actions align="end">
<button mat-raised-button (click)="cancel()">Cancel</button>
<button mat-raised-button (click)="submit()">Add Task</button>
</div>

View File

@ -1,8 +1,12 @@
import { Component, OnInit } from '@angular/core'; import {Component, Inject, OnInit} from '@angular/core';
import {FormControl, UntypedFormControl, Validators} from "@angular/forms"; import {FormControl, UntypedFormControl, Validators} from "@angular/forms";
import * as _moment from 'moment'; import * as _moment from 'moment';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from "@angular/material/core"; import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from "@angular/material/core";
import {MomentDateAdapter} from "@angular/material-moment-adapter"; import {MomentDateAdapter} from "@angular/material-moment-adapter";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {TaskService} from "../../../api";
import {TaskEditorData} from "./TaskEditorData";
import {MatSnackBar} from "@angular/material/snack-bar";
@Component({ @Component({
@ -16,9 +20,39 @@ export class TaskEditorComponent implements OnInit {
etaCtrl: FormControl = new FormControl(0, [Validators.required, Validators.min(0)]) etaCtrl: FormControl = new FormControl(0, [Validators.required, Validators.min(0)])
startDate: FormControl = new FormControl(Date.now(), [Validators.required]) startDate: FormControl = new FormControl(Date.now(), [Validators.required])
endDate: FormControl = new FormControl(''); endDate: FormControl = new FormControl('');
constructor() { } constructor(private dialog: MatDialogRef<TaskEditorComponent>,
private taskService: TaskService,
@Inject(MAT_DIALOG_DATA) public editorData: TaskEditorData,
private snackbar: MatSnackBar) { }
ngOnInit(): void { ngOnInit(): void {
} }
cancel() {
this.dialog.close();
}
submit() {
this.taskService.tasksTaskgroupIDPut(this.editorData.taskgroupID, {
taskName: this.nameCtrl.value,
eta: this.etaCtrl.value,
startDate: this.startDate.value,
deadline: this.endDate.value
}).subscribe({
next: resp => {
this.dialog.close(resp);
},
error: err => {
if(err.status == 403) {
this.snackbar.open("No permission", "", {duration: 2000});
} else if(err.status == 404) {
this.snackbar.open("Taskgroup not found", "", {duration: 2000});
} else if(err.status == 409) {
this.snackbar.open("Task already exists", "", {duration: 2000});
} else {
this.snackbar.open("Unexpected error", "", {duration: 3000});
}
}
})
}
} }