thecore_ui_commons 2.2.1 → 2.2.7

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: 22fc1b731dd63b862e6e6f9a9f16c34bcb21618908c5c5d2b12590b022e348c3
4
- data.tar.gz: 459c1dbc2745ab0d0f7a9335b5612a878eb254ae788eecc95a423783eb3c3bf0
3
+ metadata.gz: 1773c485e9a7cc05938d28da606198382b7070dd18df29b233e6b77e58f2ded7
4
+ data.tar.gz: 5204a76b9aaf067feef9e06bc23e1980888ad099331fba90d647516d0ba82e83
5
5
  SHA512:
6
- metadata.gz: e6c971bb19426bad1792434f12454b2b67581734a2eb251a8c6268df0d5485ab193f5032670d2b4e7804a9e1171c4729e6828d447f6d143acb11362c8b29a61e
7
- data.tar.gz: 51ec4751e96c3174318626be339d9add75a259880ebf15e1671e8c7c318492684550da7aea0f277d594e1211ba8ebeec453a9683c894109c532389f7060ca140
6
+ metadata.gz: 14e4c40f8f9b144a4c04e6905457d074275491a557c150ccab410623216896affeb83141b159bfd80523274b3ed7519f71aad92ed69fb5a984f2bb8fbc82c6eb
7
+ data.tar.gz: e145a22345c62517201c2cbf8ac86598e7cc760189ae034438646809368413238663f31be2e7c3363d0c5e921ed2027971ca9975d411034d53eb6d621c9e46bc
@@ -16,5 +16,6 @@
16
16
  "theme_color": "#3b4e59",
17
17
  "background_color": "#3b4e59",
18
18
  "orientation": "portrait",
19
- "display": "standalone"
19
+ "display": "standalone",
20
+ "optional_permissions": ["clipboardWrite", "clipboardRead"]
20
21
  }
@@ -0,0 +1,131 @@
1
+ <%
2
+ =begin%>
3
+ Call using, for example:
4
+ <%=render "thecore_utils/drag_drop_uploader", target: "drop-zone", file_upload_desc: I18n.t(:file_upload), file_upload_sub: I18n.t(:file_upload_subtitle, extensions: exts), url: rails_admin.send("#{action_name}_path")%>
5
+
6
+ All the parameters are mandatory:
7
+ - target (The HTML element which will inherid the D&D functionality)
8
+ - file_upload_desc (Description of the upload functionality)
9
+ - file_upload_sub (Subtitle to the description -> A space where to put extra info)
10
+ - url (the action to perform async when files are dropped on the element.)
11
+ <%
12
+ =end%>
13
+
14
+ <style>
15
+ .upload-drop-zone {
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ height: 200px;
20
+ border-width: 2px;
21
+ /* margin-bottom: 20px; */
22
+ color: #bbb;
23
+ border-style: dashed;
24
+ border-color: #ccc;
25
+ /* line-height: 200px; */
26
+ text-align: center
27
+ }
28
+ .upload-drop-zone i {
29
+ font-size: 8em
30
+ }
31
+
32
+ .upload-drop-zone.drop {
33
+ color: #222;
34
+ border-color: #222;
35
+ }
36
+
37
+ .upload-drop-zone.disabledDnD {
38
+ background-color: darkred;
39
+ color: white;
40
+ }
41
+ </style>
42
+
43
+ <div class="panel panel-default">
44
+ <div class="panel-heading">
45
+ <strong><%=file_upload_desc%></strong>
46
+ <small><%=file_upload_sub%></small>
47
+ <div class="pull-right" id="<%=target%>-upload-drop-zone-feedback">
48
+
49
+ </div>
50
+ </div>
51
+ <div class="panel-body">
52
+
53
+ <!-- Drop Zone -->
54
+ <div class="upload-drop-zone" id="<%=target%>">
55
+
56
+ </div>
57
+
58
+ <div id="upload-status">
59
+ </div>
60
+ </div>
61
+ </div>
62
+
63
+ <script>
64
+ // Enable D&D beahviour
65
+ function dndOn() {
66
+ $('#<%=target%>').on("drop", this.ondrop);
67
+ $('#<%=target%>').on("dragover", this.ondragover);
68
+ $('#<%=target%>').on("dragleave", this.ondragleave);
69
+ $('#<%=target%>').removeClass('disabledDnD');
70
+ $('#<%=target%>').html('<div><i class="fa fa-cloud-upload"></i><br/><span><%=I18n.t :please_drag_and_drop_here%></span></div>')
71
+ }
72
+ // Disable D&D beahviour
73
+ function dndOff() {
74
+ $('#<%=target%>').addClass('disabledDnD');
75
+ $('#<%=target%>').html('<div><i class="fa fa-ban"></i><br/><span><%=I18n.t :dont_leve_or_drag_here%></span></div>')
76
+ $('#<%=target%>').off("drop", this.ondrop);
77
+ $('#<%=target%>').off("dragover", this.ondragover);
78
+ $('#<%=target%>').off("dragleave", this.ondragleave);
79
+ }
80
+ var fileupload = {
81
+ init: dndOn,
82
+
83
+ beforeSuccess: function(){
84
+ console.log("beforeSuccess");
85
+ },
86
+
87
+ ondrop: function (e) {
88
+ // console.log(e)
89
+ e.preventDefault();
90
+ dndOff();
91
+ $('#<%=target%>').removeClass('drop');
92
+ $("#<%=target%>-upload-drop-zone-feedback").html("<i class='fa fa-spinner fa-spin '></i>");
93
+
94
+ // console.log(e.dataTransfer.files);
95
+ var fd = new FormData();
96
+ $.each(e.originalEvent.dataTransfer.files, function (i, file) {
97
+ fd.append('files[]', file);
98
+ });
99
+
100
+ $.ajax({
101
+ url: '<%=url%>',
102
+ data: fd,
103
+ processData: false,
104
+ contentType: false,
105
+ type: 'POST',
106
+ success: function () {
107
+ fileupload.beforeSuccess();
108
+ $("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-check-square-o" aria-hidden="true"></i>').delay(3000).fadeOut(400));
109
+ fileupload.init();
110
+ },
111
+ error: function () {
112
+ $("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-exclamation-circle" aria-hidden="true"></i>').delay(3000).fadeOut(400));
113
+ fileupload.init();
114
+ }
115
+ });
116
+ // startUpload(e.dataTransfer.files)
117
+ },
118
+
119
+ ondragover: function () {
120
+ $('#<%=target%>').addClass('drop');
121
+ return false;
122
+ },
123
+
124
+ ondragleave: function () {
125
+ $('#<%=target%>').removeClass('drop');
126
+ return false;
127
+ }
128
+
129
+ };
130
+ fileupload.init();
131
+ </script>
@@ -1,4 +1,10 @@
1
1
  en:
2
+ file_upload: Upload description, please add a translation for the element called file_upload in your translation file.
3
+ file_upload_subtitle: Descrizione aggiuntiva, prego aggiungere una traduzione per file_upload_subtitle al tuo file delle traduzioni.
4
+ dont_leve_or_drag_here: Uploading, please don't leave this page or Drag & Drop other files.
5
+ loading: Caricamento
6
+ please_drag_and_drop_here: Drag and Drop here the files to import
7
+ import_success: Import Successful!
2
8
  current_user: Current User
3
9
  devise:
4
10
  sessions:
@@ -1,4 +1,11 @@
1
1
  it:
2
+ file_upload: Descrizione della procedura, prego aggiungere una traduzione per file_upload al tuo file delle traduzioni.
3
+ file_upload_subtitle: Descrizione aggiuntiva, prego aggiungere una traduzione per file_upload_subtitle al tuo file delle traduzioni.
4
+ dont_leve_or_drag_here: Upload in corso, si prega di non lasciare la pagina o trascinare qui altri file.
5
+ loading: Caricamento
6
+ run_import: Forza l'importazione
7
+ please_drag_and_drop_here: Trascinare qui i file da importare
8
+ import_success: Importazione completata con successo
2
9
  current_user: Utente corrente
3
10
  hello: "Ciao Mondo"
4
11
  dashboard: "Pannello di controllo"
@@ -0,0 +1,6 @@
1
+ class AddSettingsForUploader < ActiveRecord::Migration[6.0]
2
+ def change
3
+ Settings.ns(:importer).import_from_folder = "tmp/imports"
4
+ Settings.ns(:importer).extension = "txt"
5
+ end
6
+ end
@@ -3,6 +3,8 @@ require 'thecore_background_jobs' # This brings backend commons also.
3
3
  require 'serviceworker-rails'
4
4
  require "groupdate"
5
5
  require "apexcharts"
6
+ require "poppler"
7
+ require "image_processing"
6
8
 
7
9
  require 'concerns/thecore_ui_commons_user'
8
10
 
@@ -13,4 +15,20 @@ require "thecore_ui_commons/engine"
13
15
 
14
16
  module ThecoreUiCommons
15
17
  # Your code goes here...
18
+
19
+ def self.save_files files
20
+ # Rails.logger.debug "AAAAAAAAAAA: POST?"
21
+ files.each do |pic|
22
+ # Rails.logger.debug "AAAAAAAAAAA: EACH PIC: #{pic.inspect}"
23
+ upload_dir = Rails.root.join(Settings.ns(:importer).import_from_folder, 'uploads')
24
+ FileUtils.mkdir_p upload_dir
25
+ # Rails.logger.debug "AAAAAAAAAAA: Fatto MKDIR di #{upload_dir}"
26
+ file_to_upload = Rails.root.join(upload_dir, "uploaded-#{Time.now.strftime("%Y%m%d%H%M%S%L")}-#{pic.original_filename}")
27
+ # Rails.logger.debug "AAAAAAAAAAA: File da uploadare #{file_to_upload}"
28
+ File.open(file_to_upload, 'wb') do |file|
29
+ # Rails.logger.debug "AAAAAAAAAAAAAAAAAA: Dentro alla scrittura"
30
+ file.write(pic.read)
31
+ end if Regexp.new("\\.#{Settings.ns(:importer).extension.gsub(/ +/, "").split(",").join("|\\.")}$").match? pic.original_filename
32
+ end
33
+ end
16
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: poppler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: image_processing
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
69
97
  description: Engine to serve configurations and rails module useful for all the UIs.
70
98
  email:
71
99
  - gabriele.tassoni@gmail.com
@@ -125,6 +153,7 @@ files:
125
153
  - app/views/layouts/mailer.html.erb
126
154
  - app/views/layouts/mailer.text.erb
127
155
  - app/views/layouts/thecore.html.erb
156
+ - app/views/thecore_utils/_drag_drop_uploader.html.erb
128
157
  - config/initializers/charts_helper.rb
129
158
  - config/initializers/thecore_ui_commons_application_config.rb
130
159
  - config/initializers/thecore_ui_commons_helper.rb
@@ -137,6 +166,7 @@ files:
137
166
  - config/routes.rb
138
167
  - db/migrate/20200515070620_add_username_to_user.rb
139
168
  - db/migrate/20200515132932_add_rememberable_to_user.rb
169
+ - db/migrate/20210208142646_add_settings_for_uploader.rb
140
170
  - lib/concerns/thecore_ui_commons_user.rb
141
171
  - lib/tasks/thecore_ui_commons_tasks.rake
142
172
  - lib/thecore_ui_commons.rb