rjack-solr 4.0.0.0-java → 4.1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +5 -0
- data/Manifest.txt +5 -4
- data/README.rdoc +1 -1
- data/init/rjack-solr +1 -1
- data/lib/rjack-solr/base.rb +1 -1
- data/lib/rjack-solr/solr-core-4.1.0.jar +0 -0
- data/lib/rjack-solr/solr-solrj-4.1.0.jar +0 -0
- data/pom.xml +2 -2
- data/webapp/META-INF/MANIFEST.MF +3 -3
- data/webapp/META-INF/NOTICE.txt +2 -2
- data/webapp/admin.html +1 -0
- data/webapp/css/styles/cloud.css +8 -1
- data/webapp/css/styles/common.css +21 -0
- data/webapp/css/styles/dashboard.css +2 -2
- data/webapp/css/styles/dataimport.css +183 -21
- data/webapp/css/styles/menu.css +2 -0
- data/webapp/css/styles/query.css +9 -3
- data/webapp/css/styles/schema-browser.css +12 -0
- data/webapp/img/ico/cross-button.png +0 -0
- data/webapp/img/ico/hammer.png +0 -0
- data/webapp/js/lib/console.js +11 -9
- data/webapp/js/lib/highlight.js +1 -1
- data/webapp/js/lib/jquery.autogrow.js +132 -0
- data/webapp/js/main.js +1 -0
- data/webapp/js/require.js +3 -1
- data/webapp/js/scripts/analysis.js +2 -2
- data/webapp/js/scripts/app.js +183 -78
- data/webapp/js/scripts/cloud.js +41 -20
- data/webapp/js/scripts/cores.js +5 -2
- data/webapp/js/scripts/dashboard.js +2 -1
- data/webapp/js/scripts/dataimport.js +415 -162
- data/webapp/js/scripts/file.js +1 -1
- data/webapp/js/scripts/index.js +3 -5
- data/webapp/js/scripts/logging.js +8 -0
- data/webapp/js/scripts/plugins.js +47 -7
- data/webapp/js/scripts/query.js +75 -49
- data/webapp/js/scripts/replication.js +4 -47
- data/webapp/js/scripts/schema-browser.js +46 -23
- data/webapp/tpl/cores.html +5 -0
- data/webapp/tpl/dashboard.html +4 -1
- data/webapp/tpl/dataimport.html +72 -12
- data/webapp/tpl/query.html +38 -3
- data/webapp/tpl/schema-browser.html +6 -0
- metadata +15 -12
- data/lib/rjack-solr/solr-core-4.0.0.jar +0 -0
- data/lib/rjack-solr/solr-solrj-4.0.0.jar +0 -0
data/webapp/js/scripts/cloud.js
CHANGED
@@ -15,6 +15,27 @@
|
|
15
15
|
limitations under the License.
|
16
16
|
*/
|
17
17
|
|
18
|
+
var zk_error = function zk_error( xhr, text_status, error_thrown )
|
19
|
+
{
|
20
|
+
var zk = null;
|
21
|
+
try
|
22
|
+
{
|
23
|
+
eval( 'zk = ' + xhr.responseText + ';' );
|
24
|
+
}
|
25
|
+
catch( e ) {}
|
26
|
+
|
27
|
+
var message = '<p class="txt">Loading of "<code>' + xhr.url + '</code>" '
|
28
|
+
+ 'failed (HTTP-Status <code>' + xhr.status + '</code>)</p>' + "\n";
|
29
|
+
|
30
|
+
if( zk.error )
|
31
|
+
{
|
32
|
+
message += '<p class="msg">"' + zk.error.esc() + '"</p>' + "\n";
|
33
|
+
}
|
34
|
+
|
35
|
+
this.closest( '#cloud' )
|
36
|
+
.html( '<div class="block" id="error">' + message + '</div>' );
|
37
|
+
};
|
38
|
+
|
18
39
|
var init_debug = function( cloud_element )
|
19
40
|
{
|
20
41
|
var debug_element = $( '#debug', cloud_element );
|
@@ -369,13 +390,13 @@ var prepare_graph = function( graph_element, callback )
|
|
369
390
|
for( var c in state )
|
370
391
|
{
|
371
392
|
var shards = [];
|
372
|
-
for( var s in state[c] )
|
393
|
+
for( var s in state[c].shards )
|
373
394
|
{
|
374
395
|
var nodes = [];
|
375
|
-
for( var n in state[c][s].replicas )
|
396
|
+
for( var n in state[c].shards[s].replicas )
|
376
397
|
{
|
377
398
|
leaf_count++;
|
378
|
-
var replica = state[c][s].replicas[n]
|
399
|
+
var replica = state[c].shards[s].replicas[n]
|
379
400
|
|
380
401
|
var uri = replica.base_url;
|
381
402
|
var parts = uri.match( /^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/ );
|
@@ -415,7 +436,7 @@ var prepare_graph = function( graph_element, callback )
|
|
415
436
|
var shard = {
|
416
437
|
name: s,
|
417
438
|
data: {
|
418
|
-
type : 'shard'
|
439
|
+
type : 'shard'
|
419
440
|
},
|
420
441
|
children: nodes
|
421
442
|
};
|
@@ -425,7 +446,7 @@ var prepare_graph = function( graph_element, callback )
|
|
425
446
|
var collection = {
|
426
447
|
name: c,
|
427
448
|
data: {
|
428
|
-
type : 'collection'
|
449
|
+
type : 'collection'
|
429
450
|
},
|
430
451
|
children: shards
|
431
452
|
};
|
@@ -633,19 +654,7 @@ var init_tree = function( tree_element )
|
|
633
654
|
}
|
634
655
|
);
|
635
656
|
},
|
636
|
-
error :
|
637
|
-
{
|
638
|
-
var message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with "' + text_status + '" '
|
639
|
-
+ '(<code>' + error_thrown.message + '</code>)';
|
640
|
-
|
641
|
-
if( 200 !== xhr.status )
|
642
|
-
{
|
643
|
-
message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with HTTP-Status ' + xhr.status + ' ';
|
644
|
-
}
|
645
|
-
|
646
|
-
this
|
647
|
-
.html( '<div class="block" id="error">' + message + '</div>' );
|
648
|
-
},
|
657
|
+
error : zk_error,
|
649
658
|
complete : function( xhr, text_status )
|
650
659
|
{
|
651
660
|
}
|
@@ -710,8 +719,20 @@ sammy.get
|
|
710
719
|
}
|
711
720
|
);
|
712
721
|
|
713
|
-
|
714
|
-
|
722
|
+
$.ajax
|
723
|
+
(
|
724
|
+
{
|
725
|
+
url : app.config.solr_path + '/zookeeper?wt=json',
|
726
|
+
dataType : 'json',
|
727
|
+
context : cloud_element,
|
728
|
+
success : function( response, text_status, xhr )
|
729
|
+
{
|
730
|
+
$( 'a[href="' + context.path + '"]', navigation_element )
|
731
|
+
.trigger( 'activate' );
|
732
|
+
},
|
733
|
+
error : zk_error
|
734
|
+
}
|
735
|
+
);
|
715
736
|
|
716
737
|
}
|
717
738
|
);
|
data/webapp/js/scripts/cores.js
CHANGED
@@ -36,7 +36,7 @@ sammy.bind
|
|
36
36
|
},
|
37
37
|
success : function( response, text_status, xhr )
|
38
38
|
{
|
39
|
-
app.
|
39
|
+
app.set_cores_data( response );
|
40
40
|
params.callback( app.cores_data );
|
41
41
|
},
|
42
42
|
error : function( xhr, text_status, error_thrown)
|
@@ -189,7 +189,7 @@ sammy.get
|
|
189
189
|
// index-data
|
190
190
|
|
191
191
|
$( '.lastModified dd', index_data_element )
|
192
|
-
.html( core_data.index.lastModified );
|
192
|
+
.html( core_data.index.lastModified || '-' );
|
193
193
|
|
194
194
|
$( '.version dd', index_data_element )
|
195
195
|
.html( core_data.index.version );
|
@@ -199,6 +199,9 @@ sammy.get
|
|
199
199
|
|
200
200
|
$( '.maxDoc dd', index_data_element )
|
201
201
|
.html( core_data.index.maxDoc );
|
202
|
+
|
203
|
+
$( '.deletedDocs dd', index_data_element )
|
204
|
+
.html( core_data.index.deletedDocs || '-' );
|
202
205
|
|
203
206
|
$( '.optimized dd', index_data_element )
|
204
207
|
.addClass( !core_data.index.hasDeletions ? 'ico-1' : 'ico-0' );
|
@@ -39,7 +39,7 @@ var set_healthcheck_status = function( status )
|
|
39
39
|
// #/:core
|
40
40
|
sammy.get
|
41
41
|
(
|
42
|
-
|
42
|
+
new RegExp( app.core_regex_base + '$' ),
|
43
43
|
function( context )
|
44
44
|
{
|
45
45
|
var core_basepath = this.active_core.attr( 'data-basepath' );
|
@@ -114,6 +114,7 @@ sammy.get
|
|
114
114
|
var data = {
|
115
115
|
'index_num-docs' : response['index']['numDocs'],
|
116
116
|
'index_max-doc' : response['index']['maxDoc'],
|
117
|
+
'index_deleted-docs' : response['index']['deletedDocs'],
|
117
118
|
'index_version' : response['index']['version'],
|
118
119
|
'index_segmentCount' : response['index']['segmentCount'],
|
119
120
|
'index_last-modified' : response['index']['lastModified']
|
@@ -15,48 +15,8 @@
|
|
15
15
|
limitations under the License.
|
16
16
|
*/
|
17
17
|
|
18
|
-
var
|
19
|
-
|
20
|
-
var ret = 0;
|
21
|
-
var parts = new String( str ).split( '.' ).shift().split( ':' ).reverse();
|
22
|
-
var parts_count = parts.length;
|
23
|
-
|
24
|
-
for( var i = 0; i < parts_count; i++ )
|
25
|
-
{
|
26
|
-
ret += parseInt( parts[i], 10 ) * Math.pow( 60, i );
|
27
|
-
}
|
28
|
-
|
29
|
-
return ret;
|
30
|
-
}
|
31
|
-
|
32
|
-
var convert_seconds_to_readable_time = function( value )
|
33
|
-
{
|
34
|
-
var text = [];
|
35
|
-
value = parseInt( value );
|
36
|
-
|
37
|
-
var minutes = Math.floor( value / 60 );
|
38
|
-
var hours = Math.floor( minutes / 60 );
|
39
|
-
|
40
|
-
if( 0 !== hours )
|
41
|
-
{
|
42
|
-
text.push( hours + 'h' );
|
43
|
-
value -= hours * 60 * 60;
|
44
|
-
minutes -= hours * 60;
|
45
|
-
}
|
46
|
-
|
47
|
-
if( 0 !== minutes )
|
48
|
-
{
|
49
|
-
text.push( minutes + 'm' );
|
50
|
-
value -= minutes * 60;
|
51
|
-
}
|
52
|
-
|
53
|
-
if( 0 !== value )
|
54
|
-
{
|
55
|
-
text.push( value + 's' );
|
56
|
-
}
|
57
|
-
|
58
|
-
return text.join( ' ' );
|
59
|
-
}
|
18
|
+
var dataimport_timeout = 2000;
|
19
|
+
var cookie_dataimport_autorefresh = 'dataimport_autorefresh';
|
60
20
|
|
61
21
|
sammy.bind
|
62
22
|
(
|
@@ -101,7 +61,7 @@ sammy.bind
|
|
101
61
|
// #/:core/dataimport
|
102
62
|
sammy.get
|
103
63
|
(
|
104
|
-
|
64
|
+
new RegExp( app.core_regex_base + '\\/(dataimport)$' ),
|
105
65
|
function( context )
|
106
66
|
{
|
107
67
|
sammy.trigger
|
@@ -129,7 +89,7 @@ sammy.get
|
|
129
89
|
// #/:core/dataimport
|
130
90
|
sammy.get
|
131
91
|
(
|
132
|
-
|
92
|
+
new RegExp( app.core_regex_base + '\\/(dataimport)\\/' ),
|
133
93
|
function( context )
|
134
94
|
{
|
135
95
|
var core_basepath = this.active_core.attr( 'data-basepath' );
|
@@ -152,7 +112,11 @@ sammy.get
|
|
152
112
|
var dataimport_element = $( '#dataimport', content_element );
|
153
113
|
var form_element = $( '#form', dataimport_element );
|
154
114
|
var config_element = $( '#config', dataimport_element );
|
155
|
-
var
|
115
|
+
var error_element = $( '#error', dataimport_element );
|
116
|
+
var debug_response_element = $( '#debug_response', dataimport_element );
|
117
|
+
|
118
|
+
var autorefresh_status = false;
|
119
|
+
var debug_mode = false;
|
156
120
|
|
157
121
|
// handler
|
158
122
|
|
@@ -195,24 +159,23 @@ sammy.get
|
|
195
159
|
$.ajax
|
196
160
|
(
|
197
161
|
{
|
198
|
-
url : handler_url + '?command=show-config',
|
162
|
+
url : handler_url + '?command=show-config&indent=true',
|
199
163
|
dataType : 'xml',
|
200
164
|
context : $( '#dataimport_config', config_element ),
|
201
165
|
beforeSend : function( xhr, settings )
|
202
166
|
{
|
167
|
+
error_element
|
168
|
+
.empty()
|
169
|
+
.hide();
|
203
170
|
},
|
204
171
|
success : function( config, text_status, xhr )
|
205
172
|
{
|
206
173
|
dataimport_element
|
207
174
|
.removeClass( 'error' );
|
208
|
-
|
209
|
-
config_error_element
|
210
|
-
.hide();
|
211
175
|
|
212
176
|
config_element
|
213
177
|
.addClass( 'hidden' );
|
214
178
|
|
215
|
-
|
216
179
|
var entities = [ '<option value=""></option>' ];
|
217
180
|
|
218
181
|
$( 'document > entity', config )
|
@@ -226,6 +189,9 @@ sammy.get
|
|
226
189
|
|
227
190
|
$( '#entity', form_element )
|
228
191
|
.html( entities.join( "\n" ) );
|
192
|
+
|
193
|
+
$( '.editable textarea', this )
|
194
|
+
.val( xhr.responseText.replace( /\n+$/, '' ) );
|
229
195
|
},
|
230
196
|
error : function( xhr, text_status, error_thrown )
|
231
197
|
{
|
@@ -234,7 +200,8 @@ sammy.get
|
|
234
200
|
dataimport_element
|
235
201
|
.addClass( 'error' );
|
236
202
|
|
237
|
-
|
203
|
+
error_element
|
204
|
+
.text( 'Dataimport XML-Configuration is not valid' )
|
238
205
|
.show();
|
239
206
|
|
240
207
|
config_element
|
@@ -248,7 +215,7 @@ sammy.get
|
|
248
215
|
xhr.responseText.esc() +
|
249
216
|
'</code></pre>'
|
250
217
|
);
|
251
|
-
this.html( code );
|
218
|
+
$( '.formatted', this ).html( code );
|
252
219
|
|
253
220
|
if( 'success' === text_status )
|
254
221
|
{
|
@@ -260,7 +227,7 @@ sammy.get
|
|
260
227
|
}
|
261
228
|
dataimport_fetch_config();
|
262
229
|
|
263
|
-
$( '.toggle',
|
230
|
+
$( '.block .toggle', dataimport_element )
|
264
231
|
.die( 'click' )
|
265
232
|
.live
|
266
233
|
(
|
@@ -325,159 +292,353 @@ sammy.get
|
|
325
292
|
);
|
326
293
|
return false;
|
327
294
|
}
|
328
|
-
)
|
295
|
+
);
|
296
|
+
|
297
|
+
var debug_mode_element = $( '.debug_mode', config_element );
|
298
|
+
debug_mode_element
|
299
|
+
.die( 'click' )
|
300
|
+
.live
|
301
|
+
(
|
302
|
+
'click',
|
303
|
+
function( event )
|
304
|
+
{
|
305
|
+
var self = $( this );
|
306
|
+
var block = self.closest( '.block' )
|
307
|
+
|
308
|
+
var debug_checkbox = $( 'input[name="debug"]', form_element );
|
309
|
+
var submit_span = $( 'button[type="submit"] span', form_element );
|
310
|
+
|
311
|
+
debug_mode = !debug_mode;
|
312
|
+
|
313
|
+
block.toggleClass( 'debug_mode', debug_mode );
|
314
|
+
|
315
|
+
if( debug_mode )
|
316
|
+
{
|
317
|
+
block.removeClass( 'hidden' );
|
318
|
+
|
319
|
+
debug_checkbox
|
320
|
+
.attr( 'checked', 'checked' )
|
321
|
+
.trigger( 'change' );
|
322
|
+
|
323
|
+
submit_span
|
324
|
+
.data( 'original', submit_span.text() )
|
325
|
+
.text( submit_span.data( 'debugmode' ) );
|
326
|
+
|
327
|
+
$( 'textarea', block )
|
328
|
+
.autogrow()
|
329
|
+
}
|
330
|
+
else
|
331
|
+
{
|
332
|
+
submit_span
|
333
|
+
.text( submit_span.data( 'original' ) )
|
334
|
+
.removeData( 'original' );
|
335
|
+
}
|
336
|
+
}
|
337
|
+
);
|
338
|
+
|
339
|
+
// abort
|
340
|
+
|
341
|
+
var abort_import_element = $( '.abort-import', dataimport_element );
|
342
|
+
abort_import_element
|
343
|
+
.off( 'click' )
|
344
|
+
.on
|
345
|
+
(
|
346
|
+
'click',
|
347
|
+
function( event )
|
348
|
+
{
|
349
|
+
var span_element = $( 'span', this );
|
350
|
+
|
351
|
+
$.ajax
|
352
|
+
(
|
353
|
+
{
|
354
|
+
url : handler_url + '?command=abort&wt=json',
|
355
|
+
dataType : 'json',
|
356
|
+
type: 'POST',
|
357
|
+
context: $( this ),
|
358
|
+
beforeSend : function( xhr, settings )
|
359
|
+
{
|
360
|
+
span_element
|
361
|
+
.addClass( 'loader' );
|
362
|
+
},
|
363
|
+
success : function( response, text_status, xhr )
|
364
|
+
{
|
365
|
+
span_element
|
366
|
+
.data( 'original', span_element.text() )
|
367
|
+
.text( span_element.data( 'aborting' ) );
|
368
|
+
|
369
|
+
this
|
370
|
+
.removeClass( 'warn' )
|
371
|
+
.addClass( 'success' );
|
372
|
+
|
373
|
+
window.setTimeout
|
374
|
+
(
|
375
|
+
function()
|
376
|
+
{
|
377
|
+
$( 'span', abort_import_element )
|
378
|
+
.removeClass( 'loader' )
|
379
|
+
.text( span_element.data( 'original' ) )
|
380
|
+
.removeData( 'original' );
|
381
|
+
|
382
|
+
abort_import_element
|
383
|
+
.removeClass( 'success' )
|
384
|
+
.addClass( 'warn' );
|
385
|
+
},
|
386
|
+
dataimport_timeout * 2
|
387
|
+
);
|
388
|
+
|
389
|
+
dataimport_fetch_status();
|
390
|
+
}
|
391
|
+
}
|
392
|
+
);
|
393
|
+
return false;
|
394
|
+
}
|
395
|
+
);
|
329
396
|
|
330
397
|
// state
|
398
|
+
|
399
|
+
var status_button = $( 'form button.refresh-status', form_element );
|
400
|
+
|
401
|
+
status_button
|
402
|
+
.off( 'click' )
|
403
|
+
.on
|
404
|
+
(
|
405
|
+
'click',
|
406
|
+
function( event )
|
407
|
+
{
|
408
|
+
dataimport_fetch_status();
|
409
|
+
return false;
|
410
|
+
}
|
411
|
+
)
|
412
|
+
.trigger( 'click' );
|
331
413
|
|
332
|
-
function dataimport_fetch_status()
|
414
|
+
function dataimport_fetch_status( clear_timeout )
|
333
415
|
{
|
416
|
+
if( clear_timeout )
|
417
|
+
{
|
418
|
+
app.clear_timeout();
|
419
|
+
}
|
420
|
+
|
334
421
|
$.ajax
|
335
422
|
(
|
336
423
|
{
|
337
|
-
url : handler_url + '?command=status',
|
338
|
-
dataType : '
|
424
|
+
url : handler_url + '?command=status&indent=true&wt=json',
|
425
|
+
dataType : 'json',
|
339
426
|
beforeSend : function( xhr, settings )
|
340
427
|
{
|
428
|
+
$( 'span', status_button )
|
429
|
+
.addClass( 'loader' );
|
341
430
|
},
|
342
431
|
success : function( response, text_status, xhr )
|
343
432
|
{
|
344
433
|
var state_element = $( '#current_state', content_element );
|
345
434
|
|
346
|
-
var status =
|
347
|
-
var
|
348
|
-
var
|
435
|
+
var status = response.status;
|
436
|
+
var rollback_time = response.statusMessages.Rolledback || null;
|
437
|
+
var abort_time = response.statusMessages.Aborted || null;
|
438
|
+
|
439
|
+
var messages = response.statusMessages;
|
440
|
+
var messages_count = 0;
|
441
|
+
for( var key in messages ) { messages_count++; }
|
349
442
|
|
350
|
-
var
|
351
|
-
if( !started_at )
|
443
|
+
var format_number = function format_number( number )
|
352
444
|
{
|
353
|
-
|
354
|
-
}
|
445
|
+
return ( number || 0 ).toString().replace( /\B(?=(\d{3})+(?!\d))/g, '\'' );
|
446
|
+
};
|
355
447
|
|
356
|
-
function dataimport_compute_details( response, details_element )
|
448
|
+
function dataimport_compute_details( response, details_element, elapsed_seconds )
|
357
449
|
{
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
{
|
363
|
-
details.push
|
364
|
-
(
|
365
|
-
'<abbr title="Total Requests made to DataSource">Requests</abbr>: ' +
|
366
|
-
requests
|
367
|
-
);
|
368
|
-
}
|
450
|
+
details_element
|
451
|
+
.show();
|
452
|
+
|
453
|
+
// --
|
369
454
|
|
370
|
-
var
|
371
|
-
|
455
|
+
var document_config = {
|
456
|
+
'Requests' : 'Total Requests made to DataSource',
|
457
|
+
'Fetched' : 'Total Rows Fetched',
|
458
|
+
'Skipped' : 'Total Documents Skipped',
|
459
|
+
'Processed' : 'Total Documents Processed'
|
460
|
+
};
|
461
|
+
|
462
|
+
var document_details = [];
|
463
|
+
for( var key in document_config )
|
372
464
|
{
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
465
|
+
var value = parseInt( response.statusMessages[document_config[key]], 10 );
|
466
|
+
|
467
|
+
var detail = '<abbr title="' + document_config[key].esc() + '">' + key.esc() + '</abbr>: ' + format_number( value ).esc();
|
468
|
+
if( elapsed_seconds && 'skipped' !== key.toLowerCase() )
|
469
|
+
{
|
470
|
+
detail += ' <span>(' + format_number( Math.round( value / elapsed_seconds ) ).esc() + '/s)</span>'
|
471
|
+
}
|
472
|
+
|
473
|
+
document_details.push( detail );
|
474
|
+
};
|
475
|
+
|
476
|
+
$( '.docs', details_element )
|
477
|
+
.html( document_details.join( ', ' ) );
|
478
|
+
|
479
|
+
// --
|
379
480
|
|
380
|
-
var
|
381
|
-
|
481
|
+
var dates_config = {
|
482
|
+
'Started' : 'Full Dump Started',
|
483
|
+
'Aborted' : 'Aborted',
|
484
|
+
'Rolledback' : 'Rolledback'
|
485
|
+
};
|
486
|
+
|
487
|
+
var dates_details = [];
|
488
|
+
for( var key in dates_config )
|
382
489
|
{
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
490
|
+
var value = response.statusMessages[dates_config[key]];
|
491
|
+
|
492
|
+
if( value )
|
493
|
+
{
|
494
|
+
var detail = '<abbr title="' + dates_config[key].esc() + '">' + key.esc() + '</abbr>: '
|
495
|
+
+ '<abbr class="time">' + value.esc() + '</abbr>';
|
496
|
+
dates_details.push( detail );
|
497
|
+
}
|
498
|
+
};
|
389
499
|
|
390
|
-
var
|
391
|
-
|
500
|
+
var dates_element = $( '.dates', details_element );
|
501
|
+
|
502
|
+
dates_element
|
503
|
+
.html( dates_details.join( ', ' ) );
|
504
|
+
|
505
|
+
$( '.time', dates_element )
|
506
|
+
.removeData( 'timeago' )
|
507
|
+
.timeago();
|
508
|
+
};
|
509
|
+
|
510
|
+
var get_time_taken = function get_default_time_taken()
|
511
|
+
{
|
512
|
+
var time_taken_text = response.statusMessages['Time taken'];
|
513
|
+
return app.convert_duration_to_seconds( time_taken_text );
|
514
|
+
};
|
515
|
+
|
516
|
+
var get_default_info_text = function default_info_text()
|
517
|
+
{
|
518
|
+
var info_text = response.statusMessages[''] || '';
|
519
|
+
|
520
|
+
// format numbers included in status nicely
|
521
|
+
info_text = info_text.replace
|
522
|
+
(
|
523
|
+
/\d{4,}/g,
|
524
|
+
function( match, position, string )
|
525
|
+
{
|
526
|
+
return format_number( parseInt( match, 10 ) );
|
527
|
+
}
|
528
|
+
);
|
529
|
+
|
530
|
+
var time_taken_text = app.convert_seconds_to_readable_time( get_time_taken() );
|
531
|
+
if( time_taken_text )
|
392
532
|
{
|
393
|
-
|
394
|
-
(
|
395
|
-
'<abbr title="Total Documents Processed">Processed</abbr>: ' +
|
396
|
-
processed
|
397
|
-
);
|
533
|
+
info_text += ' (Duration: ' + time_taken_text.esc() + ')';
|
398
534
|
}
|
399
535
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
536
|
+
return info_text;
|
537
|
+
};
|
538
|
+
|
539
|
+
var show_info = function show_info( info_text, elapsed_seconds )
|
540
|
+
{
|
541
|
+
$( '.info strong', state_element )
|
542
|
+
.text( info_text || get_default_info_text() );
|
543
|
+
|
544
|
+
$( '.info .details', state_element )
|
545
|
+
.hide();
|
546
|
+
};
|
547
|
+
|
548
|
+
var show_full_info = function show_full_info( info_text, elapsed_seconds )
|
549
|
+
{
|
550
|
+
show_info( info_text, elapsed_seconds );
|
551
|
+
|
552
|
+
dataimport_compute_details
|
553
|
+
(
|
554
|
+
response,
|
555
|
+
$( '.info .details', state_element ),
|
556
|
+
elapsed_seconds || get_time_taken()
|
557
|
+
);
|
558
|
+
};
|
404
559
|
|
405
560
|
state_element
|
406
|
-
.
|
407
|
-
|
408
|
-
|
409
|
-
|
561
|
+
.removeAttr( 'class' );
|
562
|
+
|
563
|
+
var current_time = new Date();
|
564
|
+
$( '.last_update abbr', state_element )
|
565
|
+
.text( current_time.toTimeString().split( ' ' ).shift() )
|
566
|
+
.attr( 'title', current_time.toUTCString() );
|
567
|
+
|
410
568
|
$( '.info', state_element )
|
411
569
|
.removeClass( 'loader' );
|
412
570
|
|
413
|
-
if(
|
571
|
+
if( 'busy' === status )
|
414
572
|
{
|
415
573
|
state_element
|
416
|
-
.addClass( '
|
417
|
-
.show();
|
574
|
+
.addClass( 'indexing' );
|
418
575
|
|
419
|
-
|
420
|
-
|
421
|
-
.
|
422
|
-
|
576
|
+
if( autorefresh_status )
|
577
|
+
{
|
578
|
+
$( '.info', state_element )
|
579
|
+
.addClass( 'loader' );
|
580
|
+
}
|
423
581
|
|
424
|
-
|
425
|
-
|
582
|
+
var time_elapsed_text = response.statusMessages['Time Elapsed'];
|
583
|
+
var elapsed_seconds = app.convert_duration_to_seconds( time_elapsed_text );
|
584
|
+
time_elapsed_text = app.convert_seconds_to_readable_time( elapsed_seconds );
|
426
585
|
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
586
|
+
var info_text = time_elapsed_text
|
587
|
+
? 'Indexing since ' + time_elapsed_text
|
588
|
+
: 'Indexing ...';
|
589
|
+
|
590
|
+
show_full_info( info_text, elapsed_seconds );
|
431
591
|
}
|
432
|
-
else if(
|
592
|
+
else if( rollback_time )
|
433
593
|
{
|
434
594
|
state_element
|
435
|
-
.addClass( '
|
436
|
-
.show();
|
595
|
+
.addClass( 'failure' );
|
437
596
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
.text( $( 'str[name=""]', response ).text() );
|
597
|
+
show_full_info();
|
598
|
+
}
|
599
|
+
else if( abort_time )
|
600
|
+
{
|
601
|
+
state_element
|
602
|
+
.addClass( 'aborted' );
|
445
603
|
|
446
|
-
|
604
|
+
show_full_info( 'Aborting current Import ...' );
|
447
605
|
}
|
448
|
-
else if( '
|
606
|
+
else if( 'idle' === status && 0 !== messages_count )
|
449
607
|
{
|
450
608
|
state_element
|
451
|
-
.addClass( '
|
452
|
-
.show();
|
609
|
+
.addClass( 'success' );
|
453
610
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
611
|
+
show_full_info();
|
612
|
+
}
|
613
|
+
else
|
614
|
+
{
|
615
|
+
state_element
|
616
|
+
.addClass( 'idle' );
|
458
617
|
|
459
|
-
|
460
|
-
|
618
|
+
show_info( 'No information available (idle)' );
|
619
|
+
}
|
461
620
|
|
462
|
-
|
621
|
+
// show raw status
|
463
622
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
}
|
623
|
+
var code = $(
|
624
|
+
'<pre class="syntax language-json"><code>' +
|
625
|
+
app.format_json( xhr.responseText ).esc() +
|
626
|
+
'</code></pre>'
|
627
|
+
);
|
470
628
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
dataimport_compute_details( response, $( '.info .details', state_element ) );
|
629
|
+
$( '#raw_output_container', content_element ).html( code );
|
630
|
+
hljs.highlightBlock( code.get(0) );
|
475
631
|
|
476
|
-
|
477
|
-
}
|
478
|
-
else
|
632
|
+
if( !app.timeout && autorefresh_status )
|
479
633
|
{
|
480
|
-
|
634
|
+
app.timeout = window.setTimeout
|
635
|
+
(
|
636
|
+
function()
|
637
|
+
{
|
638
|
+
dataimport_fetch_status( true )
|
639
|
+
},
|
640
|
+
dataimport_timeout
|
641
|
+
);
|
481
642
|
}
|
482
643
|
},
|
483
644
|
error : function( xhr, text_status, error_thrown )
|
@@ -489,24 +650,47 @@ sammy.get
|
|
489
650
|
},
|
490
651
|
complete : function( xhr, text_status )
|
491
652
|
{
|
653
|
+
$( 'span', status_button )
|
654
|
+
.removeClass( 'loader' )
|
655
|
+
.addClass( 'success' );
|
656
|
+
|
657
|
+
window.setTimeout
|
658
|
+
(
|
659
|
+
function()
|
660
|
+
{
|
661
|
+
$( 'span', status_button )
|
662
|
+
.removeClass( 'success' );
|
663
|
+
},
|
664
|
+
dataimport_timeout / 2
|
665
|
+
);
|
492
666
|
}
|
493
667
|
}
|
494
668
|
);
|
495
669
|
}
|
496
|
-
dataimport_fetch_status();
|
497
670
|
|
498
671
|
// form
|
499
672
|
|
500
|
-
$( 'form', form_element )
|
673
|
+
var form = $( 'form', form_element );
|
674
|
+
|
675
|
+
form
|
501
676
|
.ajaxForm
|
502
677
|
(
|
503
678
|
{
|
504
679
|
url : handler_url,
|
505
|
-
|
680
|
+
data : {
|
681
|
+
wt : 'json',
|
682
|
+
indent : 'true'
|
683
|
+
},
|
684
|
+
dataType : 'json',
|
685
|
+
type: 'POST',
|
506
686
|
beforeSend : function( xhr, settings )
|
507
687
|
{
|
508
|
-
$( '
|
688
|
+
$( 'button[type="submit"] span', form_element )
|
509
689
|
.addClass( 'loader' );
|
690
|
+
|
691
|
+
error_element
|
692
|
+
.empty()
|
693
|
+
.hide();
|
510
694
|
},
|
511
695
|
beforeSubmit : function( array, form, options )
|
512
696
|
{
|
@@ -545,22 +729,91 @@ sammy.get
|
|
545
729
|
array.push( { name : tmp[0], value: tmp[1] } );
|
546
730
|
}
|
547
731
|
}
|
732
|
+
|
733
|
+
if( debug_mode )
|
734
|
+
{
|
735
|
+
array.push( { name: 'dataConfig', value: $( '#dataimport_config .editable textarea' ).val() } );
|
736
|
+
}
|
548
737
|
},
|
549
738
|
success : function( response, text_status, xhr )
|
550
739
|
{
|
551
|
-
dataimport_fetch_status();
|
552
740
|
},
|
553
741
|
error : function( xhr, text_status, error_thrown )
|
554
742
|
{
|
555
|
-
|
743
|
+
var response = null;
|
744
|
+
try
|
745
|
+
{
|
746
|
+
eval( 'response = ' + xhr.responseText + ';' );
|
747
|
+
}
|
748
|
+
catch( e ){}
|
749
|
+
|
750
|
+
error_element
|
751
|
+
.text( response.error.msg || 'Unknown Error (Exception w/o Message)' )
|
752
|
+
.show();
|
556
753
|
},
|
557
754
|
complete : function( xhr, text_status )
|
558
755
|
{
|
559
|
-
$( '
|
756
|
+
$( 'button[type="submit"] span', form_element )
|
560
757
|
.removeClass( 'loader' );
|
758
|
+
|
759
|
+
var debug = $( 'input[name="debug"]:checked', form );
|
760
|
+
if( 0 !== debug.size() )
|
761
|
+
{
|
762
|
+
var code = $(
|
763
|
+
'<pre class="syntax language-json"><code>' +
|
764
|
+
app.format_json( xhr.responseText ).esc() +
|
765
|
+
'</code></pre>'
|
766
|
+
);
|
767
|
+
|
768
|
+
$( '.content', debug_response_element ).html( code );
|
769
|
+
hljs.highlightBlock( code.get(0) );
|
770
|
+
}
|
771
|
+
|
772
|
+
dataimport_fetch_status();
|
561
773
|
}
|
562
774
|
}
|
563
775
|
);
|
776
|
+
|
777
|
+
$( 'input[name="debug"]', form )
|
778
|
+
.off( 'change' )
|
779
|
+
.on
|
780
|
+
(
|
781
|
+
'change',
|
782
|
+
function( event )
|
783
|
+
{
|
784
|
+
debug_response_element.toggle( this.checked );
|
785
|
+
}
|
786
|
+
);
|
787
|
+
|
788
|
+
$( '#auto-refresh-status a', form_element )
|
789
|
+
.off( 'click' )
|
790
|
+
.on
|
791
|
+
(
|
792
|
+
'click',
|
793
|
+
function( event )
|
794
|
+
{
|
795
|
+
$.cookie( cookie_dataimport_autorefresh, $.cookie( cookie_dataimport_autorefresh ) ? null : true );
|
796
|
+
$( this ).trigger( 'state' );
|
797
|
+
|
798
|
+
dataimport_fetch_status();
|
799
|
+
|
800
|
+
return false;
|
801
|
+
}
|
802
|
+
)
|
803
|
+
.off( 'state' )
|
804
|
+
.on
|
805
|
+
(
|
806
|
+
'state',
|
807
|
+
function( event )
|
808
|
+
{
|
809
|
+
autorefresh_status = !!$.cookie( cookie_dataimport_autorefresh );
|
810
|
+
|
811
|
+
$.cookie( cookie_dataimport_autorefresh )
|
812
|
+
? $( this ).addClass( 'on' )
|
813
|
+
: $( this ).removeClass( 'on' );
|
814
|
+
}
|
815
|
+
)
|
816
|
+
.trigger( 'state' );
|
564
817
|
}
|
565
818
|
);
|
566
819
|
}
|