thecore_print_commons 2.0.6 β 2.1.2
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 +4 -4
- data/app/models/concerns/api/printer.rb +3 -3
- data/app/models/concerns/rails_admin/printer.rb +17 -0
- data/app/models/printer.rb +15 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1b92c4037ed26563a1e1d0e5f25f227031ff4c0a8e53dc10f17eedb99b10f5
|
4
|
+
data.tar.gz: deacf2f9bbcd581b3b333aac24ed4e70dd257f86f5dad91adad804be6a9e245b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b8a1316816c8f56fc18b7e16044c97ae191c98f5f269c5839bf273e7ac6e031caf04e18b212184269f7511ff907759903d4b28f595b0bc10d86fe812e84497
|
7
|
+
data.tar.gz: 07e92ae60c6d391b40220e21e349bf14635b45e1fb2344c8008ac0c1dae72a5ddc4abd8407c5f2107ab3bf0d15b2c45389d5d24db2eea3382686f66c4e1ca4c5
|
@@ -27,7 +27,7 @@ module Api::Printer
|
|
27
27
|
# { test: [ :first, :second, :third ], id: id, params: params}
|
28
28
|
# end
|
29
29
|
|
30
|
-
def self.custom_action_print_single_barcode
|
30
|
+
def self.custom_action_print_single_barcode params
|
31
31
|
# Example Usage:
|
32
32
|
# item = ::Item.joins(:projects).where(projects: {id: params[:order_id].to_i}).first
|
33
33
|
# printer = ::Printer.where(supplier_id: current_user.supplier_id, default: true).first
|
@@ -36,8 +36,8 @@ module Api::Printer
|
|
36
36
|
# # Preso l'ordine mi recupero l'item e ne stampo la quantitΓ richiesta
|
37
37
|
# ::PrintWorker.perform_async(printer.ip, text)
|
38
38
|
|
39
|
-
printer = Printer.find(id)
|
40
|
-
text = printer.print_template.template.gsub(printer.print_template.translation_matrix.lines.first, barcode)
|
39
|
+
printer = Printer.find(params[:id])
|
40
|
+
text = printer.print_template.template.gsub(printer.print_template.translation_matrix.lines.first, params[:barcode])
|
41
41
|
::PrintWorker.perform_async(printer.ip, printer.port, text)
|
42
42
|
{ info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }
|
43
43
|
end
|
@@ -17,11 +17,28 @@ module RailsAdmin::Printer
|
|
17
17
|
field :default, :toggle
|
18
18
|
field :temperature
|
19
19
|
field :description
|
20
|
+
field :online? do
|
21
|
+
read_only true
|
22
|
+
formatted_value do # used in form views
|
23
|
+
(value ? "<strong style='color:green'>π</strong>" : "<strong style='color:red'>π</strong>").html_safe
|
24
|
+
end
|
25
|
+
|
26
|
+
pretty_value do # used in list view columns and show views, defaults to formatted_value for non-association fields
|
27
|
+
(value ? "<strong style='color:green'>π</strong>" : "<strong style='color:red'>π</strong>").html_safe
|
28
|
+
end
|
29
|
+
|
30
|
+
export_value do
|
31
|
+
value ? "OK" : "KO" # used in exports, where no html/data is allowed
|
32
|
+
end
|
33
|
+
end
|
20
34
|
|
21
35
|
list do
|
22
36
|
configure :description do
|
23
37
|
visible false
|
24
38
|
end
|
39
|
+
configure :temperature do
|
40
|
+
visible false
|
41
|
+
end
|
25
42
|
end
|
26
43
|
end
|
27
44
|
end
|
data/app/models/printer.rb
CHANGED
@@ -2,11 +2,11 @@ class Printer < ApplicationRecord
|
|
2
2
|
include Api::Printer
|
3
3
|
include RailsAdmin::Printer
|
4
4
|
#serialize :translation, Hash
|
5
|
-
|
5
|
+
|
6
6
|
# before_save :check_if_unique_default
|
7
7
|
# validates :qty, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
8
8
|
# validates :translation, presence: true
|
9
|
-
|
9
|
+
|
10
10
|
# def template_enum
|
11
11
|
# PrintTemplate.descendants
|
12
12
|
# end
|
@@ -32,7 +32,7 @@ class Printer < ApplicationRecord
|
|
32
32
|
# def self.assigned_to section
|
33
33
|
# where(used_in: (USED.index(section.to_sym) + 1))
|
34
34
|
# end
|
35
|
-
|
35
|
+
|
36
36
|
# Usable with CUPS (STUB)
|
37
37
|
# def ip_enum
|
38
38
|
# # Getting from CUPS the list of configured printers
|
@@ -44,15 +44,24 @@ class Printer < ApplicationRecord
|
|
44
44
|
# CupsPrinter.get_all_printer_names hostname: Settings.ns(:printer_commons).cups_server
|
45
45
|
# end
|
46
46
|
# end
|
47
|
-
|
47
|
+
|
48
48
|
belongs_to :print_template, inverse_of: :printers
|
49
49
|
has_many :print_jobs, dependent: :destroy, inverse_of: :printer
|
50
|
-
|
50
|
+
|
51
51
|
validates :name, presence: true
|
52
52
|
validates :ip, presence: true
|
53
53
|
validates :port, presence: true
|
54
54
|
validates :print_template, presence: true
|
55
|
-
|
55
|
+
|
56
|
+
def online?
|
57
|
+
begin
|
58
|
+
Socket.tcp(self.ip, 9100, connect_timeout: 0.5).close
|
59
|
+
rescue
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
56
65
|
|
57
66
|
# private
|
58
67
|
# def check_if_unique_default
|
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.
|
4
|
+
version: 2.1.2
|
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-
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_background_jobs
|