Merge branch 'features/exposed_ids' of github.com:scinote-eln/scinote-web into gc_SCI_7176

This commit is contained in:
Giga Chubinidze 2022-10-28 15:30:28 +04:00
commit d1aa127b7a
25 changed files with 141 additions and 52 deletions

View file

@ -73,7 +73,7 @@ gem 'i18n-js', '~> 3.6' # Localization in javascript files
gem 'jbuilder' # JSON structures via a Builder-style DSL
gem 'logging', '~> 2.0.0'
gem 'nested_form_fields'
gem 'nokogiri', '~> 1.13.6' # HTML/XML parser
gem 'nokogiri', '~> 1.13.9' # HTML/XML parser
gem 'rails_autolink', '~> 1.1', '>= 1.1.6'
gem 'rgl' # Graph framework for project diagram calculations
gem 'roo', '~> 2.8.2' # Spreadsheet parser

View file

@ -384,7 +384,7 @@ GEM
rails (>= 3.2.0)
newrelic_rpm (6.15.0)
nio4r (2.5.8)
nokogiri (1.13.7)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oauth2 (1.4.4)
@ -689,7 +689,7 @@ DEPENDENCIES
momentjs-rails (~> 2.17.1)
nested_form_fields
newrelic_rpm
nokogiri (~> 1.13.6)
nokogiri (~> 1.13.9)
omniauth
omniauth-azure-activedirectory
omniauth-linkedin-oauth2

View file

@ -1 +1 @@
1.26.0.5
1.26.1

View file

@ -34,6 +34,18 @@
}
}
ol {
padding-left: 0;
li {
padding: .5em 0;
}
.indented_row {
padding-left: 4px;
}
}
.zebra-settings-collapse {
border-left: 3px solid $color-concrete;
margin-top: 14px;
@ -42,6 +54,10 @@
.collapse {
padding-left: 2.5em;
ol {
padding-left: 1.5em;
}
}
.collapse-row {
@ -99,6 +115,7 @@
.row-title {
@include font-h2;
margin-left: .5em;
margin-top: .25em;
}
.api-key-container {

View file

@ -130,7 +130,9 @@ class LabelTemplatesController < ApplicationController
def zpl_preview
service = LabelTemplatesPreviewService.new(params, current_user)
payload = service.generate_zpl_preview!
# only render last generated label image
payload = service.generate_zpl_preview!.split.last
if service.error.blank?
render json: { base64_preview: payload }

View file

@ -101,7 +101,7 @@
DPMM_RESOLUTION_OPTIONS,
DPI_RESOLUTION_OPTIONS,
optionsOpen: false,
width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm ,
width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm,
height: this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm,
unit: this.template.attributes.unit,
density: this.template.attributes.density,
@ -125,19 +125,16 @@
},
watch: {
unit() {
this.recalculateUnits();
this.setDefaults();
},
zpl() {
this.refreshPreview();
},
template() {
this.unit = this.template.attributes.unit
this.width = this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm
this.height = this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm
this.unit = this.template.attributes.unit
this.density = this.template.attributes.density
this.refreshPreview()
}
},
methods: {
@ -159,6 +156,8 @@
refreshPreview() {
if (this.zpl.length === 0) return;
this.base64Image = null;
$.ajax({
url: this.previewUrl,
type: 'GET',
@ -184,7 +183,9 @@
});
},
updateUnit(unit) {
if (this.unit === unit) return;
this.unit = unit;
this.recalculateUnits();
this.$emit('unit:update', this.unit);
},
updateDensity(density) {

View file

@ -2,7 +2,7 @@
<div ref="modal" class="modal fade" id="modal-print-repository-row-label" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div v-if="printers_dropdown.length > 0" class="printers-available">
<div v-if="availablePrinters.length > 0" class="printers-available">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<p class="modal-title">
@ -24,7 +24,7 @@
</label>
<DropdownSelector
:disableSearch="true"
:options="printers_dropdown"
:options="availablePrinters"
:selectorId="`LabelPrinterSelector`"
@dropdown:changed="selectPrinter"
/>
@ -38,7 +38,7 @@
<DropdownSelector
ref="labelTemplateDropdown"
:disableSearch="true"
:options="templates_dropdown"
:options="availableTemplates"
:selectorId="`LabelTemplateSelector`"
:optionLabel="templateOption"
:onOpen="initTooltip"
@ -138,7 +138,7 @@
}
},
computed: {
templates_dropdown() {
availableTemplates() {
let templates = this.templates;
if (this.selectedPrinter && this.selectedPrinter.attributes.type_of === 'zebra') {
templates = templates.filter(i => i.attributes.type === 'ZebraLabelTemplate')
@ -155,7 +155,7 @@
}
})
},
printers_dropdown() {
availablePrinters() {
return this.printers.map(i => {
return {
value: i.id,

View file

@ -4,9 +4,9 @@ module UserAssignments
class RemoveTeamUserAssignmentsJob < ApplicationJob
queue_as :high_priority
def perform(user, team)
def perform(team_user_assignment)
ActiveRecord::Base.transaction do
RemoveTeamUserAssignmentsService.new(user, team).call
RemoveTeamUserAssignmentsService.new(team_user_assignment).call
end
end
end

View file

@ -4,9 +4,9 @@ module UserAssignments
class UpdateTeamUserAssignmentsJob < ApplicationJob
queue_as :high_priority
def perform(user, team, user_role)
def perform(team_user_assignment)
ActiveRecord::Base.transaction do
UpdateTeamUserAssignmentsService.new(user, team, user_role).call
UpdateTeamUserAssignmentsService.new(team_user_assignment).call
end
end
end

View file

@ -19,6 +19,10 @@ class LabelPrinter < ApplicationRecord
validates :type_of, presence: true
validates :language_type, presence: true
def self.zebra_print_enabled?
RepositoryBase.stock_management_enabled?
end
def done?
current_print_job_ids.blank? && ready?
end

View file

@ -16,7 +16,7 @@ class LabelTemplate < ApplicationRecord
validate :ensure_single_default_template!
def self.enabled?
ApplicationSettings.instance.values['label_templates_enabled']
RepositoryBase.stock_management_enabled?
end
def icon

View file

@ -5,7 +5,11 @@ class StepText < ApplicationRecord
include ActionView::Helpers::TextHelper
auto_strip_attributes :text, nullify: false
validates :text, length: { maximum: Constants::RICH_TEXT_MAX_LENGTH }
validates :text, length:
{
maximum:
ENV['STEP_TEXT_MAX_LENGTH'].present? ? ENV['STEP_TEXT_MAX_LENGTH'].to_i : Constants::RICH_TEXT_MAX_LENGTH
}
belongs_to :step, inverse_of: :step_texts, touch: true
has_one :step_orderable_element, as: :orderable, dependent: :destroy

View file

@ -30,7 +30,7 @@ Canaid::Permissions.register_for(Repository) do
delete_repository_rows)
.each do |perm|
can perm do |user, repository|
next false if repository.shared_with?(user.current_team) && !repository.shared_with_write?(user.current_team)
repository.shared_with?(user.current_team) ? repository.shared_with_write?(user.current_team) : true
end
end

View file

@ -5,7 +5,7 @@ module UserAssignments
def initialize(team_user_assignment)
@user = team_user_assignment.user
@team = team_user_assignment.assignable
@user_role = user_role
@user_role = team_user_assignment.user_role
end
def call
@ -25,6 +25,9 @@ module UserAssignments
.select { |assignment| assignment[:user_id] == @user.id && assignment[:team_id] == @team.id }
.each { |assignment| assignment.update!(user_role: @user_role) }
end
@team.repository_sharing_user_assignments.where(user: @user).find_each do |assignment|
assignment.update!(user_role: @user_role)
end
end
def update_reports_assignments

View file

@ -10,6 +10,7 @@
<div class="modal-body">
<% users.order(full_name: :asc).each do |user| %>
<% user_assignment = experiment.user_assignments.find_by(user: user) %>
<% next if user_assignment.blank? %>
<%= render partial: 'access_permissions/partials/user_assignment', locals: { user_assignment: user_assignment, user: user, resource: experiment } %>
<% end %>
<%= render('access_permissions/partials/default_public_user_role_form', project: experiment.project, editable: false) if experiment.project.visible? %>

View file

@ -10,6 +10,7 @@
<div class="modal-body">
<% users.order(full_name: :asc).each do |user| %>
<% user_assignment = my_module.user_assignments.find_by(user: user) %>
<% next if user_assignment.blank? %>
<%= render partial: 'access_permissions/partials/user_assignment', locals: { user_assignment: user_assignment, user: user, resource: my_module } %>
<% end %>
<%= render('access_permissions/partials/default_public_user_role_form',

View file

@ -4,11 +4,11 @@
<%= image_tag "icon/team.png", class: 'img-circle pull-left' %>
</div>
<div>
<%= t('access_permissions.everyone_else', team_name: f.object.team.name) %>
<%= render 'access_permissions/partials/public_members_dropdown', team: f.object.team, project: project %>
<%= t('access_permissions.everyone_else', team_name: project.team.name) %>
<%= render 'access_permissions/partials/public_members_dropdown', team: project.team, project: project %>
<br>
<small class="text-muted">
<%= f.object.default_public_user_role.name %>
<%= project.default_public_user_role.name %>
<span class="permission-object-tag" title="<%= t("access_permissions.partials.project_tooltip") %>"">
<%= t("access_permissions.partials.project") %>
</span>
@ -18,7 +18,7 @@
<div class="user-assignment-controls">
<div class="user-assignment-role">
<% if editable %>
<%= f.select :default_public_user_role_id, options_for_select(user_roles_collection, selected: f.object.default_public_user_role_id), {}, class: 'form-control selectpicker', title: t('user_assignment.change_project_role'), data: { 'selected-text-format' => 'static' } %>
<%= f.select :default_public_user_role_id, options_for_select(user_roles_collection, selected: project.default_public_user_role_id), {}, class: 'form-control selectpicker', title: t('user_assignment.change_project_role'), data: { 'selected-text-format' => 'static' } %>
<% end %>
</div>
<div class="user-assignment-remove">

View file

@ -7,7 +7,7 @@
data-print-validation-url="<%= validate_label_template_columns_repository_row_path %>"
data-label-preview-url="<%= zpl_preview_label_templates_path %>"
data-fluics-info-url="<%= Constants::SCINOTE_FLUICS_URL %>"
data-zebra-enabled="<%= Rails.configuration.x.zebra_print_enabled %>"
data-zebra-enabled="<%= LabelPrinter.zebra_print_enabled? %>"
>
<print-modal-container
:show-modal = "showModal"

View file

@ -1,24 +1,63 @@
<ul>
<li class="zebra-settings-collapse">
<div class="collapse-row">
<i class="fas fa-caret-down" data-toggle="collapse" href="#InstructionsSection" aria-expanded="false"></i>
<i class="fas fa-caret-down collapsed" data-toggle="collapse" href="#InstructionsSection" aria-expanded="false"></i>
<div class="row-title"><%= t("users.settings.account.label_printer.instructions") %></div>
</div>
<ul class="collapse in" id="InstructionsSection">
<ul class="collapse" id="InstructionsSection">
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.p1") %>
</li>
<li class='indented_row'>
<%= t("users.settings.account.label_printer.zebra_instruction.p2_html", link: Constants::SCINOTE_ZEBRA_URL) %>
</li>
<li class='indented_row'>
<%= t("users.settings.account.label_printer.zebra_instruction.p3") %>
</li>
<li class='indented_row'>
<%= t("users.settings.account.label_printer.zebra_instruction.p4") %>
<%= t("users.settings.account.label_printer.zebra_instruction.general_html", link: Constants::SCINOTE_ZEBRA_DOWNLOAD_URL) %>
</li>
<h3><%= t("users.settings.account.label_printer.zebra_instruction.usb.header") %></h3>
<ol>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.usb.p1") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.usb.p2_html", link: Constants::SCINOTE_ZEBRA_DOWNLOAD_URL) %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.usb.p3") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.usb.p4") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.usb.p5") %>
</li>
</ol>
<h3><%= t("users.settings.account.label_printer.zebra_instruction.network.header") %></h3>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.p5") %>
<%= t("users.settings.account.label_printer.zebra_instruction.network.disclaimer") %>
</li>
<ol>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p1") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p2") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p3_html", link: Constants::SCINOTE_ZEBRA_DOWNLOAD_URL) %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p4") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p5") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p6") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p7") %>
</li>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.network.p8") %>
</li>
</ol>
<li>
<%= t("users.settings.account.label_printer.zebra_instruction.contact_html", {link_blog: Constants::SCINOTE_ZEBRA_BLOG_URL, link_zebra_support: Constants::SCINOTE_ZEBRA_SUPPORT_URL}) %>
</li>
</ul>
</li>

View file

@ -16,7 +16,7 @@
<h1 class="printer-title">
<% if @printer_type == 'fluics' %>
<%= t("users.settings.account.label_printer.fluics_printer") %>
<% elsif @printer_type == 'zebra' && Rails.configuration.x.zebra_print_enabled %>
<% elsif @printer_type == 'zebra' && LabelPrinter.zebra_print_enabled? %>
<%= t("users.settings.account.label_printer.zebra_printer") %>
<% end %>
</h1>
@ -25,7 +25,7 @@
<% if @printer_type == 'fluics' %>
<%= render "fluics_settings" %>
<% elsif @printer_type == 'zebra' && Rails.configuration.x.zebra_print_enabled %>
<% elsif @printer_type == 'zebra' && LabelPrinter.zebra_print_enabled? %>
<%= render "zebra_settings" %>
<% end %>
</div>

View file

@ -20,7 +20,7 @@
<div class="row printer-settings">
<div class="col-xs-12 col-sm-12">
<h2 class="addons-subtitle"><%= t('users.settings.account.addons.label_printers') %></h2>
<% if Rails.configuration.x.zebra_print_enabled %>
<% if LabelPrinter.zebra_print_enabled? %>
<div class="printers-container">
<div class="printer">
<div class="header">

View file

@ -57,8 +57,6 @@ module Scinote
config.x.webhooks_enabled = ENV['ENABLE_WEBHOOKS'] == 'true'
config.x.zebra_print_enabled = ENV['SCINOTE_ZEBRA_PRINT_ENABLED'] == 'true'
# Logging
config.log_formatter = proc do |severity, datetime, progname, msg|
"[#{datetime}] #{severity}: #{msg}\n"

View file

@ -236,7 +236,9 @@ class Constants
}
SCINOTE_FLUICS_URL = 'https://www.scinote.net/fluics/'.freeze
SCINOTE_ZEBRA_URL = 'https://www.zebra.com/us/en/products/software/barcode-printers/link-os/browser-print.html'.freeze
SCINOTE_ZEBRA_DOWNLOAD_URL = 'https://www.zebra.com/us/en/products/software/barcode-printers/link-os/browser-print.html'.freeze
SCINOTE_ZEBRA_BLOG_URL = 'https://www.scinote.net/blog/connect-zebra-printers/'.freeze
SCINOTE_ZEBRA_SUPPORT_URL = 'https://www.zebra.com/us/en/about-zebra/contact-zebra/contact-tech-support.html'.freeze
TWO_FACTOR_RECOVERY_CODE_COUNT = 6
TWO_FACTOR_RECOVERY_CODE_LENGTH = 12

View file

@ -2273,11 +2273,26 @@ en:
p4: "3. Enter the API key into the field below."
p5: "4. SciNote will find your printer and connect to it automatically. You can start printing labels."
zebra_instruction:
p1: 'To make it work, please follow these steps:'
p2_html: "1. Install the Zebra BROWSER PRINT application: <a href='%{link}' target='_blank'>official downloads page.</a>"
p3: '2. Install the printer drivers required by your operating system.'
p4: '3. Allow SciNote to connect to your Zebra printers.'
p5: 'Make sure that Zebra Connect shows the printer status as Connected.'
general_html: "Make sure your Zebra printer model is supported by Zebra Browser print technology on the official Zebra page: <a href='%{link}' target='_blank'>official Browser print page.</a>"
contact_html: "For more detailed instructions please check the <a href='%{link_blog}' target='_blank'>SciNote blog post</a> and <a href='%{link_zebra_support}' target='_blank'>Zebra printer support.</a>"
usb:
header: 'Connect a Zebra printer via USB cable'
p1: 'Make sure your Zebra printer is connected to power, turned on, and connected to the computer by USB cable.'
p2_html: "In order to print labels from SciNote, you need to download and install the Zebra Browser Print application according to your operating system: <a href='%{link}' target='_blank'>official downloads page.</a>. During installation, you might be prompted to install a specific Zebra printer driver."
p3: 'Update printers with the “Update printers” option on the right side of this SciNote screen.'
p4: 'Your Zebra printer should now be listed in SciNote.'
p5: 'Go to inventories, select a label template and start printing.'
network:
header: 'Connect a Zebra printer via network (LAN or WiFi)'
disclaimer: 'Some Zebra printers support connection via LAN or WiFi network. Check your printer documentation or official Zebra product page for this information.'
p1: 'Make sure your Zebra printer is connected to power and turned on.'
p2: 'Make sure your computer and Zebra printer are connected to the local network (by LAN or Wi-fi).'
p3_html: "In order to print labels from SciNote, you need to download the Zebra Browser Print application according to your operating system: <a href='%{link}' target='_blank'>official downloads page.</a>"
p4: 'Install the Zebra Browser Print application.'
p5: 'Open the Zebra Browser Print application and set the IP address and Port number of the printer. The printer IP address should be set as “Static” (you might need to contact your IT administrator for help).'
p6: 'Update printers with the “Update printers” option on the right side of this SciNote screen.'
p7: 'Your Zebra printer should now be listed in SciNote.'
p8: 'Go to inventories, set the label content, and start printing.'
settings: "Settings"
api_key_label: "API key"
api_key_warning: "API key change will lead to printer list refresh"

View file

@ -12,6 +12,8 @@ class MigrateSharedRepositoriesToUserAssignments < ActiveRecord::Migration[6.1]
TeamRepository.where(permission_level: %i(shared_read shared_write))
.preload(:team, :repository)
.find_each do |team_repository|
next if team_repository.repository.blank?
team_repository.team
.user_assignments
.preload(:user, :user_role)