Skip to content

Commit

Permalink
Merge pull request #344 from ComPlat/development
Browse files Browse the repository at this point in the history
Development

- reporting tools upg
- molecule_name upd on sample change
- disable data collector job
- fix bug on collection destroy and better test coverage
- BE json import-export upg
  • Loading branch information
PiTrem authored Nov 8, 2017
2 parents f202ff1 + 4c77f7e commit 6acac1f
Show file tree
Hide file tree
Showing 115 changed files with 3,488 additions and 2,135 deletions.
21 changes: 16 additions & 5 deletions .fontcustom-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"checksum": {
"previous": "ebea6970ab34b700768ce8bafe0ee0ca02daf2bf9277ec0e6b7ac5d7bbcb09c0",
"current": "ebea6970ab34b700768ce8bafe0ee0ca02daf2bf9277ec0e6b7ac5d7bbcb09c0"
"previous": "dd832ad0716db3e5d9d4471567047066742da49b6953efd5ce967167d6c61529",
"current": "dd832ad0716db3e5d9d4471567047066742da49b6953efd5ce967167d6c61529"
},
"fonts": [
"app/assets/fonts/icons.ttf",
"app/assets/fonts/icons.svg",
"app/assets/fonts/icons.woff",
"app/assets/fonts/icons.eot"
"app/assets/fonts/icons.eot",
"app/assets/fonts/icons.woff2"
],
"glyphs": {
"acidified-hcl": {
Expand Down Expand Up @@ -50,6 +51,14 @@
"codepoint": 61722,
"source": "app/assets/images/svg_icons/hr.svg"
},
"hr1": {
"codepoint": 61726,
"source": "app/assets/images/svg_icons/hr1.svg"
},
"hr2": {
"codepoint": 61727,
"source": "app/assets/images/svg_icons/hr2.svg"
},
"ir": {
"codepoint": 61723,
"source": "app/assets/images/svg_icons/ir.svg"
Expand Down Expand Up @@ -124,10 +133,12 @@
}
},
"options": {
"autowidth": false,
"autowidth": true,
"config": "fontcustom.yml",
"copyright": "",
"css3": false,
"css_selector": ".icon-{{glyph}}",
"debug": true,
"debug": false,
"font_ascent": 448,
"font_descent": 64,
"font_design_size": 16,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/log/*
!/log/.keep
/tmp
/tmp/*

.ruby-gemset
.ruby-version
Expand All @@ -22,6 +23,7 @@
.env
/config/mailcollector.yml
/config/datamailcollector.yml
/config/datacollectors.yml
/config/database.yml
/config/storage.yml
/node_modules
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ group :development do
gem 'web-console', '~> 2.0'
end

gem 'pg'
gem 'pg', '~> 0.20.0'
gem 'pg_search'

gem 'devise'
Expand Down
32 changes: 14 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GIT

GIT
remote: https://github.com/ComPlat/sablon
revision: b2d1ff682c4b4d984b91cf410043e42bdc5c25fc
revision: 7b688bfd5f7459ca49e786ea9908996d44c2f825
specs:
sablon (0.0.19)
nokogiri (>= 1.6.0)
Expand Down Expand Up @@ -167,8 +167,6 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
celluloid (0.16.0)
timers (~> 4.0.0)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.0.0)
Expand Down Expand Up @@ -241,13 +239,13 @@ GEM
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
fast_stack (0.2.0)
ffi (1.9.10)
ffi (1.9.18)
flamegraph (0.9.5)
font-awesome-rails (4.6.2.0)
railties (>= 3.2, < 5.1)
fontcustom (1.3.8)
fontcustom (2.0.0)
json (~> 1.4)
listen (>= 1.0, < 3.0)
listen (>= 1.0, < 4.0)
thor (~> 0.14)
globalid (0.3.7)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -285,7 +283,6 @@ GEM
hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0)
headless (2.0.0)
hitimes (1.2.4)
html2haml (2.1.0)
erubis (~> 2.7.0)
haml (~> 4.0)
Expand Down Expand Up @@ -315,10 +312,10 @@ GEM
activesupport (>= 3.0.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (2.10.1)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
Expand Down Expand Up @@ -374,7 +371,7 @@ GEM
parser (2.4.0.0)
ast (~> 2.2)
pdf-core (0.6.1)
pg (0.18.4)
pg (0.20.0)
pg_search (1.0.5)
activerecord (>= 3.1)
activesupport (>= 3.1)
Expand Down Expand Up @@ -427,9 +424,9 @@ GEM
rainbow (2.2.2)
rake
rake (12.1.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdoc (4.2.2)
json (~> 1.4)
redcarpet (3.4.0)
Expand Down Expand Up @@ -469,6 +466,7 @@ GEM
ruby-mailchecker (3.0.27)
ruby-ole (1.2.12)
ruby-progressbar (1.8.1)
ruby_dep (1.5.0)
ruby_parser (3.8.4)
sexp_processor (~> 4.1)
rubyzip (1.1.7)
Expand Down Expand Up @@ -529,8 +527,6 @@ GEM
thor (0.19.1)
thread_safe (0.3.6)
tilt (2.0.7)
timers (4.0.4)
hitimes
tins (1.11.0)
ttfunk (1.4.0)
tzinfo (1.2.2)
Expand Down Expand Up @@ -629,7 +625,7 @@ DEPENDENCIES
nokogiri
openbabel (= 2.4.0.1)!
paranoia (~> 2.0)
pg
pg (~> 0.20.0)
pg_search
prawn
prawn-svg
Expand Down
21 changes: 13 additions & 8 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ if there are errors with nokogiri compilation with new xcode7:
`gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries`

## openbabel
* `brew install cmake` for OSX
* install openbabel as described in its [documentation](https://github.com/cubuslab/openbabel/blob/master/INSTALL)
* Require
1. CMake (the `cmake` package in Ubuntu)
2. Eigen (the `libeigen2-dev` or `libeigen3-dev` package in Ubuntu)
3. Swig (the `swig`package in Ubuntu)
4. libxml2 (the `libxml2-dev` package in Ubuntu)

* openbabel will be automatically installed through `bundle install`

## rmagick
* `brew install imagemagick gs` for OSX
Expand Down Expand Up @@ -73,12 +78,12 @@ Icons are now available as css classes: '.icon-<ICON_NAME'
# Docker setup
This is a setup for a 'pseudo' production stage using passenger and aimed for user testing.
(For the development environment, change 'RAILS_ENV' to 'development' in docker-compose.yml)
* 1 - Build the image from Dockerfile `docker-compose build`
* or pull the image directly: `docker pull complat/chemotion_eln`
* 2 - Initialize database FIRST: `docker-compose run app bundle exec rake db:create db:migrate`
* 3 - Precompile assets: `docker-compose run app bundle exec rake assets:precompile`
* 4 - First run: `docker-compose up`
* Or initial setup and detach: `docker-compose up -d`

1. Build the image from Dockerfile `docker-compose build` or pull the image: `docker-compose pull`
2. Initialize database FIRST: `docker-compose run app bundle exec rake db:create db:migrate`
3. Precompile assets: `docker-compose run app bundle exec rake assets:precompile`
4. To start the server: `docker-compose up` or start server and detach: `docker-compose up -d`

* Start interactive shell with docker: `docker-compose run app /bin/bash`
* NOTE: In this Docker image, we disabled the email verification progress

5 changes: 4 additions & 1 deletion app/api/chemotion/molecule_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class MoleculeAPI < Grape::API
mol.create_molecule_name_by_user(new_name, user_id) if new_name.present?

mol.molecule_names.map do |mn|
{ id: mn.id, name: mn.name }
{
value: mn.id, label: mn.name,
desc: mn.description, mid: mn.molecule_id
}
end
end
end
Expand Down
19 changes: 5 additions & 14 deletions app/api/chemotion/public_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@ module Chemotion
class PublicAPI < Grape::API

namespace :public do
before do
error!('Unauthorized' , 401) unless TokenAuthentication.new(request).is_successful?
end

resources :samples do
desc "Return samples of all chemotion.net collections"

get do
Collection.for_publication.flat_map(&:samples).uniq
end
get 'ping' do
status 200
end
end
# TODO further resources?

namespace :upload do
before do
error!('Unauthorized' , 401) unless TokenIPAuthentication.new(request).is_successful?
error!('Unauthorized' , 401) unless TokenAuthentication.new(request, with_remote_addr: true).is_successful?
end
resource :attachments do
desc "Upload files"
Expand All @@ -33,10 +24,10 @@ class PublicAPI < Grape::API
params.delete(:recipient_email)

token = request.headers['Auth-Token'] || request.params['auth_token']
key = API::AuthenticationKey.find_by(token: token)
key = AuthenticationKey.find_by(token: token)


helper = CollectorHelper.new(key.device.email , recipient_email)
helper = CollectorHelper.new(key.user.email , recipient_email)

if helper.sender_recipient_known?
dataset = helper.prepare_dataset(subject)
Expand Down
25 changes: 21 additions & 4 deletions app/api/token_authentication.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
class TokenAuthentication
attr_reader :request
attr_reader :request, :args, :key, :token

def initialize(request)
def initialize(request, **args)
@request = request
@args = args
@token = request.headers['Authorization']&.match(
/^Bearer\s*([\w\-\.\~\+\/]+)=*/) && $1
@key = AuthenticationKey.find_by(token: token)
end

def is_successful?
token = request.headers['Auth-Token'] || request.params['auth_token']
API::AuthenticationKey.find_by(token: token).present?
key && all_checks
end

def all_checks
check_keys.map{|check| send(check) }.all?
end

private

def check_keys
args.keys & [:with_remote_addr]
end

def with_remote_addr
key && key.ip.include?(request.env['REMOTE_ADDR'])
end
end
13 changes: 0 additions & 13 deletions app/api/token_ip_authentication.rb

This file was deleted.

Binary file modified app/assets/fonts/icons.eot
Binary file not shown.
Loading

0 comments on commit 6acac1f

Please sign in to comment.