Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #330

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e16c822
fix: removed github icon from login button
CS76 Aug 14, 2024
a6fa2dc
Merge branch 'feature-regapp' into development
CS76 Dec 16, 2024
d4f672e
fix: added nfdi aai to login page with branding
CS76 Dec 16, 2024
16014e1
feat: new component to display entry details for the molecule in a pa…
sriramkanakam87 Dec 16, 2024
0acde67
fix: missing id error handling
CS76 Dec 16, 2024
304d9a6
fix: added missing imports
CS76 Dec 16, 2024
e0b8833
fix: enabled button groups, moved modal view functionality to referen…
sriramkanakam87 Dec 16, 2024
93f0224
Merge pull request #325 from Steinbeck-Lab/feat-display-molecule-coll…
CS76 Dec 16, 2024
ff830ae
feat: new command to generate heatmap data
sriramkanakam87 Dec 16, 2024
61a3efc
feat: new component to display heat map on the stats page
sriramkanakam87 Dec 16, 2024
3d74cf7
fix: added tool tip, corrected the names, and moved legend to the right.
sriramkanakam87 Dec 16, 2024
ffa816d
fix: changed title and margins
sriramkanakam87 Dec 17, 2024
1d0501c
fix: reduced the size of the data json
sriramkanakam87 Dec 17, 2024
c1d14a4
Merge pull request #326 from Steinbeck-Lab/feat-charts
CS76 Dec 17, 2024
4daa7a1
fix: various bug fixes
CS76 Dec 17, 2024
c75c65b
Merge branch 'development' of https://github.com/Steinbeck-Lab/coconu…
CS76 Dec 17, 2024
6398667
fix: added missing links in the sidebar menu on mobile screens and al…
CS76 Dec 18, 2024
c886dd5
fix: published livewire assets and composer update
CS76 Dec 18, 2024
c3ede0f
fix: composer bump
CS76 Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions SocialiteProviders/src/NFDIAAI/NFDIAAIExtendSocialite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SocialiteProviders\NFDIAAI;

use SocialiteProviders\Manager\SocialiteWasCalled;

class NFDIAAIExtendSocialite
{
/**
* Register the provider.
*
* @return void
*/
public function handle(SocialiteWasCalled $socialiteWasCalled)
{
$socialiteWasCalled->extendSocialite('nfdi-aai', Provider::class);
}
}
66 changes: 66 additions & 0 deletions SocialiteProviders/src/NFDIAAI/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace SocialiteProviders\NFDIAAI;

use GuzzleHttp\RequestOptions;
use InvalidArgumentException;
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
use SocialiteProviders\Manager\OAuth2\User;

class Provider extends AbstractProvider
{
const IDENTIFIER = 'NFDI-AAI';

/**
* {@inheritdoc}
*/
protected $scopes = ['basic'];

/**
* {@inheritdoc}
*/
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase('https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/auth', $state);
}

/**
* {@inheritdoc}
*/
protected function getTokenUrl()
{
return 'https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/token';
}

/**
* {@inheritdoc}
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get('https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/userinfo', [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
],
]);

return json_decode((string) $response->getBody(), true);
}

/**
* {@inheritdoc}
*/
protected function mapUserToObject(array $user)
{
if (! isset($user['id']) || empty($user['id'])) {
throw new InvalidArgumentException('The user data is invalid: a unique "id" is required.');
}

return (new User)->setRaw($user)->map([
'id' => $user['id'],
'nickname' => $user['username'],
'name' => $user['name'],
'email' => $user['email'],
'avatar' => $user['avatar'],
]);
}
}
21 changes: 21 additions & 0 deletions SocialiteProviders/src/NFDIAAI/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "socialiteproviders/nfdi-aai",
"description": "NFDIAAI OAuth2 Provider for Laravel Socialite",
"license": "MIT",
"authors": [
{
"name": "VCNainala",
"email": "chandu.nainala@uni-jena.de"
}
],
"require": {
"php": "^8.0",
"ext-json": "*",
"socialiteproviders/manager": "^4.4"
},
"autoload": {
"psr-4": {
"SocialiteProviders\\NFDIAAI\\": ""
}
}
}
79 changes: 79 additions & 0 deletions app/Console/Commands/GenerateHeatMapData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace App\Console\Commands;

use App\Models\Collection;
use Illuminate\Console\Command;

class GenerateHeatMapData extends Command
{
protected $signature = 'coconut:generate-heat-map-data';

protected $description = 'This generates Heat Map data for collection overlaps.';

public function handle()
{
$heat_map_data = [];
$collections = Collection::all();

// Store molecule identifiers
foreach ($collections as $collection) {
$molecule_identifiers = $collection->molecules()->pluck('identifier')->toArray();
$molecule_identifiers = array_map(function ($item) {
return preg_replace('/^CNP/i', '', $item);
}, $molecule_identifiers);
$heat_map_data['ids'][$collection->id . '|' . $collection->title] = $molecule_identifiers;
}

// Calculate percentage overlaps -> ol_d = overlap data
$heat_map_data['ol_d'] = [];
$collection_keys = array_keys($heat_map_data['ids']);

foreach ($collection_keys as $collection1_key) {
$heat_map_data['ol_d'][$collection1_key] = [];
$set1 = array_unique($heat_map_data['ids'][$collection1_key]);
$set1_count = count($set1);

foreach ($collection_keys as $collection2_key) {
$set2 = array_unique($heat_map_data['ids'][$collection2_key]);
$set2_count = count($set2);

// Calculate intersection
$intersection = array_intersect($set1, $set2);
$intersection_count = count($intersection);

// Calculate percentage overlap
if ($set1_count > 0 && $set2_count > 0) {
// Using Jaccard similarity: intersection size / union size
$union_count = $set1_count + $set2_count - $intersection_count;
$overlap_percentage = ($intersection_count / $union_count) * 100;
} else {
$overlap_percentage = 0;
}

$heat_map_data['ol_d'][$collection1_key][$collection2_key] = round($overlap_percentage, 2);

// Add additional overlap statistics -> ol_s = overlap_stats
$heat_map_data['ol_s'][$collection1_key][$collection2_key] = [
// ol = overlap count
'ol' => $intersection_count,
'c1_count' => $set1_count,
'c2_count' => $set2_count,
'p' => round($overlap_percentage, 2),
];
}
}
unset($heat_map_data['ids']);

$json = json_encode($heat_map_data, JSON_UNESCAPED_SLASHES);

// Save the JSON to a file
$filePath = public_path('reports/heat_map_metadata.json');
if (! file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0777, true);
}
file_put_contents($filePath, $json);

$this->info('JSON metadata saved to public/reports/heat_map_metadata.json');
}
}
37 changes: 37 additions & 0 deletions app/Livewire/CollectionOverlap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Livewire;

use Livewire\Component;

class CollectionOverlap extends Component
{
public $collections = [];

public function mount()
{
$jsonPath = public_path('reports/heat_map_metadata.json');

if (! file_exists($jsonPath)) {
throw new \Exception('Density chart data file not found');
}

$jsonContent = file_get_contents($jsonPath);
$decodedData = json_decode($jsonContent, true);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception('Error decoding JSON data: '.json_last_error_msg());
}

// Store in the public property
$this->collections = $decodedData['ol_d'];

}

public function render()
{
return view('livewire.collection-overlap', [
'collectionsData' => json_encode($this->collections),
]);
}
}
28 changes: 28 additions & 0 deletions app/Livewire/EntryDetailsDisplay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Livewire;

use Livewire\Component;

class EntryDetailsDisplay extends Component
{
public $mol = null;

public $collection = null;

public $reference = null;

public $entry_details = [];

public function getEntryDetails()
{
$this->entry_details = $this->mol->entries()->where('collection_id', $this->collection->id)->where('reference_id', $this->reference)->get();
}

public function render()
{
return view('livewire.entry-details-display', [
'entry_details' => $this->entry_details,
]);
}
}
3 changes: 3 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class EventServiceProvider extends ServiceProvider
public function boot(): void
{
//
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
$event->extendSocialite('regapp', \SocialiteProviders\NFDIAAI\Provider::class);
});
}

/**
Expand Down
81 changes: 42 additions & 39 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,56 @@
"license": "MIT",
"require": {
"php": "^8.3",
"archilex/filament-filter-sets": "^3.7",
"bezhansalleh/filament-exceptions": "^2.1.1",
"archilex/filament-filter-sets": "^3.7.35",
"bezhansalleh/filament-exceptions": "^2.1.2",
"bezhansalleh/filament-panel-switch": "*",
"bezhansalleh/filament-shield": "^3.2",
"dompdf/dompdf": "^3.0",
"filament/filament": "^3.2.127",
"filament/forms": "^3.2",
"filament/spatie-laravel-media-library-plugin": "^3.2",
"filament/spatie-laravel-tags-plugin": "^3.2",
"guzzlehttp/guzzle": "^7.2",
"bezhansalleh/filament-shield": "^3.3.4",
"dompdf/dompdf": "^3.0.1",
"filament/filament": "^3.2.131",
"filament/forms": "^3.2.131",
"filament/spatie-laravel-media-library-plugin": "^3.2.131",
"filament/spatie-laravel-tags-plugin": "^3.2.131",
"guzzlehttp/guzzle": "^7.9.2",
"kenepa/banner": "^0.0.9",
"laravel/framework": "^11.34.2",
"laravel/framework": "^11.36.1",
"laravel/horizon": "*",
"laravel/jetstream": "^5.0",
"laravel/jetstream": "^5.3.4",
"laravel/octane": "^2.6",
"laravel/prompts": "^0.1.25",
"laravel/sanctum": "^4.0",
"laravel/socialite": "^5.14",
"laravel/telescope": "^5.2",
"laravel/tinker": "^2.9",
"league/flysystem-aws-s3-v3": "^3.0",
"livewire/livewire": "^3.0",
"laravel/sanctum": "^4.0.7",
"laravel/socialite": "^5.16.1",
"laravel/telescope": "^5.2.6",
"laravel/tinker": "^2.10",
"league/flysystem-aws-s3-v3": "^3.29",
"livewire/livewire": "^3.5.12",
"lomkit/laravel-rest-api": "*",
"maartenpaauw/model-states-for-filament": "^2.3",
"mpdf/mpdf": "^8.2",
"owen-it/laravel-auditing": "^13.6",
"predis/predis": "^2.2",
"pxlrbt/filament-excel": "^2.3.3",
"pxlrbt/filament-spotlight": "^1.2",
"shuvroroy/filament-spatie-laravel-backup": "^2.1",
"spatie/laravel-backup": "^8.6",
"spatie/laravel-cookie-consent": "^3.3",
"spatie/laravel-model-states": "^2.7",
"spatie/laravel-permission": "^6.3",
"maartenpaauw/model-states-for-filament": "^2.4",
"mpdf/mpdf": "^8.2.5",
"owen-it/laravel-auditing": "^13.6.8",
"predis/predis": "^2.3",
"pxlrbt/filament-excel": "^2.3.4",
"pxlrbt/filament-spotlight": "^1.3",
"shuvroroy/filament-spatie-laravel-backup": "^2.2.3",
"socialiteproviders/generators": "^4.7",
"socialiteproviders/manager": "^4.7",
"spatie/laravel-backup": "^8.8.2",
"spatie/laravel-cookie-consent": "^3.3.2",
"spatie/laravel-model-states": "^2.9",
"spatie/laravel-permission": "^6.10.1",
"spatie/schema-org": "^3.23",
"stechstudio/filament-impersonate": "*",
"stephenjude/filament-debugger": "^3.0",
"tapp/filament-auditing": "^3.0",
"tecnickcom/tc-lib-pdf": "^8.0"
"stephenjude/filament-debugger": "^3.1.2",
"tapp/filament-auditing": "^3.0.8",
"tecnickcom/tc-lib-pdf": "^8.0.82"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pint": "^1.15",
"laravel/sail": "^1.29",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^10.5",
"spatie/laravel-ignition": "^2.4"
"fakerphp/faker": "^1.24.1",
"laravel/pint": "^1.18.3",
"laravel/sail": "^1.39.1",
"mockery/mockery": "^1.6.12",
"nunomaduro/collision": "^8.5",
"phpunit/phpunit": "^10.5.39",
"spatie/laravel-ignition": "^2.9"
},
"autoload": {
"files": [
Expand All @@ -65,7 +67,8 @@
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
"Database\\Seeders\\": "database/seeders/",
"SocialiteProviders\\NFDIAAI\\": "SocialiteProviders/src/NFDIAAI/"
}
},
"autoload-dev": {
Expand Down
Loading
Loading