Add opt-in MCP access with local authorization and revocable identities
CI / verify (push) Canceled after 0s
CI / verify (push) Canceled after 0s
This commit is contained in:
1 parent
febe654189
commit
93e0196dbe
20 files changed
+1246
-8
No files matched your search
+12
-5
@@ -2415,6 +2415,7 @@ function restoreQueueStateFromConfig() {
|
||||
sourceCleanupCompletedHosters: Array.isArray(job.sourceCleanupCompletedHosters) ? [...job.sourceCleanupCompletedHosters] : [],
|
||||
sourceCleanupFingerprint: job.sourceCleanupFingerprint || null,
|
||||
automationAdmission: job.automationAdmission === true,
|
||||
mcpAdmission: job.mcpAdmission === true,
|
||||
sourceFileIdentity: job.sourceFileIdentity,
|
||||
automationMtimeMs: Number.isFinite(Number(job.automationMtimeMs)) ? Number(job.automationMtimeMs) : null,
|
||||
automationSize: Number.isFinite(Number(job.automationSize)) ? Number(job.automationSize) : null,
|
||||
@@ -2447,7 +2448,7 @@ function buildPersistedQueueState() {
|
||||
const selectedFileMap = new Map(selectedFiles.map(file => [file.path, file]));
|
||||
|
||||
for (const job of persistableJobs) {
|
||||
if (job.file && job.automationAdmission !== true && !selectedFileMap.has(job.file)) {
|
||||
if (job.file && job.automationAdmission !== true && job.mcpAdmission !== true && !selectedFileMap.has(job.file)) {
|
||||
selectedFileMap.set(job.file, {
|
||||
path: job.file,
|
||||
name: job.fileName,
|
||||
@@ -2502,6 +2503,7 @@ function buildPersistedQueueState() {
|
||||
sourceCleanupCompletedHosters: Array.isArray(job.sourceCleanupCompletedHosters) ? [...job.sourceCleanupCompletedHosters] : [],
|
||||
sourceCleanupFingerprint: job.sourceCleanupFingerprint || null,
|
||||
automationAdmission: job.automationAdmission === true,
|
||||
mcpAdmission: job.mcpAdmission === true,
|
||||
sourceFileIdentity: job.sourceFileIdentity,
|
||||
automationMtimeMs: Number.isFinite(Number(job.automationMtimeMs)) ? Number(job.automationMtimeMs) : null,
|
||||
automationSize: Number.isFinite(Number(job.automationSize)) ? Number(job.automationSize) : null,
|
||||
@@ -2898,7 +2900,7 @@ function suppressPreviewKeysStillSelected(keys) {
|
||||
// Build preview jobs from selected files x selected hosters (before upload starts)
|
||||
function buildQueuePreview() {
|
||||
const hosters = getSelectedHosters();
|
||||
queueJobs = queueJobs.filter(j => j.status !== 'preview' || j.automationAdmission === true);
|
||||
queueJobs = queueJobs.filter(j => j.status !== 'preview' || j.automationAdmission === true || j.mcpAdmission === true);
|
||||
|
||||
if (hosters.length > 0) {
|
||||
const existingKeys = new Set();
|
||||
@@ -4885,8 +4887,9 @@ function _markSkippedJobs(result) {
|
||||
renderQueueTable();
|
||||
}
|
||||
|
||||
async function startSelectedUpload(explicitJobs) {
|
||||
async function startSelectedUpload(explicitJobs, options = {}) {
|
||||
if (await isAutomationPaused()) return { ok: false, error: 'Automatik ist pausiert' };
|
||||
if (options.guard) await options.guard();
|
||||
const scopedJobs = Array.isArray(explicitJobs) ? explicitJobs : _getVisibleSelectedQueueJobs();
|
||||
if (uploading) {
|
||||
_hydrateMissingJobSizes();
|
||||
@@ -4906,6 +4909,7 @@ async function startSelectedUpload(explicitJobs) {
|
||||
renderQueueTable();
|
||||
let result = null;
|
||||
try {
|
||||
if (options.guard) await options.guard();
|
||||
result = await submitAddJobsRequest(addRequest);
|
||||
} catch (err) {
|
||||
restoreSourceCleanupStates(cleanupPreparation.rollbackStates);
|
||||
@@ -4995,6 +4999,7 @@ async function startSelectedUpload(explicitJobs) {
|
||||
jobs: jobsToStart.map(serializeUploadJob),
|
||||
sourceCleanupGroups: cleanupPreparation.groups
|
||||
};
|
||||
if (options.guard) await options.guard();
|
||||
const result = await window.api.startUpload(uploadPayload);
|
||||
if (result && result.error) {
|
||||
restoreSourceCleanupStates(cleanupPreparation.rollbackStates);
|
||||
@@ -5705,7 +5710,7 @@ function moveSelectedJobs(direction) {
|
||||
function syncSelectedFilesFromQueue() {
|
||||
const fileMap = new Map();
|
||||
queueJobs
|
||||
.filter((job) => job.automationAdmission !== true && !['done', 'skipped', 'aborted'].includes(job.status))
|
||||
.filter((job) => job.automationAdmission !== true && job.mcpAdmission !== true && !['done', 'skipped', 'aborted'].includes(job.status))
|
||||
.forEach((job) => {
|
||||
if (!job.file || fileMap.has(job.file)) return;
|
||||
fileMap.set(job.file, {
|
||||
@@ -6564,7 +6569,7 @@ function renderSettings() {
|
||||
{ id: 'automatik', label: 'Automatik', group: 'base', icon: 'clock', description: 'Wiederholungen und Ordner', search: 'automatisch automation automatic retry wiederholen ordner folder monitor überwachen watch dateierweiterungen extensions unterordner subfolders duplikate duplicates' },
|
||||
{ id: 'benachrichtigungen', label: 'Benachrichtigungen', group: 'connections', icon: 'bell', description: 'Meldungen und Webhooks', search: 'benachrichtigungen notifications webhook discord meldung message ping erwähnung mention batch fertig completed' },
|
||||
{ id: 'logs', label: 'Logs & Support', group: 'management', icon: 'files', description: 'Protokolle und Supportpakete', search: 'log logs protokoll logging debug verbose diagnose diagnostics support paket package datei file ordner folder' },
|
||||
{ id: 'remote', label: 'Fernsteuerung', group: 'connections', icon: 'monitor', description: 'Server und Verbindungen', search: 'remote control fernsteuerung server input port api token verbindung connection client' },
|
||||
{ id: 'remote', label: 'Fernsteuerung', group: 'connections', icon: 'monitor', description: 'Server und Verbindungen', search: 'remote control fernsteuerung mcp server input port api token verbindung connection client' },
|
||||
{ id: 'diagnose', label: 'Diagnose-Zugriff', group: 'connections', icon: 'shield', description: 'Zugriff und Freigaben', search: 'diagnose diagnostics access zugriff lesen read allowlist netzwerk network lokal local verbindung connection code support' },
|
||||
{ id: 'backup', label: 'Backup & Übertragen', group: 'management', icon: 'archive', description: 'Sichern, importieren und exportieren', search: 'backup transfer sichern export import online schlüssel key einstellungen settings accounts übertragen' }
|
||||
];
|
||||
@@ -6948,6 +6953,7 @@ function renderSettings() {
|
||||
|
||||
pages.remote.innerHTML = `
|
||||
${pageHeader('Fernsteuerung', 'Upload-Funktionen über einen verbundenen Client steuern.')}
|
||||
${window.renderMcpSettings ? window.renderMcpSettings() : ''}
|
||||
<div class="settings-section-label">Server <span class="panel-status${remoteSettings.enabled ? ' active' : ''}" id="remoteStatusBadge">${remoteSettings.enabled ? 'Aktiv' : 'Inaktiv'}</span></div>
|
||||
<div class="settings-grid-mini">
|
||||
<div class="settings-row checkbox-row">
|
||||
@@ -7318,6 +7324,7 @@ function renderSettings() {
|
||||
|
||||
_renderLogPathsList(document.getElementById('logPathsList'));
|
||||
void refreshCloudLogStatus();
|
||||
void window.bindMcpSettings?.();
|
||||
document.getElementById('cloudLogActivateBtn')?.addEventListener('click', () => configureCloudLog(true));
|
||||
document.getElementById('cloudLogDisableBtn')?.addEventListener('click', () => configureCloudLog(false));
|
||||
document.getElementById('cloudLogBackfillBtn')?.addEventListener('click', backfillCloudLog);
|
||||
|
||||
@@ -4,6 +4,32 @@
|
||||
if (root) root.I18n = api;
|
||||
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
||||
const pairs = [
|
||||
['Strukturierter Fernzugriff über HTTPS. Nur bei laufender Anwendung; keine Portfreigabe erforderlich. Berechtigungen werden ausschließlich hier vergeben.', 'Structured remote access over HTTPS. Available while the app is running; no inbound port required. Permissions can only be granted here.'],
|
||||
['Installationsname', 'Installation name'],
|
||||
['Lokale Berechtigungen', 'Local permissions'],
|
||||
['Lesen und Diagnose', 'Read and diagnostics'],
|
||||
['App steuern', 'Control app'],
|
||||
['Freigegebene Ordner', 'Granted directories'],
|
||||
['Zugangsdaten explizit auslesen', 'Explicitly reveal secrets'],
|
||||
['Speichern und aktivieren', 'Save and enable'],
|
||||
['Deaktivieren und widerrufen', 'Disable and revoke'],
|
||||
['Verbindungscode kopieren', 'Copy connection code'],
|
||||
['Zugang erneuern', 'Rotate access'],
|
||||
['Letzter Kontakt', 'Last contact'],
|
||||
['Ausstehende Widerrufe', 'Pending revocations'],
|
||||
['Der Verbindungscode ist ein Zugangsschlüssel. Er wird weder im Backup gespeichert noch auf andere Installationen übertragen. Löschungen und andere gefährliche Aktionen verlangen eine lokale Bestätigung.', 'The connection code is a credential. It is not stored in backups or transferred to other installations. Deletions and other dangerous actions require local confirmation.'],
|
||||
['Ordner freigeben', 'Grant directory'],
|
||||
['Schreibzugriff', 'Write access'],
|
||||
['MCP-Aktion fehlgeschlagen. Verbindung und lokale Berechtigungen prüfen.', 'MCP action failed. Check connection and local permissions.'],
|
||||
['Verbindungscode kopiert.', 'Connection code copied.'],
|
||||
['Verbindung wird hergestellt', 'Connecting'],
|
||||
['Nicht verbunden – erneuter Versuch', 'Offline – retrying'],
|
||||
['Zugang abgelehnt', 'Access rejected'],
|
||||
['Zugangsdaten nicht lesbar', 'Credentials unavailable'],
|
||||
['Registrierung fehlgeschlagen', 'Enrollment failed'],
|
||||
['Verbunden', 'Connected'],
|
||||
['Deaktiviert', 'Disabled'],
|
||||
['Wird geladen', 'Loading'],
|
||||
['Konfiguration', 'Configuration'],
|
||||
['Grundlagen', 'Basics'],
|
||||
['Verwaltung', 'Management'],
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<meta name="theme-color" content="#0f0f0f">
|
||||
<title>Multi-Hoster-Uploader</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<link rel="stylesheet" href="mcp.css">
|
||||
</head>
|
||||
<body>
|
||||
<svg class="icon-sprite" aria-hidden="true">
|
||||
@@ -740,6 +741,7 @@
|
||||
<script src="auto-resume.js"></script>
|
||||
<script src="queue-stats.js"></script>
|
||||
<script src="i18n.js"></script>
|
||||
<script src="mcp.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
.mcp-controls { margin-bottom: 28px; font-size: 13px; }
|
||||
.mcp-controls p { line-height: 1.6; overflow-wrap: anywhere; }
|
||||
.mcp-controls .settings-row input { min-width: 0; flex: 1; }
|
||||
.mcp-permissions { display: flex; flex-wrap: wrap; gap: 16px 24px; border: 1px solid var(--border, #424242); border-radius: 6px; padding: 16px; margin: 16px 0; }
|
||||
.mcp-permissions label, .mcp-grant label { display: flex; align-items: center; gap: 6px; }
|
||||
.mcp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
|
||||
.mcp-actions .btn { white-space: normal; }
|
||||
.mcp-status { display: flex; flex-wrap: wrap; gap: 18px 32px; border: 1px solid var(--border, #424242); border-radius: 6px; padding: 16px; }
|
||||
.mcp-status dt { margin-bottom: 8px; }
|
||||
.mcp-status dd { margin: 0; font-weight: 600; }
|
||||
.mcp-state { padding: 5px 8px; border: 1px solid var(--border, #555); border-radius: 5px; }
|
||||
.mcp-state.connected { color: #a2edc1; background: #193829; border-color: #46735b; }
|
||||
.mcp-grant { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border, #424242); }
|
||||
.mcp-grant > span { flex: 1 1 220px; overflow-wrap: anywhere; }
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
(() => {
|
||||
const cancelled = new Set();
|
||||
const text = (de, _en) => de;
|
||||
const page = (items, args) => {
|
||||
const offset = args.offset || 0;
|
||||
const limit = args.limit || 100;
|
||||
return { total: items.length, offset, items: items.slice(offset, offset + limit), nextOffset: offset + limit < items.length ? offset + limit : null };
|
||||
};
|
||||
const refresh = async () => {
|
||||
config = await window.api.getConfig();
|
||||
hosterSettings = config.hosterSettings || {};
|
||||
ensureAccountStatusEntries(); syncSelectedUploadHosters(); renderAccounts(); renderHosterSummary();
|
||||
};
|
||||
const redraw = () => { rebuildJobIndex(); _queueStatsCache = null; syncSelectedFilesFromQueue(); renderQueueTable(); updateUploadView({ rebuildPreview: false }); updateStatusBar(); };
|
||||
const select = args => {
|
||||
const ids = new Set(args.jobIds || []);
|
||||
const jobs = queueJobs.filter(job => ids.has(job.id));
|
||||
if (jobs.length !== ids.size) throw new Error('JOB_NOT_FOUND');
|
||||
return jobs;
|
||||
};
|
||||
const handlers = {
|
||||
state: async () => ({ uploading, queueCount: queueJobs.length, selectedFileCount: selectedFiles.length, counts: queueJobs.reduce((out, job) => { out[job.status] = (out[job.status] || 0) + 1; return out; }, {}) }),
|
||||
refresh,
|
||||
'account-results': async args => { for (const row of args.results) { if (findAccountById(row.accountId)) accountStatuses[row.accountId] = { status: row.status, message: row.message, storage: row.storage, checkedAt: row.checkedAt || new Date().toISOString() }; } renderAccounts(); return { updated: args.results.length }; },
|
||||
'queue-list': async args => page(queueJobs.filter(job => !args.status || job.status === args.status).map(job => ({ id: job.id, fileName: job.fileName, hoster: job.hoster, status: job.status, bytesUploaded: job.bytesUploaded, bytesTotal: job.bytesTotal, speedKbs: job.speedKbs, error: job.error, result: job.result, attempt: job.attempt })), args),
|
||||
'queue-add': async (args, guard) => {
|
||||
const inspection = await window.api.inspectImportFiles(args.paths, existingImportPaths());
|
||||
await guard();
|
||||
const jobs = inspection.accepted.flatMap(file => args.hosters.filter(hoster => window.ImportPreflight.isImportPairEligible(file, hoster, hosterSettings)).map(hoster => ({ ...createAutomationPreviewJob(file, hoster), automationAdmission: false, mcpAdmission: true })));
|
||||
clearDedupKeysForPaths(new Set(inspection.accepted.map(file => file.path)));
|
||||
queueJobs.push(...jobs); redraw(); await persistQueueStateNow();
|
||||
return { addedJobs: jobs.length, rejectedFiles: inspection.duplicateCount + inspection.unavailableCount };
|
||||
},
|
||||
'queue-start': async (args, guard) => {
|
||||
const jobs = args.jobIds?.length ? select(args) : queueJobs.filter(job => isStartableQueueStatus(job.status));
|
||||
await guard();
|
||||
if (!jobs.length) return { started: false, reason: 'NO_ELIGIBLE_JOBS' };
|
||||
return await startSelectedUpload(jobs, { guard }) || { started: false };
|
||||
},
|
||||
'queue-retry': async (args, guard) => {
|
||||
const jobs = select(args);
|
||||
if (jobs.some(job => !['error', 'aborted', 'skipped'].includes(job.status))) throw new Error('JOB_NOT_RETRYABLE');
|
||||
await guard();
|
||||
for (const job of jobs) {
|
||||
if (job.uploadId) { _jobIndexByUploadId.delete(job.uploadId); _deletedJobIds.add(job.uploadId); }
|
||||
Object.assign(job, { status: 'preview', error: null, result: null, bytesUploaded: 0, progress: 0, uploadId: null, mcpAdmission: true });
|
||||
}
|
||||
redraw(); await persistQueueStateNow(); await guard();
|
||||
return await startSelectedUpload(jobs, { guard }) || { started: false };
|
||||
},
|
||||
'queue-cancel': async (args, guard) => {
|
||||
const jobs = select(args);
|
||||
await guard();
|
||||
await window.api.cancelSelectedJobs(jobs.map(job => job.id));
|
||||
for (const job of jobs) if (!['done', 'error', 'skipped'].includes(job.status)) Object.assign(job, { status: 'aborted', speedKbs: 0, error: 'Abgebrochen' });
|
||||
redraw(); await persistQueueStateNow(); return { cancelled: jobs.length };
|
||||
},
|
||||
'queue-remove': async (args, guard) => {
|
||||
const jobs = select(args);
|
||||
if (jobs.some(job => !['preview', 'done', 'error', 'skipped', 'aborted'].includes(job.status))) throw new Error('CANCEL_ACTIVE_JOBS_FIRST');
|
||||
await guard();
|
||||
const ids = new Set(jobs.map(job => job.id));
|
||||
jobs.forEach(job => removeJobFromIndex(job)); queueJobs = queueJobs.filter(job => !ids.has(job.id));
|
||||
redraw(); await persistQueueStateNow(); return { removed: jobs.length };
|
||||
},
|
||||
'queue-clear': async (args, guard) => handlers['queue-remove']({ jobIds: queueJobs.filter(job => ['preview', 'done', 'error', 'skipped', 'aborted'].includes(job.status)).map(job => job.id) }, guard)
|
||||
};
|
||||
window.api.onMcpCancel(id => { cancelled.add(id); if (cancelled.size > 128) cancelled.delete(cancelled.values().next().value); });
|
||||
window.api.onMcpAction(async request => {
|
||||
const guard = async () => { if (cancelled.has(request.id) || Date.now() >= request.deadline || !await window.api.mcpCheck(request.id)) throw new Error('REQUEST_EXPIRED'); };
|
||||
try {
|
||||
if (!Object.hasOwn(handlers, request.action)) throw new Error('ACTION_UNAVAILABLE');
|
||||
await guard();
|
||||
const result = await handlers[request.action](request.args, guard);
|
||||
window.api.mcpReply({ id: request.id, ok: true, result });
|
||||
} catch { window.api.mcpReply({ id: request.id, ok: false }); }
|
||||
finally { cancelled.delete(request.id); }
|
||||
});
|
||||
let current = null;
|
||||
const renderStatus = state => {
|
||||
current = state;
|
||||
const area = document.getElementById('mcpControls');
|
||||
if (!area) return;
|
||||
const states = {
|
||||
disabled: text('Deaktiviert', 'Disabled'), connecting: text('Verbindung wird hergestellt', 'Connecting'), online: text('Verbunden', 'Connected'), offline: text('Nicht verbunden – erneuter Versuch', 'Offline – retrying'),
|
||||
blocked: text('Zugang abgelehnt', 'Access rejected'), 'storage-error': text('Zugangsdaten nicht lesbar', 'Credentials unavailable'), 'enrollment-error': text('Registrierung fehlgeschlagen', 'Enrollment failed'), starting: text('Wird geladen', 'Loading')
|
||||
};
|
||||
area.querySelector('[data-mcp-status]').textContent = states[state.connection] || state.connection;
|
||||
area.querySelector('[data-mcp-status]').className = `mcp-state ${state.connection === 'online' ? 'connected' : ''}`;
|
||||
area.querySelector('[data-mcp-contact]').textContent = state.lastContact ? new Date(state.lastContact).toLocaleString(getUiLocale()) : '—';
|
||||
area.querySelector('[data-mcp-pending]').textContent = Number(state.pendingRevocations || 0).toLocaleString(getUiLocale());
|
||||
for (const action of ['copy', 'rotate']) area.querySelector(`[data-mcp-action="${action}"]`).disabled = !state.enabled;
|
||||
area.querySelector('[data-mcp-action="disable"]').disabled = !state.enabled && !state.installationId;
|
||||
area.querySelector('[data-mcp-grants]').replaceChildren(...(state.grants || []).map(grant => {
|
||||
const row = document.createElement('div'); row.className = 'mcp-grant';
|
||||
const name = document.createElement('span'); name.textContent = grant.path;
|
||||
const label = document.createElement('label'); const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.checked = !grant.readOnly;
|
||||
label.append(checkbox, text(' Schreibzugriff', ' Write access'));
|
||||
checkbox.onchange = () => act(() => window.api.mcpUpdateGrant({ id: grant.id, remove: false, readOnly: !checkbox.checked }));
|
||||
const remove = document.createElement('button'); remove.type = 'button'; remove.className = 'btn btn-sm btn-secondary'; remove.textContent = text('Entfernen', 'Remove');
|
||||
remove.onclick = () => act(() => window.api.mcpUpdateGrant({ id: grant.id, remove: true, readOnly: true }));
|
||||
row.append(name, label, remove); return row;
|
||||
}));
|
||||
};
|
||||
const act = async action => {
|
||||
try { const state = await action(); if (state && typeof state === 'object') renderStatus(state); }
|
||||
catch { showCopyToast(text('MCP-Aktion fehlgeschlagen. Verbindung und lokale Berechtigungen prüfen.', 'MCP action failed. Check connection and local permissions.'), 6000, 'error'); if (current) renderStatus(current); }
|
||||
};
|
||||
window.renderMcpSettings = () => `<section id="mcpControls" class="mcp-controls">
|
||||
<div class="settings-section-label">MCP</div>
|
||||
<p>${text('Strukturierter Fernzugriff über HTTPS. Nur bei laufender Anwendung; keine Portfreigabe erforderlich. Berechtigungen werden ausschließlich hier vergeben.', 'Structured remote access over HTTPS. Available while the app is running; no inbound port required. Permissions can only be granted here.')}</p>
|
||||
<div class="settings-row"><label for="mcpName">${text('Installationsname', 'Installation name')}</label><input id="mcpName" class="key-input" maxlength="100"></div>
|
||||
<fieldset class="mcp-permissions"><legend>${text('Lokale Berechtigungen', 'Local permissions')}</legend>${[['read','Lesen und Diagnose','Read and diagnostics'],['control','App steuern','Control app'],['files','Freigegebene Ordner','Granted directories'],['secrets','Zugangsdaten explizit auslesen','Explicitly reveal secrets']].map(([value,de,en])=>`<label><input type="checkbox" value="${value}"> ${text(de,en)}</label>`).join('')}</fieldset>
|
||||
<div class="mcp-actions"><button class="btn btn-sm btn-primary" data-mcp-action="enable">${text('Speichern und aktivieren','Save and enable')}</button><button class="btn btn-sm btn-secondary" data-mcp-action="disable">${text('Deaktivieren und widerrufen','Disable and revoke')}</button><button class="btn btn-sm btn-secondary" data-mcp-action="copy">${text('Verbindungscode kopieren','Copy connection code')}</button><button class="btn btn-sm btn-secondary" data-mcp-action="rotate">${text('Zugang erneuern','Rotate access')}</button></div>
|
||||
<dl class="mcp-status"><div><dt>Status</dt><dd data-mcp-status>—</dd></div><div><dt>${text('Letzter Kontakt','Last contact')}</dt><dd data-mcp-contact>—</dd></div><div><dt>${text('Ausstehende Widerrufe','Pending revocations')}</dt><dd data-mcp-pending>0</dd></div></dl>
|
||||
<p>${text('Der Verbindungscode ist ein Zugangsschlüssel. Er wird weder im Backup gespeichert noch auf andere Installationen übertragen. Löschungen und andere gefährliche Aktionen verlangen eine lokale Bestätigung.', 'The connection code is a credential. It is not stored in backups or transferred to other installations. Deletions and other dangerous actions require local confirmation.')}</p>
|
||||
<div class="mcp-actions"><button class="btn btn-sm btn-secondary" data-mcp-action="grant">${text('Ordner freigeben','Grant directory')}</button></div><div data-mcp-grants></div>
|
||||
</section>`;
|
||||
window.bindMcpSettings = async () => {
|
||||
const area = document.getElementById('mcpControls'); if (!area) return;
|
||||
const state = await window.api.mcpStatus(); if (!state) return;
|
||||
renderStatus(state);
|
||||
area.querySelector('#mcpName').value = state.name || 'Multi-Hoster-Uploader';
|
||||
for (const input of area.querySelectorAll('.mcp-permissions input')) input.checked = state.capabilities?.includes(input.value) === true;
|
||||
const configuration = enabled => ({ enabled, name: area.querySelector('#mcpName').value.trim(), capabilities: [...area.querySelectorAll('.mcp-permissions input:checked')].map(input => input.value) });
|
||||
area.querySelector('[data-mcp-action="enable"]').onclick = () => act(() => window.api.mcpConfigure(configuration(true)));
|
||||
area.querySelector('[data-mcp-action="disable"]').onclick = () => act(() => window.api.mcpConfigure(configuration(false)));
|
||||
area.querySelector('[data-mcp-action="rotate"]').onclick = () => act(() => window.api.mcpRotate());
|
||||
area.querySelector('[data-mcp-action="copy"]').onclick = () => act(async () => { await window.api.mcpCopyCode(); showCopyToast(text('Verbindungscode kopiert.', 'Connection code copied.')); });
|
||||
area.querySelector('[data-mcp-action="grant"]').onclick = () => act(() => window.api.mcpAddGrant());
|
||||
};
|
||||
window.api.onMcpStatus(renderStatus);
|
||||
})();
|
||||
Reference in new issue
Block a user