diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index f430104..641d8f4 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -8,6 +8,10 @@ export const routes: Routes = [ path: '', children: [ { path: '', component: ScreenEditComponent }, + /* IMPORTANT: all routes have to include a `.` (dot) + this is a workaround used in `sw.js` + to allow hosting services on the same subdomain as this PWA + */ { path: 'basic.t', component: ScreenBasicComponent }, { path: 'rotations.t', component: ScreenRotationsComponent } ] diff --git a/src/app/data.service.ts b/src/app/data.service.ts index 113e1a2..2f7fa32 100644 --- a/src/app/data.service.ts +++ b/src/app/data.service.ts @@ -7,6 +7,7 @@ import { Player } from './model'; export class DataService { private players: Player[] = []; teams: Player[][] = []; + numTeams: number = 2; setPlayers(players: Player[]){ for (let player of players){ diff --git a/src/app/radio-nteams/radio-nteams.component.html b/src/app/radio-nteams/radio-nteams.component.html new file mode 100644 index 0000000..fbc2d0a --- /dev/null +++ b/src/app/radio-nteams/radio-nteams.component.html @@ -0,0 +1,16 @@ + diff --git a/src/app/radio-nteams/radio-nteams.component.less b/src/app/radio-nteams/radio-nteams.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/radio-nteams/radio-nteams.component.spec.ts b/src/app/radio-nteams/radio-nteams.component.spec.ts new file mode 100644 index 0000000..25baa82 --- /dev/null +++ b/src/app/radio-nteams/radio-nteams.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RadioNteamsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(RadioNteamsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/radio-nteams/radio-nteams.component.ts b/src/app/radio-nteams/radio-nteams.component.ts new file mode 100644 index 0000000..78cf263 --- /dev/null +++ b/src/app/radio-nteams/radio-nteams.component.ts @@ -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"; + +} diff --git a/src/app/screen-basic/screen-basic.component.html b/src/app/screen-basic/screen-basic.component.html index c84ccae..6709ed4 100644 --- a/src/app/screen-basic/screen-basic.component.html +++ b/src/app/screen-basic/screen-basic.component.html @@ -1,21 +1,5 @@
- +

Random Teams

diff --git a/src/app/screen-basic/screen-basic.component.ts b/src/app/screen-basic/screen-basic.component.ts index 3d77c90..496fb4f 100644 --- a/src/app/screen-basic/screen-basic.component.ts +++ b/src/app/screen-basic/screen-basic.component.ts @@ -7,28 +7,20 @@ import { CommonModule } from '@angular/common'; import { Player } from '../model'; import { iter } from '../util'; import { DataService } from '../data.service'; +import { RadioNteamsComponent } from '../radio-nteams/radio-nteams.component'; @Component({ selector: 'app-screen-basic', - imports: [NgbModule, RouterOutlet, CommonModule, FormsModule], + imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, RadioNteamsComponent], templateUrl: './screen-basic.component.html', styleUrl: './screen-basic.component.less' }) export class ScreenBasicComponent { data = inject(DataService); - numTeamsSelectorValue = "2"; - numTeamsSelected = 2; - nTeamsValue = "4"; 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 let localPlayers: Player[] = this.data.getPlayers();