Added new interfaces
This commit is contained in:
parent
03dea1d87b
commit
aee256090a
@ -1,56 +1,107 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {HttpClient, HttpResponse} from '@angular/common/http';
|
import {HttpClient, HttpResponse} from '@angular/common/http';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {environment} from '../../environments/environment';
|
import {environment} from '../../environments/environment';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BackendService {
|
export class BackendService {
|
||||||
|
|
||||||
constructor(private httpClient: HttpClient) {}
|
constructor(private httpClient: HttpClient) {}
|
||||||
|
|
||||||
public getTasks(): Observable<HttpResponse<Task[]>> {
|
public getTasks(): Observable<HttpResponse<ScrumTask[]>> {
|
||||||
const url = `${environment.apiUrl}/tasks`;
|
const url = `${environment.apiUrl}/tasks`;
|
||||||
return this.httpClient.get<Task[]>(url, { observe: 'response' });
|
return this.httpClient.get<ScrumTask[]>(url, { observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTask(id: number): Observable<HttpResponse<Task>> {
|
public getTask(id: number): Observable<HttpResponse<ScrumTask>> {
|
||||||
const url = `${environment.apiUrl}/tasks/${id}`;
|
const url = `${environment.apiUrl}/tasks/${id}`;
|
||||||
return this.httpClient.get<Task>(url, { observe: 'response' });
|
return this.httpClient.get<ScrumTask>(url, { observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
public postTask(task: Task): Observable<HttpResponse<Task>> {
|
public postTask(task: ScrumTask): Observable<HttpResponse<ScrumTask>> {
|
||||||
const url = `${environment.apiUrl}/tasks`;
|
const url = `${environment.apiUrl}/tasks`;
|
||||||
return this.httpClient.post<Task>(url, task, { observe: 'response' });
|
return this.httpClient.post<ScrumTask>(url, task, { observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
public putTask(task: Task): Observable<HttpResponse<any>> {
|
public putTask(task: ScrumTask): Observable<HttpResponse<any>> {
|
||||||
const url = `${environment.apiUrl}/tasks/${task.id}`;
|
const url = `${environment.apiUrl}/tasks/${task.id}`;
|
||||||
return this.httpClient.put(url, task, { observe: 'response' });
|
return this.httpClient.put(url, task, { observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteTask(task: Task): Observable<HttpResponse<any>> {
|
public deleteTask(task: ScrumTask): Observable<HttpResponse<any>> {
|
||||||
const url = `${environment.apiUrl}/tasks/${task.id}`;
|
const url = `${environment.apiUrl}/tasks/${task.id}`;
|
||||||
return this.httpClient.delete(url, {observe: 'response'});
|
return this.httpClient.delete(url, {observe: 'response'});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum Priority {
|
|
||||||
High="high",
|
}
|
||||||
Medium="medium",
|
|
||||||
Low="low"
|
export enum Priority {
|
||||||
}
|
High="high",
|
||||||
|
Medium="medium",
|
||||||
export interface Task {
|
Low="low"
|
||||||
id?: number;
|
}
|
||||||
title: string;
|
|
||||||
content?: string;
|
export interface ScrumTask {
|
||||||
status?: number;
|
id?: number;
|
||||||
category?: number;
|
title: string;
|
||||||
assignedto?: number;
|
content?: string;
|
||||||
sprint?: number;
|
status?: number;
|
||||||
project?: number;
|
category?: number;
|
||||||
userstory?: number;
|
assignedto?: number;
|
||||||
priority?: Priority;
|
sprint?: number;
|
||||||
}
|
project?: number;
|
||||||
|
userstory?: number;
|
||||||
|
priority?: Priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrumUserstory {
|
||||||
|
id?: number;
|
||||||
|
title: string;
|
||||||
|
content?: string;
|
||||||
|
priority?: Priority;
|
||||||
|
status?: number;
|
||||||
|
category?: number;
|
||||||
|
createdby?: number;
|
||||||
|
project?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrumSprint{
|
||||||
|
id?: number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
startDate: Date;
|
||||||
|
endDate: Date;
|
||||||
|
project: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrumCategory {
|
||||||
|
id?: number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
color?: string;
|
||||||
|
project: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrumStatus {
|
||||||
|
id? : number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface ScrumUser {
|
||||||
|
id?: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrumProject {
|
||||||
|
id?: number;
|
||||||
|
title: string;
|
||||||
|
isprivate: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { BackendService, Task, Priority } from '../services/backend.service';
|
import { BackendService, ScrumTask, Priority } from '../services/backend.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-task-form',
|
selector: 'app-task-form',
|
||||||
templateUrl: './task-form.component.html',
|
templateUrl: './task-form.component.html',
|
||||||
styleUrls: ['./task-form.component.css']
|
styleUrls: ['./task-form.component.css']
|
||||||
})
|
})
|
||||||
export class TaskFormComponent implements OnInit {
|
export class TaskFormComponent implements OnInit {
|
||||||
|
|
||||||
public title: string;
|
public title: string;
|
||||||
public content: string;
|
public content: string;
|
||||||
public prio: Priority;
|
public prio: Priority;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
public task: Task;
|
public task: ScrumTask;
|
||||||
private submitted: boolean;
|
private submitted: boolean;
|
||||||
|
|
||||||
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { }
|
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.task !== null && this.task !== undefined) {
|
if (this.task !== null && this.task !== undefined) {
|
||||||
this.title = this.task.title;
|
this.title = this.task.title;
|
||||||
this.content = this.task.content;
|
this.content = this.task.content;
|
||||||
this.prio = this.task.priority;
|
this.prio = this.task.priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
if (this.task !== null && this.task !== undefined) {
|
if (this.task !== null && this.task !== undefined) {
|
||||||
this.task.title = this.title;
|
this.task.title = this.title;
|
||||||
this.task.content = this.content;
|
this.task.content = this.content;
|
||||||
this.task.priority = this.prio;
|
this.task.priority = this.prio;
|
||||||
this.backendService.putTask(this.task).subscribe(response => {
|
this.backendService.putTask(this.task).subscribe(response => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.task = { title: this.title, content: this.content, priority: this.prio };
|
this.task = { title: this.title, content: this.content, priority: this.prio };
|
||||||
this.backendService.postTask(this.task).subscribe(response => {
|
this.backendService.postTask(this.task).subscribe(response => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
this.activeModalService.close();
|
this.activeModalService.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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, Task } 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({
|
||||||
@ -10,7 +10,7 @@ import { TaskFormComponent } from '../task-form/task-form.component';
|
|||||||
})
|
})
|
||||||
export class TaskListComponent implements OnInit {
|
export class TaskListComponent implements OnInit {
|
||||||
|
|
||||||
public tasks: Task[] = [];
|
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 => {
|
||||||
@ -26,7 +26,7 @@ export class TaskListComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteTask(task: Task) {
|
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');
|
||||||
@ -38,7 +38,7 @@ export class TaskListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public openTaskForm(editTask: Task) {
|
public openTaskForm(editTask: ScrumTask) {
|
||||||
const modalRef = this.modalService.open(TaskFormComponent, {
|
const modalRef = this.modalService.open(TaskFormComponent, {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
|
0
src/app/userstory-list/userstory-list.component.css
Normal file
0
src/app/userstory-list/userstory-list.component.css
Normal file
48
src/app/userstory-list/userstory-list.component.ts
Normal file
48
src/app/userstory-list/userstory-list.component.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { BackendService, ScrumUserstory } from '../services/backend.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-userstory-list',
|
||||||
|
templateUrl: './userstory-list.component.html',
|
||||||
|
styleUrls: ['./userstory-list.component.css']
|
||||||
|
})
|
||||||
|
export class UserstoryListComponent implements OnInit {
|
||||||
|
|
||||||
|
public userstories: ScrumUserstory[] = [];
|
||||||
|
|
||||||
|
constructor(private backendService: BackendService, private modalService: NgbModal) {
|
||||||
|
backendService.getUserstories().subscribe(response => {
|
||||||
|
if (response.status > 399) {
|
||||||
|
alert('Fehler');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.userstories.push(...response.body);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
public deleteUserstory(userstory: ScrumUserstory) {
|
||||||
|
this.backendService.deleteUserstory(userstory).subscribe(response => {
|
||||||
|
if (response.status > 399) {
|
||||||
|
alert('Fehler');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const index = this.userstories.indexOf(userstory);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.userstories.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public openUserstoryForm(editUserstory: ScrumUserstory) {
|
||||||
|
const modalRef = this.modalService.open(UserstoryFormComponent, {
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: true,
|
||||||
|
});
|
||||||
|
modalRef.componentInstance.userstory = editUserstory;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user