raport 0.1.1.pre → 0.1.2.pre

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
  SHA1:
3
- metadata.gz: c2924d1fab1b2f7bacc642f5c9fa2c80fa8e2f2a
4
- data.tar.gz: f148c28cf17d07a2b44e23da21dd08ddc48b7ff9
3
+ metadata.gz: 84bbbf3b418d91be6f2119b2f24368077126956f
4
+ data.tar.gz: a8ec175448248aa8ad71b9455fcfa4d354b51cc9
5
5
  SHA512:
6
- metadata.gz: c834f1e09bd1a6f81d22f842d5321a0c7f45479b28a0a4d87acabdb31cf59a6438b0dc4f24c2426731de6ed0575bd57f568ae52d080edd74052d51da31acc440
7
- data.tar.gz: 515453848901845411dc4a26ef0b52357ee5706e6b9c4277c67c136c5d53d0bb925ab5d4dedab8529338bea16588e1183f80e73b872afe055d88ec157392b478
6
+ metadata.gz: 573224be21a48c7600bf972dab214aafeef147ec9d0d537bd9d8190f3a040af33e28e2f752ec49ced9f3bfb6cc7b3a50e9156d1a82944b308bc039696cdf3a29
7
+ data.tar.gz: 404be995fe1c688704dd2f1ec25be4dda8e5e593103ba7069696b7ea7bb1e6ce144725990e5d635e74378a62a962b684268187231f253e71141e795329a828b7
@@ -6,7 +6,7 @@ module Raport
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 1
9
- TINY = 1
9
+ TINY = 2
10
10
  PRE = 'pre'
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -0,0 +1,99 @@
1
+ /*!
2
+ * jQuery periodic plugin
3
+ *
4
+ * Copyright 2010, Tom Anderson
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ *
7
+ */
8
+
9
+ jQuery.periodic = function (options, callback) {
10
+
11
+ // if the first argument is a function then assume the options aren't being passed
12
+ if (jQuery.isFunction(options)) {
13
+ callback = options;
14
+ options = {};
15
+ }
16
+
17
+ // Merge passed settings with default values
18
+ var settings = jQuery.extend({}, jQuery.periodic.defaults, {
19
+ ajax_complete : ajaxComplete,
20
+ increment : increment,
21
+ reset : reset,
22
+ cancel : cancel
23
+ }, options);
24
+
25
+ // bookkeeping variables
26
+ settings.cur_period = settings.period;
27
+ settings.tid = false;
28
+ var prev_ajax_response = '';
29
+
30
+ run();
31
+
32
+ // return settings so user can tweak them externally
33
+ return settings;
34
+
35
+ // run (or restart if already running) the looping construct
36
+ function run() {
37
+ // clear/stop existing timer (multiple calls to run() won't result in multiple timers)
38
+ cancel();
39
+ // let it rip!
40
+ settings.tid = setTimeout(function() {
41
+ // set the context (this) for the callback to the settings object
42
+ callback.call(settings);
43
+
44
+ // compute the next value for cur_period
45
+ increment();
46
+
47
+ // queue up the next run
48
+ if(settings.tid)
49
+ run();
50
+ }, settings.cur_period);
51
+ }
52
+
53
+ // utility function for use with ajax calls
54
+ function ajaxComplete(xhr, status) {
55
+ if (status === 'success' && prev_ajax_response !== xhr.responseText) {
56
+ // reset the period whenever the response changes
57
+ prev_ajax_response = xhr.responseText;
58
+ reset();
59
+ }
60
+ }
61
+
62
+ // compute the next delay
63
+ function increment() {
64
+ settings.cur_period *= settings.decay;
65
+ if (settings.cur_period < settings.period) {
66
+ // don't let it drop below the minimum
67
+ reset();
68
+ } else if (settings.cur_period > settings.max_period) {
69
+ settings.cur_period = settings.max_period;
70
+ if (settings.on_max !== undefined) {
71
+ // call the user-supplied callback if we reach max_period
72
+ settings.on_max.call(settings);
73
+ }
74
+ }
75
+ }
76
+
77
+ function reset() {
78
+ settings.cur_period = settings.period;
79
+ // restart with the new timeout
80
+ run();
81
+ }
82
+
83
+ function cancel() {
84
+ clearTimeout(settings.tid);
85
+ settings.tid = null;
86
+ }
87
+
88
+ // other functions we might want to implement
89
+ function pause() {}
90
+ function resume() {}
91
+ function log() {}
92
+ };
93
+
94
+ jQuery.periodic.defaults = {
95
+ period : 4000, // 4 sec.
96
+ max_period : 1800000, // 30 min.
97
+ decay : 1.5, // time period multiplier
98
+ on_max : undefined // called if max_period is reached
99
+ };
@@ -0,0 +1,40 @@
1
+ #= require raport/periodic
2
+
3
+ peridicallyCall = (dom) ->
4
+ $.periodic ->
5
+ period: 5000
6
+ $.ajax
7
+ periodic: this
8
+ url: $(dom).data('async-load-report')
9
+ success: (json) ->
10
+ if $.inArray(json.state, ['finished', 'failed']) != -1
11
+ $('#report-download').html '<a href="' + json.file.url + '" class="label label-info">Download</a>'
12
+ $(dom).replaceWith '<span class="' + json.status_css_classes + '">' + json.display_status_name + '</span>'
13
+ @periodic.cancel()
14
+ complete: (xhr, status) ->
15
+ @ajax_complete
16
+ dataType: 'json'
17
+
18
+ $(document).ready ($) ->
19
+ $('[data-async-load-report]').each (i, dom) ->
20
+ peridicallyCall dom
21
+ return
22
+
23
+ $('[data-report="true"]').each (i, dom) ->
24
+ $(dom).on 'click', (e) ->
25
+ e.preventDefault()
26
+ $.ajax(
27
+ type: "GET"
28
+ url: $(dom).attr 'href'
29
+ dataType: 'json'
30
+ ).done (json) ->
31
+ if json.errors
32
+ $.each json.errors, (key, values) ->
33
+ $.each values, (i, value) ->
34
+ console.log value
35
+ return
36
+ else
37
+ window.location.replace json.permalink
38
+ return
39
+
40
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.pre
4
+ version: 0.1.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rüffer
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 4.2.3
28
+ - !ruby/object:Gem::Dependency
29
+ name: railties
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 4.2.3
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 4.2.3
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: carrierwave
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +123,7 @@ dependencies:
109
123
  - - ">="
110
124
  - !ruby/object:Gem::Version
111
125
  version: '0'
112
- description: This gem gives your rails app the ability to create large data report,
126
+ description: This gem gives your rails app the ability to create large data reports,
113
127
  without influencing the performance of the app server.
114
128
  email:
115
129
  - michael.rueffer@hitfoxgroup.com
@@ -180,7 +194,9 @@ files:
180
194
  - test/models/raport/report_test.rb
181
195
  - test/raport_test.rb
182
196
  - test/test_helper.rb
183
- homepage: https://forderungsdienstleister.com
197
+ - vendor/assets/javascripts/raport.js.coffee
198
+ - vendor/assets/javascripts/raport/periodic.js
199
+ homepage: https://github.com/HitFox/raport
184
200
  licenses:
185
201
  - MIT
186
202
  metadata: {}