@@ -108,7 +108,7 @@ let table = $("#collection_table").DataTable({
108
108
] ,
109
109
columnDefs : [
110
110
{
111
- targets : 8 ,
111
+ targets : [ 8 , 9 ] , // Added 9 for reindexing status ID
112
112
visible : false ,
113
113
} ,
114
114
{ width : "200px" , targets : 1 } ,
@@ -170,7 +170,7 @@ let table = $("#collection_table").DataTable({
170
170
searchPanes : {
171
171
show : false ,
172
172
} ,
173
- targets : [ 7 , 8 ] ,
173
+ targets : [ 7 , 8 , 9 ] , // Added 9 for reindexing status ID
174
174
} ,
175
175
{
176
176
searchPanes : {
@@ -180,6 +180,14 @@ let table = $("#collection_table").DataTable({
180
180
} ,
181
181
targets : [ 5 ] ,
182
182
} ,
183
+ {
184
+ searchPanes : {
185
+ dtOpts : {
186
+ scrollY : "100%" ,
187
+ } ,
188
+ } ,
189
+ targets : [ 6 ] , // Add searchPane for reindexing status column
190
+ } ,
183
191
] ,
184
192
} ) ;
185
193
@@ -302,6 +310,51 @@ function handleWorkflowStatusSelect() {
302
310
postWorkflowStatus ( collection_id , workflow_status ) ;
303
311
} ) ;
304
312
}
313
+ function handleReindexingStatusSelect ( ) {
314
+ $ ( "body" ) . on ( "click" , ".reindexing_status_select" , function ( ) {
315
+ var collection_id = $ ( this ) . data ( "collection-id" ) ;
316
+ var reindexing_status = $ ( this ) . attr ( "value" ) ;
317
+ var reindexing_status_text = $ ( this ) . text ( ) ;
318
+ var color_choices = {
319
+ 1 : "btn-light" , // REINDEXING_NOT_NEEDED
320
+ 2 : "btn-warning" , // REINDEXING_NEEDED_ON_DEV
321
+ 3 : "btn-secondary" , // REINDEXING_FINISHED_ON_DEV
322
+ 4 : "btn-info" , // REINDEXING_READY_FOR_CURATION
323
+ 5 : "btn-primary" , // REINDEXING_CURATED
324
+ 6 : "btn-success" , // REINDEXING_INDEXED_ON_PROD
325
+ } ;
326
+
327
+ $possible_buttons = $ ( "body" ) . find (
328
+ `[id="reindexing-status-button-${ collection_id } "]`
329
+ ) ;
330
+ if ( $possible_buttons . length > 1 ) {
331
+ $button = $possible_buttons [ 1 ] ;
332
+ $button = $ ( $button ) ;
333
+ } else {
334
+ $button = $ ( `#reindexing-status-button-${ collection_id } ` ) ;
335
+ }
336
+ $button . text ( reindexing_status_text ) ;
337
+ $button . removeClass (
338
+ "btn-light btn-danger btn-warning btn-info btn-success btn-primary btn-secondary"
339
+ ) ;
340
+ $button . addClass ( color_choices [ parseInt ( reindexing_status ) ] ) ;
341
+ var row = table . row ( "#" + collection_id ) ;
342
+ let index = row . index ( ) ;
343
+ var $html = $ ( "<div />" , { html : table . data ( ) [ index ] [ 9 ] } ) ; // Assuming this is column index 9
344
+ $html . find ( "button" ) . html ( reindexing_status_text ) ;
345
+ $html
346
+ . find ( "button" )
347
+ . removeClass (
348
+ "btn-light btn-danger btn-warning btn-info btn-success btn-primary btn-secondary"
349
+ ) ;
350
+ $html . find ( "button" ) . addClass ( color_choices [ parseInt ( reindexing_status ) ] ) ;
351
+ table . data ( ) [ index ] [ 9 ] = $html . html ( ) ;
352
+ $ ( "#collection_table" ) . DataTable ( ) . searchPanes . rebuildPane ( 9 ) ;
353
+
354
+ postReindexingStatus ( collection_id , reindexing_status ) ;
355
+ } ) ;
356
+ }
357
+
305
358
306
359
function handleCuratorSelect ( ) {
307
360
$ ( "body" ) . on ( "click" , ".curator_select" , function ( ) {
@@ -334,6 +387,24 @@ function handleCuratorSelect() {
334
387
} ) ;
335
388
}
336
389
390
+ function postReindexingStatus ( collection_id , reindexing_status ) {
391
+ var url = `/api/collections/${ collection_id } /` ;
392
+ $ . ajax ( {
393
+ url : url ,
394
+ type : "PUT" ,
395
+ data : {
396
+ reindexing_status : reindexing_status ,
397
+ csrfmiddlewaretoken : csrftoken ,
398
+ } ,
399
+ headers : {
400
+ "X-CSRFToken" : csrftoken ,
401
+ } ,
402
+ success : function ( data ) {
403
+ toastr . success ( "Reindexing Status Updated!" ) ;
404
+ } ,
405
+ } ) ;
406
+ }
407
+
337
408
function postCurationStatus ( collection_id , curation_status ) {
338
409
var url = `/api/collections/${ collection_id } /` ;
339
410
$ . ajax ( {
@@ -403,6 +474,7 @@ $(document).ready(function () {
403
474
"Workflow Status" ,
404
475
"Curator" ,
405
476
"Connector Type" ,
477
+ "Reindexing Status" ,
406
478
] ;
407
479
408
480
// Event listener for the collection search input
@@ -415,16 +487,16 @@ $(document).ready(function () {
415
487
416
488
// Filter the table based on the query in the collection name and config folder data attribute
417
489
table . rows ( ) . every ( function ( ) {
418
- let row = $ ( this . node ( ) ) ;
419
- let name = row . find ( 'td' ) . first ( ) . text ( ) . toLowerCase ( ) ;
420
- let configFolder = row . data ( 'config-folder' ) . toLowerCase ( ) ;
421
- let url = row . find ( 'td' ) . eq ( 1 ) . text ( ) . toLowerCase ( ) ;
422
-
423
- if ( name . includes ( query ) || configFolder . includes ( query ) || url . includes ( query ) ) {
424
- row . show ( ) ;
425
- } else {
426
- row . hide ( ) ;
427
- }
490
+ let row = $ ( this . node ( ) ) ;
491
+ let name = row . find ( 'td' ) . first ( ) . text ( ) . toLowerCase ( ) ;
492
+ let configFolder = row . data ( 'config-folder' ) . toLowerCase ( ) ;
493
+ let url = row . find ( 'td' ) . eq ( 1 ) . text ( ) . toLowerCase ( ) ;
494
+
495
+ if ( name . includes ( query ) || configFolder . includes ( query ) || url . includes ( query ) ) {
496
+ row . show ( ) ;
497
+ } else {
498
+ row . hide ( ) ;
499
+ }
428
500
} ) ;
429
501
} ) ;
430
502
@@ -448,6 +520,7 @@ $(document).ready(function () {
448
520
function setupClickHandlers ( ) {
449
521
// handleCurationStatusSelect();
450
522
handleWorkflowStatusSelect ( ) ;
523
+ handleReindexingStatusSelect ( ) ;
451
524
handleCuratorSelect ( ) ;
452
525
}
453
526
0 commit comments