Browse Source

Fix User Watch Stats plugin settings discovery issue

- Remove dynamic connection fields method that was causing settings discovery to fail
- Use static field definitions instead of calling getUserWatchStatsConnectionFields()
- Display all connection fields (Plex, Emby, Jellyfin) directly in settings array
- This ensures the plugin appears properly in Organizr's homepage settings interface
mgomon 8 months ago
parent
commit
7786c11507
1 changed files with 19 additions and 45 deletions
  1. 19 45
      api/homepage/userWatchStats.php

+ 19 - 45
api/homepage/userWatchStats.php

@@ -26,16 +26,25 @@ trait HomepageUserWatchStats
                     $this->settingsOption('enable', 'homepageUserWatchStatsEnabled'),
                     $this->settingsOption('auth', 'homepageUserWatchStatsAuth'),
                 ],
-                'Connection' => array_merge(
-                    [
-                        $this->settingsOption('select', 'homepageUserWatchStatsService', ['label' => 'Media Server', 'options' => [
-                            ['name' => 'Plex (via Tautulli)', 'value' => 'plex'],
-                            ['name' => 'Emby', 'value' => 'emby'],
-                            ['name' => 'Jellyfin', 'value' => 'jellyfin']
-                        ]])
-                    ],
-                    $this->getUserWatchStatsConnectionFields()
-                ),
+                'Connection' => [
+                    $this->settingsOption('select', 'homepageUserWatchStatsService', ['label' => 'Media Server', 'options' => [
+                        ['name' => 'Plex (via Tautulli)', 'value' => 'plex'],
+                        ['name' => 'Emby', 'value' => 'emby'],
+                        ['name' => 'Jellyfin', 'value' => 'jellyfin']
+                    ]]),
+                    $this->settingsOption('url', 'plexURL', ['label' => 'Tautulli URL']),
+                    $this->settingsOption('token', 'plexToken', ['label' => 'Tautulli API Key']),
+                    $this->settingsOption('disable-cert-check', 'plexDisableCertCheck'),
+                    $this->settingsOption('use-custom-certificate', 'plexUseCustomCertificate'),
+                    $this->settingsOption('url', 'embyURL', ['label' => 'Emby Server URL']),
+                    $this->settingsOption('token', 'embyToken', ['label' => 'Emby API Key']),
+                    $this->settingsOption('disable-cert-check', 'embyDisableCertCheck'),
+                    $this->settingsOption('use-custom-certificate', 'embyUseCustomCertificate'),
+                    $this->settingsOption('url', 'jellyfinURL', ['label' => 'Jellyfin Server URL']),
+                    $this->settingsOption('token', 'jellyfinToken', ['label' => 'Jellyfin API Key']),
+                    $this->settingsOption('disable-cert-check', 'jellyfinDisableCertCheck'),
+                    $this->settingsOption('use-custom-certificate', 'jellyfinUseCustomCertificate'),
+                ],
                 'Display Options' => [
                     $this->settingsOption('number', 'homepageUserWatchStatsRefresh', ['label' => 'Auto-refresh Interval (minutes)', 'min' => 1, 'max' => 60]),
                     $this->settingsOption('number', 'homepageUserWatchStatsDays', ['label' => 'Statistics Period (days)', 'min' => 1, 'max' => 365]),
@@ -54,41 +63,6 @@ trait HomepageUserWatchStats
         return array_merge($homepageInformation, $homepageSettings);
     }
 
-    private function getUserWatchStatsConnectionFields()
-    {
-        $mediaServer = $this->config['homepageUserWatchStatsService'] ?? 'plex';
-        
-        switch (strtolower($mediaServer)) {
-            case 'plex':
-                return [
-                    $this->settingsOption('url', 'plexURL', ['label' => 'Tautulli URL']),
-                    $this->settingsOption('token', 'plexToken', ['label' => 'Tautulli API Key']),
-                    $this->settingsOption('disable-cert-check', 'plexDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'plexUseCustomCertificate'),
-                ];
-            case 'emby':
-                return [
-                    $this->settingsOption('url', 'embyURL', ['label' => 'Emby Server URL']),
-                    $this->settingsOption('token', 'embyToken', ['label' => 'Emby API Key']),
-                    $this->settingsOption('disable-cert-check', 'embyDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'embyUseCustomCertificate'),
-                ];
-            case 'jellyfin':
-                return [
-                    $this->settingsOption('url', 'jellyfinURL', ['label' => 'Jellyfin Server URL']),
-                    $this->settingsOption('token', 'jellyfinToken', ['label' => 'Jellyfin API Key']),
-                    $this->settingsOption('disable-cert-check', 'jellyfinDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'jellyfinUseCustomCertificate'),
-                ];
-            default:
-                return [
-                    $this->settingsOption('url', 'plexURL', ['label' => 'Tautulli URL']),
-                    $this->settingsOption('token', 'plexToken', ['label' => 'Tautulli API Key']),
-                    $this->settingsOption('disable-cert-check', 'plexDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'plexUseCustomCertificate'),
-                ];
-        }
-    }
 
     public function testConnectionUserWatchStats()
     {