MCPcopy Create free account
hub / github.com/error311/FileRise / loadSources

Function loadSources

public/js/adminPanel.js:2256–2287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 || '');

Callers 1

initSourcesSectionFunction · 0.85

Calls 6

withBaseFunction · 0.85
pruneTestStatusFunction · 0.85
setStatusFunction · 0.70
tfFunction · 0.70
safeJsonFunction · 0.70
renderListFunction · 0.70

Tested by

no test coverage detected