thecore_print_commons 2.0.7 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86c74b9cadc64d8b0f75bd0b67364a79c84117947cf4729f993d4734bd0a9838
4
- data.tar.gz: 4ba907d65c9d61530f5da4a26669f686705acf67e62421b7f2a79bec449ed4d3
3
+ metadata.gz: f4ade4721428be9aee5378e3643e7bcc47f5e518b6ff46e4b88839fab6c8ce57
4
+ data.tar.gz: c1051c17921d2685ce61c3896dfb2d42bd2e7317ab28596d7f88bb1084bacb2a
5
5
  SHA512:
6
- metadata.gz: 5496efffaa44df68348d5a8622bde49880f133990dafd1f59716c21f7f7900830d1a8e4c1c7a74fb3372ded750e91fcc709d6dfb8442219f8754db9912d25910
7
- data.tar.gz: e2ca1d4b65cbcd51ab76488e38bbc53346266dff3aec30c252a53bb598e3e05f6a34ae250835098408723c492d79673da85a176a630fc19916b66a096e29e3be
6
+ metadata.gz: a86bc5fa0a85bada3886445801153b70b96bdd0e9786b491a482a03497dbbfb941d3f08c491d34fb9e55abdbe2c3b5e6d7c5332463667486a3a4269d3eecdc34
7
+ data.tar.gz: 8aab7a93e08509e18ba2859049190b4e790f610be272746b2622eca01fced26cfb58facafbae37206ec336789e009c4261d2fde01ad2e86080bf0fb8865be236
@@ -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
@@ -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,26 @@ 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
+ s = TCPSocket.new(self.ip, 9100)
59
+ s.puts("~hs")
60
+ s.close
61
+ rescue
62
+ return false
63
+ end
64
+ true
65
+ end
66
+
56
67
 
57
68
  # private
58
69
  # 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.0.7
4
+ version: 2.1.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-08 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs