List and Edit Taskgroups
This commit is contained in:
parent
fa7d7d503a
commit
efcab999f2
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
import {FormControl, Validators} from "@angular/forms";
|
import {FormControl, Validators} from "@angular/forms";
|
||||||
import {MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {TaskgroupService} from "../../../api";
|
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||||
import {error} from "@angular/compiler/src/util";
|
import {error} from "@angular/compiler/src/util";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
|
|
||||||
@ -17,9 +17,13 @@ export class TaskgroupCreationComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private dialogRef: MatDialogRef<TaskgroupCreationComponent>,
|
constructor(private dialogRef: MatDialogRef<TaskgroupCreationComponent>,
|
||||||
private taskgroupService: TaskgroupService,
|
private taskgroupService: TaskgroupService,
|
||||||
private snackbar: MatSnackBar) { }
|
private snackbar: MatSnackBar,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: TaskgroupEntityInfo | undefined) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
if(this.data != undefined) {
|
||||||
|
this.nameCtrl.setValue(this.data!.taskgroupName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
@ -28,22 +32,47 @@ export class TaskgroupCreationComponent implements OnInit {
|
|||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.pending = true;
|
this.pending = true;
|
||||||
this.taskgroupService.taskgroupsPut({
|
if(this.data == undefined) {
|
||||||
name: this.nameCtrl.value
|
this.taskgroupService.taskgroupsPut({
|
||||||
}).subscribe({
|
name: this.nameCtrl.value
|
||||||
next: resp => {
|
}).subscribe({
|
||||||
this.pending = false;
|
next: resp => {
|
||||||
this.dialogRef.close(resp);
|
this.pending = false;
|
||||||
},
|
this.dialogRef.close(resp);
|
||||||
error: err => {
|
},
|
||||||
this.pending = false;
|
error: err => {
|
||||||
if(err.status == 409) {
|
this.pending = false;
|
||||||
this.snackbar.open("Taskgroup already exists", "", {duration: 2000});
|
if(err.status == 409) {
|
||||||
} else {
|
this.snackbar.open("Taskgroup already exists", "", {duration: 2000});
|
||||||
this.snackbar.open("An unexpected error occured", "");
|
} else {
|
||||||
|
this.snackbar.open("An unexpected error occured", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
|
this.taskgroupService.taskgroupsTaskgroupIDPost(this.data.taskgroupID, {
|
||||||
|
name: this.nameCtrl.value
|
||||||
|
}).subscribe({
|
||||||
|
next: resp => {
|
||||||
|
this.pending = false;
|
||||||
|
this.data!.taskgroupName = this.nameCtrl.value
|
||||||
|
this.dialogRef.close(true);
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
this.pending = false;
|
||||||
|
if(err.status == 409) {
|
||||||
|
this.snackbar.open("Taskgroup already exists", "", {duration: 2000});
|
||||||
|
} else if(err.status == 403) {
|
||||||
|
this.snackbar.open("No permission", "", {duration: 2000})
|
||||||
|
} else if(err.status == 404) {
|
||||||
|
this.snackbar.open("Not found", "", {duration: 2000});
|
||||||
|
} else {
|
||||||
|
this.snackbar.open("An unexpected error occured", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,3 +26,16 @@
|
|||||||
color: grey;
|
color: grey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navLink-bar {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addTaskgroupBtn {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-btn {
|
||||||
|
background-color: #6e6e6e;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<mat-card>
|
<mat-card class="navLink-bar">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<a class="navLink" routerLink="/">Dashboard</a>
|
<a class="navLink" routerLink="/">Dashboard</a>
|
||||||
<a class="navLink-disabled">/ Taskgroups</a>
|
<a class="navLink-disabled">/ Taskgroups</a>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
<button mat-raised-button color="primary" (click)="openTaskgroupCreation()">Create new Taskgroup</button>
|
<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 class="edit-btn" (click)="openTaskgroupEditor(taskgroup)">Rename</button>
|
||||||
|
<button mat-raised-button color="warn">Delete</button>
|
||||||
|
</mat-card-content>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
<button id="addTaskgroupBtn" mat-raised-button color="primary" (click)="openTaskgroupCreation()">Create new Taskgroup</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {TaskgroupCreationComponent} from "../taskgroup-creation/taskgroup-creation.component";
|
import {TaskgroupCreationComponent} from "../taskgroup-creation/taskgroup-creation.component";
|
||||||
|
import {TaskgroupEntityInfo, TaskgroupService} from "../../../api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-taskgroup-dashboard',
|
selector: 'app-taskgroup-dashboard',
|
||||||
@ -9,12 +10,34 @@ import {TaskgroupCreationComponent} from "../taskgroup-creation/taskgroup-creati
|
|||||||
})
|
})
|
||||||
export class TaskgroupDashboardComponent implements OnInit {
|
export class TaskgroupDashboardComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private dialog: MatDialog) { }
|
constructor(private dialog: MatDialog,
|
||||||
|
private taskgroupService: TaskgroupService) { }
|
||||||
|
|
||||||
|
taskgroups: TaskgroupEntityInfo[] = []
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.taskgroupService.taskgroupsGet().subscribe({
|
||||||
|
next: resp => {
|
||||||
|
this.taskgroups = resp;
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
openTaskgroupCreation() {
|
openTaskgroupCreation() {
|
||||||
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {minWidth: "400px"})
|
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {minWidth: "400px"})
|
||||||
|
dialogRef.afterClosed().subscribe(res => {
|
||||||
|
if(res != undefined) {
|
||||||
|
this.taskgroups.push(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
openTaskgroupEditor(taskgroup: TaskgroupEntityInfo) {
|
||||||
|
const dialogRef = this.dialog.open(TaskgroupCreationComponent, {data: taskgroup, minWidth: "400px"});
|
||||||
|
dialogRef.afterClosed().subscribe(res => {
|
||||||
|
if(res) {
|
||||||
|
const data = this.taskgroups
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user