mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Catch all errors on PIO import and show message
This commit is contained in:
parent
2834edb286
commit
1c7a051551
2 changed files with 59 additions and 48 deletions
|
@ -603,6 +603,7 @@ class ProtocolsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def protocolsio_import_create
|
def protocolsio_import_create
|
||||||
|
begin
|
||||||
@protocolsio_too_big = false
|
@protocolsio_too_big = false
|
||||||
@protocolsio_invalid_file = false
|
@protocolsio_invalid_file = false
|
||||||
@protocolsio_no_file = false
|
@protocolsio_no_file = false
|
||||||
|
@ -649,13 +650,21 @@ class ProtocolsController < ApplicationController
|
||||||
@json_object['steps']
|
@json_object['steps']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@protocol = Protocol.new
|
@protocol = Protocol.new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {} # go to the js.erb file named the same as this controller,
|
format.js {} # go to the js.erb file named the same as this controller,
|
||||||
# where a preview modal is rendered,
|
# where a preview modal is rendered,
|
||||||
# and some modals get closed and opened
|
# and some modals get closed and opened
|
||||||
end
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error(e.message)
|
||||||
|
@protocolsio_general_error = true
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {} # go to the js.erb file named the same as this controller,
|
||||||
|
# where a preview modal is rendered,
|
||||||
|
# and some modals get closed and opened
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def protocolsio_import_save
|
def protocolsio_import_save
|
||||||
|
|
|
@ -5,6 +5,8 @@ $('#modal-import-json-protocol').on('hidden.bs.modal', function () {
|
||||||
$('#modal-import-json-protocol').modal('hide');
|
$('#modal-import-json-protocol').modal('hide');
|
||||||
HelperModule.flashAlertMsg(I18n.t('my_modules.protocols.load_from_file_size_error',
|
HelperModule.flashAlertMsg(I18n.t('my_modules.protocols.load_from_file_size_error',
|
||||||
{ size: $(document.body).data('file-max-size-mb') ) }, 'danger');
|
{ size: $(document.body).data('file-max-size-mb') ) }, 'danger');
|
||||||
|
<% elsif @protocolsio_general_error %>
|
||||||
|
$('#pio_no_file_error_span').addClass('has-error').html('<span class="help-block"> <%= t('protocols.import_export.load_file_error') %></span>');
|
||||||
<% elsif @protocolsio_invalid_file %>
|
<% elsif @protocolsio_invalid_file %>
|
||||||
$('#modal-import-json-protocol').modal('hide');
|
$('#modal-import-json-protocol').modal('hide');
|
||||||
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_invalid_error') %>','danger');
|
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_invalid_error') %>','danger');
|
||||||
|
|
Loading…
Add table
Reference in a new issue