thecore_ui_commons 2.1.14 → 2.2.5

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: 335ebc71696d91bccc5f8e40c0578f4d57981f38ef3abaf32d804c852f21486b
4
- data.tar.gz: f9449c252ca8cf444105fd45186fb3d8071c19eea5c1957f778acf2f1e83011c
3
+ metadata.gz: f96a230065dcec5fdb22b7959137e33b030af287152f1ef142f30830475908be
4
+ data.tar.gz: 5a01e066cb48e721f83a208a0cf5570140a02babf5dd14d730019198bef95e4b
5
5
  SHA512:
6
- metadata.gz: f71388796069c082d8f8f6a3455da74dfab15c4132419f37cf3c30e1209fda5d533237f34ccf06fc4f4fa15a30e84e71141270875871063cd458e3b52a968574
7
- data.tar.gz: f764ea7a0881c8c8a592d77b19f890cce24414a584493729409fd0f7887b86340cd04a4daa92030d35cd87d9cd6b337bc17f7cb5f31c2cbc7295851dbea75f7f
6
+ metadata.gz: 1aa2e381eb398e0b3fb29fc38ad3de5d2be9930afe486ac47352a45d76677a00317e883380bcb203c226351a409c60f4b4368bc6ce2ec6af95c272e122e5edb2
7
+ data.tar.gz: 14e72ad93387dd2600bcbb09cf54440c60857ae55c62b393b77a2a240ad3a1f9ccb271cacf42b3f94ae7591f08114665025c1d35b6352f1ea64cc92929f9bdf3
@@ -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,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>
@@ -1,4 +1,5 @@
1
1
  it:
2
+ import_success: Importazione completata con successo
2
3
  current_user: Utente corrente
3
4
  hello: "Ciao Mondo"
4
5
  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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiCommons
2
- VERSION = '2.1.14'
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
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.1.14
4
+ version: 2.2.5
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-09-17 00:00:00.000000000 Z
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