From 1f41a9169075bc3226da100fe08ca5ae78fff5d7 Mon Sep 17 00:00:00 2001 From: Nirvana Date: Tue, 23 Dec 2025 10:40:40 +0100 Subject: [PATCH] Enable provider --- resources/web/config.js | 48 ++++++++++++++++++++++++++++++++++++----- service.py | 23 ++++++++++++++------ 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/resources/web/config.js b/resources/web/config.js index 5d826a0..5b9fc45 100644 --- a/resources/web/config.js +++ b/resources/web/config.js @@ -41,7 +41,11 @@ function switchTab(tabId) { // Load proxy data if switching to proxy tab if (tabId === 'proxy' && window.proxyManager) { - window.proxyManager.init(providers); + // Filter to only enabled providers + const enabledProviders = window.providerEnableManager + ? window.providerEnableManager.getFilteredProviders('proxy') + : providers; + window.proxyManager.init(enabledProviders); window.proxyManager.loadProxyForms(); } @@ -199,6 +203,11 @@ async function loadProviders() { const data = await response.json(); providers = data.providers; + // Initialize enable manager + if (window.providerEnableManager) { + await window.providerEnableManager.init(providers); + } + // Load auth status for each provider await loadAuthStatus(); @@ -246,6 +255,11 @@ async function renderCredentialsForms() { return; } + // Add filter UI + if (window.addFilterUI) { + window.addFilterUI(); + } + // Load credentials for all providers in parallel const credentialsPromises = providers.map(async (provider) => { try { @@ -274,11 +288,27 @@ async function renderCredentialsForms() { // Get current auth status const status = authStatus[provider.name] || {}; + // Get enable/disable status + const isEnabled = window.providerEnableManager + ? window.providerEnableManager.isEnabled(provider.name) + : true; + const canModify = window.providerEnableManager + ? window.providerEnableManager.canModify(provider.name) + : true; + // Determine provider card class let providerCardClass = 'provider-card'; if (!needsUserCredentials) { providerCardClass += ' client-credentials-only'; } + if (!isEnabled) { + providerCardClass += ' disabled'; + } + + // Create toggle switch + const toggleSwitch = window.createToggleSwitch + ? window.createToggleSwitch(provider.name, isEnabled, canModify) + : ''; // Create form content based on auth type let formContent = ''; @@ -310,7 +340,7 @@ async function renderCredentialsForms() { `; @@ -352,9 +382,9 @@ async function renderCredentialsForms() { `; } - // Create buttons based on auth type + // Create buttons based on auth type and enabled state let buttonsHTML = ''; - if (needsUserCredentials) { + if (isEnabled && needsUserCredentials) { buttonsHTML = `
`; - } else { + } else if (isEnabled) { // For non-user-credential providers, only show test button buttonsHTML = `
@@ -388,6 +418,7 @@ async function renderCredentialsForms() {

${provider.label}

${provider.name} • ${provider.country}
+ ${isEnabled ? `
${getAuthTypeDescription(status)}
@@ -396,7 +427,9 @@ async function renderCredentialsForms() { ${getStatusText(status)}
${formatTokenExpiration(status)} + ` : ''}
+ ${toggleSwitch} ${formContent} @@ -413,6 +446,11 @@ async function renderCredentialsForms() { try { const htmls = await Promise.all(credentialsPromises); credentialsContainer.innerHTML = htmls.join(''); + + // Apply current filter + if (window.providerEnableManager) { + window.providerEnableManager.applyFilter(); + } } catch (error) { console.error('Error rendering credentials forms:', error); credentialsContainer.innerHTML = ` diff --git a/service.py b/service.py index 257d305..d79e43f 100644 --- a/service.py +++ b/service.py @@ -126,7 +126,7 @@ class UltimateService: css_path = os.path.join(web_dir, 'config.css') js_path = os.path.join(web_dir, 'config.js') - # NEW: Proxy files + # Proxy files proxy_css_path = os.path.join(web_dir, 'proxy.css') proxy_js_path = os.path.join(web_dir, 'proxy.js') @@ -136,6 +136,10 @@ class UltimateService: fuzzyset_path = os.path.join(web_dir, 'lib', 'fuzzyset.js') debounce_path = os.path.join(web_dir, 'lib', 'debounce.js') + # Enable/disable files + enable_css_path = os.path.join(web_dir, 'provider_enable.css') + enable_js_path = os.path.join(web_dir, 'provider_enable.js') + try: # Load HTML with open(html_path, 'r', encoding='utf-8') as f: @@ -145,23 +149,22 @@ class UltimateService: with open(css_path, 'r', encoding='utf-8') as f: css = f.read() - # NEW: Load proxy CSS with open(proxy_css_path, 'r', encoding='utf-8') as f: proxy_css = f.read() - # Load EPG CSS with open(epg_css_path, 'r', encoding='utf-8') as f: epg_css = f.read() + with open(enable_css_path, 'r', encoding='utf-8') as f: + enable_css = f.read() + # Load JS files with open(js_path, 'r', encoding='utf-8') as f: js = f.read() - # NEW: Load proxy JS with open(proxy_js_path, 'r', encoding='utf-8') as f: proxy_js = f.read() - # Load EPG JS and libraries with open(epg_js_path, 'r', encoding='utf-8') as f: epg_js = f.read() @@ -171,8 +174,11 @@ class UltimateService: with open(debounce_path, 'r', encoding='utf-8') as f: debounce_js = f.read() - # Combine all CSS (correct order: base -> proxy -> epg) - combined_css = f"{css}\n\n/* Proxy CSS */\n{proxy_css}\n\n/* EPG Mapping CSS */\n{epg_css}" + with open(enable_js_path, 'r', encoding='utf-8') as f: + enable_js = f.read() + + # Combine all CSS (correct order: base -> proxy -> epg -> enable) + combined_css = f"{css}\n\n/* Proxy CSS */\n{proxy_css}\n\n/* EPG Mapping CSS */\n{epg_css}\n\n/* Provider Enable/Disable CSS */\n{enable_css}" # Combine all JS (with proper order) combined_js = f""" @@ -190,6 +196,9 @@ class UltimateService: /* EPG Mapping JS */ {epg_js} + + /* Provider Enable/Disable JS */ + {enable_js} """ # Replace CSS in HTML