thecore_print_commons 3.0.11 → 3.1.1

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: d5f16b050cfa712b39e2cc9076c5ed143b523afb76791429ad6f1ba4ecf95c9d
4
- data.tar.gz: da7fe0dddc00664ec691485ea364a8c54f102872f0fa1dedccfbc307af02107b
3
+ metadata.gz: ac2b967fbaf1b977a15a044f1657a801f86ab557aca189db12f534e710a34fe1
4
+ data.tar.gz: 1b5b08247a48a443751dd9c6ce053f5b1412c445c58773240e9823aa90421cc7
5
5
  SHA512:
6
- metadata.gz: f112fc2de4f0d55e60d7754dd0d2a7372f8757cd60ebc5014c2b3fdbd91cc38e5d9da83ac34ecdbd99993269f5ced2499b9b7e0cac61a628f8d8ae4e151d2195
7
- data.tar.gz: 26b3fc9ca991300030aa00234b4a49649f6b4b6ffeec32b62fef9cbe7f09eb44f8a1652901833e09d1dd08035da225682a26047f1ea1d753a9ed4d28ce3840eb
6
+ metadata.gz: 959ae6116fc7d89e8d9d6d5729771d3206c5637e80b0e9eeaba609a20200d739d69c27ecdef1c5abe0f7bd0d9b0b766ff8a3fce96b46a71fe9ede329f17f36a7
7
+ data.tar.gz: 7684c869c5ff3143fc71cd3a0dea6f055c18348492b88215619c93cb5bb96d824b7268a09ccd91bbca37584ad0217b8db32d28b1044fc87b4f85c9d57e10bf8e
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,62 @@
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
+ properties: {
33
+ info: { type: "string" }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ },
39
+ 501 => {
40
+ error: :string,
41
+ }
42
+ }
43
+ }
44
+ }
45
+ def print_single_barcode params
46
+ # Example Usage:
47
+ # item = ::Item.joins(:projects).where(projects: {id: params[:order_id].to_i}).first
48
+ # printer = ::Printer.where(supplier_id: current_user.supplier_id, default: true).first
49
+ # single_text = "#{printer.print_template.template.gsub("%DESCRIPTION%", item.description)}"
50
+ # text = single_text * params[:quantity].to_i
51
+ # # Preso l'ordine mi recupero l'item e ne stampo la quantità richiesta
52
+ # ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
53
+
54
+ printer = Printer.find(params[:id])
55
+ result = base_template = printer.print_template.template.dup
56
+ result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
57
+ base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
58
+ end if printer.print_template.translation_matrix.present?
59
+ ::PrintWorker.perform_async(printer.ip, printer.port, result)
60
+ return { info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }, 200
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module ThecorePrintCommons
2
- VERSION = "3.0.11".freeze
2
+ VERSION = "3.1.1".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.1
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