Skip to content

Commit

Permalink
Merge pull request #267 from Steinbeck-Lab/feat-report-suggestions
Browse files Browse the repository at this point in the history
feat: report suggestions
  • Loading branch information
CS76 authored Nov 22, 2024
2 parents 91461df + f1ada25 commit 4bed61d
Show file tree
Hide file tree
Showing 21 changed files with 961 additions and 193 deletions.
1 change: 0 additions & 1 deletion app/Actions/Coconut/SearchMolecule.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ private function executeQuery($statement)

$ids_array = collect($hits)->pluck('id')->toArray();
$ids = implode(',', $ids_array);
// dd($ids);

if ($ids != '') {

Expand Down
3 changes: 0 additions & 3 deletions app/Filament/Dashboard/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ public static function table(Table $table): Table

public static function getRelations(): array
{
// $record = static::getOwner();
// dd(static::getOwner());
// dd(static::$model::molecules()->get());
$arr = [
EntriesRelationManager::class,
CitationsRelationManager::class,
Expand Down
7 changes: 1 addition & 6 deletions app/Filament/Dashboard/Resources/GeoLocationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Filament\Dashboard\Resources\GeoLocationResource\Pages;
use App\Filament\Dashboard\Resources\GeoLocationResource\Widgets\GeoLocationStats;
use App\Models\GeoLocation;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
Expand All @@ -26,11 +25,7 @@ class GeoLocationResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255),
]);
->schema(GeoLocation::getForm());
}

public static function table(Table $table): Table
Expand Down
8 changes: 8 additions & 0 deletions app/Filament/Dashboard/Resources/MoleculeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public static function table(Table $table): Table
}),
])
->action(function (array $data, Molecule $record): void {
$record->active = ! $record->active;
$record->active ? $record->status = 'APPROVED' : $record->status = 'REVOKED';
$record->comment = prepareComment($data['reason']);
$record->save();
self::changeMoleculeStatus($record, $data['reason']);
})
->modalHidden(function (Molecule $record) {
Expand All @@ -142,6 +146,10 @@ public static function table(Table $table): Table
])
->action(function (array $data, Collection $records): void {
foreach ($records as $record) {
$record->active = ! $record->active;
$record->active ? $record->status = 'APPROVED' : $record->status = 'REVOKED';
$record->comment = prepareComment($data['reason']);
$record->save();
self::changeMoleculeStatus($record, $data['reason']);
}
})
Expand Down
99 changes: 1 addition & 98 deletions app/Filament/Dashboard/Resources/OrganismResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use App\Forms\Components\OrganismsTable;
use App\Models\Organism;
use Archilex\AdvancedTables\Filters\AdvancedFilter;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section;
Expand Down Expand Up @@ -43,102 +41,9 @@ public static function form(Form $form): Form
Group::make()
->schema([
Section::make('')
->schema([
Forms\Components\TextInput::make('name')
->required()
->unique()
->maxLength(255)
->suffixAction(
Action::make('infoFromSources')
->icon('heroicon-m-clipboard')
// ->fillForm(function ($record, callable $get): array {
// $entered_name = $get('name');
// $name = ucfirst(trim($entered_name));
// $data = null;
// $iri = null;
// $organism = null;
// $rank = null;

// if ($name && $name != '') {
// $data = Self::getOLSIRI($name, 'species');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'species');
// Self::info("Mapped and updated: $name");
// } else {
// $data = Self::getOLSIRI(explode(' ', $name)[0], 'genus');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'genus');
// Self::info("Mapped and updated: $name");
// } else {
// $data = Self::getOLSIRI(explode(' ', $name)[0], 'family');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'genus');
// Self::info("Mapped and updated: $name");
// } else {
// [$name, $iri, $organism, $rank] = Self::getGNFMatches($name, $record);
// }
// }
// }
// }
// return [
// 'name' => $name,
// 'iri' => $iri,
// 'rank' => $rank,
// ];
// })
// ->form([
// Forms\Components\TextInput::make('name')->readOnly(),
// Forms\Components\TextInput::make('iri')->readOnly(),
// Forms\Components\TextInput::make('rank')->readOnly(),
// ])
// ->action(fn ( $record) => $record->advance())
->modalContent(function ($record, $get): View {
$name = ucfirst(trim($get('name')));
$data = null;
// $iri = null;
// $organism = null;
// $rank = null;

if ($name && $name != '') {
$data = self::getOLSIRI($name, 'species');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'species');
// } else {
// $data = Self::getOLSIRI(explode(' ', $name)[0], 'genus');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'genus');
// } else {
// $data = Self::getOLSIRI(explode(' ', $name)[0], 'family');
// if ($data) {
// Self::updateOrganismModel($name, $data, $record, 'genus');
// } else {
// [$name, $iri, $organism, $rank] = Self::getGNFMatches($name, $record);
// }
// }
// }
}

return view(
'forms.components.organism-info',
[
'data' => $data,
],
);
})
->action(function (array $data, Organism $record): void {
// Self::updateOrganismModel($data['name'], $data['iri'], $record, $data['rank']);
})
->slideOver()
),
Forms\Components\TextInput::make('iri')
->label('IRI')
->maxLength(255),
Forms\Components\TextInput::make('rank')
->maxLength(255),
]),
->schema(Organism::getForm()),
])
->columnSpan(1),

Group::make()
->schema([
Section::make('')
Expand Down Expand Up @@ -254,7 +159,6 @@ protected static function getGNFMatches($name, $organism)
$responseBody = json_decode($response->getBody(), true);

return $responseBody;
// dd($responseBody);

// if (isset($responseBody['names']) && count($responseBody['names']) > 0) {
// $r_name = $responseBody['names'][0];
Expand Down Expand Up @@ -293,7 +197,6 @@ protected static function getGNFMatches($name, $organism)

protected static function updateOrganismModel($name, $iri, $organism = null, $rank = null)
{
// dd($name, $iri, $organism, $rank);
if (! $organism) {
$organism = Organism::where('name', $name)->first();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ function (Molecule $molecule, $record): HtmlString {
foreach ($molecues_with_muliple_locations as $molecule) {
$current_sample_locations_subset = SampleLocation::findOrFail($molecule['sampleLocations']);
$current_sample_locations_multiple = $records->where('id', $molecule['id'])[0]->sampleLocations()->where('organism_id', $this->getOwnerRecord()->id)->get();
// dd($current_sample_locations_multiple, $current_sample_locations_subset);
if ($current_sample_locations_multiple->pluck('id') == $current_sample_locations_subset->pluck('id')) {
$currentOrganism->auditDetach('molecules', $molecule['id']);
}
Expand Down
Loading

0 comments on commit 4bed61d

Please sign in to comment.