Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv into prod-…
Browse files Browse the repository at this point in the history
…helm-deploy
  • Loading branch information
NishaSharma14 committed Dec 12, 2023
2 parents 6c55d06 + db6bdd3 commit a0da340
Show file tree
Hide file tree
Showing 20 changed files with 374 additions and 109 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [1.1.0-rc.16](https://github.com/NFDI4Chem/nmrxiv/compare/v1.0.0-rc.16...v1.1.0-rc.16) (2023-12-12)


### Features

* exposed oembed endpoints ([6b2e32a](https://github.com/NFDI4Chem/nmrxiv/commit/6b2e32ab8a3bf245470850845c5cbafacfc1aab7))


### Bug Fixes

* failing preview save method for independent samples fix ([e9e340b](https://github.com/NFDI4Chem/nmrxiv/commit/e9e340b06eb71f604b4c4d572691822a61a40355))
* fixes [#961](https://github.com/NFDI4Chem/nmrxiv/issues/961) ([cbc0670](https://github.com/NFDI4Chem/nmrxiv/commit/cbc0670515b1269553d14f9bae774010951420de))
* formatting changes ([a8b21d2](https://github.com/NFDI4Chem/nmrxiv/commit/a8b21d23851b2be36381b67a2578be07b4be9271))
* notify admin on project release ([b8831a9](https://github.com/NFDI4Chem/nmrxiv/commit/b8831a9097bf185baeb667754535c070ffccbcec))
* published horizon assets ([a7954c6](https://github.com/NFDI4Chem/nmrxiv/commit/a7954c681a16e60b0b9769dcb9e557081a0b2048))
* updated tags and other on blur event triggers and save details ([46eee9c](https://github.com/NFDI4Chem/nmrxiv/commit/46eee9ccb136b03b32c99c4979153f6cba500816))

## [1.1.0-rc.15](https://github.com/NFDI4Chem/nmrxiv/compare/v1.0.0-rc.15...v1.1.0-rc.15) (2023-12-08)


Expand Down
5 changes: 4 additions & 1 deletion app/Events/DraftProcessed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ class DraftProcessed implements ShouldBroadcastNow

public $project;

public $sendTo;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($project)
public function __construct($project, $sendTo)
{
$this->project = $project;
$this->sendTo = $sendTo;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ public function prepareMoleculesSchemas($sample)
foreach ($sample->molecules as &$molecule) {
$inchiKey = $molecule->inchi_key;
$pubchemLink = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/'.$inchiKey.'/property/IUPACName/JSON';
$json = json_decode(Http::get($pubchemLink)->body(), true);
$cid = $json['PropertyTable']['Properties'][0]['CID'];
$iupacName = $json['PropertyTable']['Properties'][0]['IUPACName'];
$pubchemDataJSON = json_decode(Http::get($pubchemLink)->body(), true);
$cid = '';
$iupacName = '';
if (array_key_exists('PropertyTable', $pubchemDataJSON)) {
$cid = $pubchemDataJSON['PropertyTable']['Properties'][0]['CID'];
$iupacName = $pubchemDataJSON['PropertyTable']['Properties'][0]['IUPACName'];
}

$moleculeSchema = Schema::MolecularEntity();
$moleculeSchema['@id'] = $inchiKey;
Expand Down
15 changes: 11 additions & 4 deletions app/Http/Controllers/DatasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,17 @@ public function preview(Request $request, Dataset $dataset)
$content = $request->get('img');
$study = $dataset->study;
if ($content) {
$path = '/projects/'.$study->project->uuid.'/'.$study->uuid.'/'.$dataset->slug.'.svg';
Storage::disk(env('FILESYSTEM_DRIVER_PUBLIC'))->put($path, $content, 'public');
$dataset->dataset_photo_path = $path;
$dataset->save();
if ($study->project) {
$path = '/projects/'.$study->project->uuid.'/'.$study->uuid.'/'.$dataset->slug.'.svg';
Storage::disk(env('FILESYSTEM_DRIVER_PUBLIC'))->put($path, $content, 'public');
$dataset->dataset_photo_path = $path;
$dataset->save();
} else {
$path = '/samples/'.$study->uuid.'/'.$dataset->slug.'.svg';
Storage::disk(env('FILESYSTEM_DRIVER_PUBLIC'))->put($path, $content, 'public');
$dataset->dataset_photo_path = $path;
$dataset->save();
}
}
}
}
66 changes: 66 additions & 0 deletions app/Http/Controllers/OEmbedController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace App\Http\Controllers;

use App\Http\Resources\StudyResource;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Response;

class OEmbedController extends Controller
{
public function spectra(Request $request)
{
$url = $request->get('url');
$format = $request->get('format');
$height = $request->get('height');
$width = $request->get('width');
$parsedURL = parse_url($url);
$URLPath = $parsedURL['path'];
$identifier = preg_split('#/#', $URLPath)[1];
if ($identifier) {
$resolvedModel = resolveIdentifier($identifier);
$namespace = $resolvedModel['namespace'];
$model = $resolvedModel['model'];
// dd($model);
if ($model) {
$data = [
'success' => true,
'type' => 'rich',
'version' => '1.0',
'provider_name' => config('app.name'),
'provider_url' => config('app.url'),
'title' => $model->name,
'author_name' => $model->owner->name,
'author_url' => config('app.url').'/author/'.$model->owner->username,
'height' => $height ? $height : '300',
'width' => $width ? $width : '320',
'thumbnail_width' => '300',
'thumbnail_height' => '125',
'thumbnail_url' => $model->study_preview_urls[0],
'html' => '<iframe id="nmrxiv_embed" class="nmrxiv_embed_iframe" style="width: 100%; overflow: hidden;" src="'.config('app.url').'/embed/'.$model->identifier.'" width="300" height="300" frameborder="0" scrolling="no"></iframe>',
];

return Response::json($data);
}
}
}

public function embed(Request $request, $identifier)
{
$resolvedModel = resolveIdentifier($identifier);
$namespace = $resolvedModel['namespace'];
$model = $resolvedModel['model'];
if ($model) {
if ($namespace == 'Study') {
$study = $model;

return Inertia::render('Public/Embed/Sample', [
'study' => (new StudyResource($study))->lite(false, ['tags', 'sample', 'datasets', 'molecules', 'owner', 'license']),
]);
} elseif ($namespace == 'Dataset') {
$dataset = $model;
}
}
}
}
22 changes: 21 additions & 1 deletion app/Jobs/ProcessSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function handle(AssignIdentifier $assigner, PublishProject $projectPublis

ArchiveProject::dispatch($project);

Notification::send($project->owner, new DraftProcessedNotification($project));
$project->sendNotification('publish', $this->prepareSendList($project));
}
} else {
$logs = 'Moving files in progress';
Expand Down Expand Up @@ -203,4 +203,24 @@ public function moveFolder($fsObject, $draft, $path)
}
}
}

/**
* Prepare Sent to list.
*
* @param App\Models\Project $project
* @return void
*/
public function prepareSendList($project)
{
$sendTo = [];
foreach ($project->allUsers() as $member) {
if ($member->projectMembership->role == 'creator' || $member->projectMembership->role == 'owner') {
array_push($sendTo, $member);
} else {
array_push($sendTo, $project->owner);
}
}

return $sendTo;
}
}
12 changes: 5 additions & 7 deletions app/Listeners/SendDraftProcessedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Listeners;

use App\Models\User;
use App\Notifications\DraftProcessedNotification;
use App\Notifications\ProjectPublishNotificationToAdmins;
use Illuminate\Support\Facades\Notification;

class SendDraftProcessedNotification
Expand All @@ -19,14 +21,10 @@ public function __construct()

/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
public function handle(object $event): void
{
$project = $event->project;
$owner = $project->owner;
Notification::send($owner, new DraftProcessedNotification($project));
Notification::send($event->sendTo, new DraftProcessedNotification($event->project));
Notification::send(User::role(['super-admin'])->get(), new ProjectPublishNotificationToAdmins($event->project));
}
}
38 changes: 38 additions & 0 deletions app/Mail/ProjectPublishNotifyAdmins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ProjectPublishNotifyAdmins extends Mailable
{
use Queueable, SerializesModels;

public $project;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($project)
{
$this->project = $project;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('vendor.mail.project-publish-notify-admins', [
'url' => url(config('app.url').'/dashboard/projects/'.$this->project->id),
'projectName' => $this->project->name,
'projectId' => $this->project->id,
])->subject(__('A project has been published'.' - '.$this->project->name));
}
}
4 changes: 4 additions & 0 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use App\Events\DraftProcessed;
use App\Events\ProjectArchival;
use App\Events\ProjectDeletion;
use App\Notifications\ProjectDeletionFailureNotification;
Expand Down Expand Up @@ -356,6 +357,9 @@ public function sendNotification($notifyType, $sendTo)
case 'deletionFailure':
Notification::send($sendTo, new ProjectDeletionFailureNotification($this));
break;
case 'publish':
event(new DraftProcessed($this, $sendTo));
break;
}
}
}
60 changes: 60 additions & 0 deletions app/Notifications/ProjectPublishNotificationToAdmins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Notifications;

use App\Mail\ProjectPublishNotifyAdmins;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class ProjectPublishNotificationToAdmins extends Notification implements ShouldQueue
{
use Queueable;

private $project;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($project)
{
$this->project = $project;
}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new ProjectPublishNotifyAdmins($this->project))->to($notifiable->email);
}

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
4 changes: 2 additions & 2 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default defineConfig({
},

logo: {
light: "/logo.svg",
dark: "/logo-dark.svg",
light: "/img/logo.svg",
dark: "/img/dark-logo.svg",
alt : "nmrXiv"
},

Expand Down
14 changes: 1 addition & 13 deletions docs/developer-guides/api.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# API

nmrXiv infrastructure supports API through which software developers can interact with the data programmatically. Postman tool is used to document how nmrXiv API should be used, methods, status, and error codes supported.
The infrastructure of nmrXiv facilitates API access, enabling software developers to interact with the data programmatically. The documentation for nmrXiv API, including information on methods, status, and supported error codes, is provided using [Swagger](https://swagger.io/). For detailed insights into API usage, please refer to our [Swagger documentation](https://nmrxiv.org/api/documentation).

Postman allows you to publish documentation quickly and easily. Postman automatically pulls your sample requests, headers, code snippets, etc., to populate your documentation page with dynamic examples and machine-readable instructions so you can easily share your API with the rest of the world.

## [nmrXiv APIs](https://www.postman.com/nmrxiv-jena/workspace/nmrxiv/request/17173369-2ef7d5a8-0121-418b-8762-cc47d7a5b7cd)

<img src="/img/postman.png"/>

<br/><br/>
If you are interested in specific endpoints, check out the following quick links:

- [Authentication and Authorisation](https://www.postman.com/nmrxiv-jena/workspace/nmrxiv/collection/17173369-f372ec15-9b92-4902-8844-b129ab0c17d1?ctx=documentation)
- [Projects/Studies/Dataset](https://www.postman.com/nmrxiv-jena/workspace/nmrxiv/collection/17173369-b00475c3-6171-4e58-97ab-cb88b3ac4c59?ctx=documentation)
- [Bioschemas](https://www.postman.com/nmrxiv-jena/workspace/nmrxiv/folder/17195598-561a4bcc-7c84-4669-b245-c8416dfc8e90?ctx=documentation)
6 changes: 0 additions & 6 deletions docs/public/logo.svg

This file was deleted.

2 changes: 1 addition & 1 deletion public/vendor/horizon/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/vendor/horizon/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=7e1968acfd75b8dc843675097962e3ce",
"/app.js": "/app.js?id=79bae40dcb18de9ca1b5d0008c577471",
"/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435",
"/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",
Expand Down
Loading

0 comments on commit a0da340

Please sign in to comment.