thecore_print_commons 2.1.6 → 2.3.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: 9ea66f408d04dee9a18484a617f170c16ca1e74ce5011b87b2063b25cfd86c0b
4
- data.tar.gz: 85566448eaa20b0601a4b82e17f5d668bfefdb1e3b565c099d91bf066e463228
3
+ metadata.gz: 0a660e7e19c51f70f096e2b7692f9e32fa0ff49fb308bc9436ca8d6e4179fc7a
4
+ data.tar.gz: 881571a78ffdd8a223c292ff34321be4fe9c90e25144db74980c3e915bbce5af
5
5
  SHA512:
6
- metadata.gz: a4ee226bad981af3220ba0eb1dda3a4699c1967c45278a2e18fccfdca5494bbcced4a0f6f0cedaa608badb5702db4164bbddc9cfd23989c80df9a2ac9c84606a
7
- data.tar.gz: 4abcbc5eea0f199b71696b2075ef3b23c4af111c1d9d51bb2c636fa7928f302f860c4494212dbb74def14d89e50713fb33c6cbd09d738dd73a3c3af78aaf4d43
6
+ metadata.gz: 1fd987aab9e01e8e6dc24330cb9ffb21483677721e4c2098ab01ef5824811ddbda2a589663815fba799e3d54d369cdca4769ebdf53d5b2bfbd48c683993e1f4b
7
+ data.tar.gz: 18b8d864e56936271a2a44798ae9cf33a8fce903a52e7c6005ac9447be3d9d1ad1bedcae54fd79c9164188e10790a925a506996b5f265d712650454477b342d8
@@ -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
 
@@ -6,8 +6,8 @@ module RailsAdmin::Printer
6
6
  navigation_label I18n.t("admin.settings.label")
7
7
  navigation_icon 'fa fa-print'
8
8
 
9
- field :print_template
10
9
  field :name
10
+ field :print_template
11
11
  field :ip
12
12
  field :port do
13
13
  default_value do
@@ -15,9 +15,18 @@ module RailsAdmin::Printer
15
15
  end
16
16
  end
17
17
  field :default, :toggle
18
- field :temperature
19
- field :description
20
- field :online? do
18
+
19
+ show do
20
+ field :temperature
21
+ field :description
22
+ end
23
+
24
+ edit do
25
+ field :temperature
26
+ field :description
27
+ end
28
+
29
+ field :is_online do
21
30
  read_only true
22
31
  formatted_value do # used in form views
23
32
  (value ? "<strong style='color:green'>👍</strong>" : "<strong style='color:red'>👎</strong>").html_safe
@@ -31,15 +40,6 @@ module RailsAdmin::Printer
31
40
  value ? "OK" : "KO" # used in exports, where no html/data is allowed
32
41
  end
33
42
  end
34
-
35
- list do
36
- configure :description do
37
- visible false
38
- end
39
- configure :temperature do
40
- visible false
41
- end
42
- end
43
43
  end
44
44
  end
45
45
  end
@@ -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
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.6
4
+ version: 2.3.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: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.2'
27
27
  description: Thecorized thecore_print_commons full description.
28
28
  email:
29
29
  - gabriele.tassoni@gmail.com