issue-10 #17

Merged
sebastian merged 29 commits from issue-10 into master 2023-10-22 11:40:25 +02:00
12 changed files with 166 additions and 60 deletions
Showing only changes of commit bd56d601a0 - Show all commits

View File

@ -5,9 +5,16 @@
</component>
<component name="ChangeListManager">
<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$/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/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.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/tasks/task-editor/task-editor.component.ts" afterDir="false" />
</list>
@ -41,31 +48,31 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RequestMappingsPanelOrder0": "0",
"RequestMappingsPanelOrder1": "1",
"RequestMappingsPanelWidth0": "75",
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "issue-11-angular-update",
"last_directory_selection": "D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager",
"last_opened_file_path": "D:/Programmierprojekte/Dicewars/client",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
&quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
&quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
&quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;issue-11-angular-update&quot;,
&quot;last_directory_selection&quot;: &quot;D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/Programmierprojekte/Dicewars/client&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"DatabaseDriversLRU": [
"mariadb"
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;mariadb&quot;
]
}
}]]></component>
}</component>
<component name="RunManager">
<configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<module name="demo" />
@ -88,6 +95,7 @@
<workItem from="1696399523081" duration="666000" />
<workItem from="1696517800445" duration="3887000" />
<workItem from="1696573678147" duration="111000" />
<workItem from="1697923629354" duration="1218000" />
</task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<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) {
PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName());
if(!taskgroupPermissionResult.isHasPermissions()) {

View File

@ -18,6 +18,8 @@ public class TaskEntityInfo {
private boolean overdue;
private boolean finished;
public TaskEntityInfo(Task task) {
this.taskID = task.getTaskID();
this.taskName = task.getTaskName();
@ -25,6 +27,7 @@ public class TaskEntityInfo {
this.startDate = task.getStartDate();
this.deadline = task.getDeadline();
this.overdue = LocalDate.now().isAfter(task.getDeadline());
this.finished = task.isFinished();
}
public long getTaskID() {
@ -74,4 +77,12 @@ public class TaskEntityInfo {
public void setOverdue(boolean 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 boolean finished;
public Task(Taskgroup taskgroup, String taskName, LocalDate startDate, LocalDate deadline, int eta) {
this.taskgroup = taskgroup;
this.taskName = taskName;
this.startDate = startDate;
this.deadline = deadline;
this.eta = eta;
this.finished = false;
}
public Task() {
@ -76,4 +79,16 @@ public class Task {
public void setEta(int 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": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz",
"integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==",
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
"integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==",
"dev": true,
"dependencies": {
"@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 {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule} from "@angular/material/core";
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({
declarations: [
@ -67,36 +71,40 @@ import {MatMomentDateModule, MomentDateModule} from "@angular/material-moment-ad
TaskgroupDashboardComponent,
TaskgroupCreationComponent,
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: [
HttpClientModule,
/*

View File

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

View File

@ -15,8 +15,16 @@
</mat-card-content>
</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="addTaskgroupBtn" mat-raised-button color="primary" (click)="openTaskgroupCreation()">Create new Taskgroup</button>
</div>
</div>

View File

@ -5,6 +5,7 @@ import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deletion.component";
import {ActivatedRoute} from "@angular/router";
import {TaskEditorComponent} from "../../tasks/task-editor/task-editor.component";
import {TaskEditorData} from "../../tasks/task-editor/TaskEditorData";
@Component({
selector: 'app-taskgroup-dashboard',
@ -68,6 +69,10 @@ export class TaskgroupDashboardComponent implements OnInit {
}
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-form-field>
</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 * as _moment from 'moment';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from "@angular/material/core";
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({
@ -16,9 +20,39 @@ export class TaskEditorComponent implements OnInit {
etaCtrl: FormControl = new FormControl(0, [Validators.required, Validators.min(0)])
startDate: FormControl = new FormControl(Date.now(), [Validators.required])
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 {
}
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});
}
}
})
}
}