thecore_ui_commons 2.2.0 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/manifest.json +2 -1
- data/app/views/thecore_utils/_drag_drop_uploader.html.erb +110 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/it.yml +6 -0
- data/db/migrate/20210208142646_add_settings_for_uploader.rb +6 -0
- data/lib/thecore_ui_commons.rb +16 -0
- data/lib/thecore_ui_commons/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '044692e50388d2be1a07d5ecf256cb590bbaa227d78ad32e0885fc8859dac137'
|
4
|
+
data.tar.gz: 739c924a0eed89d69e51361edd060dee8b0af722565c21b09b3f07d55e18a05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea19b48bc818c37da1df3be6d1d230dc1f20f929e89953c597219f3eb2ded0c5ddc8bb7de724e8f426407f84b0c07c8f63b490eeafc9ef43ce331c9281322af
|
7
|
+
data.tar.gz: 9ba335b796d5e6fc25d52ab5e1704597b32108f575ae1c6027b31001aea02b0685405dafc75c1705e57c0086f9015218a45992af5dba64ec9c34d089eb28aeb2
|
@@ -0,0 +1,110 @@
|
|
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
|
+
/* layout.css Style */
|
16
|
+
.upload-drop-zone {
|
17
|
+
height: 200px;
|
18
|
+
border-width: 2px;
|
19
|
+
margin-bottom: 20px;
|
20
|
+
}
|
21
|
+
|
22
|
+
/* skin.css Style*/
|
23
|
+
.upload-drop-zone {
|
24
|
+
color: #ccc;
|
25
|
+
border-style: dashed;
|
26
|
+
border-color: #ccc;
|
27
|
+
line-height: 200px;
|
28
|
+
text-align: center
|
29
|
+
}
|
30
|
+
|
31
|
+
.upload-drop-zone.drop {
|
32
|
+
color: #222;
|
33
|
+
border-color: #222;
|
34
|
+
}
|
35
|
+
</style>
|
36
|
+
|
37
|
+
<div class="panel panel-default">
|
38
|
+
<div class="panel-heading">
|
39
|
+
<strong><%=file_upload_desc%></strong>
|
40
|
+
<small><%=file_upload_sub%></small>
|
41
|
+
<div class="pull-right" id="<%=target%>-upload-drop-zone-feedback">
|
42
|
+
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<div class="panel-body">
|
46
|
+
|
47
|
+
<!-- Drop Zone -->
|
48
|
+
<div class="upload-drop-zone" id="<%=target%>">
|
49
|
+
<%=I18n.t :please_drag_and_drop_here%>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div id="upload-status">
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<script>
|
58
|
+
var fileupload = {
|
59
|
+
init: function () {
|
60
|
+
$('#<%=target%>').on("drop", this.ondrop);
|
61
|
+
$('#<%=target%>').on("dragover", this.ondragover);
|
62
|
+
$('#<%=target%>').on("dragleave", this.ondragleave);
|
63
|
+
},
|
64
|
+
|
65
|
+
beforeSuccess: function(){
|
66
|
+
console.log("beforeSuccess");
|
67
|
+
},
|
68
|
+
|
69
|
+
ondrop: function (e) {
|
70
|
+
// console.log(e)
|
71
|
+
e.preventDefault();
|
72
|
+
$('#<%=target%>').removeClass('drop');
|
73
|
+
$("#<%=target%>-upload-drop-zone-feedback").html("<i class='fa fa-spinner fa-spin '></i>");
|
74
|
+
|
75
|
+
// console.log(e.dataTransfer.files);
|
76
|
+
var fd = new FormData();
|
77
|
+
$.each(e.originalEvent.dataTransfer.files, function (i, file) {
|
78
|
+
fd.append('files[]', file);
|
79
|
+
});
|
80
|
+
|
81
|
+
$.ajax({
|
82
|
+
url: '<%=url%>',
|
83
|
+
data: fd,
|
84
|
+
processData: false,
|
85
|
+
contentType: false,
|
86
|
+
type: 'POST',
|
87
|
+
success: function () {
|
88
|
+
fileupload.beforeSuccess();
|
89
|
+
$("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-check-square-o" aria-hidden="true"></i>').delay(3000).fadeOut(400));
|
90
|
+
},
|
91
|
+
error: function () {
|
92
|
+
$("#<%=target%>-upload-drop-zone-feedback").html($('<i class="fa fa-exclamation-circle" aria-hidden="true"></i>').delay(3000).fadeOut(400));
|
93
|
+
}
|
94
|
+
});
|
95
|
+
// startUpload(e.dataTransfer.files)
|
96
|
+
},
|
97
|
+
|
98
|
+
ondragover: function () {
|
99
|
+
$('#<%=target%>').addClass('drop');
|
100
|
+
return false;
|
101
|
+
},
|
102
|
+
|
103
|
+
ondragleave: function () {
|
104
|
+
$('#<%=target%>').removeClass('drop');
|
105
|
+
return false;
|
106
|
+
}
|
107
|
+
|
108
|
+
};
|
109
|
+
fileupload.init();
|
110
|
+
</script>
|
data/config/locales/en.yml
CHANGED
@@ -1,4 +1,9 @@
|
|
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
|
+
loading: Caricamento
|
5
|
+
please_drag_and_drop_here: Drag and Drop here the files to import
|
6
|
+
import_success: Import Successful!
|
2
7
|
current_user: Current User
|
3
8
|
devise:
|
4
9
|
sessions:
|
data/config/locales/it.yml
CHANGED
@@ -1,4 +1,10 @@
|
|
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
|
+
loading: Caricamento
|
5
|
+
run_import: Forza l'importazione
|
6
|
+
please_drag_and_drop_here: Trascinare qui i file da importare
|
7
|
+
import_success: Importazione completata con successo
|
2
8
|
current_user: Utente corrente
|
3
9
|
hello: "Ciao Mondo"
|
4
10
|
dashboard: "Pannello di controllo"
|
data/lib/thecore_ui_commons.rb
CHANGED
@@ -13,4 +13,20 @@ require "thecore_ui_commons/engine"
|
|
13
13
|
|
14
14
|
module ThecoreUiCommons
|
15
15
|
# Your code goes here...
|
16
|
+
|
17
|
+
def self.save_files files
|
18
|
+
# Rails.logger.debug "AAAAAAAAAAA: POST?"
|
19
|
+
files.each do |pic|
|
20
|
+
# Rails.logger.debug "AAAAAAAAAAA: EACH PIC: #{pic.inspect}"
|
21
|
+
upload_dir = Rails.root.join(Settings.ns(:importer).import_from_folder, 'uploads')
|
22
|
+
FileUtils.mkdir_p upload_dir
|
23
|
+
# Rails.logger.debug "AAAAAAAAAAA: Fatto MKDIR di #{upload_dir}"
|
24
|
+
file_to_upload = Rails.root.join(upload_dir, "uploaded-#{Time.now.strftime("%Y%m%d%H%M%S%L")}-#{pic.original_filename}")
|
25
|
+
# Rails.logger.debug "AAAAAAAAAAA: File da uploadare #{file_to_upload}"
|
26
|
+
File.open(file_to_upload, 'wb') do |file|
|
27
|
+
# Rails.logger.debug "AAAAAAAAAAAAAAAAAA: Dentro alla scrittura"
|
28
|
+
file.write(pic.read)
|
29
|
+
end if Regexp.new("\\.#{Settings.ns(:importer).extension.gsub(/ +/, "").split(",").join("|\\.")}$").match? pic.original_filename
|
30
|
+
end
|
31
|
+
end
|
16
32
|
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.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_background_jobs
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- app/views/layouts/mailer.html.erb
|
126
126
|
- app/views/layouts/mailer.text.erb
|
127
127
|
- app/views/layouts/thecore.html.erb
|
128
|
+
- app/views/thecore_utils/_drag_drop_uploader.html.erb
|
128
129
|
- config/initializers/charts_helper.rb
|
129
130
|
- config/initializers/thecore_ui_commons_application_config.rb
|
130
131
|
- config/initializers/thecore_ui_commons_helper.rb
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- config/routes.rb
|
138
139
|
- db/migrate/20200515070620_add_username_to_user.rb
|
139
140
|
- db/migrate/20200515132932_add_rememberable_to_user.rb
|
141
|
+
- db/migrate/20210208142646_add_settings_for_uploader.rb
|
140
142
|
- lib/concerns/thecore_ui_commons_user.rb
|
141
143
|
- lib/tasks/thecore_ui_commons_tasks.rake
|
142
144
|
- lib/thecore_ui_commons.rb
|