mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-18 22:58:53 +08:00
Merge pull request #2802 from aignatov-bio/ai-sci-4930-add-office-preview-attachments
Add WOPI preview for office files [SCI-4930]
This commit is contained in:
commit
12b903dbe7
4 changed files with 29 additions and 13 deletions
|
|
@ -457,16 +457,21 @@ var FilePreviewModal = (function() {
|
||||||
link.attr('data-status', 'asset-present');
|
link.attr('data-status', 'asset-present');
|
||||||
if (data.type === 'previewable') {
|
if (data.type === 'previewable') {
|
||||||
animateSpinner('.file-preview-container', false);
|
animateSpinner('.file-preview-container', false);
|
||||||
modal.find('.file-preview-container')
|
if (data['wopi-preview-url']) {
|
||||||
.append($('<img>')
|
modal.find('.file-preview-container')
|
||||||
.css('opacity', 0)
|
.html(`<iframe class="wopi-file-preview" src="${data['wopi-preview-url']}"></iframe>`);
|
||||||
.attr('src', data['large-preview-url'])
|
} else {
|
||||||
.attr('alt', name)
|
modal.find('.file-preview-container')
|
||||||
.on('error', ActiveStoragePreviews.reCheckPreview)
|
.append($('<img>')
|
||||||
.on('load', ActiveStoragePreviews.showPreview)
|
.css('opacity', 0)
|
||||||
.click(function(ev) {
|
.attr('src', data['large-preview-url'])
|
||||||
ev.stopPropagation();
|
.attr('alt', name)
|
||||||
}));
|
.on('error', ActiveStoragePreviews.reCheckPreview)
|
||||||
|
.on('load', ActiveStoragePreviews.showPreview)
|
||||||
|
.click(function(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
}));
|
||||||
|
}
|
||||||
if (!readOnly && data.editable) {
|
if (!readOnly && data.editable) {
|
||||||
modal.find('.file-edit-link').css('display', '');
|
modal.find('.file-edit-link').css('display', '');
|
||||||
modal.find('.file-edit-link').off().click(function(ev) {
|
modal.find('.file-edit-link').off().click(function(ev) {
|
||||||
|
|
|
||||||
|
|
@ -1464,6 +1464,10 @@ ul.content-activities {
|
||||||
color: $color-white;
|
color: $color-white;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-preview-container {
|
.file-preview-container {
|
||||||
|
|
@ -1475,7 +1479,7 @@ ul.content-activities {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 60%;
|
width: 100%;
|
||||||
|
|
||||||
&.processing {
|
&.processing {
|
||||||
background-image: url("/images/medium/processing.gif");
|
background-image: url("/images/medium/processing.gif");
|
||||||
|
|
@ -1487,6 +1491,12 @@ ul.content-activities {
|
||||||
color: $color-black;
|
color: $color-black;
|
||||||
margin: 30px 0;
|
margin: 30px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wopi-file-preview {
|
||||||
|
border: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class AssetsController < ApplicationController
|
||||||
|
|
||||||
if wopi_enabled? && wopi_file?(@asset)
|
if wopi_enabled? && wopi_file?(@asset)
|
||||||
edit_supported, title = wopi_file_edit_button_status
|
edit_supported, title = wopi_file_edit_button_status
|
||||||
|
response_json['wopi-preview-url'] = @asset.get_action_url(current_user, 'embedview')
|
||||||
response_json['wopi-controls'] = render_to_string(
|
response_json['wopi-controls'] = render_to_string(
|
||||||
partial: 'assets/wopi/file_wopi_controls.html.erb',
|
partial: 'assets/wopi/file_wopi_controls.html.erb',
|
||||||
locals: {
|
locals: {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ module WopiUtil
|
||||||
wopi_app.save!
|
wopi_app.save!
|
||||||
app.xpath('action').each do |action|
|
app.xpath('action').each do |action|
|
||||||
name = action.xpath('@name').first.value
|
name = action.xpath('@name').first.value
|
||||||
next unless %w(view edit editnew wopitest).include?(name)
|
next unless %w(view edit editnew embedview wopitest).include?(name)
|
||||||
|
|
||||||
wopi_action = WopiAction.new
|
wopi_action = WopiAction.new
|
||||||
wopi_action.action = name
|
wopi_action.action = name
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue