thecore_print_commons 3.0.11 → 3.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: d5f16b050cfa712b39e2cc9076c5ed143b523afb76791429ad6f1ba4ecf95c9d
4
- data.tar.gz: da7fe0dddc00664ec691485ea364a8c54f102872f0fa1dedccfbc307af02107b
3
+ metadata.gz: 45b945b4a1bbc4ea1b0b766a1a13933b237aa674e106d12ccfdb86d78d8ad724
4
+ data.tar.gz: ab717f07bfd3a4bc69bba112f080550774901954fd96b5d7f73673f62a1e2aea
5
5
  SHA512:
6
- metadata.gz: f112fc2de4f0d55e60d7754dd0d2a7372f8757cd60ebc5014c2b3fdbd91cc38e5d9da83ac34ecdbd99993269f5ced2499b9b7e0cac61a628f8d8ae4e151d2195
7
- data.tar.gz: 26b3fc9ca991300030aa00234b4a49649f6b4b6ffeec32b62fef9cbe7f09eb44f8a1652901833e09d1dd08035da225682a26047f1ea1d753a9ed4d28ce3840eb
6
+ metadata.gz: f789ff4f87cac5aeadb901e21d00f4fd6cd9c2bfc0955d5ed5780c5d8905e67ebec26fa4e693e9cb6bd485955ae265e7d440906c9a118381c4f6cb4740ffee79
7
+ data.tar.gz: 715307e7640aaca4c78c9966bd5fcba6fb7dbb853b16bd563f087e7621ad696690ffef94930ddfda882bd2d086d455242e06aa33b3ed02db5dc1830ff52a1c5c
data/README.md CHANGED
@@ -1,73 +1 @@
1
- # ThecorePrintCommons
2
- This gem brings cups interaction into Thecore apps, allowing printing on all configured printers (be they local or remote), using cups' standardized interface.
3
-
4
- ## Usage
5
- Add all the needed printers and be sure you can print on them.
6
- to add printers to CUPS you can use http://localhost:631, but before it could be bettere to relax a bit
7
- the authentications needed for adding printers, to do so, please edit /etc/cups/cupsd.conf and replace all the Authentication directives with Authentication None.
8
-
9
- When you enter the printers section and add a new printer in Thecore backend, you'll just see available (through cups) printers and you can just select one of these.
10
-
11
- Otherwise, if you prefere to go the shell way, you can add it using lpadmin, say you'd like to install a samba printer:
12
-
13
- First of all add current user to lpadmin group:
14
-
15
- ```shell
16
- sudo apt install cups libcups2-dev gridsite-clients smbclient
17
- sudo adduser $(whoami) lpadmin
18
- newgrp lpadmin
19
- ```
20
-
21
- Then you can use lpadmin commands without sudo (example for samba shared printer, must be adapted for other protocols):
22
-
23
- ```shell
24
- echo "Printer label:"; read PRINTERLABEL;
25
- echo "Printer workgroup or Domain:";read WORKGROUP;
26
- echo "Printer ip or netbios address:";read SHARE_IP_ADDRESS_OR_NETBIOS_NAME;
27
- echo "Printer share name:";read SHARENAME;
28
- echo "Printer share username:"; read USERNAME;
29
- echo "Printer share password:"; read PASSWORD;
30
- lpadmin -p "$PRINTERLABEL" -E -v "beh://1/1/1/smb://$(urlencode $USERNAME):$(urlencode $PASSWORD)@$(urlencode $WORKGROUP)/$(urlencode $SHARE_IP_ADDRESS_OR_NETBIOS_NAME)/$(urlencode $SHARENAME)" -m everywhere
31
- ```
32
-
33
- To list shares on that remote machine:
34
-
35
- ```shell
36
- smbclient -L $(urlencode $SHARE_IP_ADDRESS_OR_NETBIOS_NAME) -U $(urlencode $USERNAME)%$(urlencode $PASSWORD) -W $(urlencode $WORKGROUP)
37
- ```
38
-
39
- To test from shell, prior to start using the rails ui:
40
-
41
- ```shell
42
- echo "Hello" > testprint
43
- lp -d "$PRINTERLABEL" -o raw testprint
44
- ```
45
-
46
- ## Installation
47
- First of all, please install libcups2-dev:
48
-
49
- ```shell
50
- sudo apt install libcups2-dev
51
- ```
52
-
53
- Add this line to your application's Gemfile:
54
-
55
- ```ruby
56
- gem 'thecore_print_commons'
57
- ```
58
-
59
- And then execute:
60
- ```bash
61
- $ bundle
62
- ```
63
-
64
- Or install it yourself as:
65
- ```bash
66
- $ gem install thecore_print_commons
67
- ```
68
-
69
- ## Contributing
70
- Contribution directions go here.
71
-
72
- ## License
73
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ This is part of Thecore framework: https://github.com/gabrieletassoni/thecore/tree/release/3
@@ -28,23 +28,5 @@ module Api::Printer
28
28
  # def self.custom_action_test id=nil, params=nil
29
29
  # { test: [ :first, :second, :third ], id: id, params: params}
30
30
  # end
31
-
32
- def self.custom_action_print_single_barcode params
33
- # Example Usage:
34
- # item = ::Item.joins(:projects).where(projects: {id: params[:order_id].to_i}).first
35
- # printer = ::Printer.where(supplier_id: current_user.supplier_id, default: true).first
36
- # single_text = "#{printer.print_template.template.gsub("%DESCRIPTION%", item.description)}"
37
- # text = single_text * params[:quantity].to_i
38
- # # Preso l'ordine mi recupero l'item e ne stampo la quantità richiesta
39
- # ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
40
-
41
- printer = Printer.find(params[:id])
42
- result = base_template = printer.print_template.template.dup
43
- result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
44
- base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
45
- end if printer.print_template.translation_matrix.present?
46
- ::PrintWorker.perform_async(printer.ip, printer.port, result)
47
- return { info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }, 200
48
- end
49
31
  end
50
32
  end
@@ -0,0 +1,60 @@
1
+ class Endpoints::Printer < NonCrudEndpoints
2
+ self.desc :print_single_barcode, {
3
+ post: {
4
+ summary: "Print a single barcode",
5
+ description: "Print a single barcode",
6
+ operationId: "print_single_barcode",
7
+ tags: ["Printer"],
8
+ requestBody: {
9
+ required: true,
10
+ content: {
11
+ "application/json": {
12
+ schema: {
13
+ type: "object",
14
+ properties: {
15
+ id: { type: "integer" },
16
+ quantity: { type: "integer" },
17
+ description: { type: "string" },
18
+ location: { type: "string" },
19
+ serial: { type: "string" }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ },
25
+ responses: {
26
+ 200 => {
27
+ description: "The openAPI json schema for this action",
28
+ content: {
29
+ "application/json": {
30
+ schema: {
31
+ type: "object",
32
+ additionalProperties: true
33
+ }
34
+ }
35
+ }
36
+ },
37
+ 501 => {
38
+ error: :string,
39
+ }
40
+ }
41
+ }
42
+ }
43
+ def print_single_barcode params
44
+ # Example Usage:
45
+ # item = ::Item.joins(:projects).where(projects: {id: params[:order_id].to_i}).first
46
+ # printer = ::Printer.where(supplier_id: current_user.supplier_id, default: true).first
47
+ # single_text = "#{printer.print_template.template.gsub("%DESCRIPTION%", item.description)}"
48
+ # text = single_text * params[:quantity].to_i
49
+ # # Preso l'ordine mi recupero l'item e ne stampo la quantità richiesta
50
+ # ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
51
+
52
+ printer = Printer.find(params[:id])
53
+ result = base_template = printer.print_template.template.dup
54
+ result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
55
+ base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
56
+ end if printer.print_template.translation_matrix.present?
57
+ ::PrintWorker.perform_async(printer.ip, printer.port, result)
58
+ return { info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }, 200
59
+ end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module ThecorePrintCommons
2
- VERSION = "3.0.11".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
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: 3.0.11
4
+ version: 3.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: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2024-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs
@@ -39,6 +39,7 @@ files:
39
39
  - app/models/concerns/api/printer.rb
40
40
  - app/models/concerns/rails_admin/print_template.rb
41
41
  - app/models/concerns/rails_admin/printer.rb
42
+ - app/models/endpoints/printer.rb
42
43
  - app/models/print_template.rb
43
44
  - app/models/printer.rb
44
45
  - app/workers/print_worker.rb
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  - !ruby/object:Gem::Version
81
82
  version: '0'
82
83
  requirements: []
83
- rubygems_version: 3.4.10
84
+ rubygems_version: 3.5.3
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: Thecorized thecore_print_commons