mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-29 03:01:58 +08:00
Fix for file annotating on Safari
This commit is contained in:
parent
daccad1346
commit
1b9db2f61e
3 changed files with 27 additions and 4 deletions
|
@ -172,7 +172,18 @@ var FilePreviewModal = (function() {
|
|||
};
|
||||
}
|
||||
|
||||
function initImageEditor(data) {
|
||||
function preInitImageEditor(data) {
|
||||
$.ajax({
|
||||
url: data['download-url'],
|
||||
type: 'get',
|
||||
success: function(responseData) {
|
||||
var fileUrl = responseData;
|
||||
initImageEditor(data, fileUrl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initImageEditor(data, fileUrl) {
|
||||
var imageEditor;
|
||||
var ps;
|
||||
var blackTheme = {
|
||||
|
@ -261,7 +272,7 @@ var FilePreviewModal = (function() {
|
|||
imageEditor = new tui.ImageEditor('#tui-image-editor', {
|
||||
includeUI: {
|
||||
loadImage: {
|
||||
path: data['download-url'],
|
||||
path: fileUrl,
|
||||
name: data.filename
|
||||
},
|
||||
theme: blackTheme,
|
||||
|
@ -453,7 +464,7 @@ var FilePreviewModal = (function() {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
modal.modal('hide');
|
||||
initImageEditor(data);
|
||||
preInitImageEditor(data);
|
||||
});
|
||||
} else {
|
||||
modal.find('.file-edit-link').css('display', 'none');
|
||||
|
|
|
@ -52,7 +52,7 @@ class AssetsController < ApplicationController
|
|||
|
||||
'filename' => truncate(escape_input(@asset.file_file_name),
|
||||
length: Constants::FILENAME_TRUNCATION_LENGTH),
|
||||
'download-url' => download_asset_path(@asset, timestamp: Time.now.to_i)
|
||||
'download-url' => asset_file_url_path(@asset)
|
||||
}
|
||||
|
||||
can_edit = if @assoc.class == Step
|
||||
|
@ -132,6 +132,17 @@ class AssetsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def file_url
|
||||
render_404 and return unless @asset.file_present
|
||||
|
||||
url = if @asset.file.is_stored_on_s3?
|
||||
@asset.presigned_url(download: true)
|
||||
else
|
||||
@asset.file.url
|
||||
end
|
||||
render plain: url
|
||||
end
|
||||
|
||||
def edit
|
||||
action = @asset.file_file_size.zero? && !@asset.locked? ? 'editnew' : 'edit'
|
||||
@action_url = append_wd_params(@asset
|
||||
|
|
|
@ -593,6 +593,7 @@ Rails.application.routes.draw do
|
|||
to: 'assets#file_preview',
|
||||
as: 'asset_file_preview'
|
||||
get 'files/:id/download', to: 'assets#download', as: 'download_asset'
|
||||
get 'files/:id/file_url', to: 'assets#file_url', as: 'asset_file_url'
|
||||
get 'files/:id/preview', to: 'assets#preview', as: 'preview_asset'
|
||||
get 'files/:id/view', to: 'assets#view', as: 'view_asset'
|
||||
get 'files/:id/edit', to: 'assets#edit', as: 'edit_asset'
|
||||
|
|
Loading…
Reference in a new issue