This commit is contained in:
salam committed 2026-09-08 08:44:04 +02:00
1 parent 9f157adc96
commit 29de0c2c6c
13 files changed
+324 -789

No files matched your search

+4 -4
View File
@@ -14,7 +14,7 @@ class PlayerPerSeason
// when data changes clear player chche
SofaScorePlayerCache::truncate();
$res = StatistikoDetail::query()->select('ss_player_id', 'ss_team_id')->get();
$res = StatistikoDetail::query()->where('is_active', 1)->select('ss_player_id', 'ss_team_id')->get();
foreach ($res as $val) {
@@ -25,7 +25,7 @@ class PlayerPerSeason
foreach ($res2 as $val2) {
if (isset($val2->event->season)) {
if (!isset($collection[$val2->event->season])) {
if (! isset($collection[$val2->event->season])) {
$collection[$val2->event->season]['events_played_home'] = 0;
$collection[$val2->event->season]['events_played_away'] = 0;
$collection[$val2->event->season]['minutes_played_home'] = 0;
@@ -37,7 +37,7 @@ class PlayerPerSeason
$collection[$val2->event->season]['events_played_home'] += 1;
$collection[$val2->event->season]['minutes_played_home'] += $val2->minutes_played;
} else if ($val2->activeteam_id == $val2->event->away_id) {
} elseif ($val2->activeteam_id == $val2->event->away_id) {
$collection[$val2->event->season]['events_played_away'] += 1;
$collection[$val2->event->season]['minutes_played_away'] += $val2->minutes_played;
@@ -52,7 +52,7 @@ class PlayerPerSeason
[
'ss_player_id' => $val->ss_player_id,
'ss_team_id' => $val->ss_team_id,
'season' => $season
'season' => $season,
],
[
'events_played_home' => $row['events_played_home'],
@@ -2,10 +2,10 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grap;
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
use App\Console\Commands\Grap;
use App\Models\SofaScoreRosa;
use App\Utilities\Notice;
use Illuminate\Support\Facades\File;
@@ -17,13 +17,12 @@ class Rose
$debug = Grap::$options['d'] ?? 0;
$restart = Grap::$options['r'] ?? 0;
if ($debug && !$restart) {
Notice::note("RESTART ?", 'bb');
if ($debug && ! $restart) {
Notice::note('RESTART ?', 'bb');
sleep(5);
}
File::makeDirectory(Grap::$storage . '/' . Grap::$folder, 0775, true, true);
File::makeDirectory(Grap::$storage.'/'.Grap::$folder, 0775, true, true);
if ($restart) {
SofaScoreRosa::query()->update(['grapped' => 0]);
@@ -36,8 +35,7 @@ class Rose
}
}
$res = SofaScoreRosa::where('grapped', 0)->get();
$res = SofaScoreRosa::where('is_active', 1)->where('grapped', 0)->get();
$all = $res->count();
@@ -52,7 +50,7 @@ class Rose
echo "\n$key/$all\n";
}
$url = Grap::$options['base_url'] . 'api/v1/team/' . $value->ss_team_id . '/players';
$url = Grap::$options['base_url'].'api/v1/team/'.$value->ss_team_id.'/players';
$data = CurlSofa::load($url);
@@ -63,7 +61,7 @@ class Rose
* add team to folder
*********************************/
File::put(Grap::$storage . '/' . Grap::$folder . '/' . Strings::clean($value->ss_team_name) . '.json', json_encode($data));
File::put(Grap::$storage.'/'.Grap::$folder.'/'.Strings::clean($value->ss_team_name).'.json', json_encode($data));
SofaScoreRosa::where('id', $value->id)->update(['grapped' => 1]);
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grap;
use App\Models\SofaScoreRosa;
use App\Models\SofaScoreTask;
use App\Models\SofaScoreTaskTournament;
use App\Models\SofaScoreTournament;
@@ -16,17 +17,29 @@ class SettingsToLocal
$debug = Grap::$options['d'] ?? 0;
if ($debug) {
Notice::note("⚽ settings to local");
Notice::note("⚽ close all vpn");
Notice::note('⚽ settings to local');
Notice::note('⚽ close all vpn');
}
exec('killall ssh');
if ($debug) {
Notice::note("⚽ open vpn");
Notice::note('⚽ open vpn');
}
exec('ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190');
/**
* SofaScoreRosa
*/
if ($debug) {
Notice::note('SofaScoreRosa', 'g');
}
SofaScoreRosa::truncate();
$rows = DB::connection('remote_mariadb')->table('sofa_score_rosas')->get();
foreach ($rows as $row) {
SofaScoreRosa::insert((array) $row);
}
/**
* SofaScoreTask
*/
if ($debug) {
Notice::note('SofaScoreTask', 'g');
}
@@ -35,7 +48,9 @@ class SettingsToLocal
foreach ($rows as $row) {
SofaScoreTask::insert((array) $row);
}
/**
* SofaScoreTaskTournament
*/
if ($debug) {
Notice::note('SofaScoreTaskTournament', 'g');
}
@@ -44,7 +59,9 @@ class SettingsToLocal
foreach ($rows as $row) {
SofaScoreTaskTournament::insert((array) $row);
}
/**
* SofaScoreTournament
*/
if ($debug) {
Notice::note('SofaScoreTournament', 'g');
}
@@ -55,7 +72,7 @@ class SettingsToLocal
}
if ($debug) {
Notice::note("⚽ close all vpn");
Notice::note('⚽ close all vpn');
}
exec('killall ssh');
}
@@ -14,7 +14,7 @@ class ImportDetails
{
$now = now()->format('Y-m-d H:i:s');
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($now) {
@@ -23,11 +23,10 @@ class ImportDetails
$row = array_values($row);
// ss_player_id
//
// ss_player_id
// ss_team_id
// tx_team_id
// player_name
// player_name
// ss_national_team_id
// birthdate
// height
@@ -50,7 +49,7 @@ class ImportDetails
'nationality' => $row[6],
'position' => $row[7],
'preferred_foot' => $row[8],
'last_update' => Carbon::parse($row[9])->format('Y-m-d H:i:s'),
'last_update' => Carbon::parse($row[9])->format('Y-m-d H:i:s'),
'is_active' => 1,
'created_at' => $now,
'updated_at' => $now,
@@ -60,6 +59,8 @@ class ImportDetails
}
});
StatistikoDetail::where('updated_at', '!=', $now)->update(['is_active' => 0]);
/**update statistic player tabel */
PlayerPerSeason::run();
}
+30 -30
View File
@@ -93,14 +93,14 @@ class Statistic extends BaseDashboard
->label('Calculate')
->icon('icon-player')
->color('indigo')
->color(fn(): string => $this->filters['team_id'] ? 'primary' : 'gray')
->disabled(fn(): string => $this->filters['team_id'] ? false : true)
->color(fn (): string => $this->filters['team_id'] ? 'primary' : 'gray')
->disabled(fn (): string => $this->filters['team_id'] ? false : true)
->slideOver()
->slideOverPosition(SlideOverPosition::Start)
->modalWidth(Width::Screen)
->modalSubmitAction(false)
->modalCancelAction(false)
->modalContent(fn(): View => view('livewire.board-dispatcher-modal-wrapper', ['filters' => $this->filters])),
->modalContent(fn (): View => view('livewire.board-dispatcher-modal-wrapper', ['filters' => $this->filters])),
];
}
@@ -138,10 +138,10 @@ class Statistic extends BaseDashboard
->live()
->preload()
->searchable(false)
->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
->prefixIconColor(fn (Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
->prefixIcon('phosphor-globe-fill')
->hiddenLabel()
->options(fn() => LoadSofaScoreCategory::load())
->options(fn () => LoadSofaScoreCategory::load())
->placeholder('Country')
->afterStateUpdated(function (callable $set, $state) {
$set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode'));
@@ -154,10 +154,10 @@ class Statistic extends BaseDashboard
Select::make('league_id')
->live()
->preload()
->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
->prefixIconColor(fn (Get $get): string => $get('league_id') ? 'success' : 'danger')
->prefixIcon('phosphor-trophy-fill')
->hiddenLabel()
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
->placeholder('League')
->afterStateUpdated(function (callable $set) {
$set('match_id', null);
@@ -168,7 +168,7 @@ class Statistic extends BaseDashboard
Select::make('match_id')
->live()
->hiddenLabel()
->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger')
->prefixIconColor(fn (Get $get): string => $get('match_id') ? 'success' : 'danger')
->prefixIcon('phosphor-calendar-check-fill')
->options(function (Get $get) {
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
@@ -193,7 +193,7 @@ class Statistic extends BaseDashboard
}
})
->prefixIcon('phosphor-users-three-fill')
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->options(function (Get $get) {
if ($get('match_id')) {
$res = StatisticFixtures::where('id', $get('match_id'))->first();
@@ -222,9 +222,9 @@ class Statistic extends BaseDashboard
Action::make('iconInfo')
->color('success')
->icon('phosphor-question-fill')
->tooltip(fn() => 'Team Position')
->tooltip(fn () => 'Team Position')
)
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->default('all')
->selectablePlaceholder(false)
->options([
@@ -280,17 +280,17 @@ class Statistic extends BaseDashboard
->hiddenLabel()
->suffixAction(Action::make('reset')
->icon('phosphor-x-circle')
->action(fn(callable $set) => $set('similar_past_matches', 'none'))
->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
->action(fn (callable $set) => $set('similar_past_matches', 'none'))
->color(fn (Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
->placeholder('Similar Past Matches')
->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '')
->suffix(fn (Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± '.$get('accuracy').'</div>') : '')
->prefix('SPM')
->prefixAction(
Action::make('iconInfo')
->icon('phosphor-question-fill')
// ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'primary')
->color('success')
->tooltip(fn() => $this->tooltip_similar_past_matches())
->tooltip(fn () => $this->tooltip_similar_past_matches())
)
->default('none')
->selectablePlaceholder(false)
@@ -310,7 +310,7 @@ class Statistic extends BaseDashboard
Slider::make('accuracy')
->live()
->hiddenLabel()
->hidden(fn(Get $get) => $get('similar_past_matches') == 'none')
->hidden(fn (Get $get) => $get('similar_past_matches') == 'none')
->fillTrack()
->minValue(0)
->maxValue(0.25)
@@ -329,17 +329,17 @@ class Statistic extends BaseDashboard
->hiddenLabel()
->allowHtml()
->placeholder('Player')
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->prefixIconColor(fn (Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
->prefixIcon('icon-player')
->preload()
->searchable()
->extraAttributes(fn() => ['id' => 'player_selector'])
->extraAttributes(fn () => ['id' => 'player_selector'])
->suffixAction(
Action::make('iconInfo')
->icon('phosphor-question-fill')
->color('success')
->tooltip(fn() => $this->tooltip_player_info())
->tooltip(fn () => $this->tooltip_player_info())
)
->options(function (Get $get) {
$team_id = $get('team_id');
@@ -356,7 +356,7 @@ class Statistic extends BaseDashboard
->placeholder('Time on field')
->prefixIcon('phosphor-watch-fill')
->default('all')
->hidden(fn(Get $get) => ! $get('ss_player_id'))
->hidden(fn (Get $get) => ! $get('ss_player_id'))
->prefixIconColor('success')
->selectablePlaceholder(false)
->options([
@@ -376,7 +376,7 @@ class Statistic extends BaseDashboard
->extraAttributes([
'class' => 'radio-statistic-group',
])
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
->columnSpan([
'default' => 4,
'sm' => 4,
@@ -400,7 +400,7 @@ class Statistic extends BaseDashboard
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->hidden(fn(Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'2026' => '2026',
@@ -420,7 +420,7 @@ class Statistic extends BaseDashboard
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
->hidden(fn(Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'26/27' => '26/27',
@@ -436,30 +436,30 @@ class Statistic extends BaseDashboard
DatePicker::make('start_date')
->live()
->hiddenLabel()
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn(Get $get): string => $get('start_date') ? 'success' : 'primary')
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('Start')
->suffixAction(
Action::make('clear_start')
->icon('phosphor-x')
->color('gray')
->action(fn(Set $set) => $set('start_date', null))
->action(fn (Set $set) => $set('start_date', null))
),
DatePicker::make('end_date')
->live()
->hiddenLabel()
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor(fn(Get $get): string => $get('end_date') ? 'success' : 'primary')
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('End')
->suffixAction(
Action::make('clear_end')
->icon('phosphor-x')
->color('gray')
->action(fn(Set $set) => $set('end_date', null))
->action(fn (Set $set) => $set('end_date', null))
),
]);
}
+92 -204
View File
@@ -3,6 +3,7 @@
namespace App\Livewire;
use App\Models\SofaScoreRosa;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -16,28 +17,33 @@ use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\HtmlString;
use Livewire\Attributes\On;
use Livewire\Component;
class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
use InteractsWithSchemas;
use InteractsWithTable;
use RestrictsFileUploadsToSchemaComponents;
public array $sourceRecords = [];
public array $lists = [];
public array $results = [];
public array $activeBoxes = [2 => 'DR', 4 => 'MR', 6 => 'RW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'LM'];
public bool $copyDisabled = true;
public bool $downloadDisabled = true;
public bool $calculationDisabled = true;
public string $calculationColor = 'gray';
public string $copyColor = 'gray';
public string $ss_team_name = '';
public array $boxes = [];
public array $beschriftung = [];
public function mount(array $filters)
@@ -48,37 +54,65 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
for ($i = 1; $i <= 35; $i++) {
$this->boxes[$i] = [];
if (isset($this->activeBoxes[$i]))
if (isset($this->activeBoxes[$i])) {
$this->beschriftung[$i] = $this->activeBoxes[$i];
else
} else {
$this->beschriftung[$i] = '';
}
}
Log::debug('boxes', $this->boxes);
}
public function getHeadingTable(): HtmlString
{
return new HtmlString('<div class="text-xl w-full">'.$this->ss_team_name.'</div>
<div class="text-[11px] p-0 flex flex-row gap-3 font-bold font-mono" style="position: relative; left: -2px; bottom: -13px;">
<div>Foot</div>
<div>Evt</div>
<div>Øm</div>
<div>Gls</div>
<div>Crn</div>
<div>Fls</div>
<div>Ofs</div>
<div>Snt</div>
<div>Tsh</div>
<div>Crd</div>
</div>');
}
public function table(Table $table): Table
{
return $table
->headerActions([
Action::make('close')->icon('phosphor-x')->close(),
Action::make('reset')->icon('phosphor-arrows-clockwise'),
Action::make('calculate')->icon('phosphor-calculator')->color('gray'),
Action::make('download')->icon('phosphor-download')->color('gray'),
Action::make('close')
->icon('phosphor-x')
->close(),
Action::make('reset')
->icon('phosphor-arrows-clockwise')
->action(fn () => $this->clearAll()),
Action::make('calculate')
->icon('phosphor-calculator')
->disabled($this->calculationDisabled)
->action(fn () => $this->calculateAspg()),
Action::make('download')
->icon('phosphor-download')
->disabled($this->downloadDisabled)
->action(fn () => $this->downloadResult()),
])
/**
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
* leeres Modell (z.B. ein beliebiges Basis-Modell deines Projekts) NUR als Dummy-Builder.
* Alternativ kannst du ein anonymes Model nutzen.
*/
->query(\App\Models\User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen
->query(User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen
->paginated(false)
// ->striped()
->striped()
->defaultSort('name')
->columns([
ViewColumn::make('drag_card')
->columnSpanFull()
->label('Roster of ' . $this->ss_team_name)
->label(fn () => $this->getHeadingTable())
->view('filament.tables.columns.drag-card'),
])
->filters([
@@ -98,9 +132,10 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
->records(function () {
$collection = collect($this->sourceRecords);
$selectedPosition = $this->tableFilters['player_position']['value'] ?? null;
if (!empty($selectedPosition)) {
if (! empty($selectedPosition)) {
$collection = $collection->where('player_position', $selectedPosition);
}
return $collection;
});
}
@@ -111,17 +146,21 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$boxNumber = (int) $boxNumber;
$player = is_array($elementData) ? $elementData : json_decode($elementData, true);
if (!$player || !isset($player['id'])) {
if (! $player || ! isset($player['id'])) {
return;
}
foreach ($this->sourceRecords as $k => $record) {
if ($record['id'] == (int) $player['id']) {
$this->calculationDisabled = false;
if ($this->boxes[$boxNumber]) {
$this->clearBox($boxNumber);
}
$this->boxes[$boxNumber] = $record;
$this->sourceRecords[$k]['active'] = 1;
$this->sourceRecords[$k]['position'] = $this->activeBoxes[$boxNumber];
}
}
}
@@ -132,207 +171,56 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$tmp = $this->boxes[$boxNumber];
$player_id = 0;
foreach ($tmp as $key => $value) {
if ($key == 'id')
if ($key == 'id') {
$player_id = $value;
}
}
foreach ($this->sourceRecords as $k => $record) {
if ($record['id'] == (int) $player_id) {
$this->boxes[$boxNumber] = [];
$this->sourceRecords[$k]['position'] = '';
$this->sourceRecords[$k]['active'] = 0;
}
}
}
}
public function calculateAspg(): void
{
$this->downloadDisabled = false;
}
public function clearAll(): void
{
for ($i = 1; $i <= 35; $i++) {
$this->boxes[$i] = [];
}
foreach ($this->sourceRecords as $k => $record) {
$this->sourceRecords[$k]['position'] = '';
$this->sourceRecords[$k]['active'] = 0;
}
$this->downloadDisabled = true;
$this->calculationDisabled = true;
}
public function downloadResult()
{
return;
$copystring = '';
foreach ($this->results as $row) {
unset($row['origin']);
unset($row['pcolor']);
unset($row['ecolor']);
unset($row['info']);
$copystring .= implode("\t", $row)."\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
}
public function render()
{
return view('livewire.board-dispatcher');
}
// public function setCalculationButton()
// {
// $count = 1;
// for ($i = 1; $i <= 35; $i++) {
// $bayKey = "dest-{$i}";
// if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
// $count++;
// }
// }
// if ($count > 2) {
// $this->calculationDisabled = false;
// $this->calculationColor = 'info';
// } else {
// $this->calculationDisabled = true;
// $this->calculationColor = 'gray';
// }
// }
// public function setCopyButton()
// {
// if (\count($this->results) > 0) {
// $this->copyDisabled = false;
// $this->copyColor = 'info';
// } else {
// $this->copyDisabled = true;
// $this->copyColor = 'gray';
// }
// }
// public function calculate()
// {
// $this->results = [];
// for ($i = 1; $i <= 35; $i++) {
// $bayKey = "dest-{$i}";
// if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
// $this->results[] = $this->lists[$bayKey][0];
// }
// }
// $this->setCopyButton();
// }
// public function copyResult()
// {
// $copystring = '';
// foreach ($this->results as $row) {
// unset($row['origin']);
// unset($row['pcolor']);
// unset($row['ecolor']);
// unset($row['info']);
// $copystring .= implode("\t", $row) . "\n";
// }
// $this->js("navigator.clipboard.writeText(`$copystring`)");
// }
// public function moveItem($itemId, $fromList, $toList, $newIndex)
// {
// $itemId = (string) $itemId;
// $newIndex = (int) $newIndex;
// if (! $toList || $fromList === $toList || ! isset($this->lists[$fromList]) || ! isset($this->lists[$toList])) {
// $this->boardVersion = uniqid();
// return;
// }
// // Limit-Guard: Wenn das Ziel bereits ein Element enthält, abbrechen
// if (count($this->lists[$toList]) >= 1) {
// $this->boardVersion = uniqid();
// return;
// }
// $foundItem = null;
// foreach ($this->lists[$fromList] as $key => $item) {
// if ((string) $item['id'] === $itemId) {
// $item['position'] = $this->positions($toList);
// $foundItem = $item;
// unset($this->lists[$fromList][$key]);
// $this->lists[$fromList] = array_values($this->lists[$fromList]);
// break;
// }
// }
// if ($foundItem) {
// array_splice($this->lists[$toList], $newIndex, 0, [$foundItem]);
// }
// $this->setCalculationButton();
// $this->boardVersion = uniqid();
// }
// public function positions(string $pos)
// {
// $pos = (int) str_replace('dest-', '', $pos);
// $options = [2 => 'DR', 4 => 'MR', 6 => 'RW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'LM'];
// if (isset($options[$pos]))
// return $options[$pos];
// else
// return $pos;
// }
// public function returnToOrigin($itemId, $currentListId)
// {
// $itemId = (string) $itemId;
// // Log::info($this->boardVersion);
// // Log::info('itemId, currentListId', [$itemId, $currentListId]);
// // Log::info('OLD LIST', $this->lists);
// if (! isset($this->lists[$currentListId])) {
// $this->boardVersion = uniqid();
// return;
// }
// $foundItem = null;
// foreach ($this->lists[$currentListId] as $key => $item) {
// if ((string) $item['id'] === $itemId) {
// $foundItem = $item;
// unset($this->lists[$currentListId][$key]);
// $this->lists[$currentListId] = array_values($this->lists[$currentListId]);
// break;
// }
// }
// if ($foundItem && isset($this->lists[$foundItem['origin']])) {
// // Nur zurücklegen, wenn die Quelle wirklich frei ist
// array_unshift($this->lists[$foundItem['origin']], $foundItem);
// // if (count($this->lists[$foundItem['origin']]) < 2) {
// // Log::info('origin');
// // array_unshift($this->lists[$foundItem['origin']], $foundItem);
// // } else {
// // // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben
// // array_unshift($this->lists[$currentListId], $foundItem);
// // Log::info('box');
// // }
// }
// $this->setCalculationButton();
// $this->boardVersion = uniqid();
// }
// public function resetBoard()
// {
// // Alle 21 Zielbays durchlaufen
// for ($i = 1; $i <= 21; $i++) {
// $bayKey = "dest-{$i}";
// if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
// foreach ($this->lists[$bayKey] as $item) {
// $targetOrigin = $item['origin'];
// // Element zurück in sein Original-Quell-Tab schieben
// if (isset($this->lists[$targetOrigin])) {
// array_unshift($this->lists[$targetOrigin], $item);
// }
// }
// // Die Zielbucht komplett leeren
// $this->lists[$bayKey] = [];
// }
// }
// // Falls Sie die boardVersion-Logik nutzen, erneuern wir sie hier für den DOM-Refresh:
// if (property_exists($this, 'boardVersion')) {
// $this->boardVersion = uniqid();
// }
// // Falls Sie die Javascript-Event/ignore-Logik nutzen, feuern wir das Refresh-Event:
// $this->dispatch('refreshBoard', lists: $this->lists);
// $this->results = [];
// $this->setCalculationButton();
// $this->setCopyButton();
// }
}
+9 -1
View File
@@ -47,7 +47,7 @@ class PlayerCalculator extends Component
$arr = [];
foreach ($player as $val) {
if ($val->details) {
if ($val->details && $val->details->is_active) {
$player_id = $val->ss_player_id;
if (! isset($arr[$player_id])) {
$arr[$player_id]['player_name'] = $val->details->player_name;
@@ -126,7 +126,15 @@ class PlayerCalculator extends Component
'timed_color' => $timed_color,
'events_played' => $events_played,
'everage_minutes' => $everage_minutes,
'position' => '',
'active' => 0,
'gls' => 0,
'crn' => 0,
'fls' => 0,
'ofs' => 0,
'snt' => 0,
'tsh' => 0,
'crd' => 0,
];
}
-284
View File
@@ -1,284 +0,0 @@
<?php
namespace App\Livewire;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Concerns\RestrictsFileUploadsToSchemaComponents;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Livewire\Component;
class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
use InteractsWithSchemas;
use InteractsWithTable;
use RestrictsFileUploadsToSchemaComponents;
public array $filters = [];
public array $lists = [];
public array $results = [];
public array $destLabels = ['DR', 'MR', 'RW', 'DC', 'DM', 'MC', 'AM', 'SW', 'DC', 'DM', 'MC', 'AM', 'SM', 'ST', 'DC', 'DM', 'MC', 'AM', 'DL', 'ML', 'LM'];
public string $boardVersion = '';
public bool $copyDisabled = true;
public bool $calculationDisabled = true;
public string $calculationColor = 'gray';
public string $copyColor = 'gray';
public function mount(array $filters)
{
$this->boardVersion = uniqid();
$this->filters = $filters;
$active = [2, 4, 6, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 30, 32, 34];
for ($i = 1; $i <= 35; $i++) {
if (in_array($i, $active))
$this->lists["dest-{$i}"] = [];
else
$this->lists["blind-{$i}"] = [];
}
}
/*
'id' => $player_id,
'name' => $val['player_name'],
'preferred_foot' => $val['preferred_foot'],
'player_position' => $player_position,
'player_color' => $player_color,
'timed_color' => $timed_color,
'events_played' => $events_played,
'everage_minutes' => $everage_minutes,
*/
public function table(Table $table): Table
{
return $table
->headerActions([
Action::make('Close')->icon('phosphor-x')->close()
])
->records(fn(): array => PlayerCalculator::load($this->filters))
->paginated(false)
->striped()
->columns([
TextColumn::make('name')
->sortable()
// ->searchable()
->icon('icon-soccerplayer')
->extraAttributes(fn($record) => [
'data-id' => $record['id'],
'class' => 'sortable-zone',
'style' => 'padding: 4px !important; cursor:pointer; user-select: none;',
'wire:key' => "item-src-" . $record['id'] . "-v-" . $this->boardVersion
]),
])
->filters([
// ...
])
->recordActions([
// ...
])
->toolbarActions([
// ...
]);
}
public function render()
{
return view('livewire.board-dispatcher');
}
public function setCalculationButton()
{
$count = 1;
for ($i = 1; $i <= 35; $i++) {
$bayKey = "dest-{$i}";
if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
$count++;
}
}
if ($count > 2) {
$this->calculationDisabled = false;
$this->calculationColor = 'info';
} else {
$this->calculationDisabled = true;
$this->calculationColor = 'gray';
}
}
public function setCopyButton()
{
if (\count($this->results) > 0) {
$this->copyDisabled = false;
$this->copyColor = 'info';
} else {
$this->copyDisabled = true;
$this->copyColor = 'gray';
}
}
public function calculate()
{
$this->results = [];
for ($i = 1; $i <= 35; $i++) {
$bayKey = "dest-{$i}";
if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
$this->results[] = $this->lists[$bayKey][0];
}
}
$this->setCopyButton();
}
public function copyResult()
{
$copystring = '';
foreach ($this->results as $row) {
unset($row['origin']);
unset($row['pcolor']);
unset($row['ecolor']);
unset($row['info']);
$copystring .= implode("\t", $row) . "\n";
}
$this->js("navigator.clipboard.writeText(`$copystring`)");
}
public function moveItem($itemId, $fromList, $toList, $newIndex)
{
$itemId = (string) $itemId;
$newIndex = (int) $newIndex;
if (! $toList || $fromList === $toList || ! isset($this->lists[$fromList]) || ! isset($this->lists[$toList])) {
$this->boardVersion = uniqid();
return;
}
// Limit-Guard: Wenn das Ziel bereits ein Element enthält, abbrechen
if (count($this->lists[$toList]) >= 1) {
$this->boardVersion = uniqid();
return;
}
$foundItem = null;
foreach ($this->lists[$fromList] as $key => $item) {
if ((string) $item['id'] === $itemId) {
$item['position'] = $this->positions($toList);
$foundItem = $item;
unset($this->lists[$fromList][$key]);
$this->lists[$fromList] = array_values($this->lists[$fromList]);
break;
}
}
if ($foundItem) {
array_splice($this->lists[$toList], $newIndex, 0, [$foundItem]);
}
$this->setCalculationButton();
$this->boardVersion = uniqid();
}
public function positions(string $pos)
{
$pos = (int) str_replace('dest-', '', $pos);
$options = [2 => 'DR', 4 => 'MR', 6 => 'RW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'LM'];
if (isset($options[$pos]))
return $options[$pos];
else
return $pos;
}
public function returnToOrigin($itemId, $currentListId)
{
$itemId = (string) $itemId;
// Log::info($this->boardVersion);
// Log::info('itemId, currentListId', [$itemId, $currentListId]);
// Log::info('OLD LIST', $this->lists);
if (! isset($this->lists[$currentListId])) {
$this->boardVersion = uniqid();
return;
}
$foundItem = null;
foreach ($this->lists[$currentListId] as $key => $item) {
if ((string) $item['id'] === $itemId) {
$foundItem = $item;
unset($this->lists[$currentListId][$key]);
$this->lists[$currentListId] = array_values($this->lists[$currentListId]);
break;
}
}
if ($foundItem && isset($this->lists[$foundItem['origin']])) {
// Nur zurücklegen, wenn die Quelle wirklich frei ist
array_unshift($this->lists[$foundItem['origin']], $foundItem);
// if (count($this->lists[$foundItem['origin']]) < 2) {
// Log::info('origin');
// array_unshift($this->lists[$foundItem['origin']], $foundItem);
// } else {
// // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben
// array_unshift($this->lists[$currentListId], $foundItem);
// Log::info('box');
// }
}
$this->setCalculationButton();
$this->boardVersion = uniqid();
}
public function resetBoard()
{
// Alle 21 Zielbays durchlaufen
for ($i = 1; $i <= 21; $i++) {
$bayKey = "dest-{$i}";
if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) {
foreach ($this->lists[$bayKey] as $item) {
$targetOrigin = $item['origin'];
// Element zurück in sein Original-Quell-Tab schieben
if (isset($this->lists[$targetOrigin])) {
array_unshift($this->lists[$targetOrigin], $item);
}
}
// Die Zielbucht komplett leeren
$this->lists[$bayKey] = [];
}
}
// Falls Sie die boardVersion-Logik nutzen, erneuern wir sie hier für den DOM-Refresh:
if (property_exists($this, 'boardVersion')) {
$this->boardVersion = uniqid();
}
// Falls Sie die Javascript-Event/ignore-Logik nutzen, feuern wir das Refresh-Event:
$this->dispatch('refreshBoard', lists: $this->lists);
$this->results = [];
$this->setCalculationButton();
$this->setCopyButton();
}
}