Compare commits
7 Commits
master
...
b6d34ce262
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6d34ce262 | ||
|
|
764ce43138 | ||
|
|
1bc97df0da | ||
|
|
5408a8d9b6 | ||
|
|
665cb25d34 | ||
|
|
3b8e5145c3 | ||
|
|
51414f5a99 |
@@ -35,7 +35,6 @@
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
"node_modules/bootstrap-icons/font/bootstrap-icons.min.css",
|
||||
"src/styles.less"
|
||||
],
|
||||
"scripts": [],
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -23,7 +23,6 @@
|
||||
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"bootstrap": "^5.3.3",
|
||||
"bootstrap-icons": "^1.13.1",
|
||||
"express": "^4.18.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"sonarqube-scanner": "^4.3.0",
|
||||
@@ -6250,22 +6249,6 @@
|
||||
"@popperjs/core": "^2.11.8"
|
||||
}
|
||||
},
|
||||
"node_modules/bootstrap-icons": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.13.1.tgz",
|
||||
"integrity": "sha512-ijombt4v6bv5CLeXvRWKy7CuM3TRTuPEuGaGKvTV5cz65rQSY8RQ2JcHt6b90cBBAC7s8fsf2EkQDldzCoXUjw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/twbs"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bootstrap"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"bootstrap": "^5.3.3",
|
||||
"bootstrap-icons": "^1.13.1",
|
||||
"express": "^4.18.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"sonarqube-scanner": "^4.3.0",
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<main class="main">
|
||||
<router-outlet></router-outlet>
|
||||
<app-screen-rotations [players]="players"></app-screen-rotations>
|
||||
</main>
|
||||
<nav>
|
||||
<ul ngbNav [activeId]="route.fragment | async" class="nav-tabs custom-navbar bg-body-secondary">
|
||||
<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.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>
|
||||
</nav>
|
||||
|
||||
<router-outlet />
|
||||
|
||||
@@ -16,20 +16,3 @@ tr{
|
||||
word-break: break-all;
|
||||
white-space: normal;
|
||||
}
|
||||
.main{
|
||||
margin-bottom: 5rem;
|
||||
padding: 1rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.custom-navbar{
|
||||
width: 100vw;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
justify-content: space-around; /* Distribute items evenly */
|
||||
z-index: 1000;
|
||||
}
|
||||
.custom-navitem{
|
||||
text-align: center; /* Center the content of each item */
|
||||
flex: 1;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, inject, OnInit} from '@angular/core';
|
||||
import { Component, OnInit} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
|
||||
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -9,29 +9,26 @@ 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, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent, RouterLink],
|
||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.less'
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'vb';
|
||||
data = inject(DataService);
|
||||
players : Player[] = [];
|
||||
|
||||
constructor(public route: ActivatedRoute){}
|
||||
constructor(private activatedRoute: ActivatedRoute){}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParams.pipe(
|
||||
this.activatedRoute.queryParams.pipe(
|
||||
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
|
||||
take(1)
|
||||
).subscribe(params => {
|
||||
if (params['names']){
|
||||
this.data.setPlayers(
|
||||
params['names'].split(',').map((name: string) => new Player(name))
|
||||
);
|
||||
this.players = params['names'].split(',').map((name: string) => new Player(name));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { ScreenBasicComponent } from './screen-basic/screen-basic.component';
|
||||
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
children: [
|
||||
{ path: '', component: ScreenEditComponent },
|
||||
{ path: 'basic.t', component: ScreenBasicComponent },
|
||||
{ path: 'rotations.t', component: ScreenRotationsComponent }
|
||||
]
|
||||
}
|
||||
];
|
||||
export const routes: Routes = [];
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DataService } from './data.service';
|
||||
|
||||
describe('DataService', () => {
|
||||
let service: DataService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(DataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Player } from './model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DataService {
|
||||
private players: Player[] = [];
|
||||
teams: Player[][] = [];
|
||||
|
||||
setPlayers(players: Player[]){
|
||||
for (let player of players){
|
||||
this.addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
addPlayer(player: Player): boolean{
|
||||
if (player.name.trim() && Player.isNew(player, this.players)){
|
||||
this.players.push(player);
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
removePlayer(player: Player){
|
||||
const index = this.players.indexOf(player);
|
||||
if (index !== -1) {
|
||||
this.players.splice(index, 1);
|
||||
}
|
||||
}
|
||||
getPlayers(): Player[] {
|
||||
let clone =Object.assign([],this.players);
|
||||
return clone
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export class Player{
|
||||
return [this.name, values];
|
||||
}
|
||||
|
||||
toString(): string{
|
||||
valueOf(): string{
|
||||
return this.name;
|
||||
}
|
||||
static deSerialize(name: string, values: string): Player{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (team of data.teams; track $index) {
|
||||
@for (team of teamsArray; track $index) {
|
||||
<tr>
|
||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||
<td class="wrap-cell">{{ team }}</td>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Original Team Generation Screen for arbitrary size and number of teams
|
||||
import { Component, inject} from '@angular/core';
|
||||
import { Component, Input, OnInit} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Player } from '../model';
|
||||
import { iter } from '../util';
|
||||
import { DataService } from '../data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-basic',
|
||||
@@ -15,10 +14,11 @@ import { DataService } from '../data.service';
|
||||
styleUrl: './screen-basic.component.less'
|
||||
})
|
||||
export class ScreenBasicComponent {
|
||||
data = inject(DataService);
|
||||
@Input() players!: Player[];
|
||||
numTeamsSelectorValue = "2";
|
||||
numTeamsSelected = 2;
|
||||
nTeamsValue = "4";
|
||||
teamsArray: string[][] = [];
|
||||
|
||||
onButtonGenerate(): void{
|
||||
if(this.numTeamsSelectorValue === 'n'){
|
||||
@@ -30,7 +30,7 @@ export class ScreenBasicComponent {
|
||||
|
||||
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
||||
// clone array here
|
||||
let localPlayers: Player[] = this.data.getPlayers();
|
||||
let localPlayers: Player[] = Object.assign([],this.players);
|
||||
|
||||
let nameslen = localPlayers.length;
|
||||
let iterator = iter(teams);
|
||||
@@ -39,10 +39,10 @@ export class ScreenBasicComponent {
|
||||
let n = localPlayers[index];
|
||||
localPlayers.splice(index,1);
|
||||
let team = iterator.next().value;
|
||||
team.push(n);
|
||||
team.push(n.name);
|
||||
|
||||
}
|
||||
this.data.teams = teams;
|
||||
this.teamsArray = teams;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="justify-content-md-center">
|
||||
<h1>Players: {{ data.getPlayers().length }}</h1>
|
||||
<h1>Players: {{ players.length }}</h1>
|
||||
<div class="input-group mb-3">
|
||||
<input
|
||||
type="text"
|
||||
@@ -17,12 +17,9 @@
|
||||
}
|
||||
<div class="container mt-4">
|
||||
<ul class="list-group mb-3">
|
||||
@for (player of data.getPlayers(); track $index) {
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer; flex-grow: 1; text-align: left;">{{ player.name }}</a>
|
||||
<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>
|
||||
</button>
|
||||
@for (player of players; track $index) {
|
||||
<li class="list-group-item">
|
||||
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer;">{{ player.name }}</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, inject, Input, ViewChild } from '@angular/core';
|
||||
import { Component, Input, ViewChild } from '@angular/core';
|
||||
import { NgbAlert, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Player } from '../model';
|
||||
import { ModalRotationsComponent } from '../modal-rotations/modal-rotations.component';
|
||||
@@ -6,7 +6,6 @@ import { FormsModule } from '@angular/forms';
|
||||
import { Subject } from 'rxjs/internal/Subject';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { debounceTime, tap } from 'rxjs/operators';
|
||||
import { DataService } from '../data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-edit',
|
||||
@@ -15,7 +14,7 @@ import { DataService } from '../data.service';
|
||||
styleUrl: './screen-edit.component.less'
|
||||
})
|
||||
export class ScreenEditComponent {
|
||||
data = inject(DataService);
|
||||
@Input() players!: Player[];
|
||||
@ViewChild('selfClosingAlert', { static: false })selfClosingAlert!: NgbAlert;
|
||||
private _message$ = new Subject<string>();
|
||||
newItem: string = "";
|
||||
@@ -35,18 +34,15 @@ export class ScreenEditComponent {
|
||||
const name = this.newItem.trim()
|
||||
if (name) {
|
||||
let newPlayer = new Player(name);
|
||||
if(this.data.addPlayer(newPlayer)){
|
||||
if (Player.isNew(newPlayer, this.players)){
|
||||
this.players.push(newPlayer);
|
||||
this.newItem = '';
|
||||
return
|
||||
}
|
||||
else{
|
||||
this.setAlertMessage(newPlayer.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
removeItem(player: Player){
|
||||
this.data.removePlayer(player);
|
||||
}
|
||||
|
||||
openPlayerModal(player: Player){
|
||||
const modalRef = this.modalService.open(ModalRotationsComponent);
|
||||
|
||||
@@ -1,75 +1,65 @@
|
||||
<div class="justify-content-md-center">
|
||||
<h1>Rotations</h1>
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem [collapsed]="false">
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Libero: {{ LiberoPlayers.length }}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of LiberoPlayers; track $index) {
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Outside</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
@for (player of outsidePlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Setter: {{ SetterPlayers.length }}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of SetterPlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Opposite: {{ OppositePlayers.length }}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of OppositePlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Middle: {{ MiddlePlayers.length }}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of MiddlePlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Outside: {{ OutsidePlayers.length}}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of OutsidePlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Middle</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>Content for the first item</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Opposite</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>Content for the first item</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Setter</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>Content for the first item</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>Libero</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>Content for the first item</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Team Generation Screen respecting volleyball roles as defined by `../model/Player`
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Player } from '../model';
|
||||
import { NgbAccordionBody, NgbAccordionCollapse, NgbAccordionHeader, NgbAccordionItem, NgbAccordionButton, NgbAccordionDirective, NgbAccordionToggle } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { DataService } from '../data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-rotations',
|
||||
@@ -12,21 +11,20 @@ import { DataService } from '../data.service';
|
||||
styleUrl: './screen-rotations.component.less'
|
||||
})
|
||||
export class ScreenRotationsComponent {
|
||||
data = inject(DataService);
|
||||
|
||||
get OutsidePlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.outside);
|
||||
@Input() players!: Player[];
|
||||
get outsidePlayers(): Player[] {
|
||||
return this.players.filter(player => !player.outside);
|
||||
}
|
||||
get MiddlePlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.middle);
|
||||
get middlePlayers(): Player[] {
|
||||
return this.players.filter(player => player.middle);
|
||||
}
|
||||
get OppositePlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.opposite);
|
||||
get oppositePlayers(): Player[] {
|
||||
return this.players.filter(player => player.opposite);
|
||||
}
|
||||
get SetterPlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.setter);
|
||||
return this.players.filter(player => player.setter);
|
||||
}
|
||||
get LiberoPlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.libero);
|
||||
return this.players.filter(player => player.libero);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ html, body {
|
||||
body {
|
||||
margin:3em auto;
|
||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||
padding:.5em auto;
|
||||
padding:0 .5em;
|
||||
}
|
||||
h1,h2,h3{
|
||||
line-height:1.2;
|
||||
|
||||
Reference in New Issue
Block a user