issue-7 #9
@ -5,12 +5,25 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/uiDesigner.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.mvn/wrapper/maven-wrapper.properties" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-creation/TaskgroupCreationData.ts" 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/TaskgroupController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/TaskgroupController.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupEntityInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupEntityInfo.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupFieldInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupFieldInfo.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskgroupRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskgroupRepository.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api.module.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api/api.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/api.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api/taskgroup.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/taskgroup.service.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/model/models.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/model/models.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/model/taskgroupEntityInfo.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/model/taskgroupEntityInfo.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/model/taskgroupFieldInfo.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/model/taskgroupFieldInfo.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app-routing.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app-routing.module.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts" 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$/../openapi.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../openapi.yaml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -69,11 +82,22 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1695647243767</updated>
|
||||
<workItem from="1695647249321" duration="397000" />
|
||||
<workItem from="1696183811713" duration="179000" />
|
||||
<workItem from="1696183811713" duration="3909000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java</url>
|
||||
<line>52</line>
|
||||
<option name="timeStamp" value="1" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
@ -10,11 +10,13 @@ import core.services.ServiceResult;
|
||||
import core.services.TaskgroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.config.Task;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
@ -74,8 +76,23 @@ public class TaskgroupController {
|
||||
|
||||
@GetMapping("/taskgroups")
|
||||
public ResponseEntity<List<TaskgroupEntityInfo>> listTaskgroupsOfUser() {
|
||||
List<Taskgroup> taskgroups = taskgroupService.getTaskgroupsByUser(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
List<Taskgroup> taskgroups = taskgroupService.getTopTaskgroupsByUser(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
List<TaskgroupEntityInfo> taskgroupEntityInfos = taskgroups.stream().map(TaskgroupEntityInfo::new).toList();
|
||||
return ResponseEntity.ok(taskgroupEntityInfos);
|
||||
}
|
||||
|
||||
@GetMapping("/taskgroups/{taskgroupID}")
|
||||
public ResponseEntity<?> getDetails(@PathVariable long taskgroupID) {
|
||||
PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
if(!taskgroupPermissionResult.isHasPermissions()) {
|
||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||
}
|
||||
|
||||
if(taskgroupPermissionResult.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
|
||||
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
|
||||
}
|
||||
|
||||
Set<Taskgroup> children = taskgroupPermissionResult.getResult().getChildren();
|
||||
return ResponseEntity.ok(children.stream().map(TaskgroupEntityInfo::new));
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,17 @@ public class TaskgroupEntityInfo {
|
||||
private long taskgroupID;
|
||||
private String taskgroupName;
|
||||
|
||||
private TaskgroupEntityInfo parentTaskgroup;
|
||||
|
||||
public TaskgroupEntityInfo(Taskgroup taskgroup) {
|
||||
this.taskgroupID = taskgroup.getTaskgroupID();
|
||||
this.taskgroupName = taskgroup.getTaskgroupName();
|
||||
|
||||
if(taskgroup.getParent() == null) {
|
||||
this.parentTaskgroup = null;
|
||||
} else {
|
||||
this.parentTaskgroup = new TaskgroupEntityInfo(taskgroup.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
public long getTaskgroupID() {
|
||||
@ -27,4 +35,12 @@ public class TaskgroupEntityInfo {
|
||||
public void setTaskgroupName(String taskgroupName) {
|
||||
this.taskgroupName = taskgroupName;
|
||||
}
|
||||
|
||||
public TaskgroupEntityInfo getParentTaskgroup() {
|
||||
return parentTaskgroup;
|
||||
}
|
||||
|
||||
public void setParentTaskgroup(TaskgroupEntityInfo parentTaskgroup) {
|
||||
this.parentTaskgroup = parentTaskgroup;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ public class TaskgroupFieldInfo {
|
||||
@Length(max = 255)
|
||||
private String name;
|
||||
|
||||
private long parentID;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -20,4 +22,12 @@ public class TaskgroupFieldInfo {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getParentID() {
|
||||
return parentID;
|
||||
}
|
||||
|
||||
public void setParentID(long parentID) {
|
||||
this.parentID = parentID;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import core.entities.User;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name= "taskgroups")
|
||||
@ -21,6 +22,13 @@ public class Taskgroup {
|
||||
@JoinColumn(name = "taskgroupuser", nullable = false)
|
||||
private User user;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
private Set<Taskgroup> children;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parent_id")
|
||||
private Taskgroup parent;
|
||||
|
||||
public Taskgroup(String taskgroupName, User user) {
|
||||
this.taskgroupName = taskgroupName;
|
||||
this.user = user;
|
||||
@ -52,4 +60,20 @@ public class Taskgroup {
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Set<Taskgroup> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(Set<Taskgroup> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Taskgroup getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Taskgroup parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public interface TaskgroupRepository extends CrudRepository<Taskgroup, Long> {
|
||||
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1")
|
||||
List<Taskgroup> findAllByUser(String username);
|
||||
|
||||
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1 AND tg.parent IS NULL")
|
||||
List<Taskgroup> findAllTopTaskgroupsByUser(String username);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
void deleteAllByUser(User user);
|
||||
|
@ -40,8 +40,20 @@ public class TaskgroupService {
|
||||
}
|
||||
|
||||
if(!taskgroupRepository.existsByTaskgroupNameAndUser(taskData.getName(), user.get())) {
|
||||
Taskgroup taskgroup;
|
||||
if(taskData.getParentID() < 0) {
|
||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
} else {
|
||||
Optional<Taskgroup> parentTaskgroup = taskgroupRepository.findById(taskData.getParentID());
|
||||
if(parentTaskgroup.isEmpty()) {
|
||||
return new ServiceResult<>(ServiceExitCode.MISSING_ENTITY);
|
||||
} else {
|
||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
taskgroup.setParent(parentTaskgroup.get());
|
||||
parentTaskgroup.get().getChildren().add(taskgroup);
|
||||
}
|
||||
}
|
||||
|
||||
Taskgroup taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||
taskgroupRepository.save(taskgroup);
|
||||
return new ServiceResult<>(taskgroup);
|
||||
} else {
|
||||
@ -72,6 +84,10 @@ public class TaskgroupService {
|
||||
return taskgroupRepository.findAllByUser(username);
|
||||
}
|
||||
|
||||
public List<Taskgroup> getTopTaskgroupsByUser(String username) {
|
||||
return taskgroupRepository.findAllTopTaskgroupsByUser(username);
|
||||
}
|
||||
|
||||
public void deleteTaskgroupByUser(User user) {
|
||||
taskgroupRepository.deleteAllByUser(user);
|
||||
}
|
||||
|
@ -94,6 +94,61 @@ export class TaskgroupService {
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsAllGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsAllGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsAllGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsAllGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
let localVarCredential: string | undefined;
|
||||
// authentication (API_TOKEN) required
|
||||
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
|
||||
if (localVarCredential) {
|
||||
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
|
||||
}
|
||||
|
||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
}
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||
if (localVarHttpContext === undefined) {
|
||||
localVarHttpContext = new HttpContext();
|
||||
}
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' = 'json';
|
||||
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<TaskgroupEntityInfo>>(`${this.configuration.basePath}/taskgroups/all`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* list all top level taskgroups of authorized user
|
||||
* list all taskgroups of authorized user
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
@ -268,6 +323,65 @@ export class TaskgroupService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get details of an existing taskgroup
|
||||
* get details of an existing taskgroup
|
||||
* @param taskgroupID internal id of taskgroup
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<TaskgroupEntityInfo>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<TaskgroupEntityInfo>>>;
|
||||
public taskgroupsTaskgroupIDGet(taskgroupID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||
if (taskgroupID === null || taskgroupID === undefined) {
|
||||
throw new Error('Required parameter taskgroupID was null or undefined when calling taskgroupsTaskgroupIDGet.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
let localVarCredential: string | undefined;
|
||||
// authentication (API_TOKEN) required
|
||||
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
|
||||
if (localVarCredential) {
|
||||
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
|
||||
}
|
||||
|
||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
}
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||
if (localVarHttpContext === undefined) {
|
||||
localVarHttpContext = new HttpContext();
|
||||
}
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' = 'json';
|
||||
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<TaskgroupEntityInfo>>(`${this.configuration.basePath}/taskgroups/${encodeURIComponent(String(taskgroupID))}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* edits taskgroup
|
||||
* edits taskgroup
|
||||
|
@ -20,5 +20,6 @@ export interface TaskgroupEntityInfo {
|
||||
* name of taskgroup
|
||||
*/
|
||||
taskgroupName: string;
|
||||
parentTaskgroup: TaskgroupEntityInfo;
|
||||
}
|
||||
|
||||
|
@ -16,5 +16,9 @@ export interface TaskgroupFieldInfo {
|
||||
* name of taskgroup
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* internal id of parent Taskgroup
|
||||
*/
|
||||
parentID: number;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,8 @@ const routes: Routes = [
|
||||
{path: '', component: MainComponent},
|
||||
{path: 'admin', component: AdminDashboardComponent},
|
||||
{path: 'user/settings', component: UserSettingsComponent},
|
||||
{path: 'taskgroups', component: TaskgroupDashboardComponent}
|
||||
{path: 'taskgroups', component: TaskgroupDashboardComponent},
|
||||
{path: 'taskgroups/:taskgroupID', component: TaskgroupDashboardComponent}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -0,0 +1,6 @@
|
||||
import {TaskgroupEntityInfo} from "../../../api";
|
||||
|
||||
export interface TaskgroupCreationData {
|
||||
taskgroup: TaskgroupEntityInfo | undefined,
|
||||
taskgroupID: number
|
||||
}
|
@ -4,6 +4,8 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||
import {error} from "@angular/compiler/src/util";
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {TaskgroupCreationData} from "./TaskgroupCreationData";
|
||||
|
||||
@Component({
|
||||
selector: 'app-taskgroup-creation',
|
||||
@ -18,11 +20,12 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
constructor(private dialogRef: MatDialogRef<TaskgroupCreationComponent>,
|
||||
private taskgroupService: TaskgroupService,
|
||||
private snackbar: MatSnackBar,
|
||||
@Inject(MAT_DIALOG_DATA) public data: TaskgroupEntityInfo | undefined) { }
|
||||
@Inject(MAT_DIALOG_DATA) public data: TaskgroupCreationData,
|
||||
private activatedRoute: ActivatedRoute) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
if(this.data != undefined) {
|
||||
this.nameCtrl.setValue(this.data!.taskgroupName)
|
||||
if(this.data.taskgroup != undefined) {
|
||||
this.nameCtrl.setValue(this.data.taskgroup!.taskgroupName)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +35,10 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
|
||||
save() {
|
||||
this.pending = true;
|
||||
if(this.data == undefined) {
|
||||
if(this.data.taskgroup == undefined) {
|
||||
this.taskgroupService.taskgroupsPut({
|
||||
name: this.nameCtrl.value
|
||||
name: this.nameCtrl.value,
|
||||
parentID: this.data.taskgroupID,
|
||||
}).subscribe({
|
||||
next: resp => {
|
||||
this.pending = false;
|
||||
@ -51,11 +55,12 @@ export class TaskgroupCreationComponent implements OnInit {
|
||||
})
|
||||
} else {
|
||||
this.taskgroupService.taskgroupsTaskgroupIDPost(this.data.taskgroupID, {
|
||||
name: this.nameCtrl.value
|
||||
name: this.nameCtrl.value,
|
||||
parentID: this.data.taskgroup!.parentTaskgroup.taskgroupID
|
||||
}).subscribe({
|
||||
next: resp => {
|
||||
this.pending = false;
|
||||
this.data!.taskgroupName = this.nameCtrl.value
|
||||
this.data.taskgroup!.taskgroupName = this.nameCtrl.value
|
||||
this.dialogRef.close(true);
|
||||
},
|
||||
error: err => {
|
||||
|
@ -9,7 +9,7 @@
|
||||
<mat-card *ngFor="let taskgroup of taskgroups">
|
||||
<mat-card-content>
|
||||
<h1>{{taskgroup.taskgroupName}}</h1>
|
||||
<button mat-raised-button color="primary">Detail</button>
|
||||
<button mat-raised-button color="primary" [routerLink]="['/taskgroups', taskgroup.taskgroupID]">Detail</button>
|
||||
<button mat-raised-button class="edit-btn" (click)="openTaskgroupEditor(taskgroup)">Rename</button>
|
||||
<button mat-raised-button color="warn" (click)="openTaskgroupDeletion(taskgroup)">Delete</button>
|
||||
</mat-card-content>
|
||||
|
@ -3,6 +3,7 @@ import {MatDialog} from "@angular/material/dialog";
|
||||
import {TaskgroupCreationComponent} from "../taskgroup-creation/taskgroup-creation.component";
|
||||
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||
import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deletion.component";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-taskgroup-dashboard',
|
||||
@ -12,20 +13,34 @@ import {TaskgroupDeletionComponent} from "../taskgroup-deletion/taskgroup-deleti
|
||||
export class TaskgroupDashboardComponent implements OnInit {
|
||||
|
||||
constructor(private dialog: MatDialog,
|
||||
private taskgroupService: TaskgroupService) { }
|
||||
private taskgroupService: TaskgroupService,
|
||||
private activatedRoute: ActivatedRoute) { }
|
||||
|
||||
taskgroups: TaskgroupEntityInfo[] = []
|
||||
taskgroupID: number = -1;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.taskgroupService.taskgroupsGet().subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp;
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if(params.has('taskgroupID')) {
|
||||
this.taskgroupID = Number(params.get('taskgroupID'));
|
||||
this.taskgroupService.taskgroupsTaskgroupIDGet(this.taskgroupID).subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.taskgroupService.taskgroupsGet().subscribe({
|
||||
next: resp => {
|
||||
this.taskgroups = resp;
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
openTaskgroupCreation() {
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {minWidth: "400px"})
|
||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {data: {taskgroup: undefined, taskgroupID: this.taskgroupID}, minWidth: "400px"})
|
||||
dialogRef.afterClosed().subscribe(res => {
|
||||
if(res != undefined) {
|
||||
this.taskgroups.push(res);
|
||||
|
85
openapi.yaml
85
openapi.yaml
@ -564,7 +564,7 @@ paths:
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
/taskgroups:
|
||||
/taskgroups/all:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -581,6 +581,23 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
/taskgroups:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
tags:
|
||||
- taskgroup
|
||||
summary: list all top level taskgroups of authorized user
|
||||
description: list all taskgroups of authorized user
|
||||
responses:
|
||||
200:
|
||||
description: Anfrage erfolgreich
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
put:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -616,6 +633,60 @@ paths:
|
||||
enum:
|
||||
- "failed"
|
||||
/taskgroups/{taskgroupID}:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
tags:
|
||||
- taskgroup
|
||||
summary: get details of an existing taskgroup
|
||||
description: get details of an existing taskgroup
|
||||
parameters:
|
||||
- name: taskgroupID
|
||||
in: path
|
||||
description: internal id of taskgroup
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
example: 1
|
||||
responses:
|
||||
200:
|
||||
description: Anfrage erfolgreich
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
403:
|
||||
description: No permission
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
404:
|
||||
description: Taskgroup does not exist
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status
|
||||
example: "failed"
|
||||
enum:
|
||||
- "failed"
|
||||
post:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
@ -948,6 +1019,7 @@ components:
|
||||
required:
|
||||
- taskgroupID
|
||||
- taskgroupName
|
||||
- parentTaskgroup
|
||||
additionalProperties: false
|
||||
properties:
|
||||
taskgroupID:
|
||||
@ -960,9 +1032,13 @@ components:
|
||||
example: Taskgroup 1
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
parentTaskgroup:
|
||||
type: object
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
TaskgroupFieldInfo:
|
||||
required:
|
||||
- name
|
||||
- parentID
|
||||
additionalProperties: false
|
||||
properties:
|
||||
name:
|
||||
@ -970,4 +1046,9 @@ components:
|
||||
description: name of taskgroup
|
||||
example: Taskgroup 1
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
minLength: 1
|
||||
parentID:
|
||||
type: number
|
||||
description: internal id of parent Taskgroup
|
||||
example: 1
|
||||
|
Loading…
Reference in New Issue
Block a user