Added more userstory stuff (teamarbeit)

This commit is contained in:
Nicolai Ort 2020-06-10 11:16:47 +02:00
parent 17b1872ebd
commit c718943af3
4 changed files with 68 additions and 66 deletions

View File

@ -6,8 +6,8 @@ import { UserstoryListComponent } from './userstory-list/userstory-list.componen
const routes: Routes = [
{ path: '/tasks', component: TaskListComponent },
{ path: '/userstories', component: UserstoryListComponent }
{ path: 'tasks', component: TaskListComponent },
{ path: 'userstories', component: UserstoryListComponent }
];
@NgModule({

View File

@ -17,7 +17,9 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
declarations: [
AppComponent,
TaskListComponent,
TaskFormComponent
TaskFormComponent,
UserstoryListComponent,
UserstoryFormComponent
],
imports: [
BrowserModule,

View File

@ -37,28 +37,28 @@ export class BackendService {
public getTasks(): Observable<HttpResponse<ScrumTask[]>> {
const url = `${environment.apiUrl}/tasks`;
return this.httpClient.get<ScrumTask[]>(url, { observe: 'response' });
public getUserstories(): Observable<HttpResponse<ScrumUserstory[]>> {
const url = `${environment.apiUrl}/userstories`;
return this.httpClient.get<ScrumUserstory[]>(url, { observe: 'response' });
}
public getTask(id: number): Observable<HttpResponse<ScrumTask>> {
const url = `${environment.apiUrl}/tasks/${id}`;
return this.httpClient.get<ScrumTask>(url, { observe: 'response' });
public getUserstory(id: number): Observable<HttpResponse<ScrumUserstory>> {
const url = `${environment.apiUrl}/userstories/${id}`;
return this.httpClient.get<ScrumUserstory>(url, { observe: 'response' });
}
public postTask(task: ScrumTask): Observable<HttpResponse<ScrumTask>> {
const url = `${environment.apiUrl}/tasks`;
return this.httpClient.post<ScrumTask>(url, task, { observe: 'response' });
public postUserstory(userstory: ScrumUserstory): Observable<HttpResponse<ScrumUserstory>> {
const url = `${environment.apiUrl}/userstories`;
return this.httpClient.post<ScrumUserstory>(url, userstory, { observe: 'response' });
}
public putTask(task: ScrumTask): Observable<HttpResponse<any>> {
const url = `${environment.apiUrl}/tasks/${task.id}`;
return this.httpClient.put(url, task, { observe: 'response' });
public putUserstory(userstory: ScrumUserstory): Observable<HttpResponse<any>> {
const url = `${environment.apiUrl}/userstories/${userstory.id}`;
return this.httpClient.put(url, userstory, { observe: 'response' });
}
public deleteTask(task: ScrumTask): Observable<HttpResponse<any>> {
const url = `${environment.apiUrl}/tasks/${task.id}`;
public deleteUserstory(userstory: ScrumUserstory): Observable<HttpResponse<any>> {
const url = `${environment.apiUrl}/userstories/${userstory.id}`;
return this.httpClient.delete(url, {observe: 'response'});
}

View File

@ -1,49 +1,49 @@
import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { BackendService, ScrumTask } from '../services/backend.service';
import { TaskFormComponent } from '../task-form/task-form.component';
@Component({
selector: 'app-task-list',
templateUrl: './task-list.component.html',
styleUrls: ['./task-list.component.css']
})
export class TaskListComponent implements OnInit {
public tasks: ScrumTask[] = [];
constructor(private backendService: BackendService, private modalService: NgbModal) {
backendService.getTasks().subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
else {
this.tasks.push(...response.body);
}
});
}
ngOnInit(): void {
}
public deleteTask(task: ScrumTask) {
this.backendService.deleteTask(task).subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
});
const index = this.tasks.indexOf(task);
if (index !== -1) {
this.tasks.splice(index, 1);
}
}
public openTaskForm(editTask: ScrumTask) {
const modalRef = this.modalService.open(TaskFormComponent, {
backdrop: 'static',
keyboard: true,
});
modalRef.componentInstance.task = editTask;
}
}
import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { BackendService, ScrumTask } from '../services/backend.service';
import { TaskFormComponent } from '../task-form/task-form.component';
@Component({
selector: 'app-task-list',
templateUrl: './task-list.component.html',
styleUrls: ['./task-list.component.css']
})
export class TaskListComponent implements OnInit {
public tasks: ScrumTask[] = [];
constructor(private backendService: BackendService, private modalService: NgbModal) {
backendService.getTasks().subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
else {
this.tasks.push(...response.body);
}
});
}
ngOnInit(): void {
}
public deleteTask(task: ScrumTask) {
this.backendService.deleteTask(task).subscribe(response => {
if (response.status > 399) {
alert('Fehler');
}
});
const index = this.tasks.indexOf(task);
if (index !== -1) {
this.tasks.splice(index, 1);
}
}
public openTaskForm(editTask: ScrumTask) {
const modalRef = this.modalService.open(TaskFormComponent, {
backdrop: 'static',
keyboard: true,
});
modalRef.componentInstance.task = editTask;
}
}