Enhancement to monitor pages.

This commit is contained in:
Matt Young 2025-10-18 22:31:53 -05:00
parent 40363a5964
commit ee958d350d
5 changed files with 114 additions and 148 deletions

View File

@ -2,9 +2,8 @@
namespace App\Http\Controllers;
use App\Actions\Tabulation\CheckPrelimResult;
use App\Models\Audition;
use App\Models\Entry;
use App\Models\PrelimDefinition;
use function compact;
@ -15,115 +14,44 @@ class MonitorController extends Controller
if (! auth()->user()->hasFlag('monitor')) {
abort(403);
}
$method = 'POST';
$formRoute = 'monitor.enterFlag';
$title = 'Flag Entry';
//return view('tabulation.choose_entry', compact('method', 'formRoute', 'title'));
$prelims = PrelimDefinition::with('audition')->get();
$prelimDefinition = null;
$auditions = Audition::orderBy('score_order')->with('flags')->get();
$audition = null;
return view('monitor.index', compact('prelims', 'prelimDefinition'));
return view('monitor.index', compact('audition', 'auditions'));
}
public function prelimStatus(PrelimDefinition $prelimDefinition)
public function auditionStatus(Audition $audition)
{
if (! auth()->user()->hasFlag('monitor')) {
abort(403);
}
$prelims = PrelimDefinition::with('audition')->get();
$entries = $prelimDefinition->audition->entries()->with('student.school')->with('PrelimScoreSheets')->get();
// foreach ($entries as $entry) {
// app(CheckPrelimResult::class)->__invoke($entry);
// }
return view('monitor.index', compact('prelims', 'prelimDefinition', 'entries'));
if ($audition->hasFlag('seats_published') || $audition->hasFlag('advancement_published')) {
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
}
$auditions = Audition::orderBy('score_order')->with('flags')->get();
$entries = $audition->entries()->with('flags')->with('student.school')->withCount([
'prelimScoreSheets', 'scoreSheets',
])->orderBy('draw_number')->get();
return view('monitor.index', compact('audition', 'auditions', 'entries'));
}
public function toggleNoShow(Entry $entry)
{
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
}
if ($entry->hasFlag('no_show')) {
$entry->removeFlag('no_show');
return;
return redirect()->back()->with('success', 'No Show Flag Cleared');
}
$entry->addFlag('no_show');
return redirect()->back()->with('success', 'No Show Entered');
}
public function flagForm()
{
if (! auth()->user()->hasFlag('monitor')) {
abort(403);
}
$validData = request()->validate([
'entry_id' => ['required', 'integer', 'exists:entries,id'],
]);
$entry = Entry::find($validData['entry_id']);
// If the entries audition is published, bounce out
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
}
// If entry has scores, bounce on out
if ($entry->scoreSheets()->count() > 0) {
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
}
return view('monitor_entry_flag_form', compact('entry'));
}
public function storeFlag(Entry $entry)
{
if (! auth()->user()->hasFlag('monitor')) {
abort(403);
}
// If the entries audition is published, bounce out
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
}
// If entry has scores, bounce on out
if ($entry->scoreSheets()->count() > 0) {
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
}
$action = request()->input('action');
$result = match ($action) {
'failed-prelim' => $this->setFlag($entry, 'failed_prelim'),
'no-show' => $this->setFlag($entry, 'no_show'),
'clear' => $this->setFlag($entry, 'clear'),
default => redirect()->route('monitor.index')->with('error', 'Invalid action requested'),
};
return redirect()->route('monitor.index')->with('success', 'Flag set for entry #'.$entry->id);
}
private function setFlag(Entry $entry, string $flag)
{
if ($flag === 'no_show') {
$entry->removeFlag('failed_prelim');
$entry->addFlag('no_show');
return true;
}
if ($flag === 'failed_prelim') {
$entry->addFlag('failed_prelim');
$entry->addFlag('no_show');
return true;
}
if ($flag === 'clear') {
$entry->removeFlag('failed_prelim');
$entry->removeFlag('no_show');
return true;
}
}
}

View File

@ -1,72 +1,76 @@
<x-layout.app>
<x-slot:page_title>Monitor Dashboard</x-slot:page_title>
{{-- PRELIM AUDITION STATUS CARD --}}
<x-card.card class="max-w-md mx-auto">
<x-card.card class="max-w-lg mx-auto mb-5">
<x-card.heading>
Prelim Auditions
Audition Status
<x-slot:right_side>
<x-form.select name="prelim_id" onchange="if (this.value) window.location.href = this.value">
<option value="" disabled hidden @if(! $prelimDefinition) selected @endif>Choose Prelim...</option>
@foreach ($prelims as $prelim)
<option @if($prelimDefinition && $prelimDefinition->id === $prelim->id) selected @endif
value="{{ route('monitor.prelimStatus', $prelim) }}">{{$prelim->audition->name}}</option>
<x-form.select name="audition_id" onchange="if (this.value) window.location.href = this.value">
<option value="" disabled hidden @if(! $audition) selected @endif>Choose Audition...</option>
@foreach ($auditions as $menuAudition)
@continue($menuAudition->hasFlag('seats_published') || $menuAudition->hasFlag('advance_published'))
<option @if($audition && $audition->id === $menuAudition->id) selected @endif
value="{{ route('monitor.auditionStatus', $menuAudition) }}">{{$menuAudition->name}}</option>
@endforeach
</x-form.select>
</x-slot:right_side>
</x-card.heading>
@if($prelimDefinition)
@if($audition)
<x-table.table>
<thead>
<tr>
<x-table.th>Entry</x-table.th>
<x-table.th> </x-table.th>
@if($audition->prelimDefinition)
<x-table.th>Prelim<br/>Scores</x-table.th>
@endif
<x-table.th>Finals<br/>Scores</x-table.th>
<x-table.th></x-table.th>
</tr>
</thead>
<tbody>
@foreach($entries as $entry)
<tr>
<x-table.td>
{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}
@if($entry->hasFlag('no_show'))
<span class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">No-Show</span>
@elseif($entry->hasFlag('failed_prelim'))
<span class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">Failed</span>
@elseif($entry->hasFlag('passed_prelim'))
<span class="inline-flex items-center rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-700 dark:bg-green-400/10 dark:text-green-400">Passed</span>
@else
<span class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-800 dark:bg-yellow-400/10 dark:text-yellow-300">
Pending
</span>
<x-table.body>
@foreach($entries as $entry)
<tr>
<x-table.td>
{{ $audition->name }} {{ $entry->draw_number }}
@if($audition->prelimDefinition && ! $entry->hasFlag('no_show'))
@if($entry->hasFlag('failed_prelim'))
<span
class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">Failed</span>
@elseif($entry->hasFlag('passed_prelim'))
<span
class="inline-flex items-center rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-700 dark:bg-green-400/10 dark:text-green-400">Passed</span>
@else
<span
class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-800 dark:bg-yellow-400/10 dark:text-yellow-300">Pending</span>
@endif
@elseif($entry->hasFlag('no_show'))
<span
class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">No-Show</span>
@endif
</x-table.td>
@if($audition->prelimDefinition)
<x-table.td>
{{ $entry->prelim_score_sheets_count }}
</x-table.td>
@endif
</x-table.td>
<x-table.td>
@if($entry->prelimScoreSheets()->count() < 1 && ! $entry->hasFlag('no_show'))
<x-modal>
<x-slot:button_text>
<x-form.button href="#">Mark No-Show</x-form.button>
</x-slot:button_text>
<x-slot:title>Mark {{ $prelimDefinition->audition->name }} {{ $entry->draw_number }} as a no-show</x-slot:title>
Confirm that you would like to mark this entry as a no-show<br>
{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}<br>
Entry ID: {{ $entry->id }}<br>
Name: {{ $entry->student->full_name() }}<br>
School: {{ $entry->student->school->name }}
<hr class="mt-3">
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
<x-form.button class="mt-3" type="submit">Confirm No-Show<br>{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}</x-form.button>
</x-form.form>
</x-modal>
@endif
</x-table.td>
</tr>
@endforeach
</tbody>
<x-table.td>
{{ $entry->score_sheets_count }}
</x-table.td>
<x-table.td>
@if($entry->prelim_score_sheets_count < 1 && $entry->score_sheets_count < 1 && ! $entry->hasFlag('no_show') && ! $audition->hasFlag('seats_published'))
@include('monitor.noshow_modal')
@endif
@if($entry->hasFlag('no_show') && ! $audition->hasFlag('seats_published'))
@include('monitor.remove_nowshow_modal')
@endif
</x-table.td>
</tr>
@endforeach
</x-table.body>
</x-table.table>
@endif
</x-card.card>
{{-- FINAL AUDITION STATUS CARD --}}
</x-layout.app>

View File

@ -0,0 +1,19 @@
<x-modal>
<x-slot:button_text>
<x-form.button href="#">Mark No-Show</x-form.button>
</x-slot:button_text>
<x-slot:title>Mark {{ $audition->name }} {{ $entry->draw_number }}
as a no-show
</x-slot:title>
Confirm that you would like to mark this entry as a no-show<br>
{{ $audition->name }} {{ $entry->draw_number }}<br>
Entry ID: {{ $entry->id }}<br>
Name: {{ $entry->student->full_name() }}<br>
School: {{ $entry->student->school->name }}
<hr class="mt-3">
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
<x-form.button class="mt-3" type="submit">Confirm
No-Show<br>{{ $audition->name }} {{ $entry->draw_number }}
</x-form.button>
</x-form.form>
</x-modal>

View File

@ -0,0 +1,18 @@
<x-modal>
<x-slot:button_text>
<x-form.button href="#">Undo No-Show</x-form.button>
</x-slot:button_text>
<x-slot:title>Remove No-Show Flag for {{ $audition->name }} {{ $entry->draw_number }}
</x-slot:title>
Confirm that you would like to remove the no-show flag for this entry<br>
{{ $audition->name }} {{ $entry->draw_number }}<br>
Entry ID: {{ $entry->id }}<br>
Name: {{ $entry->student->full_name() }}<br>
School: {{ $entry->student->school->name }}
<hr class="mt-3">
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
<x-form.button class="mt-3" type="submit">Remove
No-Show Flag<br>{{ $audition->name }} {{ $entry->draw_number }}
</x-form.button>
</x-form.form>
</x-modal>

View File

@ -31,11 +31,8 @@ Route::prefix('filters')->middleware(['auth', 'verified'])->controller(FilterCon
// Monitor Related Routes
Route::prefix('monitor')->middleware(['auth', 'verified'])->controller(MonitorController::class)->group(function () {
Route::get('/', 'index')->name('monitor.index');
Route::get('/prelim/{prelimDefinition}', 'prelimStatus')->name('monitor.prelimStatus');
Route::get('/audition/{audition}', 'auditionStatus')->name('monitor.auditionStatus');
Route::post('/toggleNoShow/{entry}', 'toggleNoShow')->name('monitor.toggleNoShow');
Route::post('/enter_flag', 'flagForm')->name('monitor.enterFlag');
Route::post('enter_flag/{entry}', 'storeFlag')->name('monitor.storeFlag');
});
//Route::get('/my_school', [SchoolController::class, 'my_school'])->middleware('auth','verified');