Fix marvinjs loading and speedup creating of the wopi files [SCI-9409]

This commit is contained in:
Andrej 2023-09-29 15:35:33 +02:00
parent 9b9c370bc3
commit e1ca9175b7
5 changed files with 37 additions and 33 deletions

View file

@ -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,

View file

@ -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 -->

View file

@ -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"

View file

@ -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 -->

View file

@ -1,4 +1,4 @@
/* global HelperModule */ /* global HelperModule animateSpinner renderFormError I18n */
const FILENAME_MAX_LENGTH = 100; const FILENAME_MAX_LENGTH = 100;
@ -19,9 +19,14 @@ export default {
} }
}); });
$wopiModal.find('form').on( $wopiModal.find('form')
.on('submit', () => {
animateSpinner(null, true);
})
.on(
'ajax:success', 'ajax:success',
(e, data, status) => { (e, data, status) => {
animateSpinner(null, false);
if (status === 'success') { if (status === 'success') {
$wopiModal.modal('hide'); $wopiModal.modal('hide');
window.open(data.edit_url, '_blank'); window.open(data.edit_url, '_blank');
@ -32,9 +37,10 @@ export default {
requestCallback(e, data, status); requestCallback(e, data, status);
} }
).on('ajax:error', function(ev, response) { ).on('ajax:error', function(ev, response) {
var element; let element;
var msg; let msg;
animateSpinner(null, false);
$(this).clearFormErrors(); $(this).clearFormErrors();
if (response.status === 400) { if (response.status === 400) {