mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 23:46:21 +08:00
Merge pull request #5950 from rekonder/aj_SCI_8962
Implemented trial period for open vector editor [SCI-8962]
This commit is contained in:
commit
5aaf1af1d8
|
@ -5,6 +5,7 @@ class GeneSequenceAssetsController < ApplicationController
|
|||
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
before_action :check_open_vector_service_enabled, except: :edit
|
||||
before_action :load_vars, except: %i(new create)
|
||||
before_action :load_create_vars, only: %i(new create)
|
||||
|
||||
|
@ -18,6 +19,7 @@ class GeneSequenceAssetsController < ApplicationController
|
|||
def edit
|
||||
@file_url = rails_representation_url(@asset.file)
|
||||
@file_name = @asset.render_file_name
|
||||
@ove_enabled = OpenVectorEditorService.enabled?
|
||||
render :edit, layout: false
|
||||
end
|
||||
|
||||
|
@ -111,11 +113,15 @@ class GeneSequenceAssetsController < ApplicationController
|
|||
end
|
||||
|
||||
def check_manage_permission
|
||||
render_403 unless can_manage_asset?
|
||||
render_403 unless asset_managable?
|
||||
end
|
||||
|
||||
helper_method :can_manage_asset?
|
||||
def can_manage_asset?
|
||||
def check_open_vector_service_enabled
|
||||
render_403 unless OpenVectorEditorService.enabled?
|
||||
end
|
||||
|
||||
helper_method :asset_managable?
|
||||
def asset_managable?
|
||||
case @parent
|
||||
when Step
|
||||
can_manage_step?(@parent)
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
<input v-model="sequenceName" class="sci-input-field" type="text" :disabled="readOnly" />
|
||||
</div>
|
||||
</span>
|
||||
<div v-if="oveEnabledDaysLeft <= 30" class="flex items-center">
|
||||
<i class="mr-1 text-brand-warning sn-icon sn-icon-alert-warning"></i>
|
||||
<p v-html="i18n.t('open_vector_editor.trial_expiration_warning_html', { count: oveEnabledDaysLeft })" class="mb-0"></p>
|
||||
</div>
|
||||
<div class="ove-buttons">
|
||||
<button v-if="!readOnly" @click="saveAndClose" class="btn btn-light">
|
||||
<i class="sn-icon sn-icon-save"></i>
|
||||
|
@ -31,7 +35,8 @@
|
|||
fileUrl: { type: String },
|
||||
fileName: { type: String },
|
||||
updateUrl: { type: String },
|
||||
readOnly: { type: Boolean, default: false }
|
||||
readOnly: { type: Boolean, default: false },
|
||||
oveEnabledDaysLeft: { type: Number }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
23
app/services/open_vector_editor_service.rb
Normal file
23
app/services/open_vector_editor_service.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class OpenVectorEditorService
|
||||
class << self
|
||||
def enabled?
|
||||
ove_enabled_until = ENV.fetch('SCINOTE_OVE_ENABLED_UNTIL', nil)
|
||||
|
||||
return false if ove_enabled_until.blank?
|
||||
|
||||
DateTime.now.utc.to_date < DateTime.strptime(ove_enabled_until, '%d-%m-%Y').utc.to_date
|
||||
end
|
||||
|
||||
def evaluation_period_left
|
||||
return 0 unless enabled?
|
||||
|
||||
ove_enabled_until = ENV.fetch('SCINOTE_OVE_ENABLED_UNTIL', nil)
|
||||
|
||||
return 0 if ove_enabled_until.blank?
|
||||
|
||||
(DateTime.strptime(ove_enabled_until, '%d-%m-%Y').utc.to_date - DateTime.now.utc.to_date).to_i
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,15 +11,20 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="open-vector-editor" data-behaviour="vue">
|
||||
<open-vector-editor
|
||||
file-url="<%= @file_url %>"
|
||||
file-name="<%= @file_name %>"
|
||||
update-url="<%= @asset ? gene_sequence_asset_url(@asset) : gene_sequence_assets_url(parent_type: params[:parent_type], parent_id: params[:parent_id]) %>"
|
||||
:read-only="<%= !can_manage_asset? %>"
|
||||
/>
|
||||
</div>
|
||||
<%= javascript_include_tag 'open_vector_editor' %>
|
||||
<%= javascript_include_tag 'vue_components_open_vector_editor' %>
|
||||
<% if @ove_enabled %>
|
||||
<div id="open-vector-editor" data-behaviour="vue">
|
||||
<open-vector-editor
|
||||
file-url="<%= @file_url %>"
|
||||
file-name="<%= @file_name %>"
|
||||
update-url="<%= @asset ? gene_sequence_asset_url(@asset) : gene_sequence_assets_url(parent_type: params[:parent_type], parent_id: params[:parent_id]) %>"
|
||||
:read-only="<%= !asset_managable? %>"
|
||||
:ove-enabled-days-left="<%= OpenVectorEditorService.evaluation_period_left %>"
|
||||
/>
|
||||
</div>
|
||||
<%= javascript_include_tag 'open_vector_editor' %>
|
||||
<%= javascript_include_tag 'vue_components_open_vector_editor' %>
|
||||
<% else %>
|
||||
<%# TODO render promo %>
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3640,7 +3640,9 @@ en:
|
|||
new_sequence: "New sequence"
|
||||
edit_sequence: "Edit sequence"
|
||||
default_sequence_name: "New sequence"
|
||||
|
||||
trial_expiration_warning_html:
|
||||
one: "Your Sequence editor trial expires in %{count} day. <a href='mailto:support@scinote.net'> Contact SciNote for more information.</a>"
|
||||
other: "Your Sequence editor trial expires in %{count} days. <a href='mailto:support@scinote.net'> Contact SciNote for more information.</a>"
|
||||
pdf_preview:
|
||||
fit_to_screen: 'Fit to screen'
|
||||
pages:
|
||||
|
|
|
@ -19,7 +19,8 @@ module.exports = {
|
|||
},
|
||||
colors: {
|
||||
transparent: 'transparent',
|
||||
current: 'currentColor'
|
||||
current: 'currentColor',
|
||||
'brand-warning': '#f0ad4e'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue