@@ -4702,51 +4702,8 @@ let huntarrUI = {
4702
4702
}
4703
4703
}
4704
4704
4705
- // Update stats display
4706
- const updateElement = ( id , value , tooltip = '' ) => {
4707
- const element = document . getElementById ( id ) ;
4708
- if ( element ) {
4709
- element . textContent = value || '--' ;
4710
- if ( tooltip ) {
4711
- element . title = tooltip ;
4712
- }
4713
- }
4714
- } ;
4715
-
4716
- // Update basic stats
4717
- updateElement ( 'prowlarr-active-indexers' , stats . active_indexers ) ;
4718
- updateElement ( 'prowlarr-total-calls' , stats . total_api_calls ) ;
4719
- updateElement ( 'prowlarr-throttled' , stats . throttled_indexers ) ;
4720
- updateElement ( 'prowlarr-failed' , stats . failed_indexers ) ;
4721
-
4722
- // Update detailed tooltips with indexer names if available
4723
- if ( stats . indexer_details ) {
4724
- const activeNames = stats . indexer_details . active ?. map ( idx => idx . name ) . join ( ', ' ) || 'None' ;
4725
- const throttledNames = stats . indexer_details . throttled ?. map ( idx => idx . name ) . join ( ', ' ) || 'None' ;
4726
- const failedNames = stats . indexer_details . failed ?. map ( idx => idx . name ) . join ( ', ' ) || 'None' ;
4727
-
4728
- updateElement ( 'prowlarr-active-indexers' , stats . active_indexers , `Active: ${ activeNames } ` ) ;
4729
- updateElement ( 'prowlarr-throttled' , stats . throttled_indexers , `Throttled: ${ throttledNames } ` ) ;
4730
- updateElement ( 'prowlarr-failed' , stats . failed_indexers , `Failed: ${ failedNames } ` ) ;
4731
- }
4732
-
4733
- // Update health status
4734
- const healthStatus = document . getElementById ( 'prowlarr-health-status' ) ;
4735
- if ( healthStatus ) {
4736
- healthStatus . textContent = stats . health_status || 'Unknown' ;
4737
-
4738
- // Color-code health status
4739
- healthStatus . className = 'health-status-text' ;
4740
- if ( stats . health_status ?. includes ( 'healthy' ) ) {
4741
- healthStatus . style . color = '#10b981' ; // Green
4742
- } else if ( stats . health_status ?. includes ( 'throttled' ) ) {
4743
- healthStatus . style . color = '#f59e0b' ; // Amber
4744
- } else if ( stats . health_status ?. includes ( 'failed' ) || stats . health_status ?. includes ( 'disabled' ) ) {
4745
- healthStatus . style . color = '#ef4444' ; // Red
4746
- } else {
4747
- healthStatus . style . color = '#9ca3af' ; // Gray
4748
- }
4749
- }
4705
+ // Update indexers list
4706
+ this . updateIndexersList ( stats . indexer_details )
4750
4707
4751
4708
} else {
4752
4709
// Handle error case
@@ -4761,31 +4718,95 @@ let huntarrUI = {
4761
4718
connectionStatus . className = 'status-badge error' ;
4762
4719
}
4763
4720
4764
- // Set all stats to error state
4765
- [ 'prowlarr-active-indexers' , 'prowlarr-total-calls' , 'prowlarr-throttled' , 'prowlarr-failed' ] . forEach ( id => {
4766
- const element = document . getElementById ( id ) ;
4767
- if ( element ) {
4768
- element . textContent = '--' ;
4769
- element . title = data . message || 'Connection error' ;
4770
- }
4771
- } ) ;
4772
-
4773
- const healthStatus = document . getElementById ( 'prowlarr-health-status' ) ;
4774
- if ( healthStatus ) {
4775
- healthStatus . textContent = data . message || 'Connection error' ;
4776
- healthStatus . style . color = '#ef4444' ; // Red
4777
- }
4721
+ // Show error in indexers list
4722
+ this . updateIndexersList ( null , data . message || 'Connection error' ) ;
4778
4723
}
4779
4724
} )
4780
4725
. catch ( error => {
4781
4726
console . error ( '[huntarrUI] Error loading Prowlarr status:' , error ) ;
4782
4727
4783
- // Hide the card on error
4728
+ // Show the card with error state
4784
4729
const prowlarrCard = document . getElementById ( 'prowlarrStatusCard' ) ;
4785
4730
if ( prowlarrCard ) {
4786
- prowlarrCard . style . display = 'none' ;
4731
+ prowlarrCard . style . display = 'block' ;
4732
+
4733
+ // Update connection status to error
4734
+ const connectionStatus = document . getElementById ( 'prowlarrConnectionStatus' ) ;
4735
+ if ( connectionStatus ) {
4736
+ connectionStatus . textContent = '🔴 Error' ;
4737
+ connectionStatus . className = 'status-badge error' ;
4738
+ }
4739
+
4740
+ // Show error in indexers list
4741
+ this . updateIndexersList ( null , 'Failed to load Prowlarr data' ) ;
4787
4742
}
4788
4743
} ) ;
4744
+ } ,
4745
+
4746
+ // Update indexers list display
4747
+ updateIndexersList : function ( indexerDetails , errorMessage = null ) {
4748
+ const indexersList = document . getElementById ( 'prowlarr-indexers-list' ) ;
4749
+ if ( ! indexersList ) return ;
4750
+
4751
+ if ( errorMessage ) {
4752
+ // Show error state
4753
+ indexersList . innerHTML = `<div class="loading-text" style="color: #ef4444;">${ errorMessage } </div>` ;
4754
+ return ;
4755
+ }
4756
+
4757
+ if ( ! indexerDetails || ( ! indexerDetails . active && ! indexerDetails . throttled && ! indexerDetails . failed ) ) {
4758
+ // No indexers found
4759
+ indexersList . innerHTML = '<div class="loading-text">No indexers configured</div>' ;
4760
+ return ;
4761
+ }
4762
+
4763
+ // Combine all indexers and sort alphabetically
4764
+ let allIndexers = [ ] ;
4765
+
4766
+ // Add active indexers
4767
+ if ( indexerDetails . active ) {
4768
+ allIndexers = allIndexers . concat (
4769
+ indexerDetails . active . map ( idx => ( { ...idx , status : 'active' } ) )
4770
+ ) ;
4771
+ }
4772
+
4773
+ // Add throttled indexers
4774
+ if ( indexerDetails . throttled ) {
4775
+ allIndexers = allIndexers . concat (
4776
+ indexerDetails . throttled . map ( idx => ( { ...idx , status : 'throttled' } ) )
4777
+ ) ;
4778
+ }
4779
+
4780
+ // Add failed indexers
4781
+ if ( indexerDetails . failed ) {
4782
+ allIndexers = allIndexers . concat (
4783
+ indexerDetails . failed . map ( idx => ( { ...idx , status : 'failed' } ) )
4784
+ ) ;
4785
+ }
4786
+
4787
+ // Sort alphabetically by name
4788
+ allIndexers . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
4789
+
4790
+ if ( allIndexers . length === 0 ) {
4791
+ indexersList . innerHTML = '<div class="loading-text">No indexers found</div>' ;
4792
+ return ;
4793
+ }
4794
+
4795
+ // Build the HTML for indexers list
4796
+ const indexersHtml = allIndexers . map ( indexer => {
4797
+ const statusText = indexer . status === 'active' ? 'Active' :
4798
+ indexer . status === 'throttled' ? 'Throttled' :
4799
+ 'Failed' ;
4800
+
4801
+ return `
4802
+ <div class="indexer-item">
4803
+ <span class="indexer-name">${ indexer . name } </span>
4804
+ <span class="indexer-status ${ indexer . status } ">${ statusText } </span>
4805
+ </div>
4806
+ ` ;
4807
+ } ) . join ( '' ) ;
4808
+
4809
+ indexersList . innerHTML = indexersHtml ;
4789
4810
}
4790
4811
} ;
4791
4812
0 commit comments