thecore_print_commons 2.1.4 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e07a4722d0b75bc1c0f707a8281560c69e92f6bee16ecb99ccd4a8df7aef9b9
4
- data.tar.gz: 521f40328804ab042452a217bf55072aafe9943c884d51b80f5ae2c04f1958e8
3
+ metadata.gz: 670b8b4f153ad70642a153811f71d2ce797e697ddc7e5af3cbc915739954abb4
4
+ data.tar.gz: daed3ca480be8480a89d93f4f6b494ace07a93224cee549d33c0941ec00a6431
5
5
  SHA512:
6
- metadata.gz: 2057d116231dc519050992601dd15e2210e7c791427d765b5c8f29c06e12a72b3a3d87d43c70df0a8495eb32afa2678cd9ced72b9f7c3a3e294e8935d383134e
7
- data.tar.gz: 754891ac9310f16af5c3f1bd75a341893ae3764e76971d4bb546b4ec77b78847c9834816915fc0ee2db08007f63e955a23db51bc9c13655ac82d7f6c6694220b
6
+ metadata.gz: dd44e8214bddfa87012ec35e728b623eb70c8b21478670175c2f25a627a5cc246d38d5f3bb43b1e2ad5cd5252cdd1bcfdf4564d609d5241778416f479efe4b49
7
+ data.tar.gz: 21d5bc33596daeef921285ea6828a5f660f50df7389c105ffc011ed4c61bc8375351277759e1811c420c1178e4b8955a25d202c99f8e8c330dd3614fd49d40d5
@@ -34,11 +34,14 @@ module Api::Printer
34
34
  # single_text = "#{printer.print_template.template.gsub("%DESCRIPTION%", item.description)}"
35
35
  # text = single_text * params[:quantity].to_i
36
36
  # # Preso l'ordine mi recupero l'item e ne stampo la quantità richiesta
37
- # ::PrintWorker.perform_async(printer.ip, text)
37
+ # ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
38
38
 
39
39
  printer = Printer.find(params[:id])
40
- text = printer.print_template.template.gsub(printer.print_template.translation_matrix.lines.first, params[:barcode])
41
- ::PrintWorker.perform_async(printer.ip, printer.port, text)
40
+ base_template = printer.print_template.template.dup
41
+ result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
42
+ base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
43
+ end
44
+ ::PrintWorker.perform_async(printer.ip, printer.port, result)
42
45
  { info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }
43
46
  end
44
47
 
@@ -17,7 +17,7 @@ module RailsAdmin::Printer
17
17
  field :default, :toggle
18
18
  field :temperature
19
19
  field :description
20
- field :online? do
20
+ field :is_online do
21
21
  read_only true
22
22
  formatted_value do # used in form views
23
23
  (value ? "<strong style='color:green'>👍</strong>" : "<strong style='color:red'>👎</strong>").html_safe
@@ -9,7 +9,7 @@ class Printer < ApplicationRecord
9
9
  validates :port, presence: true
10
10
  validates :print_template, presence: true
11
11
 
12
- def online?
12
+ def is_online
13
13
  begin
14
14
  Socket.tcp(self.ip, self.port, connect_timeout: 0.5).close
15
15
  rescue
@@ -2,7 +2,7 @@ require 'ipaddr'
2
2
  require 'socket'
3
3
  class PrintWorker
4
4
  include Sidekiq::Worker
5
- sidekiq_options retry: false
5
+ sidekiq_options retry: false, queue: "#{ENV["COMPOSE_PROJECT_NAME"]}_default"
6
6
 
7
7
  # ZPL print
8
8
  def perform ip, port, text
data/db/seeds.rb CHANGED
@@ -1,2 +1 @@
1
1
  puts "Loading ThecorePrintCommons seeds"
2
- Settings.ns(:printer_commons).cups_server = 'localhost'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_print_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs