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 = [ const routes: Routes = [
{ path: '/tasks', component: TaskListComponent }, { path: 'tasks', component: TaskListComponent },
{ path: '/userstories', component: UserstoryListComponent } { path: 'userstories', component: UserstoryListComponent }
]; ];
@NgModule({ @NgModule({

View File

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

View File

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

View File

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