Skip to content

Commit

Permalink
Merge pull request #23 from mboudet/test
Browse files Browse the repository at this point in the history
Fix async annotation + add back config file
  • Loading branch information
mboudet authored May 2, 2023
2 parents 017cc9d + a045efd commit 89ee954
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 49 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)

## [0.4.3] 2023-05-02

### Fixed

- Fixed Protein domains view in gene list
- Removed remaining console.log in Eggnog
- Fixed display for blast/diamond when there is no data
- Fixed typo in Show more / Show less for diamond
- Fixed async annotation add

### Added

- Added back config file option at startup (see config.json.template)
- Added config option to disable login (and registration) (*disable_user_login* key)
- Added config option to disable registrations (*disable_user_registration* key)
- Added config option to hide blast link (*disable_blast* key)
- Added config option to redirect blast link to custom external link (*blast_link* key)

## [0.4.2] 2023-04-13

### Fixed
Expand Down
17 changes: 17 additions & 0 deletions cli/genoboo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
/* eslint-disable no-underscore-dangle, no-console */

const fs = require('fs');
const commander = require('commander');
const { Tail } = require('tail');
const { spawn, execFileSync } = require('child_process');
Expand Down Expand Up @@ -151,6 +152,7 @@ function startMongoDaemon(

async function startGeneNoteBook(cmd) {
const {
config,
port,
rootUrl,
mongoUrl,
Expand All @@ -160,11 +162,22 @@ async function startGeneNoteBook(cmd) {
dbCacheSizeGB,
storagePath
} = cmd.opts();

const PORT = parseInt(port, 10) || 3000;
const ROOT_URL = rootUrl || `http://localhost:${PORT}`;
const STORAGE_PATH = storagePath || 'assets/app/uploads';
const opts = { PORT, ROOT_URL, GNB_VERSION: pkginfo.version, STORAGE_PATH };

if (config && fs.existsSync(config)) {
try {
const METEOR_SETTINGS = fs.readFileSync(config, 'utf8');
Object.assign(opts, { METEOR_SETTINGS });
} catch (error) {
logger.error(`Cannot read ${config}: `)
logger.error(error)
}
}

if (mongoUrl) {
if (dbPath) {
throw new Error('--db-path and --mongo-url are mutually exclusive');
Expand Down Expand Up @@ -200,6 +213,10 @@ program
.command('run')
.description('Run a GeneNoteBook server')
.usage('[options]')
.option(
'--config [config]',
'Path to an optional json config file. To be available client-side, options must be under a "public" key.'
)
.option(
'--port [port]',
'Web server port on which to serve GeneNoteBook. Default: 3000'
Expand Down
8 changes: 8 additions & 0 deletions config.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"public":{
"disable_blast": false,
"disable_user_login": false,
"disable_user_registration": false,
"blast_link": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class AnnotationProcessor {
});

if (this.geneBulkOperation.length > 0) {
this.geneBulkOperation.execute();
return this.geneBulkOperation.execute();
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions imports/api/jobqueue/process-annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ jobQueue.processJobs(
parser.abort();
}
},
complete(result) {
complete: async function(result) {
if (result.meta.aborted === true) {
job.fail();
} else {
try {
lineProcessor.lastAnnotation();
await lineProcessor.lastAnnotation();
const nAnnotation = lineProcessor.getNumberAnnotation();
job.done({ nInserted: nAnnotation });
} catch (err) {
Expand Down
8 changes: 8 additions & 0 deletions imports/startup/server/useraccounts-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Accounts.onCreateUser((options, user) => {
return user;
});

Accounts.validateLoginAttempt(attempt => {
return !Meteor.settings.public.disable_user_login === true
})

Accounts.onLogout(({ user }) => {
logger.debug('logout', { user });
if (user) {
Expand All @@ -46,3 +50,7 @@ Meteor.users.allow({
return false;
},
});

Accounts.config({
forbidClientAccountCreation: Meteor.settings.public.disable_user_registration === true
});
33 changes: 33 additions & 0 deletions imports/ui/blast/SubmitBlast.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,38 @@ function SubmitBlast({ genomes }) {
return <Redirect to={{ pathname: redirect, from: 'blast' }} />;
}


if (Meteor.settings.public.disable_blast === true || Meteor.settings.public.blast_link){
let blastLink
if (Meteor.settings.public.blast_link){
blastLink = (
<p>You can access an external blast interface <a href={Meteor.settings.public.blast_link} target="_blank" style={{color: "#485fc7"}}>here</a></p>
)
}
return (
<div className="hero is-small is-light is-bold">
<div className="hero-body">
<form className="container" id="blast">
<header className="has-background-light">
<h4 className="title is-size-4 has-text-weight-light">
BLAST search
</h4>
</header>
<div className="card">
<div className="card-content">
<p> GeneNoteBook blast interface is currently disabled. </p>
{blastLink}
</div>
</div>
</form>
</div>
</div>
)
}

return (
<div className="hero is-small is-light is-bold">
<div className="hero-body">
<form className="container" id="blast">
<div className="card">
<header className="has-background-light">
Expand Down Expand Up @@ -408,6 +439,8 @@ function SubmitBlast({ genomes }) {
</div>
</div>
</form>
</div>
</div>
);
}

Expand Down
51 changes: 37 additions & 14 deletions imports/ui/landingpage/LandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ function NoGenomes() {
<article className="message is-info" role="alert">
<div className="message-body">
No public genomes are available.&nbsp;
{/*<Link to="/login">
Sign in
</Link>
&nbsp;to access private data.*/}
{! Meteor.settings.public.disable_user_login && (
<>
<Link to="/login">
Sign in
</Link>
&nbsp;to access private data.
</>
)}
</div>
</article>
)
Expand All @@ -120,6 +124,23 @@ const withConditionalRendering = compose(
const StatsWithDataTracker = withConditionalRendering(Stats);

function LandingPage() {
const block = Meteor.settings.public.disable_blast ? 6 : 4

let blastLink = (
<Link to="/blast" className="button is-light is-link is-fullwidth">
<span className="icon-database" aria-hidden="true" />&nbsp;Blast
</Link>
)

if (Meteor.settings.public.blast_link){
blastLink = (
<a target="_blank" href={Meteor.settings.public.blast_link} className="button is-light is-link is-fullwidth">
<span className="icon-database" aria-hidden="true" />&nbsp;Blast
</a>
)
}


return (
<>
<section className="hero is-small is-light is-bold">
Expand All @@ -136,16 +157,18 @@ function LandingPage() {
!Meteor.userId()
&& (
<div className="buttons are-small" role="group">
{/*
{! (Meteor.settings.public.disable_user_login === true || Meteor.settings.public.disable_user_registration === true) && (
<Link to="/register" className="button is-success">
<span className="icon-user-add" aria-hidden="true" />
&nbsp;Create account
</Link>
)}
{! Meteor.settings.public.disable_user_login === true && (
<Link to="/login" className="button is-link">
<span className="icon-login" aria-hidden="true" />
&nbsp;Sign in
</Link>
*/}
)}
<a href="http://genenotebook.github.io/" className="button is-dark is-outlined">
<span className="icon-github" aria-hidden="true" />
&nbsp;About GeneNotebook
Expand All @@ -160,7 +183,7 @@ function LandingPage() {
<div className="hero-body">
<div className="columns">

<div className="column is-4">
<div className={"column is-" + block}>
<div className="card">
<div className="card-content">
<div className="media">
Expand Down Expand Up @@ -191,7 +214,7 @@ function LandingPage() {
</div>
</div>

<div className="column is-4">
<div className={"column is-" + block}>
<div className="card">
<div className="card-content">
<div className="media">
Expand Down Expand Up @@ -223,7 +246,9 @@ function LandingPage() {
</div>
</div>

<div className="column is-4">
{!Meteor.settings.public.disable_blast && (

<div className={"column is-" + block}>
<div className="card">
<div className="card-content">
<div className="media">
Expand All @@ -244,15 +269,13 @@ function LandingPage() {
<div className="content">
BLAST your protein or DNA sequence to genome annotations.
</div>
<div className="content">
<Link to="/blast" className="button is-light is-link is-fullwidth">
<span className="icon-database" aria-hidden="true" />
&nbsp;Blast
</Link>
<div className="content">
{blastLink}
</div>
</div>
</div>
</div>
)}
</div>
</div>
</section>
Expand Down
21 changes: 16 additions & 5 deletions imports/ui/main/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ const LoggedInButtonWithTracker = withTracker(adminTracker)(LoggedInButton);
function LoggedOutButton() {
return (
<div className="navbar-item">
{/*
{! Meteor.settings.public.disable_user_login === true && (
<Link to="/login" className="button is-small is-link" id="signin">
<span className="icon-login" aria-hidden="true" />
&nbsp;Sign in
</Link>
*/}
)}
</div>
);
}
Expand All @@ -83,6 +83,17 @@ function NavBar() {
const [show, setShow] = useState(false);
const activeText = show ? 'is-active' : '';
const urlPrefix = Meteor.absoluteUrl();

let blastLink = (
<NavLink to="/blast" className="navbar-item" activeClassName="active">
Blast
</NavLink>
)

if (Meteor.settings.public.blast_link){
blastLink = (<a target="_blank" href={Meteor.settings.public.blast_link} className="navbar-item" activeClassName="active">Blast</a>)
}

return (
<nav className="navbar is-white" role="navigation">
<div className="navbar-brand">
Expand Down Expand Up @@ -113,9 +124,9 @@ function NavBar() {
<NavLink id="gene-link" to="/genes" className="navbar-item" activeClassName="active">
Genes
</NavLink>
<NavLink to="/blast" className="navbar-item" activeClassName="active">
Blast
</NavLink>
{! Meteor.settings.public.disable_blast && (
blastLink
)}
<SearchBar />
</div>
<div className="navbar-end">
Expand Down
32 changes: 29 additions & 3 deletions imports/ui/main/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,35 @@ export default function Login({ location }) {
if (redirect) {
return <Redirect to={redirectTo} />;
}

if (Meteor.settings.public.disable_user_login === true){
return (
<div className="hero is-small is-light is-bold">
<div className="hero-body">
<div className="container is-centered has-text-centered">
<div className="card column is-4 is-offset-4 login-form">
<div className="card-image">
<figure className="image is-96x96">
<img className="is-rounded" src="logo.svg" alt="" />
</figure>
</div>
<div className="card-content">
<div className="content">
Login is currently disabled
</div>
</div>
</div>
</div>
</div>
</div>
)
}

return (
<div className="hero is-small is-light is-bold">
<div className="hero-body">
<div className="container columns is-centered has-text-centered">
<form className="card column is-4 login-form" onSubmit={handleSubmit}>
<div className="container is-centered has-text-centered">
<form className="card column is-4 is-offset-4 login-form" onSubmit={handleSubmit}>
<div className="card-image">
<figure className="image is-96x96">
<img className="is-rounded" src="logo.svg" alt="" />
Expand Down Expand Up @@ -85,12 +109,14 @@ export default function Login({ location }) {
Sign in
</button>
</div>


{ ! Meteor.settings.public.disable_user_registration === true && (
<footer className="card-footer">
<Link to="/register" id="new-account">
Create new account
</Link>
</footer>
)}
</div>
</div>
</form>
Expand Down
Loading

0 comments on commit 89ee954

Please sign in to comment.