From c718943af38b4d9a1fca7dab6b5cb3ba7935f81c Mon Sep 17 00:00:00 2001 From: Niggl Date: Wed, 10 Jun 2020 11:16:47 +0200 Subject: [PATCH] Added more userstory stuff (teamarbeit) --- src/app/app-routing.module.ts | 4 +- src/app/app.module.ts | 4 +- src/app/services/backend.service.ts | 28 +++---- src/app/task-list/task-list.component.ts | 98 ++++++++++++------------ 4 files changed, 68 insertions(+), 66 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 441ef44..ce27b6b 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -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({ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 17855fd..ea85efc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -17,7 +17,9 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; declarations: [ AppComponent, TaskListComponent, - TaskFormComponent + TaskFormComponent, + UserstoryListComponent, + UserstoryFormComponent ], imports: [ BrowserModule, diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts index f594207..9881f47 100644 --- a/src/app/services/backend.service.ts +++ b/src/app/services/backend.service.ts @@ -37,28 +37,28 @@ export class BackendService { - public getTasks(): Observable> { - const url = `${environment.apiUrl}/tasks`; - return this.httpClient.get(url, { observe: 'response' }); + public getUserstories(): Observable> { + const url = `${environment.apiUrl}/userstories`; + return this.httpClient.get(url, { observe: 'response' }); } - public getTask(id: number): Observable> { - const url = `${environment.apiUrl}/tasks/${id}`; - return this.httpClient.get(url, { observe: 'response' }); + public getUserstory(id: number): Observable> { + const url = `${environment.apiUrl}/userstories/${id}`; + return this.httpClient.get(url, { observe: 'response' }); } - public postTask(task: ScrumTask): Observable> { - const url = `${environment.apiUrl}/tasks`; - return this.httpClient.post(url, task, { observe: 'response' }); + public postUserstory(userstory: ScrumUserstory): Observable> { + const url = `${environment.apiUrl}/userstories`; + return this.httpClient.post(url, userstory, { observe: 'response' }); } - public putTask(task: ScrumTask): Observable> { - const url = `${environment.apiUrl}/tasks/${task.id}`; - return this.httpClient.put(url, task, { observe: 'response' }); + public putUserstory(userstory: ScrumUserstory): Observable> { + const url = `${environment.apiUrl}/userstories/${userstory.id}`; + return this.httpClient.put(url, userstory, { observe: 'response' }); } - public deleteTask(task: ScrumTask): Observable> { - const url = `${environment.apiUrl}/tasks/${task.id}`; + public deleteUserstory(userstory: ScrumUserstory): Observable> { + const url = `${environment.apiUrl}/userstories/${userstory.id}`; return this.httpClient.delete(url, {observe: 'response'}); } diff --git a/src/app/task-list/task-list.component.ts b/src/app/task-list/task-list.component.ts index b9549d9..5b945f4 100644 --- a/src/app/task-list/task-list.component.ts +++ b/src/app/task-list/task-list.component.ts @@ -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; + } + +}