data_tables 0.1.23 → 0.1.24
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 +8 -8
- data/data_tables.gemspec +1 -1
- data/lib/data_tables/data_tables_helper.rb +20 -5
- data/lib/data_tables.rb +28 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWY2OTVjMzE3YWVhYTEzM2NmYzIwYzBmNDQ1NTMxNGM4NDQyNjdlZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2ZhZGEyYzJkNjNlOGUzMTNmNGYzMjJjNTIxMTg5OTRkOTVmNDc4YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDhmMTgyNjQxOWM1MzA5NzE2OWVmOWJkMmRkOTFjOTA5MzIwZTE4ZTA3MTIx
|
10
|
+
NGM5ZTA2ZjYyZGQ4MzZiODQ1NjQ1MTIxZjI2YjA3ZDBhNDgwYmNmMTczMzI4
|
11
|
+
OTNjZTllNDFmNmE1ZTcyNjExYThjZmRkYTlhMGJhMjQxYWVkZjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjZlYjgzMGUwYTIwZTg4MmMyMjU5NjRlN2RlMDA5ZGMyOTdhMmY2NjI2Y2Rl
|
14
|
+
ZGE5ZmZjZTIxODVmZGEyYmUyZWE1NTdjYWUzZTc3ZDhiNjczNzYyYzBmNjM5
|
15
|
+
M2E4NGVjYWQ0N2UxMWUxMjViNzUwNTNkYTVmY2I5ZTI2ZWIzZmQ=
|
data/data_tables.gemspec
CHANGED
@@ -25,11 +25,17 @@ module DataTablesHelper
|
|
25
25
|
|
26
26
|
options[:fnServerData] ||= "function ( sSource, aoData, fnCallback ) {
|
27
27
|
var init_sSearch = $('#init_sSearch');
|
28
|
+
var start_time = $('#start_time');
|
29
|
+
var end_time = $('#end_time');
|
28
30
|
if(init_sSearch != undefined && init_sSearch.val() != '' && init_sSearch.size() != 0) {
|
29
31
|
$('.dataTables_filter input').val(init_sSearch.val());
|
30
32
|
aoData.push( { name:'sSearch', value: init_sSearch.val() });
|
31
33
|
$('#init_sSearch').remove();
|
32
34
|
}
|
35
|
+
if(start_time.val() != undefined && start_time.val() != '' && end_time.val() != undefined && end_time.val() != '') {
|
36
|
+
aoData.push( { name:'sStarttime', value:start_time.val() });
|
37
|
+
aoData.push( { name:'sEndtime', value:end_time.val() });
|
38
|
+
}
|
33
39
|
$.ajax( {
|
34
40
|
'dataType': 'json',
|
35
41
|
'url': sSource,
|
@@ -83,13 +89,22 @@ module DataTablesHelper
|
|
83
89
|
<script>
|
84
90
|
$(document).ready(function() {
|
85
91
|
var oTable = $('##{datatable[:action]}').dataTable({
|
86
|
-
#{datatables_option_string(options)}
|
92
|
+
#{datatables_option_string(options)}
|
87
93
|
});
|
88
94
|
$('tfoot input').keyup( function () {
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
/* Filter on the column (the index) of this element */
|
96
|
+
oTable.fnFilter( this.value, $('tfoot input').index(this) );
|
97
|
+
});
|
98
|
+
$('#custom_interval_select_log').click( function () {
|
99
|
+
custom_interval_select_handler_log($('#custom_start').val(),$('#custom_end').val());
|
100
|
+
oTable.fnDraw();
|
101
|
+
});
|
102
|
+
$('.interval').change( function () {
|
103
|
+
interval_click_handler_log();
|
104
|
+
oTable.fnDraw();
|
105
|
+
});
|
106
|
+
$('.dataTables_filter').after($('#tab_options_popup'));
|
107
|
+
$('.dataTables_filter').after($('#interval_choice'));
|
93
108
|
});
|
94
109
|
|
95
110
|
function change_scrollY() {
|
data/lib/data_tables.rb
CHANGED
@@ -194,6 +194,8 @@ module DataTablesController
|
|
194
194
|
objects = []
|
195
195
|
|
196
196
|
condstr = nil
|
197
|
+
starttime_str = nil
|
198
|
+
endtime_str = nil
|
197
199
|
unless params[:sSearch].blank?
|
198
200
|
sort_column_id = params[:iSortCol_0].to_i
|
199
201
|
sort_column = columns[sort_column_id]
|
@@ -201,7 +203,15 @@ module DataTablesController
|
|
201
203
|
condstr = params[:sSearch].gsub(/_/, '\\\\_').gsub(/%/, '\\\\%')
|
202
204
|
end
|
203
205
|
end
|
204
|
-
|
206
|
+
unless params[:sStarttime].blank? || params[:sEndtime].blank?
|
207
|
+
sort_column_id = params[:iSortCol_0].to_i
|
208
|
+
sort_column = columns[sort_column_id]
|
209
|
+
if sort_column && sort_column.has_key?(:attribute)
|
210
|
+
starttime = params[:sStarttime]
|
211
|
+
endtime = params[:sEndtime]
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
205
215
|
sort_column = params[:iSortCol_0].to_i
|
206
216
|
current_page = (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i rescue 0)+1
|
207
217
|
per_page = params[:iDisplayLength] || 10
|
@@ -213,7 +223,7 @@ module DataTablesController
|
|
213
223
|
query do
|
214
224
|
boolean do
|
215
225
|
if condstr
|
216
|
-
must { match :_all, condstr, type: 'phrase_prefix' }
|
226
|
+
must { match :_all, condstr, type: 'phrase_prefix' }
|
217
227
|
else
|
218
228
|
must { all }
|
219
229
|
end
|
@@ -222,6 +232,7 @@ module DataTablesController
|
|
222
232
|
end
|
223
233
|
end
|
224
234
|
end
|
235
|
+
filter(:range, created_at: {gte: starttime,lte: endtime}) unless starttime.blank? || endtime.blank?
|
225
236
|
filter(:term, domain: domain_name) unless domain_name.blank?
|
226
237
|
es_block.call(self) if es_block.respond_to?(:call)
|
227
238
|
end
|
@@ -261,17 +272,30 @@ module DataTablesController
|
|
261
272
|
|
262
273
|
define_method action.to_sym do
|
263
274
|
condition_local = ''
|
275
|
+
condition = ''
|
276
|
+
|
264
277
|
unless params[:sSearch].blank?
|
265
278
|
sort_column_id = params[:iSortCol_0].to_i
|
266
279
|
sort_column = columns[sort_column_id]
|
267
280
|
condstr = params[:sSearch].strip.gsub(/%/, '%%').gsub(/'/,"''")
|
268
281
|
|
269
282
|
search_columns = options[:columns].map{|e| e.class == Symbol ? e : e[:attribute] }.compact
|
270
|
-
|
283
|
+
condition = search_columns.map do |column_name|
|
271
284
|
" ((text(#{column_name}) ILIKE '%#{condstr}%')) "
|
272
285
|
end.compact.join(" OR ")
|
273
|
-
|
286
|
+
condition = "(#{condition})" unless condition.blank?
|
287
|
+
end
|
288
|
+
unless params[:sStarttime].blank? || params[:sEndtime].blank?
|
289
|
+
sort_column_id = params[:iSortCol_0].to_i
|
290
|
+
sort_column = columns[sort_column_id]
|
291
|
+
if sort_column && sort_column.has_key?(:attribute)
|
292
|
+
starttime = params[:sStarttime]
|
293
|
+
endtime = params[:sEndtime]
|
294
|
+
end
|
295
|
+
condition = condition + "AND" unless condition.blank?
|
296
|
+
condition = condition + "(last_seen BETWEEN '#{starttime}' AND '#{endtime}') "
|
274
297
|
end
|
298
|
+
condition_local = "(#{condition})" unless condition.blank?
|
275
299
|
|
276
300
|
# We just need one conditions string for search at a time. Every time we input
|
277
301
|
# something else in the search bar we will pop the previous search condition
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duane Compton
|
@@ -12,10 +12,9 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
|
-
prerelease: false
|
19
18
|
name: rspec
|
20
19
|
requirement: !ruby/object:Gem::Requirement
|
21
20
|
requirements:
|
@@ -23,6 +22,7 @@ dependencies:
|
|
23
22
|
- !ruby/object:Gem::Version
|
24
23
|
version: '2.10'
|
25
24
|
type: :development
|
25
|
+
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ~>
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.2.
|
73
|
+
rubygems_version: 2.2.2
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Rails friendly interface into DataTables
|