mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 11:57:16 +08:00
Merge branch 'release/1.30.0'
This commit is contained in:
commit
cb2f0b1bcd
4 changed files with 31 additions and 25 deletions
|
@ -237,7 +237,9 @@ var MarvinJsEditorApi = (function() {
|
||||||
enabled: function() {
|
enabled: function() {
|
||||||
return ($('#MarvinJsModal').length > 0);
|
return ($('#MarvinJsModal').length > 0);
|
||||||
},
|
},
|
||||||
|
isRemote: function() {
|
||||||
|
return marvinJsMode === 'remote';
|
||||||
|
},
|
||||||
open: function(config) {
|
open: function(config) {
|
||||||
if (!MarvinJsEditor.enabled()) {
|
if (!MarvinJsEditor.enabled()) {
|
||||||
$('#MarvinJsPromoModal').modal('show');
|
$('#MarvinJsPromoModal').modal('show');
|
||||||
|
@ -322,19 +324,22 @@ $(document).on('click', '.gene-sequence-edit-button', function() {
|
||||||
function initMarvinJs() {
|
function initMarvinJs() {
|
||||||
MarvinJsEditor = MarvinJsEditorApi();
|
MarvinJsEditor = MarvinJsEditorApi();
|
||||||
|
|
||||||
if (MarvinJsEditor.enabled()) {
|
// MarvinJS is disabled, nothing to initialize
|
||||||
if (typeof (ChemicalizeMarvinJs) === 'undefined') {
|
if (!MarvinJsEditor.enabled()) return;
|
||||||
setTimeout(initMarvinJs, 100);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#marvinjs-editor')[0].dataset.marvinjsMode === 'remote') {
|
// wait for remote MarvinJS to initialize
|
||||||
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
|
if (MarvinJsEditor.isRemote() && typeof (ChemicalizeMarvinJs) === 'undefined') {
|
||||||
marvin.setDisplaySettings({ toolbars: 'reporting' });
|
setTimeout(initMarvinJs, 100);
|
||||||
marvinJsRemoteEditor = marvin;
|
return;
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MarvinJsEditor.isRemote()) {
|
||||||
|
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
|
||||||
|
marvin.setDisplaySettings({ toolbars: 'reporting' });
|
||||||
|
marvinJsRemoteEditor = marvin;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button');
|
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ module Reports
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_pdf_content
|
def generate_pdf_content
|
||||||
@has_cover = Rails.root.join('app', 'views', 'reports', 'templates', @template, 'cover.html.erb').exist?
|
@num_of_cover_pages = cover_pages_count
|
||||||
|
|
||||||
render_header_footer_and_report
|
render_header_footer_and_report
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ module Reports
|
||||||
template: 'reports/report',
|
template: 'reports/report',
|
||||||
layout: false,
|
layout: false,
|
||||||
assigns: { settings: @report.settings },
|
assigns: { settings: @report.settings },
|
||||||
locals: { report: @report, user: @user, has_cover: @has_cover }
|
locals: { report: @report, user: @user, num_of_cover_pages: @num_of_cover_pages }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,8 +130,6 @@ module Reports
|
||||||
current_margin = extract_margins_from_header ||
|
current_margin = extract_margins_from_header ||
|
||||||
{ top: '2cm', bottom: '2cm', left: '1cm', right: '1.5cm' }
|
{ top: '2cm', bottom: '2cm', left: '1cm', right: '1.5cm' }
|
||||||
|
|
||||||
cover_pages_shift = cover_page_shift_from_template
|
|
||||||
|
|
||||||
Grover.new(
|
Grover.new(
|
||||||
@report_html,
|
@report_html,
|
||||||
format: 'A4',
|
format: 'A4',
|
||||||
|
@ -142,7 +140,7 @@ module Reports
|
||||||
footer_template: @footer_html,
|
footer_template: @footer_html,
|
||||||
style_tag_options: @style_tag_options,
|
style_tag_options: @style_tag_options,
|
||||||
script_tag_options: @script_tag_options,
|
script_tag_options: @script_tag_options,
|
||||||
page_ranges: "#{cover_pages_shift}-999999",
|
page_ranges: "#{@num_of_cover_pages + 1}-999999",
|
||||||
emulate_media: 'screen',
|
emulate_media: 'screen',
|
||||||
display_url: Rails.application.routes.default_url_options[:host]
|
display_url: Rails.application.routes.default_url_options[:host]
|
||||||
).to_pdf(@file.path)
|
).to_pdf(@file.path)
|
||||||
|
@ -150,7 +148,7 @@ module Reports
|
||||||
|
|
||||||
def process_attach_pdf_report_and_notify
|
def process_attach_pdf_report_and_notify
|
||||||
@file.rewind
|
@file.rewind
|
||||||
@file = prepend_title_page if @has_cover
|
@file = prepend_title_page if @num_of_cover_pages.positive?
|
||||||
@file = append_result_asset_previews if @report.settings.dig(:task, :file_results_previews)
|
@file = append_result_asset_previews if @report.settings.dig(:task, :file_results_previews)
|
||||||
|
|
||||||
@report.pdf_file.attach(io: @file, filename: 'report.pdf')
|
@report.pdf_file.attach(io: @file, filename: 'report.pdf')
|
||||||
|
@ -337,16 +335,16 @@ module Reports
|
||||||
margins
|
margins
|
||||||
end
|
end
|
||||||
|
|
||||||
def cover_page_shift_from_template
|
def cover_pages_count
|
||||||
cover_file_path = Rails.root.join('app', 'views', 'reports', 'templates', @template, 'cover.html.erb')
|
cover_file_path = Rails.root.join('app', 'views', 'reports', 'templates', @template, 'cover.html.erb')
|
||||||
return 1 unless cover_file_path.exist?
|
return 0 unless cover_file_path.exist?
|
||||||
|
|
||||||
content = File.read(cover_file_path)
|
content = File.read(cover_file_path)
|
||||||
|
|
||||||
cover_pages_comment = content.match(/<!--\s*cover_pages_count:(\d+)\s*-->/)
|
cover_pages_comment = content.match(/<!--\s*cover_pages_count:(\d+)\s*-->/)
|
||||||
return 2 unless cover_pages_comment
|
return 1 unless cover_pages_comment
|
||||||
|
|
||||||
cover_pages_comment[1].to_i + 1
|
cover_pages_comment[1].to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body class="print-report-body">
|
<body class="print-report-body">
|
||||||
<% if has_cover %>
|
<% num_of_cover_pages.times do %>
|
||||||
<div style="break-after: page;"></div>
|
<div style="min-height: 100vh; break-after: page;"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="print-report">
|
<div class="print-report">
|
||||||
<% report.root_elements.each do |el| %>
|
<% report.root_elements.each do |el| %>
|
||||||
|
|
|
@ -192,7 +192,10 @@ Devise.setup do |config|
|
||||||
|
|
||||||
# ==> Configuration for :validatable
|
# ==> Configuration for :validatable
|
||||||
# Range for password length.
|
# Range for password length.
|
||||||
config.password_length = 8..72
|
password_min_length = ENV['PASSWORD_MIN_LENGTH'].to_i
|
||||||
|
password_max_length = 72
|
||||||
|
password_min_length = 8 unless password_min_length.positive? && password_min_length < password_max_length
|
||||||
|
config.password_length = password_min_length..password_max_length
|
||||||
|
|
||||||
# Email regex used to validate email formats. It simply asserts that
|
# Email regex used to validate email formats. It simply asserts that
|
||||||
# one (and only one) @ exists in the given string. This is mainly
|
# one (and only one) @ exists in the given string. This is mainly
|
||||||
|
|
Loading…
Add table
Reference in a new issue