added API VICON integration for updating admission plans via admin panel (queued).

Updated exams and contests display on programs/show page.
Added relevant enums for admission plans.
This commit is contained in:
F4ilji
2025-04-09 15:58:29 +05:00
parent 7793d078e9
commit 88e729aa87
19 changed files with 684 additions and 100 deletions
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\AdmissionPlanResource\Pages;
use App\Filament\Resources\AdmissionPlanResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
class ListAdmissionPlans extends ListRecords
@@ -13,7 +14,52 @@ class ListAdmissionPlans extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Actions\CreateAction::make(), // Стандартная кнопка "Создать"
Actions\Action::make('fetchData') // Кастомная кнопка
->label('Обновить данные')
->color('primary') // Цвет кнопки
->icon('heroicon-o-arrow-path') // Иконка
->action(function () {
// Отправляем запрос в фоновом режиме
$this->js(<<<JS
fetch('/api/get-admission-plans-data', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
}
})
.then(response => response.json())
.then(() => {
// Показываем уведомление об успешном завершении
window.dispatchEvent(new CustomEvent('filament-notify', {
detail: {
type: 'success',
title: 'Данные обновлены',
body: 'Данные успешно обновлены.'
}
}));
})
.catch(() => {
// Показываем уведомление об ошибке
window.dispatchEvent(new CustomEvent('filament-notify', {
detail: {
type: 'danger',
title: 'Ошибка',
body: 'Произошла ошибка при обновлении данных.'
}
}));
});
JS);
// Показываем уведомление
Notification::make()
->title('Данные обновляются')
->body('Данные обновляются в фоновом режиме.')
->success()
->send();
}),
];
}
}