mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 10:06:53 +08:00
Making asset sync feature switchable [SCI-9709]
This commit is contained in:
parent
6feb61d45c
commit
dd2611bb82
3 changed files with 20 additions and 7 deletions
|
@ -4,6 +4,7 @@ class AssetSyncController < ApplicationController
|
||||||
skip_before_action :authenticate_user!, only: %i(update download)
|
skip_before_action :authenticate_user!, only: %i(update download)
|
||||||
skip_before_action :verify_authenticity_token, only: %i(update download)
|
skip_before_action :verify_authenticity_token, only: %i(update download)
|
||||||
before_action :authenticate_asset_sync_token!, only: %i(update download)
|
before_action :authenticate_asset_sync_token!, only: %i(update download)
|
||||||
|
before_action :check_asset_sync
|
||||||
|
|
||||||
def show
|
def show
|
||||||
asset = Asset.find_by(id: params[:asset_id])
|
asset = Asset.find_by(id: params[:asset_id])
|
||||||
|
@ -42,7 +43,7 @@ class AssetSyncController < ApplicationController
|
||||||
render plain: Constants::ASSET_SYNC_URL
|
render plain: Constants::ASSET_SYNC_URL
|
||||||
end
|
end
|
||||||
|
|
||||||
# private
|
private
|
||||||
|
|
||||||
def conflicting_asset_copy_token
|
def conflicting_asset_copy_token
|
||||||
Asset.transaction do
|
Asset.transaction do
|
||||||
|
@ -74,4 +75,8 @@ class AssetSyncController < ApplicationController
|
||||||
|
|
||||||
head :forbidden unless can_manage_asset?(@asset)
|
head :forbidden unless can_manage_asset?(@asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_asset_sync
|
||||||
|
render_404 if ENV['ASSET_SYNC_URL'].blank?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,10 +102,12 @@
|
||||||
emit: 'open_scinote_editor',
|
emit: 'open_scinote_editor',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
menu.push({
|
if (this.attachment.attributes.urls.open_locally) {
|
||||||
text: this.i18n.t('Open_locally'),
|
menu.push({
|
||||||
emit: 'open_locally'
|
text: this.i18n.t('Open_locally'),
|
||||||
})
|
emit: 'open_locally'
|
||||||
|
})
|
||||||
|
}
|
||||||
menu.push({
|
menu.push({
|
||||||
text: this.i18n.t('Download'),
|
text: this.i18n.t('Download'),
|
||||||
url: this.attachment.attributes.urls.download,
|
url: this.attachment.attributes.urls.download,
|
||||||
|
|
|
@ -131,14 +131,20 @@ class AssetSerializer < ActiveModel::Serializer
|
||||||
start_edit_image: start_edit_image_path(object),
|
start_edit_image: start_edit_image_path(object),
|
||||||
delete: asset_destroy_path(object),
|
delete: asset_destroy_path(object),
|
||||||
move_targets: asset_move_tagets_path(object),
|
move_targets: asset_move_tagets_path(object),
|
||||||
move: asset_move_path(object),
|
move: asset_move_path(object)
|
||||||
open_locally: asset_sync_show_path(object)
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
urls[:open_vector_editor_edit] = edit_gene_sequence_asset_path(object.id) if can_manage_asset?(user, object)
|
urls[:open_vector_editor_edit] = edit_gene_sequence_asset_path(object.id) if can_manage_asset?(user, object)
|
||||||
|
urls[:open_locally] = asset_sync_show_path(object) if can_manage_asset?(user, object) && can_open_locally?
|
||||||
urls[:wopi_action] = object.get_action_url(user, 'embedview') if wopi && can_manage_asset?(user, object)
|
urls[:wopi_action] = object.get_action_url(user, 'embedview') if wopi && can_manage_asset?(user, object)
|
||||||
urls[:blob] = rails_blob_path(object.file, disposition: 'attachment') if object.file.attached?
|
urls[:blob] = rails_blob_path(object.file, disposition: 'attachment') if object.file.attached?
|
||||||
|
|
||||||
urls
|
urls
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def can_open_locally?
|
||||||
|
ENV['ASSET_SYNC_URL'].present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue