importr 0.0.2 → 0.0.3
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 +4 -4
- data/app/views/importr/admin/data_imports/_rows_with_errors.haml +8 -1
- data/app/views/importr/admin/data_imports/_ws_client.haml +11 -4
- data/lib/importr/active_admin.rb +9 -3
- data/lib/importr/config.rb +2 -1
- data/lib/importr/importer.rb +16 -12
- data/lib/importr/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17a29355c196c8aac87b18a1d1aeb27d896897f2
|
|
4
|
+
data.tar.gz: aba05d865b2156224475e6a1aa94e13342ad7bf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 837ea81edf3b88a6ead963188b7d40b52e67f8614232118ea58745745de24efa7303cca5d00ede087253128e1e9039e7015605a184800e337e88330ff3328a66
|
|
7
|
+
data.tar.gz: 51f72029dfa4253f11f1ea7b32c847a9f4c87b88dce0272fb88f1d074758df8c77df42874ec5b88d23bc22bee33da1c26c4f781922ccbdbe48c7649c1f368913
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
:javascript
|
|
2
2
|
(function() {
|
|
3
|
-
|
|
4
|
-
|
|
5
3
|
var client = new Faye.Client("#{websocket_url_service}", { retry: 5 });
|
|
6
4
|
|
|
5
|
+
var max = {
|
|
6
|
+
processed_rows: 0,
|
|
7
|
+
success_count: 0,
|
|
8
|
+
error_count: 0,
|
|
9
|
+
};
|
|
10
|
+
|
|
7
11
|
function update_row_count(message) {
|
|
8
12
|
if (typeof(message.processed_rows) != 'undefined') {
|
|
9
|
-
|
|
13
|
+
max.processed_rows = Math.max(message.processed_rows, max.processed_rows)
|
|
14
|
+
$('#rows-processed').html('' + max.processed_rows + ' / ' + message.total_rows)
|
|
10
15
|
}
|
|
11
16
|
console.log(message)
|
|
12
17
|
}
|
|
@@ -18,13 +23,15 @@
|
|
|
18
23
|
|
|
19
24
|
client.subscribe("#{@data_import.websocket_channel(:error)}", function(message) {
|
|
20
25
|
update_row_count(message)
|
|
21
|
-
|
|
26
|
+
max.error_count = Math.max(message.error_count, max.error_count)
|
|
27
|
+
$('#rows-with-errors').html(max.error_count)
|
|
22
28
|
|
|
23
29
|
$('#row-errors-panel tbody').append("<tr><td>" + message.index + "</td><td>" + message.error + "</td></tr>")
|
|
24
30
|
$('#row-errors-panel').show();
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
client.subscribe("#{@data_import.websocket_channel(:success)}", function(message) {
|
|
34
|
+
max.success_count = Math.max(message.success_count, max.success_count)
|
|
28
35
|
update_row_count(message)
|
|
29
36
|
});
|
|
30
37
|
|
data/lib/importr/active_admin.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Importr
|
|
|
8
8
|
importer_type ||= "#{klass}Importer".constantize
|
|
9
9
|
|
|
10
10
|
action_item :only => :index do
|
|
11
|
-
link_to 'Import from Excel', :action => 'upload_excel'
|
|
11
|
+
link_to 'Import from Excel', :action => 'upload_excel' #if current_admin_user.is_admin?
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
collection_action :upload_excel do
|
|
@@ -27,8 +27,14 @@ module Importr
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
controller do
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
before_filter :check_permisions, only: [:import_excel, :upload_excel]
|
|
31
|
+
|
|
32
|
+
def check_permisions
|
|
33
|
+
self.send(Importr::Config.restriction_method.to_sym) unless Importr::Config.restriction_method.blank?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def importer_params
|
|
37
|
+
{data_import: [:document, :uuid, :importer_type]}
|
|
32
38
|
end
|
|
33
39
|
end
|
|
34
40
|
end
|
data/lib/importr/config.rb
CHANGED
data/lib/importr/importer.rb
CHANGED
|
@@ -14,24 +14,21 @@ module Importr
|
|
|
14
14
|
|
|
15
15
|
alias_method :data_import, :context
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
super
|
|
17
|
+
on :row_success do
|
|
19
18
|
update_counters
|
|
20
19
|
notify(:success, @counters)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
notify(:error, @counters.merge(index: row_index, error: error_message))
|
|
22
|
+
on :row_error do |e|
|
|
23
|
+
update_counters({index: row_index, error: e.message})
|
|
24
|
+
notify(:error, @counters.merge(index: row_index, error: e.message))
|
|
27
25
|
end
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
notify(:base, error: error_message)
|
|
27
|
+
on :import_failed do |e|
|
|
28
|
+
notify(:base, error: e.message)
|
|
32
29
|
end
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
on :import_finished do
|
|
35
32
|
data_import.update_attribute(:finished, true) if data_import
|
|
36
33
|
end
|
|
37
34
|
|
|
@@ -42,14 +39,21 @@ module Importr
|
|
|
42
39
|
Importr::Notifier.notify(channel, message)
|
|
43
40
|
end
|
|
44
41
|
|
|
45
|
-
def update_counters
|
|
42
|
+
def update_counters(err= {})
|
|
46
43
|
@counters = {
|
|
47
44
|
success_count: row_success_count,
|
|
48
45
|
error_count: row_error_count,
|
|
49
46
|
processed_rows: row_processed_count,
|
|
50
47
|
total_rows: row_count,
|
|
51
48
|
}
|
|
52
|
-
|
|
49
|
+
if data_import
|
|
50
|
+
data_import.update_attributes(@counters)
|
|
51
|
+
add_error(err) unless err.blank?
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add_error(err)
|
|
56
|
+
data_import.update_attributes(error_messages: data_import.error_messages << err ) if data_import
|
|
53
57
|
end
|
|
54
58
|
end
|
|
55
59
|
end
|
data/lib/importr/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: importr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ernesto Garcia
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-11-
|
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -29,16 +29,16 @@ dependencies:
|
|
|
29
29
|
name: active_importer
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- -
|
|
32
|
+
- - ~>
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
34
|
+
version: 0.2.0
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- -
|
|
39
|
+
- - ~>
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
41
|
+
version: 0.2.0
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: carrierwave
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|