@@ -108,7 +108,7 @@ let table = $("#collection_table").DataTable({
108108 ] ,
109109 columnDefs : [
110110 {
111- targets : 8 ,
111+ targets : [ 8 , 9 ] , // Added 9 for reindexing status ID
112112 visible : false ,
113113 } ,
114114 { width : "200px" , targets : 1 } ,
@@ -170,7 +170,7 @@ let table = $("#collection_table").DataTable({
170170 searchPanes : {
171171 show : false ,
172172 } ,
173- targets : [ 7 , 8 ] ,
173+ targets : [ 7 , 8 , 9 ] , // Added 9 for reindexing status ID
174174 } ,
175175 {
176176 searchPanes : {
@@ -180,6 +180,14 @@ let table = $("#collection_table").DataTable({
180180 } ,
181181 targets : [ 5 ] ,
182182 } ,
183+ {
184+ searchPanes : {
185+ dtOpts : {
186+ scrollY : "100%" ,
187+ } ,
188+ } ,
189+ targets : [ 6 ] , // Add searchPane for reindexing status column
190+ } ,
183191 ] ,
184192} ) ;
185193
@@ -302,6 +310,51 @@ function handleWorkflowStatusSelect() {
302310 postWorkflowStatus ( collection_id , workflow_status ) ;
303311 } ) ;
304312}
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+
305358
306359function handleCuratorSelect ( ) {
307360 $ ( "body" ) . on ( "click" , ".curator_select" , function ( ) {
@@ -334,6 +387,24 @@ function handleCuratorSelect() {
334387 } ) ;
335388}
336389
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+
337408function postCurationStatus ( collection_id , curation_status ) {
338409 var url = `/api/collections/${ collection_id } /` ;
339410 $ . ajax ( {
@@ -403,6 +474,7 @@ $(document).ready(function () {
403474 "Workflow Status" ,
404475 "Curator" ,
405476 "Connector Type" ,
477+ "Reindexing Status" ,
406478 ] ;
407479
408480 // Event listener for the collection search input
@@ -415,16 +487,16 @@ $(document).ready(function () {
415487
416488 // Filter the table based on the query in the collection name and config folder data attribute
417489 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+ }
428500 } ) ;
429501 } ) ;
430502
@@ -448,6 +520,7 @@ $(document).ready(function () {
448520function setupClickHandlers ( ) {
449521 // handleCurationStatusSelect();
450522 handleWorkflowStatusSelect ( ) ;
523+ handleReindexingStatusSelect ( ) ;
451524 handleCuratorSelect ( ) ;
452525}
453526
0 commit comments