Embed U-Navigator in Dynamix
This commit is contained in:
+10
-5
@@ -1,5 +1,6 @@
|
||||
const workspace = document.querySelector('#workspace');
|
||||
const statusText = document.querySelector('#statusText');
|
||||
const API_BASE = window.UNAV_API_BASE || '/api';
|
||||
const state = {
|
||||
config: null,
|
||||
windows: [],
|
||||
@@ -25,7 +26,7 @@ init();
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
state.config = await api('/api/config');
|
||||
state.config = await api(apiUrl('config'));
|
||||
statusText.textContent = `${state.config.roots.length} Root, ${state.config.readOnly ? 'Read-only' : 'Schreibzugriff aktiv'}`;
|
||||
openExplorer(state.config.roots[0].path);
|
||||
openProperties();
|
||||
@@ -276,7 +277,7 @@ async function loadExplorer(win, targetPath) {
|
||||
win.data.path = targetPath;
|
||||
render();
|
||||
try {
|
||||
const result = await api(`/api/list?path=${encodeURIComponent(targetPath)}`);
|
||||
const result = await api(apiUrl(`list.php?path=${encodeURIComponent(targetPath)}`));
|
||||
win.data.path = result.path;
|
||||
win.data.entries = result.entries;
|
||||
} catch (error) {
|
||||
@@ -307,7 +308,7 @@ async function handleDrop(event, win, targetPath) {
|
||||
for (const file of event.dataTransfer.files) {
|
||||
form.append('files', file, file.name);
|
||||
}
|
||||
await fetchChecked(`/api/upload?path=${encodeURIComponent(targetPath)}`, {
|
||||
await fetchChecked(apiUrl(`upload.php?path=${encodeURIComponent(targetPath)}`), {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
@@ -316,7 +317,7 @@ async function handleDrop(event, win, targetPath) {
|
||||
}
|
||||
|
||||
async function createJob(type, source, destination) {
|
||||
const job = await api(`/api/jobs/${type}`, {
|
||||
const job = await api(apiUrl(`job.php?action=${encodeURIComponent(type)}`), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ source, destination })
|
||||
@@ -327,7 +328,7 @@ async function createJob(type, source, destination) {
|
||||
}
|
||||
|
||||
async function pollJob(id) {
|
||||
const job = await api(`/api/jobs/${id}`);
|
||||
const job = await api(apiUrl(`job.php?id=${encodeURIComponent(id)}`));
|
||||
state.jobs.set(id, job);
|
||||
render();
|
||||
if (['queued', 'running', 'cancel_requested'].includes(job.status)) {
|
||||
@@ -446,3 +447,7 @@ function escapeAttr(value) {
|
||||
function clamp(value, min, max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
function apiUrl(path) {
|
||||
return `${API_BASE.replace(/\/$/, '')}/${path.replace(/^\//, '')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user