mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 11:57:16 +08:00
Merge pull request #1115 from ZmagoD/zd_SCI_2321
fixes images preview in repository/library [fixes SCI-2321]
This commit is contained in:
commit
9d2303c777
8 changed files with 89 additions and 13 deletions
|
@ -595,6 +595,7 @@
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
setupAssetsLoading();
|
setupAssetsLoading();
|
||||||
DragNDropSteps.clearFiles();
|
DragNDropSteps.clearFiles();
|
||||||
|
initPreviewModal();
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
if (xhr.responseJSON['assets.file']) {
|
if (xhr.responseJSON['assets.file']) {
|
||||||
|
|
|
@ -125,6 +125,7 @@ var RepositoryDatatable = (function(global) {
|
||||||
changeToViewMode();
|
changeToViewMode();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
updateDataTableSelectAllCtrl();
|
updateDataTableSelectAllCtrl();
|
||||||
|
initPreviewModal();
|
||||||
// Prevent row toggling when selecting user smart annotation link
|
// Prevent row toggling when selecting user smart annotation link
|
||||||
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
link.attr('data-no-turbolink', true);
|
link.attr('data-no-turbolink', true);
|
||||||
link.attr('data-status', 'asset-present');
|
link.attr('data-status', 'asset-present');
|
||||||
if (data['type'] === 'image') {
|
if (data['type'] === 'image') {
|
||||||
|
if(data['processing']) {
|
||||||
|
animateSpinner('.file-preview-container', true);
|
||||||
|
} else {
|
||||||
|
animateSpinner('.file-preview-container', false);
|
||||||
modal.find('.file-preview-container')
|
modal.find('.file-preview-container')
|
||||||
.append($('<img>')
|
.append($('<img>')
|
||||||
.attr('src', data['large-preview-url'])
|
.attr('src', data['large-preview-url'])
|
||||||
|
@ -40,9 +44,13 @@
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
modal.find('.file-preview-container').html(data['preview-icon']);
|
modal.find('.file-preview-container').html(data['preview-icon']);
|
||||||
}
|
}
|
||||||
|
if(data['processing']) {
|
||||||
|
checkFileReady(url, modal);
|
||||||
|
}
|
||||||
modal.find('.file-name').text(name);
|
modal.find('.file-name').text(name);
|
||||||
modal.find('.modal-body').click(function() {
|
modal.find('.modal-body').click(function() {
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
|
@ -55,4 +63,44 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkFileReady(url, modal) {
|
||||||
|
$.get(url, function(data) {
|
||||||
|
if(data['processing']) {
|
||||||
|
$('.file-download-link')
|
||||||
|
.addClass('disabled-with-click-events')
|
||||||
|
.attr('title',
|
||||||
|
'<%= I18n.t('general.file.processing')%>')
|
||||||
|
.click(function(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
checkFileReady(url, modal);
|
||||||
|
}, 10000);
|
||||||
|
} else {
|
||||||
|
if(data['type'] === 'image') {
|
||||||
|
modal.find('.file-preview-container').empty();
|
||||||
|
modal.find('.file-preview-container')
|
||||||
|
.append($('<img>')
|
||||||
|
.attr('src', data['large-preview-url'])
|
||||||
|
.attr('alt', data['filename'])
|
||||||
|
.click(function(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
modal.find('.file-name').text(data['filename']);
|
||||||
|
modal.find('.modal-body').click(function() {
|
||||||
|
modal.modal('hide');
|
||||||
|
});
|
||||||
|
modal.modal();
|
||||||
|
$('.modal-backdrop').last().css('z-index', modal.css('z-index') - 1);
|
||||||
|
}
|
||||||
|
$('.file-download-link')
|
||||||
|
.removeClass('disabled-with-click-events')
|
||||||
|
.removeAttr('title')
|
||||||
|
.off();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})(window);
|
})(window);
|
|
@ -1780,6 +1780,17 @@ th.custom-field .modal-tooltiptext {
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.disabled {
|
||||||
|
opacity: .5;
|
||||||
|
pointer-events: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.disabled-with-click-events {
|
||||||
|
opacity: .5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
#alert-flash {
|
#alert-flash {
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
|
|
@ -53,12 +53,19 @@ class AssetsController < ApplicationController
|
||||||
}
|
}
|
||||||
|
|
||||||
if @asset.is_image?
|
if @asset.is_image?
|
||||||
response_json['large-preview-url'] = @asset.url(:large)
|
response_json.merge!(
|
||||||
|
'processing' => @asset.file.processing?,
|
||||||
|
'large-preview-url' => @asset.url(:large),
|
||||||
|
'processing-url' => image_tag('medium/processing.gif')
|
||||||
|
)
|
||||||
else
|
else
|
||||||
response_json['preview-icon'] = render_to_string(
|
response_json.merge!(
|
||||||
|
'processing' => @asset.file.processing?,
|
||||||
|
'preview-icon' => render_to_string(
|
||||||
partial: 'shared/file_preview_icon.html.erb',
|
partial: 'shared/file_preview_icon.html.erb',
|
||||||
locals: { asset: @asset }
|
locals: { asset: @asset }
|
||||||
)
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
if wopi_file?(@asset)
|
if wopi_file?(@asset)
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
<% if asset.file_present %>
|
<% if asset.file_present %>
|
||||||
<% if asset.file.processing? && display_image_tag %>
|
<% if asset.file.processing? && display_image_tag && asset.is_image? %>
|
||||||
<span data-status='asset-loading'
|
<span data-status='asset-loading'
|
||||||
data-present-url='<%= file_present_asset_path(asset.id) %>'>
|
data-present-url='<%= file_present_asset_path(asset.id) %>'>
|
||||||
<%= image_tag 'medium/processing.gif' %>
|
<%= image_tag 'medium/processing.gif' %>
|
||||||
|
<%= link_to download_asset_path(asset),
|
||||||
|
class: 'file-preview-link',
|
||||||
|
id: "modal_link#{asset.id}",
|
||||||
|
data: { no_turbolink: true, id: true, status: 'asset-present', 'preview-url': asset_file_preview_path(asset) } do %>
|
||||||
|
<p><%= truncate(asset.file_file_name,
|
||||||
|
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to download_asset_path(asset),
|
<%= link_to download_asset_path(asset),
|
||||||
|
|
|
@ -1899,6 +1899,7 @@ en:
|
||||||
private: "private"
|
private: "private"
|
||||||
search: "Search"
|
search: "Search"
|
||||||
file:
|
file:
|
||||||
|
processing: "File is still being processed and cannot be downloaded yet."
|
||||||
total_size: "You can upload max %{size} MB of files at one time. Please remove one or more files and try to submit again."
|
total_size: "You can upload max %{size} MB of files at one time. Please remove one or more files and try to submit again."
|
||||||
size_exceeded: "File size must be less than %{file_size} MB."
|
size_exceeded: "File size must be less than %{file_size} MB."
|
||||||
blank: "You didn't select any file"
|
blank: "You didn't select any file"
|
||||||
|
|
BIN
public/images/medium/processing.gif
Normal file
BIN
public/images/medium/processing.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Loading…
Add table
Reference in a new issue