1671 lines
54 KiB
HTML
1671 lines
54 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{ title }}</title>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.2/socket.io.min.js"></script>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Syne:wght@400;700;800&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--bg: #0d0f14;
|
|
--surface: #161921;
|
|
--surface2: #1e2330;
|
|
--border: #2a3040;
|
|
--accent: #00e5a0;
|
|
--accent2: #0099ff;
|
|
--danger: #ff4455;
|
|
--text: #e2e8f0;
|
|
--muted: #6b7a99;
|
|
--folder: #f0b429;
|
|
--file: #7eb8f7;
|
|
--header-h: 52px;
|
|
--queue-h: 200px;
|
|
}
|
|
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-family: 'JetBrains Mono', monospace;
|
|
font-size: 13px;
|
|
height: 100dvh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* HEADER */
|
|
header {
|
|
height: var(--header-h);
|
|
background: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 16px;
|
|
gap: 16px;
|
|
flex-shrink: 0;
|
|
position: relative;
|
|
}
|
|
|
|
.logo {
|
|
font-family: 'Syne', sans-serif;
|
|
font-size: 18px;
|
|
font-weight: 800;
|
|
letter-spacing: -0.5px;
|
|
color: var(--accent);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.logo span { color: var(--text); }
|
|
|
|
.status-bar {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 7px; height: 7px;
|
|
border-radius: 50%;
|
|
background: var(--muted);
|
|
flex-shrink: 0;
|
|
transition: background 0.3s;
|
|
}
|
|
.status-dot.active { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
|
|
|
|
.status-text {
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
/* PROGRESS GLOBAL */
|
|
.global-progress {
|
|
position: absolute;
|
|
bottom: 0; left: 0; right: 0;
|
|
height: 2px;
|
|
background: var(--border);
|
|
overflow: hidden;
|
|
}
|
|
.global-progress-bar {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, var(--accent), var(--accent2));
|
|
width: 0%;
|
|
transition: width 0.3s;
|
|
}
|
|
|
|
/* LAYOUT PRINCIPAL */
|
|
.main {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.panels {
|
|
flex: 1;
|
|
display: flex;
|
|
gap: 1px;
|
|
background: var(--border);
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* PANEL */
|
|
.panel {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--bg);
|
|
overflow: hidden;
|
|
min-width: 0;
|
|
}
|
|
|
|
.panel-header {
|
|
background: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
padding: 0 12px;
|
|
height: 36px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.panel-label {
|
|
font-family: 'Syne', sans-serif;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
letter-spacing: 1.5px;
|
|
text-transform: uppercase;
|
|
padding: 2px 8px;
|
|
border-radius: 3px;
|
|
flex-shrink: 0;
|
|
}
|
|
.panel-label.seed { background: rgba(0,229,160,0.12); color: var(--accent); }
|
|
.panel-label.nas { background: rgba(0,153,255,0.12); color: var(--accent2); }
|
|
|
|
.panel-path {
|
|
flex: 1;
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.btn-icon {
|
|
background: none;
|
|
border: 1px solid var(--border);
|
|
color: var(--muted);
|
|
width: 26px; height: 26px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 14px;
|
|
flex-shrink: 0;
|
|
transition: all 0.15s;
|
|
}
|
|
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
|
|
|
|
/* BREADCRUMB */
|
|
.breadcrumb {
|
|
padding: 6px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
flex-wrap: wrap;
|
|
flex-shrink: 0;
|
|
background: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
min-height: 32px;
|
|
}
|
|
|
|
.crumb {
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
padding: 1px 4px;
|
|
border-radius: 3px;
|
|
font-size: 11px;
|
|
transition: color 0.15s;
|
|
white-space: nowrap;
|
|
}
|
|
.crumb:hover { color: var(--text); }
|
|
.crumb.active { color: var(--text); cursor: default; }
|
|
.crumb-sep { color: var(--border); font-size: 11px; }
|
|
|
|
/* FILE LIST */
|
|
.file-list {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 4px 0;
|
|
}
|
|
|
|
.file-list::-webkit-scrollbar { width: 5px; }
|
|
.file-list::-webkit-scrollbar-track { background: transparent; }
|
|
.file-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
|
|
|
|
.file-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 5px 12px;
|
|
gap: 8px;
|
|
cursor: pointer;
|
|
border-bottom: 1px solid transparent;
|
|
transition: background 0.1s;
|
|
user-select: none;
|
|
}
|
|
.file-item:hover { background: var(--surface); }
|
|
.file-item.selected {
|
|
background: rgba(0,229,160,0.08);
|
|
border-bottom-color: rgba(0,229,160,0.1);
|
|
}
|
|
.panel.right .file-item.selected { background: rgba(0,153,255,0.08); }
|
|
|
|
.file-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
|
|
.file-name {
|
|
flex: 1;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
font-size: 12px;
|
|
}
|
|
.file-name.is-dir { color: var(--folder); }
|
|
.file-size {
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
flex-shrink: 0;
|
|
min-width: 60px;
|
|
text-align: right;
|
|
}
|
|
|
|
.empty-state {
|
|
padding: 40px 16px;
|
|
text-align: center;
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
}
|
|
|
|
.loading {
|
|
padding: 20px;
|
|
text-align: center;
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
}
|
|
|
|
/* TOOLBAR */
|
|
.toolbar {
|
|
padding: 6px 12px;
|
|
display: flex;
|
|
gap: 6px;
|
|
border-top: 1px solid var(--border);
|
|
background: var(--surface);
|
|
flex-shrink: 0;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn {
|
|
padding: 5px 10px;
|
|
border-radius: 4px;
|
|
border: 1px solid var(--border);
|
|
background: var(--surface2);
|
|
color: var(--text);
|
|
cursor: pointer;
|
|
font-family: 'JetBrains Mono', monospace;
|
|
font-size: 11px;
|
|
transition: all 0.15s;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
white-space: nowrap;
|
|
}
|
|
.btn:hover { border-color: var(--accent); color: var(--accent); }
|
|
.btn.primary {
|
|
background: rgba(0,229,160,0.12);
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
.btn.primary:hover { background: rgba(0,229,160,0.22); }
|
|
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
|
|
/* QUEUE */
|
|
.queue-section {
|
|
height: var(--queue-h);
|
|
background: var(--surface);
|
|
border-top: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.queue-header {
|
|
padding: 8px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
border-bottom: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.queue-title {
|
|
font-family: 'Syne', sans-serif;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
letter-spacing: 1.5px;
|
|
text-transform: uppercase;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.queue-count {
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
color: var(--muted);
|
|
font-size: 10px;
|
|
padding: 1px 6px;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.queue-list {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 4px 0;
|
|
}
|
|
|
|
.queue-list::-webkit-scrollbar { width: 4px; }
|
|
.queue-list::-webkit-scrollbar-thumb { background: var(--border); }
|
|
|
|
.queue-item {
|
|
padding: 6px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.queue-item.current { background: rgba(0,229,160,0.06); }
|
|
|
|
.queue-status {
|
|
font-size: 10px;
|
|
flex-shrink: 0;
|
|
width: 14px;
|
|
text-align: center;
|
|
}
|
|
|
|
.queue-name {
|
|
flex: 1;
|
|
font-size: 11px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.queue-item.current .queue-name { color: var(--accent); }
|
|
|
|
.queue-progress-wrap {
|
|
width: 120px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.queue-progress-bar-bg {
|
|
background: var(--border);
|
|
border-radius: 2px;
|
|
height: 4px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.queue-progress-bar-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, var(--accent), var(--accent2));
|
|
border-radius: 2px;
|
|
transition: width 0.3s;
|
|
}
|
|
|
|
.queue-pct { font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; }
|
|
|
|
.queue-size { font-size: 10px; color: var(--muted); flex-shrink: 0; min-width: 80px; text-align: right; }
|
|
|
|
.queue-remove {
|
|
background: none;
|
|
border: none;
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
padding: 0 2px;
|
|
flex-shrink: 0;
|
|
transition: color 0.15s;
|
|
}
|
|
.queue-remove:hover { color: var(--danger); }
|
|
|
|
.queue-empty {
|
|
padding: 24px;
|
|
text-align: center;
|
|
color: var(--muted);
|
|
font-size: 11px;
|
|
}
|
|
|
|
/* MODAL */
|
|
.modal-overlay {
|
|
display: none;
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(0,0,0,0.7);
|
|
z-index: 100;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.modal-overlay.open { display: flex; }
|
|
|
|
.modal {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
min-width: 300px;
|
|
max-width: 90vw;
|
|
}
|
|
|
|
.modal-title {
|
|
font-family: 'Syne', sans-serif;
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
margin-bottom: 14px;
|
|
color: var(--text);
|
|
}
|
|
|
|
.modal input {
|
|
width: 100%;
|
|
background: var(--bg);
|
|
border: 1px solid var(--border);
|
|
color: var(--text);
|
|
padding: 8px 10px;
|
|
border-radius: 4px;
|
|
font-family: 'JetBrains Mono', monospace;
|
|
font-size: 13px;
|
|
outline: none;
|
|
margin-bottom: 14px;
|
|
transition: border-color 0.15s;
|
|
}
|
|
.modal input:focus { border-color: var(--accent); }
|
|
|
|
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
|
|
|
|
/* TOAST */
|
|
.toast-container {
|
|
position: fixed;
|
|
bottom: 220px;
|
|
right: 16px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
z-index: 200;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.toast {
|
|
padding: 8px 14px;
|
|
border-radius: 5px;
|
|
font-size: 11px;
|
|
opacity: 0;
|
|
transform: translateX(20px);
|
|
transition: all 0.25s;
|
|
pointer-events: none;
|
|
}
|
|
.toast.success { background: rgba(0,229,160,0.15); border: 1px solid var(--accent); color: var(--accent); }
|
|
.toast.error { background: rgba(255,68,85,0.15); border: 1px solid var(--danger); color: var(--danger); }
|
|
.toast.show { opacity: 1; transform: translateX(0); }
|
|
|
|
/* MOBILE */
|
|
@media (max-width: 640px) {
|
|
:root { --queue-h: 160px; }
|
|
.panels { flex-direction: column; }
|
|
.panel { min-height: 35vh; }
|
|
.file-size { display: none; }
|
|
.queue-progress-wrap { display: none; }
|
|
.queue-size { display: none; }
|
|
.btn { padding: 5px 8px; font-size: 10px; }
|
|
}
|
|
|
|
.conn-select {
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
color: var(--text);
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-family: 'JetBrains Mono', monospace;
|
|
font-size: 10px;
|
|
cursor: pointer;
|
|
max-width: 120px;
|
|
outline: none;
|
|
}
|
|
.conn-select:focus { border-color: var(--accent); }
|
|
|
|
.conn-modal { min-width: 420px; max-width: 95vw; }
|
|
.conn-list { max-height: 200px; overflow-y: auto; margin-bottom: 16px; }
|
|
.conn-item {
|
|
display: flex; align-items: center; gap: 8px;
|
|
padding: 8px 10px; border: 1px solid var(--border);
|
|
border-radius: 6px; margin-bottom: 6px; background: var(--bg);
|
|
}
|
|
.conn-item-name { flex: 1; font-size: 12px; }
|
|
.conn-item-type {
|
|
font-size: 10px; padding: 2px 6px; border-radius: 3px;
|
|
background: var(--surface2); color: var(--muted);
|
|
}
|
|
.conn-item-type.local { background: rgba(0,229,160,0.1); color: var(--accent); }
|
|
.conn-item-type.sftp { background: rgba(0,153,255,0.1); color: var(--accent2); }
|
|
.conn-readonly { font-size: 10px; color: var(--muted); }
|
|
.conn-form { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
|
|
.conn-form-title { font-size: 11px; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
|
|
.form-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
|
|
.form-row .field { flex: 1; min-width: 120px; }
|
|
.form-row label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.8px; }
|
|
.form-row input, .form-row select {
|
|
width: 100%; background: var(--bg); border: 1px solid var(--border);
|
|
color: var(--text); padding: 6px 8px; border-radius: 4px;
|
|
font-family: 'JetBrains Mono', monospace; font-size: 12px; outline: none;
|
|
}
|
|
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }
|
|
|
|
/* ONGLETS */
|
|
.tabs {
|
|
display: flex;
|
|
gap: 0;
|
|
border-bottom: 1px solid var(--border);
|
|
background: var(--surface);
|
|
flex-shrink: 0;
|
|
}
|
|
.tab-btn {
|
|
padding: 8px 18px;
|
|
font-family: 'Syne', sans-serif;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
letter-spacing: 1.2px;
|
|
text-transform: uppercase;
|
|
color: var(--muted);
|
|
background: none;
|
|
border: none;
|
|
border-bottom: 2px solid transparent;
|
|
cursor: pointer;
|
|
transition: all 0.15s;
|
|
}
|
|
.tab-btn:hover { color: var(--text); }
|
|
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
|
|
|
|
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
|
|
.tab-content.active { display: flex; }
|
|
|
|
/* HISTORIQUE */
|
|
.history-toolbar {
|
|
padding: 8px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
border-bottom: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
background: var(--surface);
|
|
}
|
|
.history-count { color: var(--muted); font-size: 11px; flex: 1; }
|
|
|
|
.history-table-wrap { flex: 1; overflow-y: auto; }
|
|
.history-table-wrap::-webkit-scrollbar { width: 5px; }
|
|
.history-table-wrap::-webkit-scrollbar-thumb { background: var(--border); }
|
|
|
|
table.history {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 11px;
|
|
}
|
|
table.history thead th {
|
|
position: sticky; top: 0;
|
|
background: var(--surface2);
|
|
color: var(--muted);
|
|
padding: 6px 12px;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
font-size: 10px;
|
|
letter-spacing: 0.8px;
|
|
text-transform: uppercase;
|
|
border-bottom: 1px solid var(--border);
|
|
white-space: nowrap;
|
|
}
|
|
table.history tbody tr {
|
|
border-bottom: 1px solid var(--border);
|
|
transition: background 0.1s;
|
|
}
|
|
table.history tbody tr:hover { background: var(--surface); }
|
|
table.history td {
|
|
padding: 7px 12px;
|
|
vertical-align: middle;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
max-width: 200px;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.hist-status { text-align: center; font-size: 13px; }
|
|
.hist-name { color: var(--text); font-size: 12px; }
|
|
.hist-path { color: var(--muted); font-size: 10px; }
|
|
.hist-size { color: var(--accent2); }
|
|
.hist-dur { color: var(--muted); }
|
|
.hist-date { color: var(--muted); font-size: 10px; }
|
|
.hist-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 11px; }
|
|
|
|
/* Modal overwrite */
|
|
.overwrite-icon { font-size: 32px; text-align: center; margin-bottom: 10px; }
|
|
.overwrite-filename {
|
|
background: var(--surface2); border: 1px solid var(--border);
|
|
border-radius: 6px; padding: 10px 14px; margin: 10px 0;
|
|
font-size: 13px; color: var(--accent2); word-break: break-all;
|
|
}
|
|
.overwrite-size { color: var(--muted); font-size: 11px; margin-top: 4px; }
|
|
.overwrite-warning { color: var(--danger); font-size: 11px; margin: 8px 0 14px; }
|
|
.overwrite-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
|
|
|
|
/* Spinner animation */
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
.spinner {
|
|
display: inline-block;
|
|
width: 10px; height: 10px;
|
|
border: 2px solid var(--border);
|
|
border-top-color: var(--accent);
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<div class="logo">Seed<span>Mover</span></div>
|
|
<div class="status-bar">
|
|
<div class="status-dot" id="statusDot"></div>
|
|
<div class="status-text" id="statusText">Inactif</div>
|
|
</div>
|
|
<button class="btn" onclick="saveAsDefault()" style="margin-left:auto;font-size:11px;" title="Sauvegarder la vue actuelle comme démarrage par défaut">★ Défaut</button>
|
|
<button class="btn" onclick="openConnModal()" style="font-size:11px;" title="Gérer les connexions">⚙ Connexions</button>
|
|
<a href="/logout" style="font-size:11px;color:var(--muted);text-decoration:none;border:1px solid var(--border);padding:4px 10px;border-radius:4px;transition:all 0.15s;flex-shrink:0;" onmouseover="this.style.color='var(--danger)';this.style.borderColor='var(--danger)'" onmouseout="this.style.color='var(--muted)';this.style.borderColor='var(--border)'">⏏ Déconnexion</a>
|
|
<div class="global-progress">
|
|
<div class="global-progress-bar" id="globalBar"></div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="main">
|
|
<!-- ONGLETS -->
|
|
<div class="tabs">
|
|
<button class="tab-btn active" id="tabBtnTransfer" onclick="switchTab('transfer')">⟶ Transfert</button>
|
|
<button class="tab-btn" id="tabBtnHistory" onclick="switchTab('history')">📋 Historique</button>
|
|
</div>
|
|
|
|
<!-- ONGLET TRANSFERT -->
|
|
<div class="tab-content active" id="tabTransfer">
|
|
<div class="panels">
|
|
<!-- PANEL GAUCHE : Seedbox -->
|
|
<div class="panel left" id="panel-left">
|
|
<div class="panel-header">
|
|
<span class="panel-label seed">Seedbox</span>
|
|
<select id="leftConnection" class="conn-select" onchange="changeConnection('left', this.value)"></select>
|
|
<span class="panel-path" id="leftPath"></span>
|
|
<button class="btn-icon" onclick="mkdirModal('left')" title="Nouveau dossier">📁</button>
|
|
</div>
|
|
<div class="breadcrumb" id="leftBreadcrumb"></div>
|
|
<div class="file-list" id="leftList"><div class="loading">Chargement…</div></div>
|
|
<div class="toolbar">
|
|
<button class="btn primary" id="btnCopy" onclick="copySelected()" disabled>
|
|
⟶ Copier vers NAS
|
|
</button>
|
|
<button class="btn" onclick="refreshPanel('left')">↻ Actualiser</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- PANEL DROIT : NAS -->
|
|
<div class="panel right" id="panel-right">
|
|
<div class="panel-header">
|
|
<span class="panel-label nas">NAS</span>
|
|
<select id="rightConnection" class="conn-select" onchange="changeConnection('right', this.value)"></select>
|
|
<span class="panel-path" id="rightPath"></span>
|
|
<button class="btn-icon" onclick="mkdirModal('right')" title="Nouveau dossier">📁</button>
|
|
</div>
|
|
<div class="breadcrumb" id="rightBreadcrumb"></div>
|
|
<div class="file-list" id="rightList"><div class="loading">Chargement…</div></div>
|
|
<div class="toolbar">
|
|
<button class="btn" onclick="refreshPanel('right')">↻ Actualiser</button>
|
|
<button class="btn" id="btnRename" onclick="renameSelected()" disabled>✏ Renommer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- QUEUE -->
|
|
<div class="queue-section">
|
|
<div class="queue-header">
|
|
<span class="queue-title">File de transfert</span>
|
|
<span class="queue-count" id="queueCount">0</span>
|
|
<div style="margin-left:auto;display:flex;gap:6px;">
|
|
<button class="btn" id="btnPause" onclick="togglePause()" disabled title="Pause / Reprendre">⏸ Pause</button>
|
|
<button class="btn" id="btnStop" onclick="stopTransfer()" disabled title="Arrêter et supprimer le fichier partiel" style="color:var(--danger);border-color:var(--danger)">⏹ Stop</button>
|
|
</div>
|
|
</div>
|
|
<div class="queue-list" id="queueList">
|
|
<div class="queue-empty">File vide — sélectionne des fichiers et clique sur "Copier vers NAS"</div>
|
|
</div>
|
|
</div>
|
|
</div> <!-- /tabTransfer -->
|
|
|
|
<!-- ONGLET HISTORIQUE -->
|
|
<div class="tab-content" id="tabHistory">
|
|
<div class="history-toolbar">
|
|
<span class="history-count" id="histCount">0 transferts</span>
|
|
<button class="btn" onclick="loadHistory(true)">↻ Actualiser</button>
|
|
<button class="btn" style="color:var(--danger);border-color:var(--danger)" onclick="clearHistory()">🗑 Vider</button>
|
|
</div>
|
|
<div class="history-table-wrap">
|
|
<table class="history">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:30px"></th>
|
|
<th>Fichier</th>
|
|
<th>Source</th>
|
|
<th>Destination</th>
|
|
<th>Taille</th>
|
|
<th>Durée</th>
|
|
<th>Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="histBody">
|
|
<tr><td colspan="7" class="hist-empty">Aucun transfert enregistré</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- MODAL CONNEXIONS -->
|
|
<div class="modal-overlay" id="connModal">
|
|
<div class="modal conn-modal">
|
|
<div class="modal-title">Connexions</div>
|
|
<div class="conn-list" id="connList"></div>
|
|
<div class="conn-form">
|
|
<div class="conn-form-title">Nouvelle connexion</div>
|
|
<div class="form-row">
|
|
<div class="field">
|
|
<label>Nom</label>
|
|
<input type="text" id="newConnName" placeholder="Ma seedbox SFTP" />
|
|
</div>
|
|
<div class="field">
|
|
<label>Type</label>
|
|
<select id="newConnType" onchange="renderConnFields()">
|
|
<option value="">-- Choisir --</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div id="connFields"></div>
|
|
<div class="form-row">
|
|
<div class="field" style="display:flex;align-items:center;gap:6px;padding-top:18px;">
|
|
<input type="checkbox" id="newConnReadonly" style="width:auto;" />
|
|
<label for="newConnReadonly" style="text-transform:none;letter-spacing:0;font-size:11px;">Lecture seule</label>
|
|
</div>
|
|
</div>
|
|
<div style="display:flex;gap:8px;justify-content:flex-end;margin-top:4px;">
|
|
<button class="btn" onclick="closeConnModal()">Fermer</button>
|
|
<button class="btn primary" onclick="addConnection()">Ajouter</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL EDIT CONNEXION -->
|
|
<div class="modal-overlay" id="editConnModal">
|
|
<div class="modal conn-modal">
|
|
<div class="modal-title">Modifier la connexion</div>
|
|
<input type="hidden" id="editConnId" />
|
|
<div class="form-row">
|
|
<div class="field">
|
|
<label>Nom</label>
|
|
<input type="text" id="editConnName" placeholder="Nom de la connexion" />
|
|
</div>
|
|
<div class="field">
|
|
<label>Type</label>
|
|
<span id="editConnType" style="color:var(--muted);font-size:12px;padding-top:18px;display:block;"></span>
|
|
</div>
|
|
</div>
|
|
<div id="editConnFields"></div>
|
|
<div class="form-row">
|
|
<div class="field" style="display:flex;align-items:center;gap:6px;padding-top:18px;">
|
|
<input type="checkbox" id="editConnReadonly" style="width:auto;" />
|
|
<label for="editConnReadonly" style="text-transform:none;letter-spacing:0;font-size:11px;">Lecture seule</label>
|
|
</div>
|
|
</div>
|
|
<div style="display:flex;gap:8px;justify-content:flex-end;margin-top:14px;">
|
|
<button class="btn" onclick="closeEditConn()">Annuler</button>
|
|
<button class="btn primary" onclick="saveEditConn()">Enregistrer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL OVERWRITE -->
|
|
<div class="modal-overlay" id="overwriteModal">
|
|
<div class="modal" style="max-width:420px;">
|
|
<div class="overwrite-icon">⚠️</div>
|
|
<div class="modal-title" style="text-align:center;">Fichier déjà présent</div>
|
|
<div class="overwrite-filename" id="overwriteFileName"></div>
|
|
<div class="overwrite-size" id="overwriteFileSize"></div>
|
|
<div class="overwrite-warning">Ce fichier existe déjà à destination. Que veux-tu faire ?</div>
|
|
<div class="overwrite-actions">
|
|
<button class="btn" onclick="closeOverwriteModal()">Annuler</button>
|
|
<button class="btn" onclick="overwriteSkip()" style="color:var(--muted);">⏭ Passer</button>
|
|
<button class="btn primary" onclick="overwriteConfirm()" style="background:var(--danger);border-color:var(--danger);">♻ Écraser</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL MKDIR -->
|
|
<div class="modal-overlay" id="mkdirModal">
|
|
<div class="modal">
|
|
<div class="modal-title">Nouveau dossier</div>
|
|
<input type="text" id="mkdirName" placeholder="Nom du dossier" />
|
|
<div class="modal-actions">
|
|
<button class="btn" onclick="closeMkdirModal()">Annuler</button>
|
|
<button class="btn primary" onclick="confirmMkdir()">Créer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL RENAME -->
|
|
<div class="modal-overlay" id="renameModal">
|
|
<div class="modal">
|
|
<div class="modal-title">Renommer</div>
|
|
<input type="text" id="renameName" placeholder="Nouveau nom" />
|
|
<div class="modal-actions">
|
|
<button class="btn" onclick="closeRenameModal()">Annuler</button>
|
|
<button class="btn primary" onclick="confirmRename()">Renommer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="toast-container" id="toastContainer"></div>
|
|
|
|
<script>
|
|
const state = {
|
|
left: { connection: 'seedbox', path: '', selected: new Set(), items: [] },
|
|
right: { connection: 'nas', path: '', selected: new Set(), items: [] }
|
|
};
|
|
|
|
let allConnections = [];
|
|
let availablePlugins = [];
|
|
|
|
const queue = [];
|
|
let currentTransfer = null;
|
|
let mkdirTarget = null;
|
|
let renameTarget = null;
|
|
|
|
// ─── SOCKET.IO ───────────────────────────────────────────────
|
|
const socket = io();
|
|
|
|
socket.on('transfer_started', data => {
|
|
currentTransfer = data.id;
|
|
updateQueueUI();
|
|
setStatus('active', `Transfert : ${data.name}`);
|
|
updateControlBtns(true);
|
|
});
|
|
|
|
socket.on('transfer_progress', data => {
|
|
const item = document.querySelector(`.queue-item[data-id="${data.id}"]`);
|
|
if (item) {
|
|
const bar = item.querySelector('.queue-progress-bar-fill');
|
|
const pct = item.querySelector('.queue-pct');
|
|
const size = item.querySelector('.queue-size');
|
|
if (bar) bar.style.width = data.percent + '%';
|
|
if (pct) pct.textContent = data.percent + '%';
|
|
if (size) size.textContent = `${data.copied_fmt} / ${data.total_fmt}`;
|
|
}
|
|
document.getElementById('globalBar').style.width = data.percent + '%';
|
|
});
|
|
|
|
socket.on('transfer_done', data => {
|
|
const idx = queue.findIndex(t => t.id === data.id);
|
|
if (idx !== -1) queue.splice(idx, 1);
|
|
currentTransfer = null;
|
|
document.getElementById('globalBar').style.width = '0%';
|
|
updateControlBtns(false);
|
|
updatePauseBtn(false);
|
|
if (data.success) {
|
|
toast('Transfert terminé ✓', 'success');
|
|
refreshPanel('right');
|
|
} else if (data.error === "Arrêté par l'utilisateur") {
|
|
toast('Transfert arrêté', 'error');
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
updateQueueUI();
|
|
if (queue.length === 0) setStatus('idle', 'Inactif');
|
|
});
|
|
|
|
socket.on('connect', () => {
|
|
syncQueueFromServer();
|
|
});
|
|
|
|
socket.on('transfer_paused', data => {
|
|
updatePauseBtn(data.paused);
|
|
});
|
|
|
|
socket.on('queue_updated', () => {
|
|
syncQueueFromServer();
|
|
});
|
|
|
|
async function syncQueueFromServer() {
|
|
const res = await fetch('/api/queue');
|
|
const data = await res.json();
|
|
|
|
// Reconstruire le tableau local depuis l'état serveur
|
|
queue.length = 0;
|
|
|
|
// Transfert en cours en premier
|
|
if (data.current) {
|
|
queue.push({ id: data.current.id, name: data.current.name, percent: data.current.percent || 0 });
|
|
currentTransfer = data.current.id;
|
|
setStatus('active', `Transfert : ${data.current.name}`);
|
|
} else {
|
|
currentTransfer = null;
|
|
}
|
|
|
|
// Puis la file d'attente
|
|
data.queue.forEach(t => {
|
|
if (!queue.find(q => q.id === t.id)) {
|
|
queue.push({ id: t.id, name: t.name, percent: 0 });
|
|
}
|
|
});
|
|
|
|
if (queue.length === 0) setStatus('idle', 'Inactif');
|
|
updateControlBtns(!!currentTransfer);
|
|
if (data.paused) updatePauseBtn(true);
|
|
updateQueueUI();
|
|
}
|
|
|
|
// ─── NAVIGATION ──────────────────────────────────────────────
|
|
async function loadDir(panel, path, force = false) {
|
|
const listEl = document.getElementById(panel + 'List');
|
|
listEl.innerHTML = '<div class="loading"><span class="spinner"></span> Chargement…</div>';
|
|
state[panel].selected.clear();
|
|
updateToolbar();
|
|
|
|
const connection = state[panel].connection;
|
|
const res = await fetch(`/api/list?connection=${connection}&path=${encodeURIComponent(path)}&force=${force ? 'true' : 'false'}`);
|
|
const data = await res.json();
|
|
|
|
if (data.error) {
|
|
listEl.innerHTML = `<div class="empty-state">⚠ ${data.error}</div>`;
|
|
return;
|
|
}
|
|
|
|
state[panel].path = path;
|
|
state[panel].items = data.items;
|
|
state[panel].readonly = data.readonly;
|
|
document.getElementById(panel + 'Path').textContent = path;
|
|
renderBreadcrumb(panel, path);
|
|
renderList(panel, data.items);
|
|
}
|
|
|
|
async function changeConnection(panel, connectionId) {
|
|
state[panel].connection = connectionId;
|
|
state[panel].path = '';
|
|
state[panel].selected.clear();
|
|
// Récupérer la root_path de la connexion
|
|
const conn = allConnections.find(c => c.id === connectionId);
|
|
const root = conn?.config?.root_path || '/';
|
|
await loadDir(panel, root, true);
|
|
}
|
|
|
|
function renderBreadcrumb(panel, path) {
|
|
const conn = allConnections.find(c => c.id === state[panel].connection);
|
|
const base = conn?.config?.root_path || '/';
|
|
const el = document.getElementById(panel + 'Breadcrumb');
|
|
const rel = path.startsWith(base) ? path.slice(base.length) : path;
|
|
const parts = rel.split('/').filter(Boolean);
|
|
|
|
let html = `<span class="crumb" onclick="loadDir('${panel}', '${base}')">~</span>`;
|
|
let cur = base;
|
|
parts.forEach((part, i) => {
|
|
cur += '/' + part;
|
|
const curPath = cur;
|
|
const isLast = i === parts.length - 1;
|
|
html += `<span class="crumb-sep">/</span>`;
|
|
html += `<span class="crumb ${isLast ? 'active' : ''}" onclick="loadDir('${panel}', '${curPath}')">${escHtml(part)}</span>`;
|
|
});
|
|
el.innerHTML = html;
|
|
}
|
|
|
|
function renderList(panel, items) {
|
|
const listEl = document.getElementById(panel + 'List');
|
|
if (!items.length) {
|
|
listEl.innerHTML = '<div class="empty-state">Dossier vide</div>';
|
|
return;
|
|
}
|
|
|
|
listEl.innerHTML = items.map(item => {
|
|
const icon = item.is_dir ? '📁' : getFileIcon(item.name);
|
|
const size = item.is_dir ? '' : formatSize(item.size);
|
|
const sel = state[panel].selected.has(item.path) ? 'selected' : '';
|
|
return `<div class="file-item ${sel}" data-path="${escAttr(item.path)}" data-isdir="${item.is_dir}" data-panel="${panel}"
|
|
onclick="toggleSelect(this, '${panel}')" ondblclick="onDblClick(this, '${panel}')">
|
|
<span class="file-icon">${icon}</span>
|
|
<span class="file-name ${item.is_dir ? 'is-dir' : ''}">${escHtml(item.name)}</span>
|
|
<span class="file-size">${size}</span>
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
function toggleSelect(el, panel) {
|
|
const path = el.dataset.path;
|
|
if (state[panel].selected.has(path)) {
|
|
state[panel].selected.delete(path);
|
|
el.classList.remove('selected');
|
|
} else {
|
|
state[panel].selected.add(path);
|
|
el.classList.add('selected');
|
|
}
|
|
updateToolbar();
|
|
}
|
|
|
|
function onDblClick(el, panel) {
|
|
if (el.dataset.isdir === 'true') {
|
|
loadDir(panel, el.dataset.path);
|
|
}
|
|
}
|
|
|
|
function updateToolbar() {
|
|
const hasLeft = state.left.selected.size > 0;
|
|
const hasRight = state.right.selected.size > 0;
|
|
document.getElementById('btnCopy').disabled = !hasLeft;
|
|
document.getElementById('btnRename').disabled = state.right.selected.size !== 1;
|
|
}
|
|
|
|
function refreshPanel(panel) {
|
|
loadDir(panel, state[panel].path, true);
|
|
}
|
|
|
|
// ─── COPY ────────────────────────────────────────────────────
|
|
// File d'attente d'écrasement : items en attente de confirmation
|
|
let overwriteQueue = [];
|
|
let overwriteCurrent = null;
|
|
|
|
async function copySelected() {
|
|
const dst = state.right.path;
|
|
const selected = [...state.left.selected];
|
|
if (!selected.length) return;
|
|
|
|
for (const src of selected) {
|
|
const name = src.split('/').pop();
|
|
const res = await fetch('/api/queue/add', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
src, dst, name,
|
|
src_connection: state.left.connection,
|
|
dst_connection: state.right.connection
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (data.exists) {
|
|
overwriteQueue.push({
|
|
src, dst, name,
|
|
src_connection: state.left.connection,
|
|
dst_connection: state.right.connection,
|
|
existing_size: data.existing_size,
|
|
dst_path: data.dst_path
|
|
});
|
|
} else if (!data.success) {
|
|
toast('Erreur : ' + (data.error || 'Inconnue'), 'error');
|
|
}
|
|
}
|
|
|
|
state.left.selected.clear();
|
|
document.querySelectorAll('#leftList .file-item.selected').forEach(el => el.classList.remove('selected'));
|
|
updateToolbar();
|
|
syncQueueFromServer();
|
|
|
|
if (overwriteQueue.length) processNextOverwrite();
|
|
}
|
|
|
|
function processNextOverwrite() {
|
|
if (!overwriteQueue.length) return;
|
|
overwriteCurrent = overwriteQueue.shift();
|
|
document.getElementById('overwriteFileName').textContent = overwriteCurrent.dst_path;
|
|
document.getElementById('overwriteFileSize').textContent = overwriteCurrent.existing_size
|
|
? 'Taille actuelle : ' + formatSize(overwriteCurrent.existing_size)
|
|
: '';
|
|
document.getElementById('overwriteModal').classList.add('open');
|
|
}
|
|
|
|
function closeOverwriteModal() {
|
|
document.getElementById('overwriteModal').classList.remove('open');
|
|
overwriteCurrent = null;
|
|
if (overwriteQueue.length) processNextOverwrite();
|
|
}
|
|
|
|
function overwriteSkip() {
|
|
document.getElementById('overwriteModal').classList.remove('open');
|
|
overwriteCurrent = null;
|
|
if (overwriteQueue.length) processNextOverwrite();
|
|
}
|
|
|
|
async function overwriteConfirm() {
|
|
document.getElementById('overwriteModal').classList.remove('open');
|
|
if (!overwriteCurrent) return;
|
|
const item = overwriteCurrent;
|
|
overwriteCurrent = null;
|
|
const res = await fetch('/api/queue/add', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ ...item, force: true })
|
|
});
|
|
const data = await res.json();
|
|
if (!data.success) toast('Erreur : ' + (data.error || 'Inconnue'), 'error');
|
|
syncQueueFromServer();
|
|
if (overwriteQueue.length) processNextOverwrite();
|
|
}
|
|
|
|
function removeFromQueue(id) {
|
|
fetch('/api/queue/remove', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ id })
|
|
});
|
|
const idx = queue.findIndex(t => t.id === id);
|
|
if (idx !== -1) queue.splice(idx, 1);
|
|
updateQueueUI();
|
|
}
|
|
|
|
function updateQueueUI() {
|
|
const listEl = document.getElementById('queueList');
|
|
document.getElementById('queueCount').textContent = queue.length;
|
|
|
|
if (!queue.length && !currentTransfer) {
|
|
listEl.innerHTML = '<div class="queue-empty">File vide — sélectionne des fichiers et clique sur "Copier vers NAS"</div>';
|
|
return;
|
|
}
|
|
|
|
const allItems = currentTransfer
|
|
? queue
|
|
: queue;
|
|
|
|
listEl.innerHTML = queue.map((t, i) => {
|
|
const isCurrent = t.id === currentTransfer;
|
|
const statusIcon = isCurrent ? '<span class="spinner"></span>' : `<span style="color:var(--muted)">${i + 1}</span>`;
|
|
return `<div class="queue-item ${isCurrent ? 'current' : ''}" data-id="${t.id}">
|
|
<span class="queue-status">${statusIcon}</span>
|
|
<span class="queue-name">${escHtml(t.name)}</span>
|
|
<div class="queue-progress-wrap">
|
|
<div class="queue-progress-bar-bg">
|
|
<div class="queue-progress-bar-fill" style="width:${t.percent || 0}%"></div>
|
|
</div>
|
|
<div class="queue-pct">${t.percent || 0}%</div>
|
|
</div>
|
|
<span class="queue-size"></span>
|
|
${!isCurrent ? `<button class="queue-remove" onclick="removeFromQueue('${t.id}')" title="Retirer">✕</button>` : ''}
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
// ─── MKDIR ───────────────────────────────────────────────────
|
|
function mkdirModal(panel) {
|
|
mkdirTarget = panel;
|
|
document.getElementById('mkdirName').value = '';
|
|
document.getElementById('mkdirModal').classList.add('open');
|
|
setTimeout(() => document.getElementById('mkdirName').focus(), 50);
|
|
}
|
|
|
|
function closeMkdirModal() {
|
|
document.getElementById('mkdirModal').classList.remove('open');
|
|
mkdirTarget = null;
|
|
}
|
|
|
|
async function confirmMkdir() {
|
|
const name = document.getElementById('mkdirName').value.trim();
|
|
if (!name) return;
|
|
const panel = mkdirTarget;
|
|
const path = state[panel].path;
|
|
|
|
const res = await fetch('/api/mkdir', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ connection: state[panel].connection, path, name })
|
|
});
|
|
const data = await res.json();
|
|
closeMkdirModal();
|
|
if (data.success) {
|
|
toast(`Dossier créé : ${name}`, 'success');
|
|
refreshPanel(panel);
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
}
|
|
|
|
// ─── RENAME ──────────────────────────────────────────────────
|
|
function renameSelected() {
|
|
const selected = [...state.right.selected];
|
|
if (selected.length !== 1) return;
|
|
renameTarget = selected[0];
|
|
const oldName = renameTarget.split('/').pop();
|
|
document.getElementById('renameName').value = oldName;
|
|
document.getElementById('renameModal').classList.add('open');
|
|
setTimeout(() => {
|
|
const inp = document.getElementById('renameName');
|
|
inp.focus();
|
|
const dot = oldName.lastIndexOf('.');
|
|
inp.setSelectionRange(0, dot > 0 ? dot : oldName.length);
|
|
}, 50);
|
|
}
|
|
|
|
function closeRenameModal() {
|
|
document.getElementById('renameModal').classList.remove('open');
|
|
renameTarget = null;
|
|
}
|
|
|
|
async function confirmRename() {
|
|
const newName = document.getElementById('renameName').value.trim();
|
|
if (!newName || !renameTarget) return;
|
|
|
|
const res = await fetch('/api/rename', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ connection: state.right.connection, old_path: renameTarget, new_name: newName })
|
|
});
|
|
const data = await res.json();
|
|
closeRenameModal();
|
|
if (data.success) {
|
|
toast(`Renommé : ${newName}`, 'success');
|
|
refreshPanel('right');
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
}
|
|
|
|
// ─── STOP / PAUSE ────────────────────────────────────────
|
|
async function togglePause() {
|
|
const res = await fetch('/api/transfer/pause', { method: 'POST' });
|
|
const data = await res.json();
|
|
updatePauseBtn(data.paused);
|
|
}
|
|
|
|
async function stopTransfer() {
|
|
if (!confirm('Arrêter le transfert en cours ? Le fichier partiel sera supprimé.')) return;
|
|
await fetch('/api/transfer/stop', { method: 'POST' });
|
|
}
|
|
|
|
function updatePauseBtn(paused) {
|
|
const btn = document.getElementById('btnPause');
|
|
if (paused) {
|
|
btn.textContent = '▶ Reprendre';
|
|
btn.style.color = 'var(--accent)';
|
|
btn.style.borderColor = 'var(--accent)';
|
|
} else {
|
|
btn.textContent = '⏸ Pause';
|
|
btn.style.color = '';
|
|
btn.style.borderColor = '';
|
|
}
|
|
}
|
|
|
|
function updateControlBtns(hasActive) {
|
|
document.getElementById('btnPause').disabled = !hasActive;
|
|
document.getElementById('btnStop').disabled = !hasActive;
|
|
}
|
|
|
|
// ─── STATUS ──────────────────────────────────────────────────
|
|
function setStatus(state, text) {
|
|
const dot = document.getElementById('statusDot');
|
|
const txt = document.getElementById('statusText');
|
|
dot.className = 'status-dot' + (state === 'active' ? ' active' : '');
|
|
txt.textContent = text;
|
|
}
|
|
|
|
// ─── TOAST ───────────────────────────────────────────────────
|
|
function toast(msg, type = 'success') {
|
|
const c = document.getElementById('toastContainer');
|
|
const t = document.createElement('div');
|
|
t.className = `toast ${type}`;
|
|
t.textContent = msg;
|
|
c.appendChild(t);
|
|
requestAnimationFrame(() => { requestAnimationFrame(() => t.classList.add('show')); });
|
|
setTimeout(() => {
|
|
t.classList.remove('show');
|
|
setTimeout(() => t.remove(), 300);
|
|
}, 3000);
|
|
}
|
|
|
|
// ─── KEYBOARD ────────────────────────────────────────────────
|
|
document.addEventListener('keydown', e => {
|
|
if (e.key === 'Escape') {
|
|
closeMkdirModal();
|
|
closeRenameModal();
|
|
closeEditConn();
|
|
closeConnModal();
|
|
closeOverwriteModal();
|
|
}
|
|
if (e.key === 'Enter') {
|
|
if (document.getElementById('mkdirModal').classList.contains('open')) confirmMkdir();
|
|
if (document.getElementById('renameModal').classList.contains('open')) confirmRename();
|
|
}
|
|
});
|
|
|
|
// ─── UTILS ───────────────────────────────────────────────────
|
|
function formatSize(bytes) {
|
|
const units = ['B','KB','MB','GB','TB'];
|
|
let i = 0;
|
|
while (bytes >= 1024 && i < units.length - 1) { bytes /= 1024; i++; }
|
|
return bytes.toFixed(1) + ' ' + units[i];
|
|
}
|
|
|
|
function getFileIcon(name) {
|
|
const ext = name.split('.').pop().toLowerCase();
|
|
const icons = {
|
|
mkv: '🎬', mp4: '🎬', avi: '🎬', mov: '🎬', ts: '🎬',
|
|
mp3: '🎵', flac: '🎵', aac: '🎵',
|
|
jpg: '🖼', jpeg: '🖼', png: '🖼', gif: '🖼', webp: '🖼',
|
|
zip: '📦', rar: '📦', '7z': '📦',
|
|
nfo: '📄', srt: '💬', ass: '💬'
|
|
};
|
|
return icons[ext] || '📄';
|
|
}
|
|
|
|
function escHtml(s) {
|
|
return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
|
}
|
|
function escAttr(s) {
|
|
return s.replace(/"/g, '"').replace(/'/g, ''');
|
|
}
|
|
|
|
// ─── CONNEXIONS ──────────────────────────────────────────────
|
|
async function loadConnections() {
|
|
try {
|
|
const [resC, resP] = await Promise.all([
|
|
fetch('/api/connections'),
|
|
fetch('/api/plugins')
|
|
]);
|
|
const dataC = await resC.json();
|
|
const dataP = await resP.json();
|
|
|
|
// Sécurité : s'assurer que ce sont bien des tableaux
|
|
allConnections = Array.isArray(dataC) ? dataC : [];
|
|
availablePlugins = Array.isArray(dataP) ? dataP : [];
|
|
|
|
if (!allConnections.length) {
|
|
console.warn('Aucune connexion retournée par /api/connections', dataC);
|
|
}
|
|
|
|
// Remplir les selects de panneau
|
|
['left', 'right'].forEach(panel => {
|
|
const sel = document.getElementById(panel + 'Connection');
|
|
const cur = state[panel].connection;
|
|
sel.innerHTML = allConnections.map(c =>
|
|
`<option value="${c.id}" ${c.id === cur ? 'selected' : ''}>${c.name}</option>`
|
|
).join('');
|
|
});
|
|
|
|
// Remplir le select de type dans la modal
|
|
const typeSelect = document.getElementById('newConnType');
|
|
typeSelect.innerHTML = '<option value="">-- Choisir --</option>' +
|
|
availablePlugins.map(p => `<option value="${p.name}">${p.label}</option>`).join('');
|
|
} catch(e) {
|
|
console.error('Erreur loadConnections:', e);
|
|
toast('Erreur chargement des connexions', 'error');
|
|
}
|
|
}
|
|
|
|
function openConnModal() {
|
|
renderConnList();
|
|
document.getElementById('connModal').classList.add('open');
|
|
}
|
|
|
|
function closeConnModal() {
|
|
document.getElementById('connModal').classList.remove('open');
|
|
}
|
|
|
|
function renderConnList() {
|
|
const el = document.getElementById('connList');
|
|
if (!allConnections.length) {
|
|
el.innerHTML = '<div style="color:var(--muted);font-size:11px;padding:8px;">Aucune connexion</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = allConnections.map(c => `
|
|
<div class="conn-item">
|
|
<span class="conn-item-name">${escHtml(c.name)}</span>
|
|
<span class="conn-item-type ${c.type}">${c.type_label || c.type}</span>
|
|
${c.readonly ? '<span class="conn-readonly">🔒 readonly</span>' : ''}
|
|
<button class="btn" style="font-size:10px;padding:3px 8px;" onclick="testConn('${c.id}', this)">Test</button>
|
|
<button class="btn" style="font-size:10px;padding:3px 8px;" onclick="openEditConn('${c.id}')">✏</button>
|
|
${!['seedbox','nas'].includes(c.id) ? `<button class="queue-remove" onclick="deleteConn('${c.id}')" title="Supprimer">✕</button>` : ''}
|
|
</div>`).join('');
|
|
}
|
|
|
|
function renderConnFields() {
|
|
const type = document.getElementById('newConnType').value;
|
|
const plugin = availablePlugins.find(p => p.name === type);
|
|
const el = document.getElementById('connFields');
|
|
if (!plugin) { el.innerHTML = ''; return; }
|
|
|
|
const rows = [];
|
|
let row = [];
|
|
plugin.fields.forEach((field, i) => {
|
|
row.push(`
|
|
<div class="field">
|
|
<label>${field.label}${field.required ? ' *' : ''}</label>
|
|
<input type="${field.type}" id="cf_${field.name}"
|
|
placeholder="${field.placeholder || field.default || ''}"
|
|
value="${field.default || ''}" />
|
|
</div>`);
|
|
if (row.length === 2 || i === plugin.fields.length - 1) {
|
|
rows.push(`<div class="form-row">${row.join('')}</div>`);
|
|
row = [];
|
|
}
|
|
});
|
|
el.innerHTML = rows.join('');
|
|
}
|
|
|
|
async function addConnection() {
|
|
const name = document.getElementById('newConnName').value.trim();
|
|
const type = document.getElementById('newConnType').value;
|
|
if (!name || !type) { toast('Nom et type requis', 'error'); return; }
|
|
|
|
const plugin = availablePlugins.find(p => p.name === type);
|
|
const config = {};
|
|
plugin.fields.forEach(field => {
|
|
const val = document.getElementById('cf_' + field.name)?.value?.trim();
|
|
if (val) config[field.name] = field.type === 'number' ? parseInt(val) : val;
|
|
else if (field.default !== undefined) config[field.name] = field.default;
|
|
});
|
|
|
|
const res = await fetch('/api/connections', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ name, type, config, readonly: document.getElementById('newConnReadonly').checked })
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
toast(`Connexion ajoutée : ${name}`, 'success');
|
|
await loadConnections();
|
|
renderConnList();
|
|
document.getElementById('newConnName').value = '';
|
|
document.getElementById('newConnType').value = '';
|
|
document.getElementById('connFields').innerHTML = '';
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
}
|
|
|
|
// ─── ÉDITION CONNEXION ───────────────────────────────────
|
|
function openEditConn(id) {
|
|
const conn = allConnections.find(c => c.id === id);
|
|
if (!conn) return;
|
|
|
|
// Remplir le formulaire d'édition
|
|
document.getElementById('editConnId').value = id;
|
|
document.getElementById('editConnName').value = conn.name;
|
|
document.getElementById('editConnType').textContent = conn.type_label || conn.type;
|
|
document.getElementById('editConnReadonly').checked = conn.readonly || false;
|
|
|
|
// Générer les champs de config
|
|
const plugin = availablePlugins.find(p => p.name === conn.type);
|
|
const el = document.getElementById('editConnFields');
|
|
if (!plugin) { el.innerHTML = ''; }
|
|
else {
|
|
const rows = [];
|
|
let row = [];
|
|
plugin.fields.forEach((field, i) => {
|
|
const current = conn.config?.[field.name];
|
|
const displayVal = current === undefined ? (field.default || '') : current;
|
|
row.push(`
|
|
<div class="field">
|
|
<label>${field.label}</label>
|
|
<input type="${field.type}" id="ef_${field.name}"
|
|
placeholder="${field.placeholder || ''}"
|
|
value="${escHtml(String(displayVal))}" />
|
|
</div>`);
|
|
if (row.length === 2 || i === plugin.fields.length - 1) {
|
|
rows.push(`<div class="form-row">${row.join('')}</div>`);
|
|
row = [];
|
|
}
|
|
});
|
|
el.innerHTML = rows.join('');
|
|
}
|
|
|
|
document.getElementById('editConnModal').classList.add('open');
|
|
}
|
|
|
|
function closeEditConn() {
|
|
document.getElementById('editConnModal').classList.remove('open');
|
|
}
|
|
|
|
async function saveEditConn() {
|
|
const id = document.getElementById('editConnId').value;
|
|
const name = document.getElementById('editConnName').value.trim();
|
|
const readonly = document.getElementById('editConnReadonly').checked;
|
|
const conn = allConnections.find(c => c.id === id);
|
|
if (!conn || !name) { toast('Nom requis', 'error'); return; }
|
|
|
|
const plugin = availablePlugins.find(p => p.name === conn.type);
|
|
const config = {};
|
|
if (plugin) {
|
|
plugin.fields.forEach(field => {
|
|
const val = document.getElementById('ef_' + field.name)?.value?.trim();
|
|
if (val !== undefined) config[field.name] = field.type === 'number' ? parseInt(val) : val;
|
|
});
|
|
}
|
|
|
|
const res = await fetch(`/api/connections/${id}`, {
|
|
method: 'PUT',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ name, config, readonly })
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
toast(`Connexion mise à jour : ${name}`, 'success');
|
|
closeEditConn();
|
|
await loadConnections();
|
|
renderConnList();
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
}
|
|
|
|
async function deleteConn(id) {
|
|
if (!confirm('Supprimer cette connexion ?')) return;
|
|
const res = await fetch(`/api/connections/${id}`, { method: 'DELETE' });
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
toast('Connexion supprimée', 'success');
|
|
await loadConnections();
|
|
renderConnList();
|
|
} else {
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
}
|
|
|
|
async function testConn(id, btn) {
|
|
btn.textContent = '…';
|
|
btn.disabled = true;
|
|
const res = await fetch(`/api/connections/${id}/test`, { method: 'POST' });
|
|
const data = await res.json();
|
|
btn.disabled = false;
|
|
if (data.success) {
|
|
btn.textContent = '✓ OK';
|
|
btn.style.color = 'var(--accent)';
|
|
} else {
|
|
btn.textContent = '✗ Err';
|
|
btn.style.color = 'var(--danger)';
|
|
toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
setTimeout(() => { btn.textContent = 'Test'; btn.style.color = ''; }, 3000);
|
|
}
|
|
|
|
// ─── ONGLETS ─────────────────────────────────────────────────
|
|
function switchTab(tab) {
|
|
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
|
|
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
|
document.getElementById('tabBtn' + tab.charAt(0).toUpperCase() + tab.slice(1)).classList.add('active');
|
|
document.getElementById('tab' + tab.charAt(0).toUpperCase() + tab.slice(1)).classList.add('active');
|
|
if (tab === 'history') loadHistory();
|
|
}
|
|
|
|
// ─── HISTORIQUE ───────────────────────────────────────────────
|
|
let historyLoaded = false;
|
|
|
|
async function loadHistory(force = false) {
|
|
if (historyLoaded && !force) return;
|
|
const res = await fetch('/api/history');
|
|
const data = await res.json();
|
|
historyLoaded = true;
|
|
renderHistory(data);
|
|
}
|
|
|
|
function renderHistory(entries) {
|
|
const tbody = document.getElementById('histBody');
|
|
const count = document.getElementById('histCount');
|
|
count.textContent = entries.length + ' transfert' + (entries.length > 1 ? 's' : '');
|
|
|
|
if (!entries.length) {
|
|
tbody.innerHTML = '<tr><td colspan="7" class="hist-empty">Aucun transfert enregistré</td></tr>';
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = entries.map(e => {
|
|
const icon = e.success ? '✅' : '❌';
|
|
const size = e.size ? formatSize(e.size) : '—';
|
|
const dur = e.duration ? (e.duration >= 60
|
|
? Math.floor(e.duration/60) + 'm ' + (e.duration%60).toFixed(0) + 's'
|
|
: e.duration.toFixed(1) + 's') : '—';
|
|
const srcShort = (e.src || '').split('/').pop();
|
|
const dstShort = (e.dst || '').split('/').slice(-2).join('/');
|
|
return `<tr title="${e.error ? 'Erreur : ' + escHtml(e.error) : ''}">
|
|
<td class="hist-status">${icon}</td>
|
|
<td class="hist-name" title="${escHtml(e.name)}">${escHtml(e.name)}</td>
|
|
<td class="hist-path" title="${escHtml(e.src)}">${escHtml(e.src_connection)} / ${escHtml(srcShort)}</td>
|
|
<td class="hist-path" title="${escHtml(e.dst)}">${escHtml(e.dst_connection)} / ${escHtml(dstShort)}</td>
|
|
<td class="hist-size">${size}</td>
|
|
<td class="hist-dur">${dur}</td>
|
|
<td class="hist-date">${escHtml(e.date)}</td>
|
|
</tr>`;
|
|
}).join('');
|
|
}
|
|
|
|
async function clearHistory() {
|
|
if (!confirm('Vider tout l\'historique ?')) return;
|
|
await fetch('/api/history/clear', { method: 'POST' });
|
|
historyLoaded = false;
|
|
renderHistory([]);
|
|
toast('Historique vidé', 'success');
|
|
}
|
|
|
|
// Mettre à jour l'historique en temps réel après un transfert terminé
|
|
socket.on('transfer_done', data => {
|
|
if (data.success) historyLoaded = false; // force reload au prochain switch
|
|
});
|
|
|
|
// ─── INIT ────────────────────────────────────────────────────
|
|
async function init() {
|
|
await loadConnections();
|
|
|
|
// Charger les panneaux par défaut
|
|
const resD = await fetch('/api/panels/default');
|
|
const defaults = await resD.json();
|
|
|
|
for (const panel of ['left', 'right']) {
|
|
const def = defaults[panel];
|
|
const conn = allConnections.find(c => c.id === def.connection) || allConnections[0];
|
|
if (!conn) continue;
|
|
state[panel].connection = conn.id;
|
|
// Mettre à jour le select
|
|
const sel = document.getElementById(panel + 'Connection');
|
|
if (sel) sel.value = conn.id;
|
|
const root = def.path || conn.config?.root_path || '/';
|
|
loadDir(panel, root);
|
|
}
|
|
}
|
|
|
|
async function saveAsDefault() {
|
|
const res = await fetch('/api/panels/default', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
left_connection: state.left.connection,
|
|
left_path: state.left.path,
|
|
right_connection: state.right.connection,
|
|
right_path: state.right.path
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) toast('Vue sauvegardée comme démarrage par défaut ★', 'success');
|
|
else toast('Erreur : ' + data.error, 'error');
|
|
}
|
|
|
|
init();
|
|
</script>
|
|
</body>
|
|
</html> |