From 89429b49b36e01c54204a1c69ea82a9538d0dbc1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jun 2020 13:23:08 +0200 Subject: [PATCH] added status title --- src/app/app-routing.module.ts | 12 +- src/app/app.module.ts | 14 +- src/app/dashboard/dashboard.component.css | 4 +- src/app/dashboard/dashboard.component.html | 4 +- src/app/dashboard/dashboard.component.ts | 268 ++++++++++++--------- src/app/task-form/task-form.component.html | 196 +++++++++------ src/app/task-form/task-form.component.ts | 9 + 7 files changed, 296 insertions(+), 211 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 3774aa5..909fbbc 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,21 +1,21 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import {UserstoryTableComponent} from './userstory-table/userstory-table.component'; -import {TaskTableComponent} from './task-table/task-table.component'; +import { UserstoryTableComponent } from './userstory-table/userstory-table.component'; +import { TaskTableComponent } from './task-table/task-table.component'; import { SprintTableComponent } from './sprint-table/sprint-table.component'; -import { DashboardComponent } from './dashboard/dashboard.component'; +// import { DashboardComponent } from './dashboard/dashboard.component'; const routes: Routes = [ { path: 'tasks', component: TaskTableComponent }, { path: 'userstories', component: UserstoryTableComponent }, { path: 'sprints', component: SprintTableComponent }, - { path: 'dashboard', component: DashboardComponent }, + // { path: 'dashboard', component: DashboardComponent }, { path: '', redirectTo: '/tasks', pathMatch: 'full' }, ]; @NgModule({ - imports: [ RouterModule.forRoot(routes) ], - exports: [ RouterModule ] + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule], }) export class AppRoutingModule {} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 31855b7..df6ac7c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,7 +14,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { UserstoryTableComponent } from './userstory-table/userstory-table.component'; import { TaskTableComponent } from './task-table/task-table.component'; import { SprintTableComponent } from './sprint-table/sprint-table.component'; -import { DashboardComponent } from './dashboard/dashboard.component'; +// import { DashboardComponent } from './dashboard/dashboard.component'; @NgModule({ declarations: [ @@ -26,18 +26,16 @@ import { DashboardComponent } from './dashboard/dashboard.component'; UserstoryTableComponent, SprintFormComponent, SprintTableComponent, - DashboardComponent + // DashboardComponent, ], imports: [ BrowserModule, AppRoutingModule, HttpClientModule, FormsModule, - NgbModule + NgbModule, ], - providers: [ - BackendService, - ], - bootstrap: [AppComponent] + providers: [BackendService], + bootstrap: [AppComponent], }) -export class AppModule { } +export class AppModule {} diff --git a/src/app/dashboard/dashboard.component.css b/src/app/dashboard/dashboard.component.css index bfaa597..4a386a0 100644 --- a/src/app/dashboard/dashboard.component.css +++ b/src/app/dashboard/dashboard.component.css @@ -1,3 +1,3 @@ -.text-2em { +/* .text-2em { font-size: 2rem; -} +} */ diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index e604953..b63d9f1 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -1,4 +1,4 @@ -
+{% comment %}

Dashboard

@@ -57,4 +57,4 @@
-
+
{% endcomment %} diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 470e6f3..edbe983 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,127 +1,159 @@ -import {Component, OnInit} from '@angular/core'; -import Chart from 'chart.js'; -import {BackendService, ScrumStatus, ScrumUser, ScrumUserstory, ScrumSprint} from '../services/backend.service'; +// import { Component, OnInit } from '@angular/core'; +// // import Chart from 'chart.js'; +// import { +// BackendService, +// ScrumStatus, +// ScrumUser, +// ScrumUserstory, +// ScrumSprint, +// } from '../services/backend.service'; -@Component({ - selector: 'app-dashboard', - templateUrl: 'dashboard.component.html', - styleUrls: ['./dashboard.component.css'] -}) -export class DashboardComponent implements OnInit { - /** - * Returns the status that are used by at least one userstory. - */ - public get usedStatus(): ScrumStatus[] { - return this.status.filter(s => this.userstories.find(us => us.statusid === s.id) !== undefined); - } +// @Component({ +// selector: 'app-dashboard', +// templateUrl: 'dashboard.component.html', +// styleUrls: ['./dashboard.component.css'], +// }) +// export class DashboardComponent implements OnInit { +// /** +// * Returns the status that are used by at least one userstory. +// */ +// public get usedStatus(): ScrumStatus[] { +// return this.status.filter( +// (s) => this.userstories.find((us) => us.statusid === s.id) !== undefined +// ); +// } - private status: ScrumStatus[]; - private userstories: ScrumUserstory[]; - private sprints: ScrumSprint[]; +// private status: ScrumStatus[]; +// private userstories: ScrumUserstory[]; +// private sprints: ScrumSprint[]; - constructor(private backendService: BackendService) { - // backendService.getUserstories().subscribe(response => { - // if (response.status > 399) { - // alert('Fehler'); - // } else { - // this.userstories.push(...response.body); - // } - // }); - // backendService.getAllStatus().subscribe(response => { - // if (response.status > 399) { - // alert('Fehler'); - // } else { - // this.status.push(...response.body); - // } - // }); - // backendService.getSprints().subscribe(response => { - // if (response.status > 399) { - // alert('Fehler'); - // } else { - // this.sprints.push(...response.body); - // } - // }); +// constructor(private backendService: BackendService) { +// // backendService.getUserstories().subscribe(response => { +// // if (response.status > 399) { +// // alert('Fehler'); +// // } else { +// // this.userstories.push(...response.body); +// // } +// // }); +// // backendService.getAllStatus().subscribe(response => { +// // if (response.status > 399) { +// // alert('Fehler'); +// // } else { +// // this.status.push(...response.body); +// // } +// // }); +// // backendService.getSprints().subscribe(response => { +// // if (response.status > 399) { +// // alert('Fehler'); +// // } else { +// // this.sprints.push(...response.body); +// // } +// // }); - this.status = [ - {id: 0, title: "In progress", description:""}, - {id: 1, title: "Done", description:""}, - ]; - this.userstories = [ - {statusid: 0, title:""}, - {statusid: 0, title:""}, - {statusid: 0, title:""}, - {statusid: 1, title:""}, - {statusid: 1, title:""}, - ]; - this.sprints = [ - {description:"", title:"", project: 0, startDate: new Date(2020, 5, 22), endDate: new Date(2020, 5, 28)}, - {description:"", title:"", project: 0, startDate: new Date(2020, 5, 29), endDate: new Date(2020, 6, 5)}, - ] - } +// this.status = [ +// { id: 0, title: 'In progress', description: '' }, +// { id: 1, title: 'Done', description: '' }, +// ]; +// this.userstories = [ +// { statusid: 0, title: '' }, +// { statusid: 0, title: '' }, +// { statusid: 0, title: '' }, +// { statusid: 1, title: '' }, +// { statusid: 1, title: '' }, +// ]; +// this.sprints = [ +// { +// description: '', +// title: '', +// project: 0, +// startDate: new Date(2020, 5, 22), +// endDate: new Date(2020, 5, 28), +// }, +// { +// description: '', +// title: '', +// project: 0, +// startDate: new Date(2020, 5, 29), +// endDate: new Date(2020, 6, 5), +// }, +// ]; +// } +// ngOnInit(): void { +// // @ts-ignore +// const context = document +// .getElementById('done-stories-chart') +// .getContext('2d'); +// const chart = new Chart(context, { +// type: 'pie', +// data: { +// labels: this.usedStatus.map((s) => s.title), +// datasets: [ +// { +// label: 'Done stories', +// data: this.usedStatus.map((s) => +// this.getNumberOfUserstoriesByStatus(s) +// ), +// backgroundColor: this.getBackgroundColors(), +// }, +// ], +// }, +// }); +// } - ngOnInit(): void { - // @ts-ignore - const context = document.getElementById('done-stories-chart').getContext('2d'); - const chart = new Chart(context, { - type: 'pie', - data: { - labels: this.usedStatus.map(s => s.title), - datasets: [{ - label: 'Done stories', - data: this.usedStatus.map(s => this.getNumberOfUserstoriesByStatus(s)), - backgroundColor: this.getBackgroundColors(), - }] - } - }); - } +// private getBackgroundColors(): string[] { +// const baseColors = [ +// 'rgb(255, 153, 102)', +// 'rgb(255, 102, 102)', +// 'rgb(153, 204, 255)', +// 'rgb(102, 153, 102)', +// 'rgb(204, 204, 153)', +// 'rgb(153, 102, 204)', +// 'rgb(204, 102, 102)', +// 'rgb(255, 204, 153)', +// 'rgb(153, 102, 255)', +// 'rgb(204, 204, 204)', +// 'rgb(102, 255, 204)', +// 'rgb(102, 153, 255)', +// 'rgb(153, 102, 153)', +// 'rgb(204, 204, 255)', +// ]; +// const colors = []; +// while (colors.length < this.usedStatus.length) { +// colors.push(...baseColors); +// } +// return colors; +// } - private getBackgroundColors(): string[] { - const baseColors = [ - 'rgb(255, 153, 102)', - 'rgb(255, 102, 102)', - 'rgb(153, 204, 255)', - 'rgb(102, 153, 102)', - 'rgb(204, 204, 153)', - 'rgb(153, 102, 204)', - 'rgb(204, 102, 102)', - 'rgb(255, 204, 153)', - 'rgb(153, 102, 255)', - 'rgb(204, 204, 204)', - 'rgb(102, 255, 204)', - 'rgb(102, 153, 255)', - 'rgb(153, 102, 153)', - 'rgb(204, 204, 255)', - ]; - const colors = []; - while (colors.length < this.usedStatus.length) { - colors.push(...baseColors); - } - return colors; - } +// public getNumberOfUserstoriesByStatus(status: ScrumStatus): number { +// return this.userstories.filter((us) => us.statusid === status.id).length; +// } - public getNumberOfUserstoriesByStatus(status: ScrumStatus): number { - return this.userstories.filter(us => us.statusid === status.id).length; - } +// public getRemainingDaysInSprint(): number { +// const now = new Date(); +// const currentSprint = this.sprints.find( +// (s) => s.endDate > now && s.startDate < now +// ); +// if (currentSprint === undefined) { +// return undefined; +// } +// const daysDelta = Math.floor( +// (currentSprint.endDate.getTime() - now.getTime()) / 86400000 +// ); +// return daysDelta; +// } - public getRemainingDaysInSprint(): number { - const now = new Date(); - const currentSprint = this.sprints.find(s => s.endDate > now && s.startDate < now); - if (currentSprint === undefined) { - return undefined; - } - const daysDelta = Math.floor((currentSprint.endDate.getTime() - now.getTime()) / 86400000); - return daysDelta; - } - - public getSprintUrgency(): number { - const now = new Date(); - const currentSprint = this.sprints.find(s => s.endDate > now && s.startDate < now); - if (currentSprint === undefined) { - return undefined; - } - const deltaFromNow = currentSprint.endDate.getTime() - now.getTime(); - const deltaFromStart = currentSprint.endDate.getTime() - currentSprint.startDate.getTime(); - return Math.floor(3 * deltaFromNow / deltaFromStart); - } -} +// public getSprintUrgency(): number { +// const now = new Date(); +// const currentSprint = this.sprints.find( +// (s) => s.endDate > now && s.startDate < now +// ); +// if (currentSprint === undefined) { +// return undefined; +// } +// const deltaFromNow = currentSprint.endDate.getTime() - now.getTime(); +// const deltaFromStart = +// currentSprint.endDate.getTime() - currentSprint.startDate.getTime(); +// return Math.floor((3 * deltaFromNow) / deltaFromStart); +// } +// } diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index 595fff4..b6b4015 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -1,78 +1,124 @@ + + + diff --git a/src/app/task-form/task-form.component.ts b/src/app/task-form/task-form.component.ts index ed7ddbe..a22c025 100644 --- a/src/app/task-form/task-form.component.ts +++ b/src/app/task-form/task-form.component.ts @@ -24,6 +24,7 @@ export class TaskFormComponent implements OnInit { public userstoryId: string; public userstories: any[] = []; public allStatus: any[] = []; + public status: ScrumStatus; constructor( private backendService: BackendService, @@ -95,6 +96,14 @@ export class TaskFormComponent implements OnInit { }); } + createTaskStatus() { + this.backendService.postStatus(this.status).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + // addNewStatus() { // this.allStatus; // }