Initial commit: Pireon Admin — headless admin panel and public API

Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer
collective, backed by the Pireon OAuth identity server. The public site is a
separate, server-rendered application consuming /api/public/v1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 17:55:27 +02:00
commit 3897113313
534 changed files with 64050 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\RelationManagers;
use App\Filament\Support\TranslatableTabs;
use App\Models\ImageAttachment;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
/**
* The gallery of a project.
*
* A table rather than a repeater inside the form, because the thing you need
* to see while editing a gallery is the images themselves, and because the
* order matters — it is dragged here rather than typed into a number field.
*/
class GalleryRelationManager extends RelationManager
{
protected static string $relationship = 'images';
public static function getTitle(Model $ownerRecord, string $pageClass): string
{
return __('panel.gallery.title');
}
public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
$count = $ownerRecord->images()->count();
return $count > 0 ? (string) $count : null;
}
public function form(Schema $schema): Schema
{
return $schema->components([
FileUpload::make('path')
->label(__('panel.gallery.fields.image'))
->image()
// Explicit: the default disk is private, and the frontend runs
// on another host.
->disk(config('media.disk'))
->directory('projects/gallery')
->imageEditor()
->required()
->columnSpanFull(),
TranslatableTabs::make(fn (string $locale) => [
TextInput::make("alt.{$locale}")
->label(__('panel.gallery.fields.alt'))
->helperText(__('panel.gallery.fields.alt_hint'))
->maxLength(255)
->columnSpanFull(),
// Shown to everyone, unlike the alt text. "Before" and
// "after" belong here.
TextInput::make("caption.{$locale}")
->label(__('panel.gallery.fields.caption'))
->helperText(__('panel.gallery.fields.caption_hint'))
->maxLength(255)
->columnSpanFull(),
])->columnSpanFull(),
]);
}
public function table(Table $table): Table
{
$locale = app()->getLocale();
return $table
->defaultSort('position')
->reorderable('position')
// The table shows each image's real dimensions; loaded up front so
// that costs one query rather than one per row.
->modifyQueryUsing(fn (Builder $query) => $query->with('media'))
->columns([
ImageColumn::make('path')
->label('')
->disk(config('media.disk'))
->height(56),
TextColumn::make('caption')
->label(__('panel.gallery.fields.caption'))
->state(fn (ImageAttachment $record) => $record->getTranslation('caption', $locale, false) ?: null)
->placeholder('—')
->wrap(),
TextColumn::make('alt')
->label(__('panel.gallery.fields.alt'))
->state(fn (ImageAttachment $record) => $record->getTranslation('alt', $locale, false) ?: null)
// An image nobody described is the one worth spotting from
// the listing.
->placeholder(__('panel.gallery.missing_alt'))
->color(fn (ImageAttachment $record) => $record->getTranslation('alt', $locale, false)
? null
: 'warning')
->wrap()
->toggleable(),
TextColumn::make('media.width')
->label(__('panel.gallery.fields.size'))
->state(fn (ImageAttachment $record) => $record->media?->width
? "{$record->media->width}×{$record->media->height}"
: __('panel.gallery.pending'))
->badge()
->color(fn (ImageAttachment $record) => $record->media?->width ? 'gray' : 'warning')
->toggleable(),
])
->headerActions([
CreateAction::make()
->label(__('panel.gallery.actions.add'))
// New images go at the end rather than jumping to the top.
->mutateDataUsing(function (array $data): array {
$data['position'] = (int) $this->getOwnerRecord()->images()->max('position') + 1;
return $data;
}),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->toolbarActions([
DeleteBulkAction::make(),
])
->emptyStateHeading(__('panel.gallery.empty.heading'))
->emptyStateDescription(__('panel.gallery.empty.description'))
->emptyStateIcon('heroicon-o-photo');
}
}

View File

@@ -0,0 +1,136 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\RelationManagers;
use App\Enums\GitProvider;
use App\Models\Repository;
use App\Services\Git\GitException;
use App\Services\Git\GitManager;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
/**
* Connect repositories from inside a project, which is where the person adding
* them is already working.
*
* A newly attached repository is synced immediately so its stats appear at
* once, rather than staying blank until the hourly schedule runs.
*/
class RepositoriesRelationManager extends RelationManager
{
protected static string $relationship = 'repositories';
public static function getTitle(Model $ownerRecord, string $pageClass): string
{
return __('panel.repositories.plural');
}
public function form(Schema $schema): Schema
{
return $schema->components([
Select::make('provider')
->label(__('panel.repositories.fields.provider'))
->options(GitProvider::class)
->default(GitProvider::default())
->required()
->disableOptionWhen(fn (string $value) => ! GitProvider::from($value)->isSupported()),
TextInput::make('full_name')
->label(__('panel.repositories.fields.full_name'))
->placeholder('colectivo/mi-proyecto')
->helperText(__('panel.repositories.fields.full_name_hint'))
->required()
->maxLength(255),
Toggle::make('is_primary')
->label(__('panel.repositories.fields.is_primary')),
Toggle::make('show_publicly')
->label(__('panel.repositories.fields.show_publicly'))
->default(true),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('full_name')
->columns([
TextColumn::make('full_name')
->label(__('panel.repositories.fields.full_name'))
->url(fn (Repository $r) => $r->html_url, shouldOpenInNewTab: true),
TextColumn::make('primary_language')
->label(__('panel.repositories.fields.language'))
->badge()
->placeholder('—'),
TextColumn::make('stars')->label('★')->badge()->color('warning'),
TextColumn::make('good_first_issues_count')
->label(__('panel.repositories.fields.good_first_issues'))
->counts('goodFirstIssues')
->badge(),
TextColumn::make('pushed_at')
->label(__('panel.repositories.fields.pushed_at'))
->since()
->color(fn (Repository $r) => $r->isDormant() ? 'danger' : null)
->placeholder('—'),
])
->headerActions([
CreateAction::make()
// Sync straight away so the stats are not blank until the
// next scheduled run.
->after(function (Repository $record, GitManager $git): void {
try {
$git->sync($record);
} catch (GitException $e) {
Notification::make()
->warning()
->title(__('panel.repositories.notifications.sync_failed'))
->body($e->getMessage())
->send();
}
}),
])
->recordActions([
Action::make('sync')
->label(__('panel.repositories.actions.sync'))
->icon('heroicon-o-arrow-path')
->color('gray')
->visible(fn () => Auth::user()?->can('repositories.sync'))
->action(function (Repository $record, GitManager $git): void {
try {
$git->sync($record);
Notification::make()
->success()
->title(__('panel.repositories.notifications.synced'))
->send();
} catch (GitException $e) {
Notification::make()
->danger()
->title(__('panel.repositories.notifications.sync_failed'))
->body($e->getMessage())
->send();
}
}),
DeleteAction::make(),
]);
}
}