diff --git a/app/Console/Commands/ImportEntries.php b/app/Console/Commands/ImportEntries.php index f3e85b81..9906d9b7 100644 --- a/app/Console/Commands/ImportEntries.php +++ b/app/Console/Commands/ImportEntries.php @@ -8,6 +8,7 @@ use Illuminate\Bus\Batch; use Illuminate\Console\Command; use Illuminate\Support\Facades\Bus; +use Illuminate\Support\Facades\Cache; class ImportEntries extends Command { @@ -55,6 +56,7 @@ public function handle() $collection->jobs_status = 'INCURATION'; $collection->job_info = ''; $collection->save(); + Cache::forget('stats.collections'.$collection->id.'molecules.count'); })->name('Import Entries '.$collection->id) ->allowFailures(false) ->onConnection('redis') diff --git a/app/Filament/Dashboard/Resources/CollectionResource.php b/app/Filament/Dashboard/Resources/CollectionResource.php index bbe9848b..a8548c39 100644 --- a/app/Filament/Dashboard/Resources/CollectionResource.php +++ b/app/Filament/Dashboard/Resources/CollectionResource.php @@ -5,6 +5,7 @@ use App\Filament\Dashboard\Resources\CollectionResource\Pages; use App\Filament\Dashboard\Resources\CollectionResource\RelationManagers\CitationsRelationManager; use App\Filament\Dashboard\Resources\CollectionResource\RelationManagers\EntriesRelationManager; +use App\Filament\Dashboard\Resources\CollectionResource\RelationManagers\MoleculesRelationManager; use App\Filament\Dashboard\Resources\CollectionResource\Widgets\CollectionStats; use App\Livewire\ShowJobStatus; use App\Models\Collection; @@ -21,6 +22,7 @@ use Filament\Tables\Table; use Illuminate\Support\Str; use Tapp\FilamentAuditing\RelationManagers\AuditsRelationManager; +use Illuminate\Database\Eloquent\Model; class CollectionResource extends Resource { @@ -91,11 +93,16 @@ public static function table(Table $table): Table public static function getRelations(): array { - return [ + // $record = static::getOwner(); + // dd(static::getOwner()); + // dd(static::$model::molecules()->get()); + $arr = [ EntriesRelationManager::class, CitationsRelationManager::class, AuditsRelationManager::class, + MoleculesRelationManager::class, ]; + return $arr; } public static function getPages(): array diff --git a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php index 53831fbe..5b49073f 100644 --- a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php +++ b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php @@ -15,6 +15,8 @@ use Filament\Tables\Columns\ImageColumn; use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; +use Filament\Tables\Actions\Action; +use Illuminate\Support\Facades\Artisan; class EntriesRelationManager extends RelationManager { @@ -157,6 +159,13 @@ public function table(Table $table): Table ->options([ 'collection_id' => $this->ownerRecord->id, ]), + Action::make('process') + ->hidden(function () { + return $this->ownerRecord->entries()->where('status', 'SUBMITTED')->count() < 1; + }) + ->action(function () { + Artisan::call('entries:process'); + }), // Tables\Actions\CreateAction::make(), ]) ->actions([ diff --git a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/MoleculesRelationManager.php b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/MoleculesRelationManager.php new file mode 100644 index 00000000..ccd0e21a --- /dev/null +++ b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/MoleculesRelationManager.php @@ -0,0 +1,50 @@ +schema([ + Forms\Components\TextInput::make('canonical_smiles') + ->required() + ->maxLength(255), + ]); + } + + public function table(Table $table): Table + { + return $table + ->recordTitleAttribute('canonical_smiles') + ->columns([ + Tables\Columns\TextColumn::make('canonical_smiles'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } +}