Compare commits
2 Commits
master
...
e3824b15b8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3824b15b8 | ||
|
|
66fff4ee07 |
@@ -2,15 +2,9 @@
|
|||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
<nav>
|
<nav>
|
||||||
<ul ngbNav [activeId]="activeId" class="nav-tabs custom-navbar bg-body-secondary">
|
<ul ngbNav [activeId]="route.fragment | async" class="nav-tabs custom-navbar bg-body-secondary">
|
||||||
<li ngbNavItem="/" class="custom-navitem"><a ngbNavLink routerLink="" routerLinkActive="active">
|
<li ngbNavItem="" class="custom-navitem"><a ngbNavLink routerLink="" routerLinkActive="active"><i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a></li>
|
||||||
<i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a>
|
<li ngbNavItem="/basic.t" class="custom-navitem"><a ngbNavLink routerLink="/basic.t" routerLinkActive="active"><i class="bi bi-shuffle"></i></a></li>
|
||||||
</li>
|
<li ngbNavItem="/rotations.t" class="custom-navitem"><a ngbNavLink routerLink="/rotations.t" routerLinkActive="active"><i class="bi bi-arrow-repeat"></i></a></li>
|
||||||
<li ngbNavItem="/basic.t" class="custom-navitem"><a ngbNavLink routerLink="/basic.t" routerLinkActive="active">
|
|
||||||
<i class="bi bi-shuffle"></i></a>
|
|
||||||
</li>
|
|
||||||
<li ngbNavItem="/rotations.t" class="custom-navitem"><a ngbNavLink routerLink="/rotations.t" routerLinkActive="active">
|
|
||||||
<i class="bi bi-arrow-repeat"></i></a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,39 +1,31 @@
|
|||||||
import { Component, inject, OnInit} from '@angular/core';
|
import { Component, inject, OnInit} from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { RouterOutlet, ActivatedRoute, RouterLink, Router, NavigationEnd } from '@angular/router';
|
import { RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { filter, take } from 'rxjs';
|
import { filter, take } from 'rxjs';
|
||||||
|
import { ScreenBasicComponent } from "./screen-basic/screen-basic.component";
|
||||||
|
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||||
import { Player } from './model';
|
import { Player } from './model';
|
||||||
|
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||||
import { DataService } from './data.service';
|
import { DataService } from './data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, RouterLink],
|
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent, RouterLink],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.less'
|
styleUrl: './app.component.less'
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title = 'vb';
|
title = 'vb';
|
||||||
data = inject(DataService);
|
data = inject(DataService);
|
||||||
activeId = '/';
|
|
||||||
|
|
||||||
constructor(
|
constructor(public route: ActivatedRoute){}
|
||||||
private route: ActivatedRoute,
|
|
||||||
private router: Router
|
|
||||||
){}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.router.events
|
|
||||||
.pipe(filter(event => event instanceof NavigationEnd))
|
|
||||||
.subscribe(() => {
|
|
||||||
this.activeId = this.router.url;
|
|
||||||
});
|
|
||||||
// process query params
|
|
||||||
this.route.queryParams.pipe(
|
this.route.queryParams.pipe(
|
||||||
// Only proceed if params are not empty
|
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
|
||||||
filter(params => Object.keys(params).length > 0),
|
|
||||||
take(1)
|
take(1)
|
||||||
).subscribe(params => {
|
).subscribe(params => {
|
||||||
if (params['names']){
|
if (params['names']){
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Player } from './model';
|
|||||||
export class DataService {
|
export class DataService {
|
||||||
private players: Player[] = [];
|
private players: Player[] = [];
|
||||||
teams: Player[][] = [];
|
teams: Player[][] = [];
|
||||||
|
numTeams: number = 2;
|
||||||
|
|
||||||
setPlayers(players: Player[]){
|
setPlayers(players: Player[]){
|
||||||
for (let player of players){
|
for (let player of players){
|
||||||
|
|||||||
@@ -21,14 +21,9 @@ export class Player{
|
|||||||
this.setter = setter;
|
this.setter = setter;
|
||||||
this.libero = libero;
|
this.libero = libero;
|
||||||
}
|
}
|
||||||
getRoles(): string[] {
|
serialize(): string[] {
|
||||||
const roles = [];
|
const values = 'OOOO'
|
||||||
if (this.outside){roles.push('OH')}
|
return [this.name, values];
|
||||||
if (this.middle){roles.push('M')}
|
|
||||||
if (this.opposite){roles.push('OPP')}
|
|
||||||
if (this.setter){roles.push('S')}
|
|
||||||
if (this.libero){roles.push('L')}
|
|
||||||
return roles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string{
|
toString(): string{
|
||||||
|
|||||||
16
src/app/radio-nteams/radio-nteams.component.html
Normal file
16
src/app/radio-nteams/radio-nteams.component.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="btn-toolbar mb-3 col justify-content-center" role="toolbar">
|
||||||
|
<div class="btn-group me-2" id="numTeamsSelector" role="group">
|
||||||
|
<input value=2 [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio1">Two</label>
|
||||||
|
|
||||||
|
<input value=3 [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio2">Three</label>
|
||||||
|
|
||||||
|
<input value=0 [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio3">n</label>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="numTeamsSelectorValue !==2 && numTeamsSelectorValue !==3" id="nTeamsText" class="col-md-auto">
|
||||||
|
<label for="nTeamsField">n Teams</label>
|
||||||
|
<input type="number" pattern="\d*" [(ngModel)]="nTeamsValue" id="nTeamsField" class="form-control" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
0
src/app/radio-nteams/radio-nteams.component.less
Normal file
0
src/app/radio-nteams/radio-nteams.component.less
Normal file
23
src/app/radio-nteams/radio-nteams.component.spec.ts
Normal file
23
src/app/radio-nteams/radio-nteams.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { RadioNteamsComponent } from './radio-nteams.component';
|
||||||
|
|
||||||
|
describe('RadioNteamsComponent', () => {
|
||||||
|
let component: RadioNteamsComponent;
|
||||||
|
let fixture: ComponentFixture<RadioNteamsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [RadioNteamsComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(RadioNteamsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
19
src/app/radio-nteams/radio-nteams.component.ts
Normal file
19
src/app/radio-nteams/radio-nteams.component.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { DataService } from '../data.service';
|
||||||
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-radio-nteams',
|
||||||
|
imports: [FormsModule, NgbModule, CommonModule],
|
||||||
|
templateUrl: './radio-nteams.component.html',
|
||||||
|
styleUrl: './radio-nteams.component.less'
|
||||||
|
})
|
||||||
|
export class RadioNteamsComponent {
|
||||||
|
data = inject(DataService);
|
||||||
|
numTeamsSelectorValue = 2;
|
||||||
|
numTeamsSelected = 2;
|
||||||
|
nTeamsValue = "4";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,21 +1,5 @@
|
|||||||
<div class="justify-content-md-center">
|
<div class="justify-content-md-center">
|
||||||
<div class="btn-toolbar mb-3 col justify-content-center" role="toolbar">
|
<app-radio-nteams></app-radio-nteams>
|
||||||
<div class="btn-group me-2" id="numTeamsSelector" role="group"
|
|
||||||
value="2">
|
|
||||||
<input value="2" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio1">Two</label>
|
|
||||||
|
|
||||||
<input value="3" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio2">Three</label>
|
|
||||||
|
|
||||||
<input value="n" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio3">n</label>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="numTeamsSelectorValue === 'n'" id="nTeamsText" class="col-md-auto">
|
|
||||||
<label for="nTeamsField">n Teams</label>
|
|
||||||
<input type="number" pattern="\d*" [(ngModel)]="nTeamsValue" id="nTeamsField" class="form-control" >
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h1>Random Teams</h1>
|
<h1>Random Teams</h1>
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
|
|||||||
@@ -1,33 +1,26 @@
|
|||||||
// Original Team Generation Screen for arbitrary size and number of teams
|
// Original Team Generation Screen for arbitrary size and number of teams
|
||||||
import { Component, inject} from '@angular/core';
|
import { Component, inject} from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Player } from '../model';
|
import { Player } from '../model';
|
||||||
import { iter } from '../util';
|
import { iter } from '../util';
|
||||||
import { DataService } from '../data.service';
|
import { DataService } from '../data.service';
|
||||||
|
import { RadioNteamsComponent } from '../radio-nteams/radio-nteams.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-screen-basic',
|
selector: 'app-screen-basic',
|
||||||
imports: [NgbModule, CommonModule, FormsModule],
|
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, RadioNteamsComponent],
|
||||||
templateUrl: './screen-basic.component.html',
|
templateUrl: './screen-basic.component.html',
|
||||||
styleUrl: './screen-basic.component.less'
|
styleUrl: './screen-basic.component.less'
|
||||||
})
|
})
|
||||||
export class ScreenBasicComponent {
|
export class ScreenBasicComponent {
|
||||||
data = inject(DataService);
|
data = inject(DataService);
|
||||||
numTeamsSelectorValue = "2";
|
|
||||||
numTeamsSelected = 2;
|
|
||||||
nTeamsValue = "4";
|
|
||||||
|
|
||||||
onButtonGenerate(): void{
|
onButtonGenerate(): void{
|
||||||
if(this.numTeamsSelectorValue === 'n'){
|
|
||||||
this.numTeamsSelected = Number(this.nTeamsValue);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
let teams = Array.from({ length: this.data.numTeams }, () => []);
|
||||||
// clone array here
|
// clone array here
|
||||||
let localPlayers: Player[] = this.data.getPlayers();
|
let localPlayers: Player[] = this.data.getPlayers();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="Enter a name..."
|
placeholder="Enter a name..."
|
||||||
(keyup.enter)="addItem()"
|
(keyup.enter)="addItem()"
|
||||||
autocapitalize="words"
|
|
||||||
/>
|
/>
|
||||||
<button class="btn btn-primary" type="button" (click)="addItem()" >
|
<button class="btn btn-primary" type="button" (click)="addItem()" >
|
||||||
<i class="bi bi-plus-lg"></i> Add
|
<i class="bi bi-plus-lg"></i> Add
|
||||||
@@ -20,10 +19,7 @@
|
|||||||
<ul class="list-group mb-3">
|
<ul class="list-group mb-3">
|
||||||
@for (player of data.getPlayers(); track $index) {
|
@for (player of data.getPlayers(); track $index) {
|
||||||
<li class="list-group-item d-flex justify-content-between">
|
<li class="list-group-item d-flex justify-content-between">
|
||||||
<div (click)="openPlayerModal(player)" class="player-content">
|
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer; flex-grow: 1; text-align: left;">{{ player.name }}</a>
|
||||||
<div class="text-start">{{ player.name }}</div>
|
|
||||||
<div class="text-end text-muted">{{ player.getRoles() }}</div>
|
|
||||||
</div>
|
|
||||||
<button (click)="removeItem(player)" class="btn btn-secondary btn-sm p-0 ms-2" style="width: 24px; height: 24px" >
|
<button (click)="removeItem(player)" class="btn btn-secondary btn-sm p-0 ms-2" style="width: 24px; height: 24px" >
|
||||||
<i class="bi bi-x"></i>
|
<i class="bi bi-x"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
.player-content{
|
|
||||||
cursor: pointer;
|
|
||||||
flex-grow: 1;
|
|
||||||
text-align: left;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// Team Generation Screen respecting volleyball roles as defined by `../model/Player`
|
// Team Generation Screen respecting volleyball roles as defined by `../model/Player`
|
||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, inject, Input } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { Player } from '../model';
|
import { Player } from '../model';
|
||||||
import { NgbAccordionBody, NgbAccordionCollapse, NgbAccordionHeader, NgbAccordionItem, NgbAccordionButton, NgbAccordionDirective, NgbAccordionToggle } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbAccordionBody, NgbAccordionCollapse, NgbAccordionHeader, NgbAccordionItem, NgbAccordionButton, NgbAccordionDirective, NgbAccordionToggle } from '@ng-bootstrap/ng-bootstrap';
|
||||||
@@ -11,13 +11,8 @@ import { DataService } from '../data.service';
|
|||||||
templateUrl: './screen-rotations.component.html',
|
templateUrl: './screen-rotations.component.html',
|
||||||
styleUrl: './screen-rotations.component.less'
|
styleUrl: './screen-rotations.component.less'
|
||||||
})
|
})
|
||||||
export class ScreenRotationsComponent implements OnInit{
|
export class ScreenRotationsComponent {
|
||||||
data = inject(DataService);
|
data = inject(DataService);
|
||||||
ngOnInit(): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
// https://de.wikipedia.org/wiki/Volleyball#Spielpositionen
|
|
||||||
// we want 2 outside, 1 opp, 1 set and either 2*middle or middle + libero
|
|
||||||
|
|
||||||
get OutsidePlayers(): Player[] {
|
get OutsidePlayers(): Player[] {
|
||||||
return this.data.getPlayers().filter(player => player.outside);
|
return this.data.getPlayers().filter(player => player.outside);
|
||||||
|
|||||||
Reference in New Issue
Block a user