mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 22:24: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
|
render_404 and return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prepare file preview in advance
|
|
||||||
asset.medium_preview.processed && asset.large_preview.processed
|
|
||||||
# Return edit url and asset info
|
# Return edit url and asset info
|
||||||
render json: {
|
render json: {
|
||||||
attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json,
|
attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json,
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
class="new-marvinjs-upload-button hidden"
|
class="new-marvinjs-upload-button hidden"
|
||||||
:data-object-id="step.id"
|
:data-object-id="step.id"
|
||||||
ref="marvinJsButton"
|
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"
|
:data-object-type="step.attributes.type"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
></span> <!-- Hidden element to support legacy code -->
|
></span> <!-- Hidden element to support legacy code -->
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<a
|
<a
|
||||||
class="new-marvinjs-upload-button btn btn-light"
|
class="new-marvinjs-upload-button btn btn-light"
|
||||||
:data-object-id="step.id"
|
: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"
|
data-object-type="Step"
|
||||||
@click="openMarvinJsModal"
|
@click="openMarvinJsModal"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
class="new-marvinjs-upload-button hidden"
|
class="new-marvinjs-upload-button hidden"
|
||||||
:data-object-id="result.id"
|
:data-object-id="result.id"
|
||||||
ref="marvinJsButton"
|
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"
|
:data-object-type="result.attributes.type"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
></span> <!-- Hidden element to support legacy code -->
|
></span> <!-- Hidden element to support legacy code -->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global HelperModule */
|
/* global HelperModule animateSpinner renderFormError I18n */
|
||||||
|
|
||||||
const FILENAME_MAX_LENGTH = 100;
|
const FILENAME_MAX_LENGTH = 100;
|
||||||
|
|
||||||
|
@ -19,36 +19,42 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$wopiModal.find('form').on(
|
$wopiModal.find('form')
|
||||||
'ajax:success',
|
.on('submit', () => {
|
||||||
(e, data, status) => {
|
animateSpinner(null, true);
|
||||||
if (status === 'success') {
|
})
|
||||||
$wopiModal.modal('hide');
|
.on(
|
||||||
window.open(data.edit_url, '_blank');
|
'ajax:success',
|
||||||
window.focus();
|
(e, data, status) => {
|
||||||
} else {
|
animateSpinner(null, false);
|
||||||
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
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) {
|
||||||
}
|
let element;
|
||||||
).on('ajax:error', function(ev, response) {
|
let msg;
|
||||||
var element;
|
|
||||||
var msg;
|
|
||||||
|
|
||||||
$(this).clearFormErrors();
|
animateSpinner(null, false);
|
||||||
|
$(this).clearFormErrors();
|
||||||
|
|
||||||
if (response.status === 400) {
|
if (response.status === 400) {
|
||||||
element = $(this).find('#new-wopi-file-name');
|
element = $(this).find('#new-wopi-file-name');
|
||||||
msg = response.responseJSON.message.file.toString();
|
msg = response.responseJSON.message.file.toString();
|
||||||
} else if (response.status === 403) {
|
} else if (response.status === 403) {
|
||||||
element = $(this).find('#other-wopi-errors');
|
element = $(this).find('#other-wopi-errors');
|
||||||
msg = I18n.t('assets.create_wopi_file.errors.forbidden');
|
msg = I18n.t('assets.create_wopi_file.errors.forbidden');
|
||||||
} else if (response.status === 404) {
|
} else if (response.status === 404) {
|
||||||
element = $(this).find('#other-wopi-errors');
|
element = $(this).find('#other-wopi-errors');
|
||||||
msg = I18n.t('assets.create_wopi_file.errors.not_found');
|
msg = I18n.t('assets.create_wopi_file.errors.not_found');
|
||||||
}
|
}
|
||||||
renderFormError(undefined, element, msg);
|
renderFormError(undefined, element, msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue