thecore_ui_commons 2.2.3 → 2.2.8

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: 9f924dcad192b5d24f2fc3a0be94d15e912cb941b5b0dfb4ce7cba3882874e2b
4
- data.tar.gz: 38f19553b375388a0b60a95a43fe9d919088a42def92988beac0a64120f98053
3
+ metadata.gz: e968ab13046b26d5d3c71151ba7b8c68536170cd56d4d6aea5eb3d120943fc86
4
+ data.tar.gz: e4fb2f50a0262fdbc9db8b1a36fc0d731fc92ce56dd0b69d406f6a105a604bdb
5
5
  SHA512:
6
- metadata.gz: 5219728df9a71e358b3c40c102413c34cd785875e0a92ee022f4d7968ae32ec685110480359a8a914721048adfa6a28cce9dec69bf44de26523117d9164f9321
7
- data.tar.gz: 902b74b25da44917554def41bcdadb41dfc979784233b29ab11e99c30c31c0621678cf9a46b3770b2a48c3b7c8cc7e5ffd09c3ce3dc00e778160f2d7d8fa91b3
6
+ metadata.gz: ec412403fe573000296f229165db664262875df8d778fd02732b9e1045491017bc7a4662f05f57bbc538fb0b81f473f07d527a1ffc5fc5549a5681995d5384e9
7
+ data.tar.gz: 62369a802b70d31e16cc2dc666fcf909f4fd226724bee6132023417cdfc37f88459b5e3d415661e155e354e88d0297aa42945bee7f43ed93d856d37488ad7bfa
@@ -31,7 +31,7 @@
31
31
  <div class="col-md-4 col-md-offset-4 text-center">
32
32
  <img class="main-menu-app-logo" style="width: 25%; max-width: 152px" src="<%= image_url('logo.png') %>"/>
33
33
  </div>
34
- <%- unless flash.empty? %>
34
+ <%- unless flash.blank? %>
35
35
  <div class="col-md-4 col-md-offset-4" style="margin-top: 1em;">
36
36
  <%= render partial: 'shared/flash' %>
37
37
  </div>
@@ -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,10 @@ require 'thecore_background_jobs' # This brings backend commons also.
3
3
  require 'serviceworker-rails'
4
4
  require "groupdate"
5
5
  require "apexcharts"
6
+ require "gtk3"
7
+ require "cairo"
8
+ require "poppler"
9
+ require "image_processing"
6
10
 
7
11
  require 'concerns/thecore_ui_commons_user'
8
12
 
@@ -13,4 +17,20 @@ require "thecore_ui_commons/engine"
13
17
 
14
18
  module ThecoreUiCommons
15
19
  # Your code goes here...
20
+
21
+ def self.save_files files
22
+ # Rails.logger.debug "AAAAAAAAAAA: POST?"
23
+ files.each do |pic|
24
+ # Rails.logger.debug "AAAAAAAAAAA: EACH PIC: #{pic.inspect}"
25
+ upload_dir = Rails.root.join(Settings.ns(:importer).import_from_folder, 'uploads')
26
+ FileUtils.mkdir_p upload_dir
27
+ # Rails.logger.debug "AAAAAAAAAAA: Fatto MKDIR di #{upload_dir}"
28
+ file_to_upload = Rails.root.join(upload_dir, "uploaded-#{Time.now.strftime("%Y%m%d%H%M%S%L")}-#{pic.original_filename}")
29
+ # Rails.logger.debug "AAAAAAAAAAA: File da uploadare #{file_to_upload}"
30
+ File.open(file_to_upload, 'wb') do |file|
31
+ # Rails.logger.debug "AAAAAAAAAAAAAAAAAA: Dentro alla scrittura"
32
+ file.write(pic.read)
33
+ end if Regexp.new("\\.#{Settings.ns(:importer).extension.gsub(/ +/, "").split(",").join("|\\.")}$").match? pic.original_filename
34
+ end
35
+ end
16
36
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiCommons
2
- VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`.chomp}"
3
3
  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.3
4
+ version: 2.2.8
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-01-26 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs
@@ -66,6 +66,62 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gtk3
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: cairo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.17'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.17'
97
+ - !ruby/object:Gem::Dependency
98
+ name: poppler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: image_processing
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.2'
69
125
  description: Engine to serve configurations and rails module useful for all the UIs.
70
126
  email:
71
127
  - gabriele.tassoni@gmail.com
@@ -125,6 +181,7 @@ files:
125
181
  - app/views/layouts/mailer.html.erb
126
182
  - app/views/layouts/mailer.text.erb
127
183
  - app/views/layouts/thecore.html.erb
184
+ - app/views/thecore_utils/_drag_drop_uploader.html.erb
128
185
  - config/initializers/charts_helper.rb
129
186
  - config/initializers/thecore_ui_commons_application_config.rb
130
187
  - config/initializers/thecore_ui_commons_helper.rb
@@ -137,6 +194,7 @@ files:
137
194
  - config/routes.rb
138
195
  - db/migrate/20200515070620_add_username_to_user.rb
139
196
  - db/migrate/20200515132932_add_rememberable_to_user.rb
197
+ - db/migrate/20210208142646_add_settings_for_uploader.rb
140
198
  - lib/concerns/thecore_ui_commons_user.rb
141
199
  - lib/tasks/thecore_ui_commons_tasks.rake
142
200
  - lib/thecore_ui_commons.rb