mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 13:44:23 +08:00
Fix marvinjs loading and speedup creating of the wopi files [SCI-9409]
This commit is contained in:
parent
9b9c370bc3
commit
e1ca9175b7
5 changed files with 37 additions and 33 deletions
|
@ -268,8 +268,6 @@ class AssetsController < ApplicationController
|
|||
render_404 and return
|
||||
end
|
||||
|
||||
# Prepare file preview in advance
|
||||
asset.medium_preview.processed && asset.large_preview.processed
|
||||
# Return edit url and asset info
|
||||
render json: {
|
||||
attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json,
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
class="new-marvinjs-upload-button hidden"
|
||||
:data-object-id="step.id"
|
||||
ref="marvinJsButton"
|
||||
:data-marvin-url="step.attributes.marvinjs_context.marvin_js_asset_url"
|
||||
:data-marvin-url="step.attributes.marvinjs_context?.marvin_js_asset_url"
|
||||
:data-object-type="step.attributes.type"
|
||||
tabindex="0"
|
||||
></span> <!-- Hidden element to support legacy code -->
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<a
|
||||
class="new-marvinjs-upload-button btn btn-light"
|
||||
:data-object-id="step.id"
|
||||
:data-marvin-url="step.attributes.marvinjs_context.marvin_js_asset_url"
|
||||
:data-marvin-url="step.attributes.marvinjs_context?.marvin_js_asset_url"
|
||||
data-object-type="Step"
|
||||
@click="openMarvinJsModal"
|
||||
tabindex="0"
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
class="new-marvinjs-upload-button hidden"
|
||||
:data-object-id="result.id"
|
||||
ref="marvinJsButton"
|
||||
:data-marvin-url="result.attributes.marvinjs_context.marvin_js_asset_url"
|
||||
:data-marvin-url="result.attributes.marvinjs_context?.marvin_js_asset_url"
|
||||
:data-object-type="result.attributes.type"
|
||||
tabindex="0"
|
||||
></span> <!-- Hidden element to support legacy code -->
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global HelperModule */
|
||||
/* global HelperModule animateSpinner renderFormError I18n */
|
||||
|
||||
const FILENAME_MAX_LENGTH = 100;
|
||||
|
||||
|
@ -19,36 +19,42 @@ export default {
|
|||
}
|
||||
});
|
||||
|
||||
$wopiModal.find('form').on(
|
||||
'ajax:success',
|
||||
(e, data, status) => {
|
||||
if (status === 'success') {
|
||||
$wopiModal.modal('hide');
|
||||
window.open(data.edit_url, '_blank');
|
||||
window.focus();
|
||||
} else {
|
||||
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
||||
$wopiModal.find('form')
|
||||
.on('submit', () => {
|
||||
animateSpinner(null, true);
|
||||
})
|
||||
.on(
|
||||
'ajax:success',
|
||||
(e, data, status) => {
|
||||
animateSpinner(null, false);
|
||||
if (status === 'success') {
|
||||
$wopiModal.modal('hide');
|
||||
window.open(data.edit_url, '_blank');
|
||||
window.focus();
|
||||
} else {
|
||||
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
||||
}
|
||||
requestCallback(e, data, status);
|
||||
}
|
||||
requestCallback(e, data, status);
|
||||
}
|
||||
).on('ajax:error', function(ev, response) {
|
||||
var element;
|
||||
var msg;
|
||||
).on('ajax:error', function(ev, response) {
|
||||
let element;
|
||||
let msg;
|
||||
|
||||
$(this).clearFormErrors();
|
||||
animateSpinner(null, false);
|
||||
$(this).clearFormErrors();
|
||||
|
||||
if (response.status === 400) {
|
||||
element = $(this).find('#new-wopi-file-name');
|
||||
msg = response.responseJSON.message.file.toString();
|
||||
} else if (response.status === 403) {
|
||||
element = $(this).find('#other-wopi-errors');
|
||||
msg = I18n.t('assets.create_wopi_file.errors.forbidden');
|
||||
} else if (response.status === 404) {
|
||||
element = $(this).find('#other-wopi-errors');
|
||||
msg = I18n.t('assets.create_wopi_file.errors.not_found');
|
||||
}
|
||||
renderFormError(undefined, element, msg);
|
||||
});
|
||||
if (response.status === 400) {
|
||||
element = $(this).find('#new-wopi-file-name');
|
||||
msg = response.responseJSON.message.file.toString();
|
||||
} else if (response.status === 403) {
|
||||
element = $(this).find('#other-wopi-errors');
|
||||
msg = I18n.t('assets.create_wopi_file.errors.forbidden');
|
||||
} else if (response.status === 404) {
|
||||
element = $(this).find('#other-wopi-errors');
|
||||
msg = I18n.t('assets.create_wopi_file.errors.not_found');
|
||||
}
|
||||
renderFormError(undefined, element, msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue