-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/Steinbeck-Lab/coconut …
…into development
- Loading branch information
Showing
6 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Citation; | ||
use App\Models\Collection; | ||
use App\Models\GeoLocation; | ||
use App\Models\Molecule; | ||
use App\Models\Organism; | ||
use App\Models\Report; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Cache; | ||
|
||
class DashWidgetsRefresh extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:dash-widgets-refresh'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'This refreshes the dashboard widgets.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
// Clear the cache for all dashboard widgets | ||
Cache::forget('stats.collections'); | ||
Cache::forget('stats.citations'); | ||
Cache::forget('stats.organisms'); | ||
Cache::forget('stats.geo_locations'); | ||
Cache::forget('stats.reports'); | ||
Cache::forget('stats.molecules'); | ||
Cache::forget('stats.molecules.non_stereo'); | ||
Cache::forget('stats.molecules.stereo'); | ||
Cache::forget('stats.molecules.parent'); | ||
|
||
// Create the cache for all DashboardStats widgets | ||
Cache::rememberForever('stats.collections', function () { | ||
return Collection::count(); | ||
}); | ||
Cache::rememberForever('stats.citations', function () { | ||
return Citation::count(); | ||
}); | ||
Cache::rememberForever('stats.organisms', function () { | ||
return Organism::count(); | ||
}); | ||
Cache::rememberForever('stats.geo_locations', function () { | ||
return GeoLocation::count(); | ||
}); | ||
Cache::rememberForever('stats.reports', function () { | ||
return Report::count(); | ||
}); | ||
|
||
// Create the cache for all DashboardStatsMid widgets | ||
Cache::rememberForever('stats.molecules', function () { | ||
return Molecule::count(); | ||
}); | ||
Cache::rememberForever('stats.molecules.non_stereo', function () { | ||
return Molecule::where([ | ||
['has_stereo', false], | ||
['is_parent', false], | ||
])->count(); | ||
}); | ||
Cache::rememberForever('stats.molecules.stereo', function () { | ||
return Molecule::where([ | ||
['has_stereo', true], | ||
])->count(); | ||
}); | ||
Cache::rememberForever('stats.molecules.parent', function () { | ||
return Molecule::where([ | ||
['has_stereo', false], | ||
['is_parent', true], | ||
])->count(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ment/Dashboard/Resources/CollectionResource/RelationManagers/MoleculesRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\CollectionResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
|
||
class MoleculesRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'molecules'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->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(), | ||
]), | ||
]); | ||
} | ||
} |