()
| 7561 | state.appsPath = (data.roots.find(function(root){ return root.label === 'DedSec'; }) || {}).path || data.current_path; |
| 7562 | data = await apiGet('/api/files?path=' + encodeURIComponent(state.appsPath)); |
| 7563 | } else { |
| 7564 | state.appsPath = data.current_path; |
| 7565 | } |
| 7566 | document.getElementById('appsPath').textContent = data.current_path; |
| 7567 | document.getElementById('appsRoots').innerHTML = pathButtons(data.roots || []); |
| 7568 | bindRootButtons('appsRoots', function(newPath){ loadApps(newPath).catch(handleError); }); |
| 7569 | var rows = []; |
| 7570 | if (data.parent_path) { |
| 7571 | rows.push('<div class="file-row"><div class="file-row-top"><div><div class="file-name">..</div><div class="file-meta">Go back</div></div></div><div class="file-actions"><button class="file-btn open-app-dir" data-path="' + escapeHtml(data.parent_path) + '">Open</button></div></div>'); |
| 7572 | } |
| 7573 | rows = rows.concat(data.entries.map(function(entry) { |
| 7574 | var actions = []; |
| 7575 | if (entry.is_dir) { |
| 7576 | actions.push('<button class="file-btn open-app-dir" data-path="' + escapeHtml(entry.path) + '">Open</button>'); |
| 7577 | } |
| 7578 | if (!entry.is_dir && entry.runnable) { |
| 7579 | actions.push('<button class="file-btn run-app-script" data-path="' + escapeHtml(entry.path) + '">Run</button>'); |
| 7580 | } |
| 7581 | return '<div class="file-row"><div class="file-row-top"><div><div class="file-name">' + escapeHtml(entry.name) + '</div><div class="file-meta">' + (entry.is_dir ? t('Folder') : (entry.runnable ? t('Runnable file') : t('File'))) + '</div></div></div><div class="file-actions">' + actions.join('') + '</div></div>'; |
| 7582 | })); |
| 7583 | document.getElementById('appsList').innerHTML = rows.join(''); |
| 7584 | document.querySelectorAll('.open-app-dir').forEach(function(btn){ |
| 7585 | btn.addEventListener('click', function(){ loadApps(btn.getAttribute('data-path')).catch(handleError); }); |
| 7586 | }); |
| 7587 | document.querySelectorAll('.run-app-script').forEach(function(btn){ |
| 7588 | btn.addEventListener('click', function(){ runDedSec(btn.getAttribute('data-path')); }); |
| 7589 | }); |
| 7590 | } |
| 7591 | |
| 7592 | async function runDedSec(path) { |
| 7593 | try { |
| 7594 | var data = await apiPost('/api/dedsec/run', { path: path }); |
| 7595 | await refreshJobs(data.session.id); |
| 7596 | setActiveApp('terminal'); |
| 7597 | showToast(t('Launched') + ' ' + (data.session.label || 'session')); |
| 7598 | } catch (err) { handleError(err); } |
| 7599 | } |
| 7600 | |
| 7601 | async function loadStore() { |
| 7602 | var data = await apiGet('/api/programs'); |
| 7603 | var items = data.programs || []; |
| 7604 | document.getElementById('storeList').innerHTML = items.map(function(program) { |
| 7605 | var actions = [ |
| 7606 | '<button class="file-btn install-program" data-id="' + escapeHtml(program.id) + '">Install</button>', |
| 7607 | '<button class="file-btn run-program" data-id="' + escapeHtml(program.id) + '">Run</button>', |
| 7608 | '<button class="file-btn delete-program" data-id="' + escapeHtml(program.id) + '">Delete</button>', |
no test coverage detected