Compare commits
5 Commits
feat/rotat
...
e3824b15b8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3824b15b8 | ||
|
|
66fff4ee07 | ||
|
|
8493e742e9 | ||
|
|
2999d8eee7 | ||
|
|
c4a2307530 |
@@ -3,8 +3,8 @@
|
|||||||
</main>
|
</main>
|
||||||
<nav>
|
<nav>
|
||||||
<ul ngbNav [activeId]="route.fragment | async" class="nav-tabs custom-navbar bg-body-secondary">
|
<ul ngbNav [activeId]="route.fragment | async" class="nav-tabs custom-navbar bg-body-secondary">
|
||||||
<li ngbNavItem="/edit" class="custom-navitem"><a ngbNavLink routerLink="/edit" routerLinkActive="active"><i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a></li>
|
<li ngbNavItem="" class="custom-navitem"><a ngbNavLink routerLink="" routerLinkActive="active"><i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a></li>
|
||||||
<li ngbNavItem="/basic" class="custom-navitem"><a ngbNavLink routerLink="/basic" routerLinkActive="active"><i class="bi bi-shuffle"></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" class="custom-navitem"><a ngbNavLink routerLink="/rotations" routerLinkActive="active"><i class="bi bi-arrow-repeat"></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>
|
||||||
@@ -22,7 +22,6 @@ tr{
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
.custom-navbar{
|
.custom-navbar{
|
||||||
height: 3rem;
|
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@@ -34,5 +33,3 @@ tr{
|
|||||||
text-align: center; /* Center the content of each item */
|
text-align: center; /* Center the content of each item */
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
.nav-link.active{
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,18 @@ import { Routes } from '@angular/router';
|
|||||||
import { ScreenBasicComponent } from './screen-basic/screen-basic.component';
|
import { ScreenBasicComponent } from './screen-basic/screen-basic.component';
|
||||||
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||||
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||||
import { AppComponent } from './app.component';
|
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
children: [
|
children: [
|
||||||
{ path: '', redirectTo: 'edit', pathMatch: 'full' },
|
{ path: '', component: ScreenEditComponent },
|
||||||
{ path: 'edit', component: ScreenEditComponent },
|
/* IMPORTANT: all routes have to include a `.` (dot)
|
||||||
{ path: 'basic', component: ScreenBasicComponent },
|
this is a workaround used in `sw.js`
|
||||||
{ path: 'rotations', component: ScreenRotationsComponent }
|
to allow hosting services on the same subdomain as this PWA
|
||||||
|
*/
|
||||||
|
{ path: 'basic.t', component: ScreenBasicComponent },
|
||||||
|
{ path: 'rotations.t', component: ScreenRotationsComponent }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { Player } from './model';
|
|||||||
})
|
})
|
||||||
export class DataService {
|
export class DataService {
|
||||||
private players: Player[] = [];
|
private players: Player[] = [];
|
||||||
|
teams: Player[][] = [];
|
||||||
|
numTeams: number = 2;
|
||||||
|
|
||||||
setPlayers(players: Player[]){
|
setPlayers(players: Player[]){
|
||||||
for (let player of players){
|
for (let player of players){
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class Player{
|
|||||||
return [this.name, values];
|
return [this.name, values];
|
||||||
}
|
}
|
||||||
|
|
||||||
valueOf(): string{
|
toString(): string{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
static deSerialize(name: string, values: string): Player{
|
static deSerialize(name: string, values: string): Player{
|
||||||
|
|||||||
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>
|
||||||
@@ -30,7 +14,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@for (team of teamsArray; track $index) {
|
@for (team of data.teams; track $index) {
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||||
<td class="wrap-cell">{{ team }}</td>
|
<td class="wrap-cell">{{ team }}</td>
|
||||||
|
|||||||
@@ -7,29 +7,20 @@ 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, RouterOutlet, 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";
|
|
||||||
teamsArray: string[][] = [];
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@@ -40,10 +31,10 @@ export class ScreenBasicComponent {
|
|||||||
let n = localPlayers[index];
|
let n = localPlayers[index];
|
||||||
localPlayers.splice(index,1);
|
localPlayers.splice(index,1);
|
||||||
let team = iterator.next().value;
|
let team = iterator.next().value;
|
||||||
team.push(n.name);
|
team.push(n);
|
||||||
|
|
||||||
}
|
}
|
||||||
this.teamsArray = teams;
|
this.data.teams = teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ html, body {
|
|||||||
body {
|
body {
|
||||||
margin:3em auto;
|
margin:3em auto;
|
||||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||||
padding:0 .5em;
|
padding:.5em auto;
|
||||||
}
|
}
|
||||||
h1,h2,h3{
|
h1,h2,h3{
|
||||||
line-height:1.2;
|
line-height:1.2;
|
||||||
|
|||||||
Reference in New Issue
Block a user