Merge pull request #2172 from biosistemika/release_1_17_3

Merge release 1.17.3 to master
This commit is contained in:
Alex Kriuchykhin 2019-10-22 12:45:02 +02:00 committed by GitHub
commit 5524598d53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 104 additions and 86 deletions

View file

@ -1,13 +1,14 @@
FROM ruby:2.6.4-buster
MAINTAINER BioSistemika <info@biosistemika.com>
ARG WKHTMLTOPDF_PACKAGE_URL=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list && \
wget -O /usr/bin/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip && \
unzip /usr/bin/chromedriver_linux64.zip -d /usr/bin/
# additional dependecies
# libSSL-1.0 is required by wkhtmltopdf binary
# libreoffice for file preview generation
RUN apt-get update -qq && \
apt-get install -y \
@ -24,6 +25,9 @@ RUN apt-get update -qq && \
libreoffice \
libfile-mimeinfo-perl \
google-chrome-stable=77.* && \
wget -q -O /tmp/wkhtmltox_amd64.deb $WKHTMLTOPDF_PACKAGE_URL && \
apt-get install -y /tmp/wkhtmltox_amd64.deb && \
rm /tmp/wkhtmltox_amd64.deb && \
npm install -g yarn && \
ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so && \
rm -rf /var/lib/apt/lists/*

View file

@ -1,8 +1,9 @@
FROM ruby:2.6.4-buster
MAINTAINER BioSistemika <info@biosistemika.com>
ARG WKHTMLTOPDF_PACKAGE_URL=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
# additional dependecies
# libSSL-1.0 is required by wkhtmltopdf binary
# libreoffice for file preview generation
RUN apt-get update -qq && \
apt-get install -y \
@ -21,6 +22,9 @@ RUN apt-get update -qq && \
sudo graphviz --no-install-recommends \
libreoffice \
libfile-mimeinfo-perl && \
wget -q -O /tmp/wkhtmltox_amd64.deb $WKHTMLTOPDF_PACKAGE_URL && \
apt-get install -y /tmp/wkhtmltox_amd64.deb && \
rm /tmp/wkhtmltox_amd64.deb && \
npm install -g yarn && \
ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so && \
rm -rf /var/lib/apt/lists/*

View file

@ -80,8 +80,8 @@ gem 'silencer' # Silence certain Rails logs
gem 'sneaky-save', git: 'https://github.com/einzige/sneaky-save'
gem 'turbolinks', '~> 5.1.1'
gem 'underscore-rails'
gem 'wicked_pdf', '~> 1.1.0'
gem 'wkhtmltopdf-heroku', '2.12.4'
gem 'wicked_pdf', '~> 1.4.0'
gem 'wkhtmltopdf-heroku', '2.12.5'
gem 'aws-sdk-rails'
gem 'aws-sdk-s3'

View file

@ -579,8 +579,9 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
whacamole (1.2.0)
wicked_pdf (1.1.0)
wkhtmltopdf-heroku (2.12.4.0)
wicked_pdf (1.4.0)
activesupport
wkhtmltopdf-heroku (2.12.5.0)
xpath (3.2.0)
nokogiri (~> 1.8)
yomu (0.1.5)
@ -694,8 +695,8 @@ DEPENDENCIES
webmock
webpacker (~> 4.0.0)
whacamole
wicked_pdf (~> 1.1.0)
wkhtmltopdf-heroku (= 2.12.4)
wicked_pdf (~> 1.4.0)
wkhtmltopdf-heroku (= 2.12.5)
yomu
RUBY VERSION

View file

@ -1 +1 @@
1.17.2
1.17.3

View file

@ -12,7 +12,6 @@ var repositoryType;
function init() {
updateButtons();
initProtocolsTable();
initRowSelection();
initKeywordFiltering();
initProtocolPreviewModal();
initLinkedChildrenModal();
@ -99,6 +98,7 @@ function initProtocolsTable() {
},
fnDrawCallback: function(settings, json) {
animateSpinner(this, false);
initRowSelection();
$.initTooltips();
},
preDrawCallback: function(settings) {
@ -129,6 +129,8 @@ function initProtocolsTable() {
}
function initRowSelection() {
let protocolsTableScrollHead = protocolsTableEl.closest('.dataTables_scroll').find('.dataTables_scrollHead');
// Handle click on table cells with checkboxes
protocolsTableEl.on("click", "tbody td, thead th:first-child", function(e) {
$(this).parent().find("input[type='checkbox']").trigger("click");
@ -164,11 +166,11 @@ function initRowSelection() {
});
// Handle click on "Select all" control
protocolsTableEl.find("thead input[name='select_all']").on("click", function(e) {
protocolsTableScrollHead.find("thead input[name='select_all']").on('click', function(e) {
if (this.checked) {
protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger("click");
protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger('click');
} else {
protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger("click");
protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger('click');
}
// Prevent click event from propagating to parent

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ReportActions
extend ActiveSupport::Concern
@ -30,19 +32,18 @@ module ReportActions
def generate_project_contents_json
res = []
if params.include? :modules
modules = (params[:modules].select { |_, p| p == '1' })
.keys
.collect(&:to_i)
module_ids = (params[:modules].select { |_, p| p == '1' }).keys.collect(&:to_i)
# Get unique experiments from given modules
experiments = MyModule.where(id: modules).map(&:experiment).uniq
experiments = @project.experiments.distinct.joins(:my_modules).where('my_modules.id': module_ids)
experiments.each do |experiment|
res << generate_new_el(false)
el = generate_el(
'reports/elements/experiment_element.html.erb',
experiment: experiment
)
el[:children] = generate_experiment_contents_json(experiment, modules)
selected_modules = experiment.my_modules.includes(:tags).where(id: module_ids)
el[:children] = generate_experiment_contents_json(selected_modules)
res << el
end
end
@ -50,11 +51,9 @@ module ReportActions
res
end
def generate_experiment_contents_json(experiment, selected_modules)
def generate_experiment_contents_json(selected_modules)
res = []
experiment.my_modules.order(:workflow_order).each do |my_module|
next unless selected_modules.include?(my_module.id)
selected_modules.order(:workflow_order).each do |my_module|
res << generate_new_el(false)
el = generate_el(
'reports/elements/my_module_element.html.erb',
@ -75,13 +74,12 @@ module ReportActions
contents.values.each do |element|
if contents.has_many
elements = params.select { |k| k.starts_with?("module_#{element}") }
elements = elements.select { |_,v| v == '1' }.keys
elements.map! { |el| el.gsub('module_', '')}.map!{|el| el.split('_') }
elements = elements.select { |_, v| v == '1' }.keys
elements.map! { |el| el.gsub('module_', '') }.map! { |el| el.split('_') }
elements.map! { |el| [el[0].to_sym, el[1].to_i] }
break unless elements.empty?
else
present = in_params?("module_#{element}".to_sym) ||
in_params?(element.to_sym)
present = in_params?("module_#{element}".to_sym) || in_params?(element.to_sym)
if present
elements << [element.to_sym, nil]
break
@ -131,8 +129,7 @@ module ReportActions
step.checklists.asc.each do |checklist|
res << generate_new_el(false)
res << generate_el(
'reports/elements/step_checklist_element.html.erb',
{ checklist: checklist }
'reports/elements/step_checklist_element.html.erb', checklist: checklist
)
end
end
@ -140,8 +137,7 @@ module ReportActions
step.assets.each do |asset|
res << generate_new_el(false)
res << generate_el(
'reports/elements/step_asset_element.html.erb',
{ asset: asset }
'reports/elements/step_asset_element.html.erb', asset: asset
)
end
end
@ -149,16 +145,14 @@ module ReportActions
step.tables.each do |table|
res << generate_new_el(false)
res << generate_el(
'reports/elements/step_table_element.html.erb',
{ table: table }
'reports/elements/step_table_element.html.erb', table: table
)
end
end
if in_params? :step_comments
res << generate_new_el(false)
res << generate_el(
'reports/elements/step_comments_element.html.erb',
{ step: step, order: :asc }
'reports/elements/step_comments_element.html.erb', step: step, order: :asc
)
end
res << generate_new_el(false)
@ -170,8 +164,7 @@ module ReportActions
if in_params? :result_comments
res << generate_new_el(true)
res << generate_el(
'reports/elements/result_comments_element.html.erb',
{ result: result, order: :asc }
'reports/elements/result_comments_element.html.erb', result: result, order: :asc
)
else
res << generate_new_el(false)
@ -180,11 +173,12 @@ module ReportActions
end
def elements_empty?(elements)
return true if elements.blank? || elements.count == 0
return true if elements.blank? || elements.count.zero?
if elements.count == 1
el = elements[0]
return true if el.include?(:new_element) && el[:new_element]
return false
end
false

View file

@ -325,22 +325,20 @@ class ReportsController < ApplicationController
if elements_empty? elements
format.json { render json: {}, status: :no_content }
else
format.json {
format.json do
render json: {
status: :ok,
elements: elements
}
}
end
end
end
end
def experiment_contents
experiment = @project.experiments.find_by_id(params[:id])
exp_module_ids = experiment.my_modules.pluck(:id)
modules = (params[:modules].select { |k, p| exp_module_ids.include?(k.to_i) && p == '1' })
.keys
.collect(&:to_i)
experiment = @project.experiments.find_by(id: params[:id])
module_ids = (params[:modules].select { |_, p| p == '1' }).keys.collect(&:to_i)
selected_modules = experiment.my_modules.where(id: module_ids)
respond_to do |format|
if experiment.blank?
@ -348,7 +346,7 @@ class ReportsController < ApplicationController
elsif modules.blank?
format.json { render json: {}, status: :no_content }
else
elements = generate_experiment_contents_json(experiment, modules)
elements = generate_experiment_contents_json(selected_modules)
end
if elements_empty? elements
@ -451,12 +449,12 @@ class ReportsController < ApplicationController
AvailableRepository = Struct.new(:id, :name)
def load_vars
@report = Report.find_by_id(params[:id])
@report = current_team.reports.find_by(id: params[:id])
render_404 unless @report
end
def load_vars_nested
@project = Project.find_by_id(params[:project_id])
@project = current_team.projects.find_by(id: params[:project_id])
render_404 unless @project
render_403 unless can_read_project?(@project)
end

View file

@ -98,8 +98,10 @@ module ReportsHelper
end
# "Hack" to omit file preview URL because of WKHTML issues
def report_image_asset_url(asset, _type = :asset, klass = nil)
image_tag(asset.generate_base64(:medium), class: klass)
def report_image_asset_url(asset)
image_tag(asset.medium_preview
.processed
.service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME))
end
# "Hack" to load Glyphicons css directly from the CDN

View file

@ -20,7 +20,7 @@ module TinyMceImages
tiny_mce_assets.each do |tm_asset|
next unless tm_asset&.image&.attached?
new_tm_asset_src = tm_asset.convert_variant_to_base64(tm_asset.preview)
new_tm_asset_src = tm_asset.preview.processed.service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME)
html_description = Nokogiri::HTML(description)
tm_asset_to_update = html_description.css(
"img[data-mce-token=\"#{Base62.encode(tm_asset.id)}\"]"

View file

@ -370,6 +370,7 @@ class MyModule < ApplicationRecord
def repository_json_hot(repository_id, order)
data = []
repository_rows
.includes(:created_by)
.where(repository_id: repository_id)
.order(created_at: order).find_each do |row|
row_json = []

View file

@ -17,11 +17,13 @@ module ImportRepository
private
def run_import_actions
@repository.import_records(
SpreadsheetParser.open_spreadsheet(@temp_file.file),
@mappings,
@user
)
@temp_file.file.open do |temp_file|
@repository.import_records(
SpreadsheetParser.open_spreadsheet(temp_file),
@mappings,
@user
)
end
end
def run_checks

View file

@ -7,8 +7,8 @@ class SpreadsheetParser
filename = file.original_filename
file_path = file.path
else
filename = file.filename.to_s
file_path = file.service_url
filename = File.basename(file.path)
file_path = file.path
end
case File.extname(filename)

View file

@ -19,7 +19,7 @@
<div class="report-element-body">
<div class="row">
<div class="col-xs-12 activity-container">
<% if activities.count > 0 %>
<% if activities.any? %>
<!-- TODO: This might become potentially very big! -->
<ul class="no-style activity-list">
<% activities.each do |activity| %>

View file

@ -48,7 +48,7 @@
<div class="pull-left">
<%=t "projects.reports.elements.module.tags_header" %>
</div>
<% if my_module.tags.count > 0 %>
<% if my_module.tags.any? %>
<% my_module.tags.each do |tag| %>
<div class="pull-left module-tag" style="background-color: <%= tag.color %>;">
<%= tag.name %>

View file

@ -4,7 +4,14 @@
<% comments = result.result_comments %>
<% timestamp = asset.created_at %>
<% icon_class = 'fas ' + (is_image ? 'fa-image' : 'fa-file') %>
<div class="report-element report-result-element report-result-asset-element" data-ts="<%= timestamp.to_i %>" data-type="result_asset" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= result.name %>" data-icon-class="<%= icon_class %>">
<div class="report-element report-result-element report-result-asset-element"
data-ts="<%= timestamp.to_i %>"
data-type="result_asset"
data-id='{ "result_id": <%= result.id %> }'
data-scroll-id="<%= result.id %>"
data-modal-title="<%= t("projects.reports.elements.modals.result_contents.head_title", result: result.name) %>"
data-name="<%= result.name %>"
data-icon-class="<%= icon_class %>">
<div class="report-element-header">
<div class="row">
<div class="pull-left result-icon">
@ -13,23 +20,21 @@
<div class="pull-left result-name">
<%= result.name %>
<% if result.archived? %>
<span class="label label-warning"><%=t 'search.index.archived' %></span>
<span class="label label-warning"><%= t('search.index.archived') %></span>
<% end %>
</div>
<div class="pull-left file-name">
<% if defined? export_all and export_all %>
<a href="<%= path %>">
<em><%=t "projects.reports.elements.result_asset.file_name",
file: filename %></em>
<em><%= t("projects.reports.elements.result_asset.file_name", file: filename) %></em>
</a>
<% else %>
<em><%=t "projects.reports.elements.result_asset.file_name",
file: truncate(asset.file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></em>
<em><%= t("projects.reports.elements.result_asset.file_name",
file: truncate(asset.file_name, length: Constants::FILENAME_TRUNCATION_LENGTH)) %></em>
<% end %>
</div>
<div class="pull-left user-time">
<%=t "projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full) %>
<%= t("projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
</div>
<div class="pull-right controls">
<%= render partial: "reports/elements/element_controls.html.erb" %>

View file

@ -19,14 +19,14 @@
<div class="report-element-body">
<div class="row">
<div class="col-xs-12 comments-container simple">
<% if comments.count == 0 %>
<em><%=t "projects.reports.elements.result_comments.no_comments" %></em>
<% else %>
<% if comments.any? %>
<ul class="no-style content-comments">
<% comments.each do |comment| %>
<%= render partial: 'shared/comments/item.html.erb', locals: { comment: comment, readonly: true, report: true } %>
<% end %>
</ul>
<% else %>
<em><%=t "projects.reports.elements.result_comments.no_comments" %></em>
<% end %>
</div>
</div>

View file

@ -19,14 +19,14 @@
<div class="report-element-body">
<div class="row">
<div class="col-xs-12 comments-container simple">
<% if comments.count == 0 %>
<em><%=t "projects.reports.elements.step_comments.no_comments" %></em>
<% else %>
<% if comments.any? %>
<ul class="no-style content-comments">
<% comments.each do |comment| %>
<%= render partial: 'shared/comments/item.html.erb', locals: { comment: comment, readonly: true, report: true } %>
<% end %>
</ul>
<% else %>
<em><%=t "projects.reports.elements.step_comments.no_comments" %></em>
<% end %>
</div>
</div>

View file

@ -11,7 +11,7 @@
<%= form.check_box :project, label: project.name %>
<ul>
<% project.experiments.is_archived(false).each do |experiment| %>
<% project.experiments.includes(:my_module_groups).is_archived(false).each do |experiment| %>
<% next unless experiment.my_modules.is_archived(false).exists? %>
<li>
<%= form.check_box "experiment_#{experiment.id}", label: experiment.name %>

View file

@ -78,21 +78,21 @@ module ReportExtends
true,
[:result],
proc do |my_module|
my_module.results.select { |r| r.is_asset && r.active? }
my_module.results.joins(:result_asset).select(&:active?)
end),
ModuleElement.new([:result_tables],
:result_tables,
true,
[:result],
proc do |my_module|
my_module.results.select { |r| r.is_table && r.active? }
my_module.results.joins(:result_table).select(&:active?)
end),
ModuleElement.new([:result_texts],
:result_texts,
true,
[:result],
proc do |my_module|
my_module.results.select { |r| r.is_text && r.active? }
my_module.results.joins(:result_text).select(&:active?)
end),
ModuleElement.new([:activity],
:activity,

View file

@ -1,21 +1,25 @@
# frozen_string_literal: true
WickedPdf.config ||= {}
ENV['PATH'].split(':').each do |path|
exe_path = File.join(path, 'wkhtmltopdf')
WickedPdf.config[:exe_path] = File.join(path, 'wkhtmltopdf') if File.file?(exe_path)
end
# WickedPdfHelper patch that fixes issue with including application.css
# in environments like Heroku where assets.compile option is disabled and
# it is not acceptable to enable it.
if Rails.env.production? and Rails.configuration.assets.compile == false
if Rails.env.production? && Rails.configuration.assets.compile == false
WickedPdf::WickedPdfHelper::Assets.module_eval do
def read_asset(source)
manifest = Rails.application.assets_manifest
path = File.join(manifest.dir, manifest.assets[source])
File.read(path)
manifest = Rails.application.assets_manifest
path = File.join(manifest.dir, manifest.assets[source])
File.read(path)
end
def asset_exists?(source)
Rails.application.assets_manifest.assets.key?(source)
Rails.application.assets_manifest.assets.key?(source)
end
end
end

View file

@ -6520,6 +6520,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20190812072649'),
('20190830141257'),
('20190910125740'),
('20191001133557');
('20191001133557'),
('20191009146101');

View file

@ -6,7 +6,7 @@ services:
volumes:
- scinote_development_postgres:/var/lib/postgresql/data
ports:
- "6543:5432"
- "5432:5432"
web:
build: