Skip to content

Commit

Permalink
Merge pull request #146 from Steinbeck-Lab/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
CS76 authored Aug 9, 2024
2 parents 7bf807c + e461c89 commit 07ba7ef
Show file tree
Hide file tree
Showing 170 changed files with 1,763 additions and 1,121 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy Coconut docs to Pages

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
# - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # or pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci # or pnpm install / yarn install / bun install
- name: Build with VitePress
run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
17 changes: 17 additions & 0 deletions app/Actions/Coconut/SearchMolecule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Coconut;

use App\Models\Citation;
use App\Models\Collection;
use App\Models\Molecule;
use App\Models\Organism;
Expand All @@ -26,6 +27,8 @@ class SearchMolecule

public $organisms = null;

public $citations = null;

/**
* Search based on given query.
*/
Expand Down Expand Up @@ -140,6 +143,8 @@ private function getFilterMap()
'subclass' => 'chemical_sub_class',
'superclass' => 'chemical_super_class',
'parent' => 'direct_parent_classification',
'org' => 'organism',
'cite' => 'ciatation',
];
}

Expand Down Expand Up @@ -233,6 +238,18 @@ private function buildTagsStatement($offset)
return Molecule::whereHas('organisms', function ($query) use ($organismIds) {
$query->whereIn('organism_id', $organismIds);
})->where('active', true)->where('is_parent', false)->orderBy('annotation_level', 'DESC')->paginate($this->size);
} elseif ($this->tagType == 'citations') {
$this->citations = array_map('strtolower', array_map('trim', explode(',', $this->query)));
$citationIds = Citation::where(function ($query) {
foreach ($this->citations as $name) {
$query->orWhereRaw('LOWER(doi) LIKE ?', ['%'.strtolower($name).'%'])
->orWhereRaw('LOWER(title) LIKE ?', ['%'.strtolower($name).'%']);
}
})->pluck('id');

return Molecule::whereHas('citations', function ($query) use ($citationIds) {
$query->whereIn('citation_id', $citationIds);
})->where('active', true)->where('is_parent', false)->orderBy('annotation_level', 'DESC')->paginate($this->size);
} else {
return Molecule::withAnyTags([$this->query], $this->tagType)->where('active', true)->where('is_parent', false)->paginate($this->size);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function create(array $input): User
])->validate();

return User::create([
'name' => $input['username'],
'name' => $input['first_name'].' '.$input['last_name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DashWidgetsRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DashWidgetsRefresh extends Command
public function handle()
{
// Clear the cache for all widgets
Cache::flush();
// Cache::flush();

// Create the cache for all DashboardStats widgets
Cache::rememberForever('stats.collections', function () {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/API/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function register(Request $request): JsonResponse
'last_name' => $validatedData['last_name'],
'email' => $validatedData['email'],
'username' => $validatedData['username'],
'name' => $validatedData['username'],
'name' => $validatedData['first_name'].' '.$validatedData['last_name'],
'orcid_id' => $request['orcid_id'],
'affiliation' => $request['affiliation'],
'password' => Hash::make($validatedData['password']),
Expand Down
18 changes: 8 additions & 10 deletions app/Livewire/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class Search extends Component

public $organisms = null;

#[Url(as: 'activeTab')]
public $activeTab = 'molecules';

public function placeholder()
{
return <<<'HTML'
Expand Down Expand Up @@ -65,23 +68,18 @@ public function placeholder()
HTML;
}

protected $listeners = ['updateSmiles' => 'setSmiles'];

public function setSmiles($smiles, $searchType)
{
$this->query = $smiles;
$this->type = $searchType;
$this->page = null;
$this->tagType = null;
}

public function updatedQuery()
{
$this->page = 1;
$this->type = null;
$this->tagType = null;
}

public function search(SearchMolecule $search)
{
$this->render($search);
}

public function render(SearchMolecule $search)
{
try {
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/StructureEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class StructureEditor extends Component

public $smiles;

public $type = 'substructure';

public function mount($smiles)
{
$this->smiles = $smiles;
Expand Down
7 changes: 0 additions & 7 deletions app/Livewire/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ class Welcome extends Component

public $citationsMapped;

protected $listeners = ['updateSmiles' => 'setSmiles'];

public function setSmiles($smiles, $searchType)
{
return redirect()->to('/search?q='.urlencode($smiles).'&type='.urlencode($searchType));
}

public function placeholder()
{
return <<<'HTML'
Expand Down
12 changes: 12 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@ public function linkedSocialAccounts()
{
return $this->hasMany(LinkedSocialAccount::class);
}

/**
* Check if user can access a particular panel.
*/
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'control-panel') {
return $this->roles()->exists();
}

return true;
}
}
7 changes: 1 addition & 6 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->string('name');
$table->string('email')->unique();
$table->string('username')->unique();
$table->string('first_name');
$table->string('last_name');
$table->string('orcid_id')->nullable();
$table->string('affiliation')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name')->nullable()->change();
$table->string('username')->unique()->nullable();
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('orcid_id')->nullable();
$table->string('affiliation')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['username', 'first_name', 'last_name', 'orcid_id', 'affiliation']);
});
}
};
14 changes: 7 additions & 7 deletions docs/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"hash": "f6991786",
"hash": "911d3a82",
"configHash": "a6dc731f",
"lockfileHash": "ba8dc5dd",
"browserHash": "6d39fbea",
"lockfileHash": "65d0b609",
"browserHash": "3f416605",
"optimized": {
"vue": {
"src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "81b3a260",
"fileHash": "698daf6a",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "085c132f",
"fileHash": "abeac802",
"needsInterop": false
},
"vitepress > @vueuse/core": {
"src": "../../../../node_modules/@vueuse/core/index.mjs",
"file": "vitepress___@vueuse_core.js",
"fileHash": "d9cc147b",
"fileHash": "354fcef1",
"needsInterop": false
},
"@theme/index": {
"src": "../../../../node_modules/vitepress/dist/client/theme-default/index.js",
"file": "@theme_index.js",
"fileHash": "5ba4d4f8",
"fileHash": "d4ea2476",
"needsInterop": false
}
},
Expand Down
Loading

0 comments on commit 07ba7ef

Please sign in to comment.