()
| 2254 | }; |
| 2255 | |
| 2256 | const loadSources = async () => { |
| 2257 | if (sourcesCfg && sourcesCfg.available === false) { |
| 2258 | return; |
| 2259 | } |
| 2260 | setStatus(tf('loading', 'Loading...')); |
| 2261 | listEl.innerHTML = `<div class="text-muted">${tf('loading', 'Loading...')}</div>`; |
| 2262 | let data = null; |
| 2263 | try { |
| 2264 | const res = await fetch(withBase('/api/pro/sources/list.php'), { |
| 2265 | method: 'GET', |
| 2266 | credentials: 'include', |
| 2267 | headers: { 'Accept': 'application/json' } |
| 2268 | }); |
| 2269 | data = await safeJson(res); |
| 2270 | } catch (e) { |
| 2271 | console.warn('Sources list failed', e); |
| 2272 | setStatus(e?.message || tf('error', 'Error'), 'danger'); |
| 2273 | } |
| 2274 | |
| 2275 | if (data && data.ok === true) { |
| 2276 | state.enabled = !!data.enabled; |
| 2277 | state.sources = Array.isArray(data.sources) ? data.sources : []; |
| 2278 | state.activeId = data.activeId || ''; |
| 2279 | setStatus(''); |
| 2280 | } else if (!state.sources.length) { |
| 2281 | state.sources = Array.isArray(sourcesCfg.sources) ? sourcesCfg.sources : []; |
| 2282 | } |
| 2283 | |
| 2284 | if (enabledToggle) enabledToggle.checked = !!state.enabled; |
| 2285 | pruneTestStatus(); |
| 2286 | renderList(); |
| 2287 | }; |
| 2288 | |
| 2289 | const runSourceTest = async (src) => { |
| 2290 | const id = String(src.id || ''); |
no test coverage detected