Restructure for enabling/disabling

This commit is contained in:
Nirvana
2025-12-25 13:17:12 +01:00
parent ba3215c177
commit c59099bd94
4 changed files with 17 additions and 45 deletions
@@ -23,8 +23,12 @@ class ProviderMetadata:
if self.plugin_class.supports_multiple_countries():
self.name = f"{self.plugin_name}_{self.country}"
# For multi-country providers, include country in label
self.label = self.plugin_class.get_static_label(self.country)
else:
self.name = self.plugin_name
self.name = self.plugin_name # e.g., "hrti" (no country suffix)
# For single-country providers, don't include country in label
self.label = self.plugin_class.get_static_label() # ← Call WITHOUT country!
self.label = self.plugin_class.get_static_label(self.country)
self.supported_auth_types = self.plugin_class.get_static_auth_types()
+2 -1
View File
@@ -983,4 +983,5 @@ async function clearAllConfigurations() {
// Make functions available globally
window.saveCredentials = saveCredentials;
window.deleteCredentials = deleteCredentials;
window.testAuth = testAuth;
window.testAuth = testAuth;
window.loadProviders = loadProviders; // Export for provider toggle reload
+10 -6
View File
@@ -245,17 +245,21 @@ async function handleProviderToggle(providerName, checkbox) {
const success = await window.providerEnableManager.toggleProvider(providerName, newState);
if (success) {
// Update card appearance
// If enabling a provider, reload providers data to get full auth details
if (newState) {
card.classList.remove('disabled');
showAlert('success', `${providerName} enabled`);
showAlert('success', `${providerName} enabled - reloading provider details...`);
// Reload providers to get complete auth information
if (typeof loadProviders === 'function') {
await loadProviders();
}
} else {
card.classList.add('disabled');
showAlert('success', `${providerName} disabled`);
}
// Update filter info
window.providerEnableManager.applyFilter();
// Just update filter info for disabled
window.providerEnableManager.applyFilter();
}
} else {
// Revert checkbox on failure
checkbox.checked = !newState;
-37
View File
@@ -2036,43 +2036,6 @@ class UltimateService:
response.status = 500
return {'error': f'Internal server error: {str(api_err)}'}
@self.app.route('/api/providers/enabled', method='GET')
def get_all_enabled_status():
"""Get enabled status for all providers"""
try:
manager = self.manager # ProviderManager
enable_manager = ProviderEnableManager() # Our new class
all_providers = manager.list_providers()
result = {}
for provider in all_providers:
# Get current status (following precedence)
status = enable_manager.is_provider_enabled(provider)
# Get source information
source = enable_manager.get_enabled_source(provider)
# FIX: Convert enum to string value for JSON serialization
source_value = source.value if hasattr(source, 'value') else str(source)
result[provider] = {
'enabled': status,
'source': source_value, # Now a string, not an enum
'can_modify': source != 'kodi' # Can't modify if set in Kodi
}
return {
'success': True,
'providers': result,
'count': len(result)
}
except Exception as e:
logger.error(f"Error getting enabled status: {e}")
response.status = 500
return {'error': str(e)}
@self.app.route('/api/providers/<provider>/enabled', method='GET')
def get_provider_enabled(provider):
"""Get enabled status for specific provider"""