feat: 3 screens for rotations

commit 563116331f
Author: eneller <erikneller@gmx.de>
Date:   Sun Feb 1 10:28:19 2026 +0100

    fix: edit list items

commit 1946c599be
Author: eneller <erikneller@gmx.de>
Date:   Sun Feb 1 10:19:16 2026 +0100

    fix: minor misc ui and data

commit 7c7762515b
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 23:02:01 2026 +0100

    feat: navbar

commit aaa0ab0638
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 21:05:23 2026 +0100

    feat: remove players

commit 4082932095
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 20:36:49 2026 +0100

    feat: dataservice

commit b6d34ce262
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 17:12:37 2026 +0100

    wip: rotations accordion

commit 764ce43138
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 16:29:11 2026 +0100

    refactor: basic screen

commit 1bc97df0da
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 15:52:06 2026 +0100

    feat: deduplicated player adding

commit 5408a8d9b6
Author: eneller <erikneller@gmx.de>
Date:   Sat Jan 31 00:31:01 2026 +0100

    central players list

commit 665cb25d34
Author: eneller <erikneller@gmx.de>
Date:   Fri Jan 30 23:15:16 2026 +0100

    feat: modal

commit 3b8e5145c3
Author: eneller <erikneller@gmx.de>
Date:   Fri Jan 30 22:51:09 2026 +0100

    wip: player modal

commit 51414f5a99
Author: eneller <erikneller@gmx.de>
Date:   Fri Jan 30 22:03:48 2026 +0100

    refactor: extract randomizer to component
This commit is contained in:
eneller
2026-02-01 10:40:05 +01:00
parent 7e7313916b
commit c4a2307530
27 changed files with 659 additions and 110 deletions

View File

@@ -1,77 +1,40 @@
import { Component, OnInit} from '@angular/core';
import { Component, inject, OnInit} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterOutlet, ActivatedRoute } from '@angular/router';
import { RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { CommonModule } from '@angular/common';
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 { ScreenEditComponent } from './screen-edit/screen-edit.component';
import { DataService } from './data.service';
@Component({
selector: 'app-root',
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule],
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent, RouterLink],
templateUrl: './app.component.html',
styleUrl: './app.component.less'
})
export class AppComponent implements OnInit {
title = 'vb';
playerNamesValue = "";
numTeamsSelectorValue = "2";
numTeamsSelected = 2;
nTeamsValue = "4";
teamsArray: string[][] = [];
duplicateNames: string[] = [];
data = inject(DataService);
constructor(private activatedRoute: ActivatedRoute){}
constructor(public route: ActivatedRoute){}
ngOnInit(): void {
this.activatedRoute.queryParams.pipe(
this.route.queryParams.pipe(
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
take(1)
).subscribe(params => {
const names = params['names']?.replaceAll(',', '\n');
if (names) {
this.playerNamesValue = names;
if (params['names']){
this.data.setPlayers(
params['names'].split(',').map((name: string) => new Player(name))
);
}
});
}
onButtonGenerate(textinput: string): void{
if(this.numTeamsSelectorValue === 'n'){
this.numTeamsSelected = Number(this.nTeamsValue);
}
else{
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
}
let nameslist = this.playerNamesValue
.split('\n')
.map(function(str){return str.trim();})
.filter(function(str){return str}); // boolean interpretation is same as non-empty
// remove duplicates by using a Set
let namesset = new Set(nameslist);
let names = [...namesset];
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
let playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
let nameslen = names.length;
function* iter(list: any[]){
let index = 0;
while(true){
yield list[index % list.length];
index++;
}
}
let iterator = iter(teams);
for(let i =0; i < nameslen; i++){
let index = Math.floor(Math.random()* names.length);
let n = names[index];
names.splice(index,1);
let team = iterator.next().value;
team.push(n);
}
this.teamsArray = teams;
}
}