diff --git a/package.json b/package.json index 22bbf00..f1353ed 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,13 @@ "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~3.8.3" - } + }, + "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.7.", + "main": "karma.conf.js", + "repository": { + "type": "git", + "url": "https://git.informatik.fh-nuernberg.de/scrum-taskboard/frontend.git" + }, + "author": "", + "license": "ISC" } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7e0c37c..a59d88d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,15 +4,14 @@ import { Routes, RouterModule } from '@angular/router'; import { TaskListComponent } from './task-list/task-list.component'; import { UserstoryListComponent } from './userstory-list/userstory-list.component'; - const routes: Routes = [ - { path: 'tasks', component: TaskListComponent }, - { path: 'userstories', component: UserstoryListComponent }, - { path: '', redirectTo: '/tasks', pathMatch: 'full' }, + { path: 'tasks', component: TaskListComponent }, + { path: 'userstories', component: UserstoryListComponent }, + { path: '', redirectTo: '/tasks', pathMatch: 'full' } ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] + imports: [ RouterModule.forRoot(routes) ], + exports: [ RouterModule ] }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e6c683f..a724a81 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,6 +11,7 @@ import { TaskListComponent } from './task-list/task-list.component'; import { TaskFormComponent } from './task-form/task-form.component'; import { UserstoryListComponent } from './userstory-list/userstory-list.component'; import { UserstoryFormComponent } from './userstory-form/userstory-form.component'; +import { SprintFormComponent } from './sprint-form/sprint-form.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @NgModule({ @@ -19,7 +20,8 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; TaskListComponent, TaskFormComponent, UserstoryListComponent, - UserstoryFormComponent + UserstoryFormComponent, + SprintFormComponent ], imports: [ BrowserModule, diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts index 239f82a..8682de8 100644 --- a/src/app/services/backend.service.ts +++ b/src/app/services/backend.service.ts @@ -232,7 +232,7 @@ export interface ScrumUserstory { export interface ScrumSprint{ id?: number; title: string; - description: string; + description?: string; startDate: Date; endDate: Date; project: number; diff --git a/src/app/sprint-component/sprint.component.css b/src/app/sprint-component/sprint.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/sprint-component/sprint.component.html b/src/app/sprint-component/sprint.component.html new file mode 100644 index 0000000..9190d3a --- /dev/null +++ b/src/app/sprint-component/sprint.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/sprint-component/sprint.component.ts b/src/app/sprint-component/sprint.component.ts new file mode 100644 index 0000000..d47b86b --- /dev/null +++ b/src/app/sprint-component/sprint.component.ts @@ -0,0 +1,54 @@ +import { Component, OnInit } from '@angular/core'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { BackendService, ScrumSprint } from '../services/backend.service'; +import { SprintFormComponent } from '../sprint-form/sprint-form.component'; + +@Component({ + selector: 'app-sprint', + templateUrl: './sprint.component.html', + styleUrls: ['./sprint.component.css'] +}) +export class SprintComponent implements OnInit { + + public sprints: ScrumSprint[] = []; + + constructor(private backendService: BackendService, private modalService: NgbModal) { + backendService.getSprints().subscribe(response => { + if (response.status > 399) { + alert('Fehler'); + } + else { + this.sprints.push(...response.body); + } + }); + } + + ngOnInit(): void { + } + + public deleteSprint(sprint: ScrumSprint) { + this.backendService.deleteSprint(sprint).subscribe(response => { + if (response.status > 399) { + alert('Fehler'); + } + }); + const index = this.sprints.indexOf(sprint); + if (index !== -1) { + this.sprints.splice(index, 1); + } + } + + public openSprintForm(editSprint: ScrumSprint) { + const modalRef = this.modalService.open(SprintFormComponent, { + backdrop: 'static', + keyboard: true, + }); + if (editSprint === null) { + modalRef.result.then(result => { + this.sprints.push(result); + }); + } + modalRef.componentInstance.userstory = editSprint; + } + +} diff --git a/src/app/sprint-form/sprint-form.component.css b/src/app/sprint-form/sprint-form.component.css new file mode 100644 index 0000000..717de4c --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.css @@ -0,0 +1,4 @@ +.modal-footer { + border-top: 0px solid; + padding-top: 5%; +} \ No newline at end of file diff --git a/src/app/sprint-form/sprint-form.component.html b/src/app/sprint-form/sprint-form.component.html new file mode 100644 index 0000000..d8b7ecd --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.html @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/src/app/sprint-form/sprint-form.component.ts b/src/app/sprint-form/sprint-form.component.ts new file mode 100644 index 0000000..f19c1bb --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.ts @@ -0,0 +1,62 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { + BackendService, + ScrumTask, + Priority, + ScrumStatus, + ScrumCategory, + ScrumUser, + ScrumProject, + ScrumUserstory, + ScrumSprint +} from '../services/backend.service'; +import { Observable } from 'rxjs'; +import { HttpResponse } from '@angular/common/http'; + +@Component({ + selector: 'app-task-form', + templateUrl: './sprint-form.component.html', + styleUrls: ['./sprint-form.component.css'], +}) +export class SprintFormComponent implements OnInit { + @Input() public sprint: ScrumSprint; + public editing: Boolean; + public sprintid: string; + + constructor( + private backendService: BackendService, + private activeModalService: NgbActiveModal + ) { } + + ngOnInit(): void { + if (this.sprint === null || this.sprint === undefined) { + this.sprint = { title: '', startDate: new Date(), endDate: new Date(), project: 0 }; //project id: static counter? + this.editing = false; + } else { + this.editing = true; + } + document.getElementById('titleField').focus(); + } + + onSubmit() { + if (this.editing) { + this.backendService.putSprint(this.sprint).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } else { + this.backendService.postSprint(this.sprint).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + this.activeModalService.close(this.sprint); + } + + onClose() { + this.activeModalService.dismiss(this.sprint); + } +} diff --git a/src/app/task-form/task-form.component.css b/src/app/task-form/task-form.component.css index e69de29..2b8a6fe 100644 --- a/src/app/task-form/task-form.component.css +++ b/src/app/task-form/task-form.component.css @@ -0,0 +1,13 @@ +.modal-footer { + border-top: 0px solid; + padding-top: 5%; +} +.modal-content { + width: 1040px; + right: 55%; + border: 0px; +} + +.modal { + margin: 0 auto; +} diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index b0a5f4e..d63239f 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -1,30 +1,68 @@