agent-cleandrive 0.0.0-stage → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +357 -2
- package/bin/cleandrive.js +280 -0
- package/config.example.json +35 -0
- package/docs/offload-strategy.md +132 -0
- package/lib/actions.js +263 -0
- package/lib/archives.js +242 -0
- package/lib/catalog.js +222 -0
- package/lib/offload.js +534 -0
- package/lib/projects.js +114 -0
- package/lib/scan.js +236 -0
- package/lib/server.js +261 -0
- package/lib/util.js +134 -0
- package/package.json +60 -4
- package/ui/index.html +521 -0
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-cleandrive",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Safe disk cleanup that any AI agent can drive: the agent proposes, you approve, the tool enforces. Risk-tiered cleaning, checksum-verified archives to your own drive, iCloud-style offload. macOS today, Linux next. Zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cleandrive": "bin/cleandrive.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/cleandrive.js",
|
|
11
|
+
"lib/",
|
|
12
|
+
"ui/",
|
|
13
|
+
"config.example.json",
|
|
14
|
+
"docs/offload-strategy.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"scan": "node bin/cleandrive.js scan",
|
|
18
|
+
"serve": "node bin/cleandrive.js serve",
|
|
19
|
+
"state": "node bin/cleandrive.js state",
|
|
20
|
+
"test": "node --test test/*.test.mjs",
|
|
21
|
+
"prepublishOnly": "node --test test/*.test.mjs"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"os": [
|
|
27
|
+
"darwin"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"agent",
|
|
31
|
+
"agentic",
|
|
32
|
+
"ai-agent",
|
|
33
|
+
"apple-silicon",
|
|
34
|
+
"archive",
|
|
35
|
+
"claude-code",
|
|
36
|
+
"cleanup",
|
|
37
|
+
"cli",
|
|
38
|
+
"codex",
|
|
39
|
+
"cursor",
|
|
40
|
+
"dashboard",
|
|
41
|
+
"disk-cleanup",
|
|
42
|
+
"disk-space",
|
|
43
|
+
"low-resource",
|
|
44
|
+
"macos",
|
|
45
|
+
"mcp",
|
|
46
|
+
"offload",
|
|
47
|
+
"rsync",
|
|
48
|
+
"swap",
|
|
49
|
+
"tailscale",
|
|
50
|
+
"zero-dependencies"
|
|
51
|
+
],
|
|
52
|
+
"author": "Martin Kaiser (https://github.com/kaiser-data)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"homepage": "https://github.com/kaiser-data/agent-cleandrive#readme",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/kaiser-data/agent-cleandrive.git"
|
|
58
|
+
},
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/kaiser-data/agent-cleandrive/issues"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/ui/index.html
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>agent-cleandrive</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
--page: #f9f9f7; --surface: #fcfcfb;
|
|
10
|
+
--ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
|
|
11
|
+
--grid: #e1e0d9; --baseline: #c3c2b7; --border: rgba(11,11,11,0.10);
|
|
12
|
+
--c-pkgcache: #2a78d6; --c-cache: #1baf7a; --c-nm: #eda100;
|
|
13
|
+
--c-projects: #008300; --c-appdata: #4a3aa7; --c-apps: #e87ba4; --c-models: #e34948;
|
|
14
|
+
--seq-light: #86b6ef; --seq-mid: #2a78d6;
|
|
15
|
+
--good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
|
|
16
|
+
--good-ink: #006300;
|
|
17
|
+
}
|
|
18
|
+
@media (prefers-color-scheme: dark) {
|
|
19
|
+
:root {
|
|
20
|
+
--page: #0d0d0d; --surface: #1a1a19;
|
|
21
|
+
--ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
|
|
22
|
+
--grid: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,0.10);
|
|
23
|
+
--c-pkgcache: #3987e5; --c-cache: #199e70; --c-nm: #c98500;
|
|
24
|
+
--c-projects: #008300; --c-appdata: #9085e9; --c-apps: #d55181; --c-models: #e66767;
|
|
25
|
+
--seq-light: #1c5cab; --seq-mid: #3987e5;
|
|
26
|
+
--good-ink: #0ca30c;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
* { box-sizing: border-box; margin: 0; }
|
|
30
|
+
body {
|
|
31
|
+
background: var(--page); color: var(--ink);
|
|
32
|
+
font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
33
|
+
padding: 24px; max-width: 1180px; margin: 0 auto;
|
|
34
|
+
}
|
|
35
|
+
h1 { font-size: 20px; font-weight: 650; }
|
|
36
|
+
h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
|
|
37
|
+
header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
|
|
38
|
+
header .meta { color: var(--muted); font-size: 12.5px; }
|
|
39
|
+
.spacer { flex: 1; }
|
|
40
|
+
button {
|
|
41
|
+
font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 7px; cursor: pointer;
|
|
42
|
+
border: 1px solid var(--border); background: var(--surface); color: var(--ink);
|
|
43
|
+
}
|
|
44
|
+
button:hover { border-color: var(--baseline); }
|
|
45
|
+
button.primary { background: var(--seq-mid); border-color: transparent; color: #fff; }
|
|
46
|
+
button.danger { background: var(--critical); border-color: transparent; color: #fff; }
|
|
47
|
+
button:disabled { opacity: .45; cursor: default; }
|
|
48
|
+
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
|
|
49
|
+
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
|
|
50
|
+
.tile .label { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
|
|
51
|
+
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -.01em; }
|
|
52
|
+
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
|
53
|
+
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); }
|
|
54
|
+
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
|
|
55
|
+
/* capacity bar */
|
|
56
|
+
.capbar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: transparent; border: 1px solid var(--grid); }
|
|
57
|
+
.capbar .seg { height: 100%; }
|
|
58
|
+
.capbar .seg + .seg { margin-left: 2px; }
|
|
59
|
+
.caplegend { display: flex; gap: 18px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
|
|
60
|
+
.caplegend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border); }
|
|
61
|
+
/* category bars */
|
|
62
|
+
.catrow { display: grid; grid-template-columns: 170px 1fr 90px; align-items: center; gap: 12px; padding: 5px 0; }
|
|
63
|
+
.catrow .name { font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
|
|
64
|
+
.catrow .track { height: 12px; position: relative; }
|
|
65
|
+
.catrow .bar { height: 12px; border-radius: 0 4px 4px 0; min-width: 2px; }
|
|
66
|
+
.catrow .val { font-size: 13px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
|
|
67
|
+
/* filters + table */
|
|
68
|
+
.filters { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
|
|
69
|
+
.filters button { padding: 4px 12px; border-radius: 999px; font-size: 12.5px; }
|
|
70
|
+
.filters button.on { background: var(--ink); color: var(--page); border-color: transparent; }
|
|
71
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
72
|
+
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
|
|
73
|
+
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
|
|
74
|
+
td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
|
|
75
|
+
td .path { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
|
|
76
|
+
td .note { color: var(--muted); font-size: 11.5px; }
|
|
77
|
+
.risk { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
|
|
78
|
+
.risk.low { color: var(--good-ink); } .risk.medium { color: var(--ink-2); } .risk.review { color: var(--ink-2); }
|
|
79
|
+
select { font: inherit; font-size: 12.5px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
|
|
80
|
+
.rowbtns { display: flex; gap: 6px; }
|
|
81
|
+
.rowbtns button { padding: 3px 10px; font-size: 12px; }
|
|
82
|
+
.st { font-size: 11.5px; font-weight: 600; }
|
|
83
|
+
.st.approved { color: var(--seq-mid); } .st.done { color: var(--good-ink); } .st.failed { color: var(--critical); } .st.skipped { color: var(--muted); } .st.reviewed { color: var(--c-appdata); }
|
|
84
|
+
.filters .divider { width: 1px; background: var(--grid); margin: 0 2px; align-self: stretch; }
|
|
85
|
+
.filters button.toggle { border-style: dashed; }
|
|
86
|
+
.filters button.toggle.on { background: var(--c-appdata); border-color: transparent; color: #fff; }
|
|
87
|
+
.rowbtns button.reviewed { background: var(--c-appdata); border-color: transparent; color: #fff; }
|
|
88
|
+
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
|
|
89
|
+
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
|
|
90
|
+
.logbox { font-family: ui-monospace, monospace; font-size: 11.5px; background: var(--page); border: 1px solid var(--grid); border-radius: 8px; padding: 10px; height: 240px; overflow-y: auto; white-space: pre-wrap; color: var(--ink-2); }
|
|
91
|
+
.remote input { font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--border); background: var(--page); color: var(--ink); width: 100%; }
|
|
92
|
+
.remote .frow { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
|
|
93
|
+
.remote label { font-size: 12.5px; color: var(--ink-2); }
|
|
94
|
+
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
|
|
95
|
+
/* tooltip */
|
|
96
|
+
#tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12px; padding: 6px 10px; border-radius: 7px; z-index: 50; display: none; max-width: 340px; }
|
|
97
|
+
/* modal */
|
|
98
|
+
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 40; }
|
|
99
|
+
#modal .box { background: var(--surface); border-radius: 14px; padding: 24px; width: 440px; max-width: 92vw; }
|
|
100
|
+
#modal input { font: inherit; width: 100%; padding: 8px 10px; margin: 12px 0; border-radius: 7px; border: 1px solid var(--border); background: var(--page); color: var(--ink); }
|
|
101
|
+
#modal ul { margin: 10px 0 4px 18px; font-size: 12.5px; color: var(--ink-2); max-height: 180px; overflow-y: auto; }
|
|
102
|
+
section { margin-top: 16px; }
|
|
103
|
+
</style>
|
|
104
|
+
</head>
|
|
105
|
+
<body>
|
|
106
|
+
<header>
|
|
107
|
+
<h1>agent-cleandrive</h1>
|
|
108
|
+
<span class="meta" id="scanTs">no scan yet</span>
|
|
109
|
+
<span class="spacer"></span>
|
|
110
|
+
<span class="chip" id="diskChip"></span>
|
|
111
|
+
<button id="rescan">Rescan</button>
|
|
112
|
+
</header>
|
|
113
|
+
|
|
114
|
+
<div class="tiles">
|
|
115
|
+
<div class="card tile"><div class="label">Disk used</div><div class="value" id="tUsed">–</div><div class="sub" id="tUsedSub"></div></div>
|
|
116
|
+
<div class="card tile"><div class="label">Free now</div><div class="value" id="tFree">–</div><div class="sub">on the data volume</div></div>
|
|
117
|
+
<div class="card tile"><div class="label">Reclaimable, low risk</div><div class="value" id="tReclaim">–</div><div class="sub">caches + node_modules</div></div>
|
|
118
|
+
<div class="card tile"><div class="label">Approved in plan</div><div class="value" id="tPlan">–</div><div class="sub" id="tPlanSub">nothing approved yet</div></div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div class="card">
|
|
122
|
+
<h2>Capacity</h2>
|
|
123
|
+
<div class="capbar" id="capbar"></div>
|
|
124
|
+
<div class="caplegend" id="caplegend"></div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<section class="card">
|
|
128
|
+
<h2>Where the space goes</h2>
|
|
129
|
+
<div id="catbars"></div>
|
|
130
|
+
<div class="hint">Project sizes exclude their node_modules (listed separately). App data and AI models unlock deletion only after you mark them reviewed — then choose rm, approve, and confirm. Applications are never deleted by the dashboard.</div>
|
|
131
|
+
</section>
|
|
132
|
+
|
|
133
|
+
<section class="card">
|
|
134
|
+
<h2>Items</h2>
|
|
135
|
+
<div class="filters" id="filters"></div>
|
|
136
|
+
<div style="overflow-x:auto"><table>
|
|
137
|
+
<thead><tr><th>Path</th><th style="text-align:right">Size</th><th>Risk</th><th>Action</th><th>Status</th><th></th></tr></thead>
|
|
138
|
+
<tbody id="rows"></tbody>
|
|
139
|
+
</table></div>
|
|
140
|
+
</section>
|
|
141
|
+
|
|
142
|
+
<div class="grid2">
|
|
143
|
+
<div class="card">
|
|
144
|
+
<h2>Plan & execution</h2>
|
|
145
|
+
<div class="filters" id="presets"></div>
|
|
146
|
+
<div id="planSummary" style="font-size:13px;color:var(--ink-2);margin-bottom:10px">No approved actions.</div>
|
|
147
|
+
<div style="display:flex;gap:8px;margin-bottom:12px">
|
|
148
|
+
<button class="danger" id="execBtn" disabled>Execute plan…</button>
|
|
149
|
+
<button id="dryrunBtn" disabled>Dry-run archives</button>
|
|
150
|
+
</div>
|
|
151
|
+
<div class="logbox" id="logbox">idle</div>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="card remote">
|
|
154
|
+
<h2>Remote archive target (SSH / Tailscale)</h2>
|
|
155
|
+
<div class="frow"><label>Host</label><input id="rHost" placeholder="raspberrypi (tailscale name)"></div>
|
|
156
|
+
<div class="frow"><label>User</label><input id="rUser" placeholder="pi"></div>
|
|
157
|
+
<div class="frow"><label>Path</label><input id="rPath" placeholder="/mnt/external/mac-archive"></div>
|
|
158
|
+
<div class="frow"><label>SSH key</label><input id="rKey" placeholder="~/.ssh/id_ed25519 (optional — blank uses agent)"></div>
|
|
159
|
+
<div class="frow"><label>SSH port</label><input id="rPort" placeholder="22 (optional)"></div>
|
|
160
|
+
<div style="display:flex;gap:8px;align-items:center">
|
|
161
|
+
<button id="rSave">Save</button>
|
|
162
|
+
<button id="rTest">Test connection</button>
|
|
163
|
+
<span id="rStatus" class="risk" style="font-size:12px"></span>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="hint">Project archives get a unique version directory and a receipt recording the original path, then are checksum-verified. Local copies are only removed with the “archive + remove local” action, and only after verification succeeds.</div>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<section class="card" aria-labelledby="archiveHeading">
|
|
170
|
+
<h2 id="archiveHeading">Project archives on your remote drive</h2>
|
|
171
|
+
<label for="archiveSearch">Find a project</label>
|
|
172
|
+
<input id="archiveSearch" type="search" placeholder="Name, original path, or archive ID" style="width:min(100%,420px)">
|
|
173
|
+
<p class="hint">Transfer verification confirms the stored contents. Independent backup status is unknown. Restore commands recover a project only when its original path is absent.</p>
|
|
174
|
+
<div style="overflow-x:auto"><table>
|
|
175
|
+
<thead><tr><th>Project and location</th><th>Size</th><th>State</th><th>Restore</th></tr></thead>
|
|
176
|
+
<tbody id="archiveRows"></tbody>
|
|
177
|
+
</table></div>
|
|
178
|
+
</section>
|
|
179
|
+
|
|
180
|
+
<section class="card">
|
|
181
|
+
<h2>Offload to the remote drive <span class="note" style="text-transform:none;letter-spacing:0;font-weight:400">— like iCloud: a verified copy goes to your remote drive, a small <code>.cloud</code> placeholder stays here</span></h2>
|
|
182
|
+
<div style="display:flex;gap:8px;align-items:center;margin-bottom:10px;flex-wrap:wrap">
|
|
183
|
+
<button id="ofFind">Find candidates</button>
|
|
184
|
+
<button class="primary" id="ofGo" disabled>Offload selected…</button>
|
|
185
|
+
<span class="note" id="ofSummary"></span>
|
|
186
|
+
</div>
|
|
187
|
+
<div style="overflow-x:auto"><table>
|
|
188
|
+
<thead><tr><th></th><th>File</th><th style="text-align:right">Size</th><th>State</th><th></th></tr></thead>
|
|
189
|
+
<tbody id="ofRows"><tr><td colspan="5" class="note">No candidates yet. Click “Find candidates” (videos and other big media ≥ 200 MB, unused for 30 days, duplicates first).</td></tr></tbody>
|
|
190
|
+
</table></div>
|
|
191
|
+
<div class="hint">Nothing runs in the background. The local file is removed only after its sha256 matches on the remote drive. Fetch downloads it, checks it again, and restores the original. The remote copy stays, so offloading it again is instant. CLI: <code>cleandrive offload / fetch / offloaded</code>.</div>
|
|
192
|
+
</section>
|
|
193
|
+
|
|
194
|
+
<div id="tip"></div>
|
|
195
|
+
<div id="modal"><div class="box">
|
|
196
|
+
<h2 style="margin-bottom:6px">Execute approved actions</h2>
|
|
197
|
+
<div style="font-size:13px;color:var(--ink-2)" id="modalSummary"></div>
|
|
198
|
+
<ul id="modalList"></ul>
|
|
199
|
+
<div style="font-size:12.5px;color:var(--ink-2)">Type <b>FREE</b> to confirm. Deletes are permanent; archives are verified before any local removal.</div>
|
|
200
|
+
<input id="confirmWord" placeholder="FREE" autocomplete="off">
|
|
201
|
+
<div style="display:flex;gap:8px;justify-content:flex-end">
|
|
202
|
+
<button id="modalCancel">Cancel</button>
|
|
203
|
+
<button class="danger" id="modalGo" disabled>Execute</button>
|
|
204
|
+
</div>
|
|
205
|
+
</div></div>
|
|
206
|
+
|
|
207
|
+
<script>
|
|
208
|
+
const CAT = {
|
|
209
|
+
pkgcache: { label: 'Package caches', color: 'var(--c-pkgcache)', risk: 'low' },
|
|
210
|
+
cache: { label: 'App & tool caches', color: 'var(--c-cache)', risk: 'low' },
|
|
211
|
+
node_modules:{ label: 'node_modules', color: 'var(--c-nm)', risk: 'low' },
|
|
212
|
+
projects: { label: 'Projects', color: 'var(--c-projects)', risk: 'medium' },
|
|
213
|
+
appdata: { label: 'App data', color: 'var(--c-appdata)', risk: 'review' },
|
|
214
|
+
apps: { label: 'Applications', color: 'var(--c-apps)', risk: 'review' },
|
|
215
|
+
models: { label: 'AI models', color: 'var(--c-models)', risk: 'review' },
|
|
216
|
+
};
|
|
217
|
+
const RISK_LABEL = { low: '✓ low risk', medium: '⚠ verify first', review: '◉ manual review' };
|
|
218
|
+
const ACTIONS = {
|
|
219
|
+
pkgcache: ['clean', 'rm'], cache: ['rm'], node_modules: ['rm'],
|
|
220
|
+
projects: ['archive', 'archive+rm', 'keep'], appdata: [], apps: [], models: [],
|
|
221
|
+
};
|
|
222
|
+
// review-only categories where rm unlocks after "Mark reviewed"; apps stay manual
|
|
223
|
+
const REVIEW_RM = ['appdata', 'models'];
|
|
224
|
+
function actionsFor(it) {
|
|
225
|
+
if (it.kind === 'group') return [];
|
|
226
|
+
if (it.activity?.band === 'pinned') return ['keep', 'archive'];
|
|
227
|
+
if (it.protected) return [];
|
|
228
|
+
const base = ACTIONS[it.category] || [];
|
|
229
|
+
if (base.length) return base;
|
|
230
|
+
return REVIEW_RM.includes(it.category) && planOf(it).reviewed ? ['keep', 'rm'] : [];
|
|
231
|
+
}
|
|
232
|
+
let S = { scan: null, plan: { items: {} }, filter: 'all', executing: false };
|
|
233
|
+
const $ = (id) => document.getElementById(id);
|
|
234
|
+
const gb = (kb) => { const g = kb/1048576; return g >= 10 ? g.toFixed(0)+' GB' : g >= 1 ? g.toFixed(1)+' GB' : (kb/1024).toFixed(0)+' MB'; };
|
|
235
|
+
const esc = (s) => s.replace(/[&<>"]/g, (c) => ({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
|
236
|
+
|
|
237
|
+
// per-run token the server injects into this page; API calls without it are refused
|
|
238
|
+
const TOKEN = document.querySelector('meta[name="cleandrive-token"]')?.content || '';
|
|
239
|
+
async function api(path, body) {
|
|
240
|
+
const headers = { 'X-Cleandrive-Token': TOKEN };
|
|
241
|
+
const r = await fetch(path, body ? { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : { headers });
|
|
242
|
+
const j = await r.json();
|
|
243
|
+
// the server refuses approvals the executor would refuse; say why instead of failing silently
|
|
244
|
+
if (!r.ok && j.error) alert('Not approved: ' + j.error);
|
|
245
|
+
if (j.refused?.length) alert('Not approved:\n' + j.refused.map((x) => '• ' + x.error).join('\n'));
|
|
246
|
+
return j;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function planOf(it) { return S.plan.items[it.id] || {}; }
|
|
250
|
+
function effectiveAction(it) { return planOf(it).action || it.suggest; }
|
|
251
|
+
function isApproved(it) { return planOf(it).status === 'approved'; }
|
|
252
|
+
|
|
253
|
+
function tip(el, html) {
|
|
254
|
+
el.addEventListener('mousemove', (e) => { const t = $('tip'); t.innerHTML = html(); t.style.display = 'block'; t.style.left = Math.min(e.clientX + 14, innerWidth - 360) + 'px'; t.style.top = (e.clientY + 14) + 'px'; });
|
|
255
|
+
el.addEventListener('mouseleave', () => { $('tip').style.display = 'none'; });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function render() {
|
|
259
|
+
const scan = S.scan;
|
|
260
|
+
if (!scan) return;
|
|
261
|
+
const d = S.disk || scan.disk;
|
|
262
|
+
$('scanTs').textContent = 'scanned ' + new Date(scan.ts).toLocaleString();
|
|
263
|
+
$('tUsed').textContent = d.pct + '%';
|
|
264
|
+
$('tUsedSub').textContent = gb(d.usedKB) + ' of ' + gb(d.sizeKB);
|
|
265
|
+
$('tFree').textContent = gb(d.availKB);
|
|
266
|
+
|
|
267
|
+
const chip = $('diskChip');
|
|
268
|
+
const level = d.pct >= 95 ? ['critical', '⛔ critical'] : d.pct >= 85 ? ['serious', '⚠ tight'] : ['good', '✓ healthy'];
|
|
269
|
+
chip.innerHTML = '<span class="dot" style="background:var(--' + level[0] + ')"></span>' + level[1] + ' · ' + d.pct + '% full';
|
|
270
|
+
|
|
271
|
+
const lowRisk = scan.items.filter((i) => CAT[i.category]?.risk === 'low');
|
|
272
|
+
const reclaimKB = lowRisk.reduce((s, i) => s + i.kb, 0);
|
|
273
|
+
$('tReclaim').textContent = gb(reclaimKB);
|
|
274
|
+
const approved = scan.items.filter(isApproved);
|
|
275
|
+
const apKB = approved.reduce((s, i) => s + i.kb, 0);
|
|
276
|
+
$('tPlan').textContent = approved.length ? gb(apKB) : '0';
|
|
277
|
+
$('tPlanSub').textContent = approved.length ? approved.length + ' action(s) approved' : 'nothing approved yet';
|
|
278
|
+
$('execBtn').disabled = !approved.length || S.executing;
|
|
279
|
+
$('dryrunBtn').disabled = !approved.some((i) => (effectiveAction(i) || '').startsWith('archive')) || S.executing;
|
|
280
|
+
$('planSummary').textContent = approved.length
|
|
281
|
+
? approved.length + ' approved action(s), ~' + gb(apKB) + ' affected.'
|
|
282
|
+
: 'No approved actions. Approve items in the table above.';
|
|
283
|
+
|
|
284
|
+
// one-click presets: bulk-approve whole low-risk groups with their suggested action
|
|
285
|
+
const presetDefs = [
|
|
286
|
+
{ label: 'caches', cats: ['pkgcache', 'cache'] },
|
|
287
|
+
{ label: 'caches + node_modules', cats: ['pkgcache', 'cache', 'node_modules'] },
|
|
288
|
+
];
|
|
289
|
+
const pr = $('presets'); pr.innerHTML = '';
|
|
290
|
+
for (const def of presetDefs) {
|
|
291
|
+
const eligible = scan.items.filter((i) => def.cats.includes(i.category) && !i.protected
|
|
292
|
+
&& !['done', 'skipped'].includes(planOf(i).status));
|
|
293
|
+
if (!eligible.length) continue;
|
|
294
|
+
const kb = eligible.reduce((s, i) => s + i.kb, 0);
|
|
295
|
+
const b = document.createElement('button');
|
|
296
|
+
b.textContent = 'Select ' + def.label + ' — ' + gb(kb);
|
|
297
|
+
b.disabled = S.executing;
|
|
298
|
+
b.onclick = async () => {
|
|
299
|
+
await api('/api/plan/bulk', { changes: eligible.map((i) => ({ id: i.id, status: 'approved', action: planOf(i).action || i.suggest })) });
|
|
300
|
+
refresh();
|
|
301
|
+
};
|
|
302
|
+
pr.appendChild(b);
|
|
303
|
+
}
|
|
304
|
+
if (approved.length) {
|
|
305
|
+
const c = document.createElement('button');
|
|
306
|
+
c.textContent = 'Clear selection';
|
|
307
|
+
c.disabled = S.executing;
|
|
308
|
+
c.onclick = async () => {
|
|
309
|
+
await api('/api/plan/bulk', { changes: approved.map((i) => ({ id: i.id, status: 'proposed' })) });
|
|
310
|
+
refresh();
|
|
311
|
+
};
|
|
312
|
+
pr.appendChild(c);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// capacity bar: other-used | reclaimable | free (APFS: used+avail is the real total)
|
|
316
|
+
const totKB = d.usedKB + d.availKB;
|
|
317
|
+
const otherKB = Math.max(0, d.usedKB - reclaimKB);
|
|
318
|
+
const segs = [
|
|
319
|
+
{ kb: otherKB, color: 'var(--seq-mid)', label: 'Used (everything else)' },
|
|
320
|
+
{ kb: reclaimKB, color: 'var(--seq-light)', label: 'Reclaimable low-risk (caches, node_modules)' },
|
|
321
|
+
{ kb: d.availKB, color: 'transparent', label: 'Free' },
|
|
322
|
+
];
|
|
323
|
+
const bar = $('capbar'); bar.innerHTML = '';
|
|
324
|
+
const leg = $('caplegend'); leg.innerHTML = '';
|
|
325
|
+
for (const s of segs) {
|
|
326
|
+
const el = document.createElement('div');
|
|
327
|
+
el.className = 'seg';
|
|
328
|
+
el.style.width = (s.kb / totKB * 100) + '%';
|
|
329
|
+
el.style.background = s.color;
|
|
330
|
+
tip(el, () => '<b>' + s.label + '</b><br>' + gb(s.kb) + ' · ' + (s.kb / totKB * 100).toFixed(1) + '%');
|
|
331
|
+
bar.appendChild(el);
|
|
332
|
+
leg.insertAdjacentHTML('beforeend', '<span><span class="sw" style="background:' + s.color + '"></span>' + s.label + ' — ' + gb(s.kb) + '</span>');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// category bars
|
|
336
|
+
const totals = Object.keys(CAT).map((k) => ({ k, kb: scan.items.filter((i) => i.category === k).reduce((s, i) => s + i.kb, 0) }));
|
|
337
|
+
const maxKB = Math.max(...totals.map((t) => t.kb), 1);
|
|
338
|
+
const cb = $('catbars'); cb.innerHTML = '';
|
|
339
|
+
for (const t of totals) {
|
|
340
|
+
if (!t.kb) continue;
|
|
341
|
+
const row = document.createElement('div');
|
|
342
|
+
row.className = 'catrow';
|
|
343
|
+
row.innerHTML = '<span class="name"><span class="sw" style="display:inline-block;width:10px;height:10px;border-radius:3px;background:' + CAT[t.k].color + '"></span>' + CAT[t.k].label + '</span>'
|
|
344
|
+
+ '<span class="track"><span class="bar" style="width:' + (t.kb / maxKB * 100) + '%;background:' + CAT[t.k].color + '"></span></span>'
|
|
345
|
+
+ '<span class="val">' + gb(t.kb) + '</span>';
|
|
346
|
+
tip(row.querySelector('.track'), () => '<b>' + CAT[t.k].label + '</b><br>' + gb(t.kb) + ' across ' + scan.items.filter((i) => i.category === t.k).length + ' item(s)');
|
|
347
|
+
cb.appendChild(row);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// filters
|
|
351
|
+
const fl = $('filters'); fl.innerHTML = '';
|
|
352
|
+
const cats = ['all', ...Object.keys(CAT).filter((k) => scan.items.some((i) => i.category === k))];
|
|
353
|
+
for (const c of cats) {
|
|
354
|
+
const b = document.createElement('button');
|
|
355
|
+
b.textContent = c === 'all' ? 'All' : CAT[c].label;
|
|
356
|
+
b.className = S.filter === c ? 'on' : '';
|
|
357
|
+
b.onclick = () => { S.filter = c; render(); };
|
|
358
|
+
fl.appendChild(b);
|
|
359
|
+
}
|
|
360
|
+
// Review-progress: how many review-only items are handled (reviewed or skipped)
|
|
361
|
+
const reviewItems = scan.items.filter((i) => CAT[i.category].risk === 'review');
|
|
362
|
+
const handled = reviewItems.filter((i) => ['reviewed', 'skipped'].includes(planOf(i).status)).length;
|
|
363
|
+
if (reviewItems.length) {
|
|
364
|
+
const div = document.createElement('span'); div.className = 'divider'; fl.appendChild(div);
|
|
365
|
+
const t = document.createElement('button');
|
|
366
|
+
t.className = 'toggle' + (S.hideReviewed ? ' on' : '');
|
|
367
|
+
t.textContent = (S.hideReviewed ? '☑' : '☐') + ' Hide handled — ' + handled + '/' + reviewItems.length + ' reviewed';
|
|
368
|
+
t.title = 'Hide review-only items you have marked reviewed or skipped';
|
|
369
|
+
t.onclick = () => { S.hideReviewed = !S.hideReviewed; render(); };
|
|
370
|
+
fl.appendChild(t);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// table
|
|
374
|
+
const rows = $('rows'); rows.innerHTML = '';
|
|
375
|
+
const visible = scan.items.filter((i) => S.filter === 'all' || i.category === S.filter)
|
|
376
|
+
.filter((i) => !(S.hideReviewed && CAT[i.category].risk === 'review' && ['reviewed', 'skipped'].includes(planOf(i).status)));
|
|
377
|
+
for (const it of visible.slice(0, 80)) {
|
|
378
|
+
const p = planOf(it);
|
|
379
|
+
const opts = actionsFor(it);
|
|
380
|
+
// review items default to 'keep' so rm is always a deliberate pick
|
|
381
|
+
const act = opts.length && !opts.includes(effectiveAction(it)) ? opts[0] : effectiveAction(it);
|
|
382
|
+
const tr = document.createElement('tr');
|
|
383
|
+
const shortPath = it.path.replace(/^\/Users\/[^/]+/, '~');
|
|
384
|
+
tr.innerHTML =
|
|
385
|
+
'<td><div class="path">' + esc(shortPath) + '</div><div class="note">' + esc(it.note || '') + '</div>' + (it.activity ? '<details><summary>Activity evidence</summary><div class="note">' + esc('Source edit: ' + (it.activity.newestSource ? new Date(it.activity.newestSource).toLocaleString() : 'unknown') + '; opened: ' + (it.activity.lastOpened ? new Date(it.activity.lastOpened).toLocaleString() : 'unknown') + '; Git: ' + (it.activity.git ? (it.activity.git.dirty === null ? 'unknown' : it.activity.git.dirty ? 'uncommitted work' : 'clean') : 'not detected') + '; inspection: ' + (it.activity.complete ? 'complete' : 'incomplete')) + '</div></details>' : '') + '</td>'
|
|
386
|
+
+ '<td class="num">' + gb(it.kb) + '</td>'
|
|
387
|
+
+ '<td><span class="risk ' + CAT[it.category].risk + '">' + (it.protected ? '🔒 protected' : RISK_LABEL[CAT[it.category].risk]) + '</span></td>'
|
|
388
|
+
+ '<td>' + (opts.length ? '<select>' + opts.map((o) => '<option' + (o === act ? ' selected' : '') + '>' + o + '</option>').join('') + '</select>' : '<span class="note">' + esc(it.suggest) + '</span>') + '</td>'
|
|
389
|
+
+ '<td><span class="st ' + (p.status || '') + '">' + (p.status || '·') + '</span></td>'
|
|
390
|
+
+ '<td><div class="rowbtns">'
|
|
391
|
+
+ (opts.length && !['keep'].includes(act) ? '<button data-a="approve">' + (p.status === 'approved' ? 'Unapprove' : 'Approve') + '</button>' : '')
|
|
392
|
+
+ (CAT[it.category].risk === 'review' && !it.protected ? '<button data-a="review" class="' + (p.status === 'reviewed' ? 'reviewed' : '') + '">' + (p.status === 'reviewed' ? '✓ Reviewed' : 'Mark reviewed') + '</button>' : '')
|
|
393
|
+
+ '<button data-a="skip">Skip</button></div></td>';
|
|
394
|
+
const sel = tr.querySelector('select');
|
|
395
|
+
if (sel) sel.onchange = async () => { await api('/api/plan', { id: it.id, action: sel.value }); refresh(); };
|
|
396
|
+
tr.querySelectorAll('button').forEach((b) => {
|
|
397
|
+
b.onclick = async () => {
|
|
398
|
+
if (b.dataset.a === 'review') {
|
|
399
|
+
const on = p.status !== 'reviewed';
|
|
400
|
+
await api('/api/plan', { id: it.id, status: on ? 'reviewed' : 'proposed', reviewed: on });
|
|
401
|
+
return refresh();
|
|
402
|
+
}
|
|
403
|
+
let status;
|
|
404
|
+
if (b.dataset.a === 'skip') status = p.status === 'skipped' ? 'proposed' : 'skipped';
|
|
405
|
+
else status = p.status === 'approved' ? 'proposed' : 'approved';
|
|
406
|
+
await api('/api/plan', { id: it.id, status, action: sel ? sel.value : it.suggest });
|
|
407
|
+
refresh();
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
rows.appendChild(tr);
|
|
411
|
+
}
|
|
412
|
+
if (visible.length > 80) rows.insertAdjacentHTML('beforeend', '<tr><td colspan="6" class="note" style="padding:10px 8px">… ' + (visible.length - 80) + ' smaller items not shown (see CLI: cleandrive state)</td></tr>');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function renderArchives() {
|
|
416
|
+
const query = $('archiveSearch').value.toLowerCase();
|
|
417
|
+
const records = (S.archives || []).filter(r => [r.id, r.originalPath, r.remotePath, r.label].join(' ').toLowerCase().includes(query));
|
|
418
|
+
$('archiveRows').innerHTML = records.map(r => '<tr><td><div class="path">' + esc(r.originalPath) + '</div><div class="note">'
|
|
419
|
+
+ esc(r.remote.host + ':' + r.remotePath) + '</div><div class="note">Transfer verified ' + esc(r.verification.checkedAt)
|
|
420
|
+
+ ' · Independent backup: unknown</div></td><td class="num">' + gb(r.bytes / 1024) + '</td><td>' + esc(r.state)
|
|
421
|
+
+ '</td><td><code>' + esc('cleandrive restore ' + r.id) + '</code></td></tr>').join('')
|
|
422
|
+
|| '<tr><td colspan="4">No matching project archives. Earlier archives without receipts are not included.</td></tr>';
|
|
423
|
+
}
|
|
424
|
+
$('archiveSearch').oninput = renderArchives;
|
|
425
|
+
|
|
426
|
+
async function refresh() {
|
|
427
|
+
const st = await api('/api/state');
|
|
428
|
+
S.archives = st.archives || []; renderArchives();
|
|
429
|
+
S.scan = st.scan; S.plan = st.plan || { items: {} }; S.disk = st.disk; S.executing = st.executing;
|
|
430
|
+
const cfgR = st.config?.remote || {};
|
|
431
|
+
if (document.activeElement?.tagName !== 'INPUT') {
|
|
432
|
+
$('rHost').value = cfgR.host || ''; $('rUser').value = cfgR.user || ''; $('rPath').value = cfgR.path || '';
|
|
433
|
+
$('rKey').value = cfgR.sshKey || ''; $('rPort').value = cfgR.sshPort || '';
|
|
434
|
+
}
|
|
435
|
+
$('rescan').textContent = st.scanning ? 'Scanning… (' + (st.scanStep || '') + ')' : 'Rescan';
|
|
436
|
+
$('rescan').disabled = st.scanning;
|
|
437
|
+
const lb = $('logbox');
|
|
438
|
+
if (st.log?.length) { lb.textContent = st.log.join('\n'); lb.scrollTop = lb.scrollHeight; }
|
|
439
|
+
render();
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
$('rescan').onclick = async () => { await api('/api/scan', {}); refresh(); };
|
|
443
|
+
$('rSave').onclick = async () => {
|
|
444
|
+
await api('/api/remote/config', { host: $('rHost').value.trim(), user: $('rUser').value.trim(), path: $('rPath').value.trim(), sshKey: $('rKey').value.trim(), sshPort: $('rPort').value.trim() });
|
|
445
|
+
$('rStatus').textContent = 'saved'; setTimeout(() => $('rStatus').textContent = '', 1500);
|
|
446
|
+
};
|
|
447
|
+
$('rTest').onclick = async () => {
|
|
448
|
+
$('rStatus').textContent = 'testing…';
|
|
449
|
+
const r = await api('/api/remote/test', {});
|
|
450
|
+
$('rStatus').textContent = (r.ok ? '✓ ' : '✗ ') + r.msg;
|
|
451
|
+
$('rStatus').style.color = r.ok ? 'var(--good-ink)' : 'var(--critical)';
|
|
452
|
+
};
|
|
453
|
+
$('dryrunBtn').onclick = async () => { await api('/api/offload/dryrun', {}); };
|
|
454
|
+
$('execBtn').onclick = () => {
|
|
455
|
+
const approved = S.scan.items.filter(isApproved);
|
|
456
|
+
$('modalSummary').textContent = approved.length + ' action(s), ~' + gb(approved.reduce((s, i) => s + i.kb, 0)) + ':';
|
|
457
|
+
$('modalList').innerHTML = approved.map((i) => '<li>' + esc(effectiveAction(i)) + ' — ' + esc(i.path.replace(/^\/Users\/[^/]+/, '~')) + ' (' + gb(i.kb) + ')</li>').join('');
|
|
458
|
+
$('confirmWord').value = ''; $('modalGo').disabled = true;
|
|
459
|
+
$('modal').style.display = 'flex'; $('confirmWord').focus();
|
|
460
|
+
};
|
|
461
|
+
$('confirmWord').oninput = () => { $('modalGo').disabled = $('confirmWord').value.trim() !== 'FREE'; };
|
|
462
|
+
$('modalCancel').onclick = () => { $('modal').style.display = 'none'; };
|
|
463
|
+
$('modalGo').onclick = async () => {
|
|
464
|
+
$('modal').style.display = 'none';
|
|
465
|
+
await api('/api/execute', { confirm: 'FREE' });
|
|
466
|
+
refresh();
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// ---- offload card ----
|
|
470
|
+
const OF = { sel: new Set(), data: null };
|
|
471
|
+
async function refreshOffload() {
|
|
472
|
+
OF.data = await api('/api/offload');
|
|
473
|
+
const d = OF.data, rows = $('ofRows');
|
|
474
|
+
const offloaded = d.files.filter((f) => f.state === 'offloaded');
|
|
475
|
+
const known = new Set(d.files.filter((f) => f.state !== 'local').map((f) => f.path));
|
|
476
|
+
const cands = (d.candidates?.candidates || []).filter((c) => !known.has(c.path));
|
|
477
|
+
const list = [...offloaded.map((f) => ({ ...f, kind: 'off' })), ...cands.map((c) => ({ ...c, kind: 'cand' }))];
|
|
478
|
+
$('ofFind').disabled = d.finding; $('ofFind').textContent = d.finding ? 'Searching…' : 'Find candidates';
|
|
479
|
+
const selKB = cands.filter((c) => OF.sel.has(c.path)).reduce((s, c) => s + c.kb, 0);
|
|
480
|
+
$('ofGo').disabled = !OF.sel.size || S.executing;
|
|
481
|
+
$('ofSummary').textContent = offloaded.length + ' offloaded (' + gb(offloaded.reduce((s, f) => s + f.size, 0) / 1024) + ' on the remote drive)'
|
|
482
|
+
+ (cands.length ? ' · ' + cands.length + ' candidates, ' + gb(cands.reduce((s, c) => s + c.kb, 0)) : '')
|
|
483
|
+
+ (OF.sel.size ? ' · selected ' + gb(selKB) : '') + (d.candidates?.unreadable ? ' · ⚠ some folders unreadable (Full Disk Access)' : '');
|
|
484
|
+
if (!list.length) return;
|
|
485
|
+
rows.innerHTML = '';
|
|
486
|
+
for (const it of list.slice(0, 60)) {
|
|
487
|
+
const tr = document.createElement('tr');
|
|
488
|
+
const sp = it.path.replace(/^\/Users\/[^/]+/, '~');
|
|
489
|
+
const sub = it.kind === 'off' ? 'offloaded ' + new Date(it.offloadedAt).toLocaleDateString()
|
|
490
|
+
: (it.duplicateOf ? '⧉ duplicate of ' + it.duplicateOf.replace(/^\/Users\/[^/]+/, '~') + ' · ' : '') + 'unused ' + it.idleDays + ' d';
|
|
491
|
+
tr.innerHTML = '<td>' + (it.kind === 'cand' ? '<input type="checkbox"' + (OF.sel.has(it.path) ? ' checked' : '') + '>' : '☁︎') + '</td>'
|
|
492
|
+
+ '<td><div class="path">' + esc(sp) + '</div><div class="note">' + esc(sub) + '</div></td>'
|
|
493
|
+
+ '<td class="num">' + gb(it.kind === 'off' ? it.size / 1024 : it.kb) + '</td>'
|
|
494
|
+
+ '<td><span class="st ' + (it.kind === 'off' ? 'done' : '') + '">' + (it.kind === 'off' ? 'remote' : 'local') + '</span></td>'
|
|
495
|
+
+ '<td><div class="rowbtns">' + (it.kind === 'off' ? '<button data-a="fetch">Fetch</button>' : '<button data-a="pin">Keep local</button>') + '</div></td>';
|
|
496
|
+
const cb = tr.querySelector('input');
|
|
497
|
+
if (cb) cb.onchange = () => { cb.checked ? OF.sel.add(it.path) : OF.sel.delete(it.path); refreshOffload(); };
|
|
498
|
+
tr.querySelectorAll('button').forEach((b) => b.onclick = async () => {
|
|
499
|
+
if (b.dataset.a === 'fetch') { b.disabled = true; await api('/api/offload/fetch', { paths: [it.path] }); }
|
|
500
|
+
else { OF.sel.delete(it.path); await api('/api/offload/pin', { path: it.path, pinned: true }); }
|
|
501
|
+
refreshOffload();
|
|
502
|
+
});
|
|
503
|
+
rows.appendChild(tr);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
$('ofFind').onclick = async () => { await api('/api/offload/candidates', {}); refreshOffload(); };
|
|
507
|
+
$('ofGo').onclick = async () => {
|
|
508
|
+
const paths = [...OF.sel];
|
|
509
|
+
const w = prompt(paths.length + ' file(s) go to the remote drive. Each one is verified before the local copy is removed.\nType OFFLOAD to confirm:');
|
|
510
|
+
if ((w || '').trim() !== 'OFFLOAD') return;
|
|
511
|
+
await api('/api/offload/run', { paths, confirm: 'OFFLOAD' });
|
|
512
|
+
OF.sel.clear(); refreshOffload();
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
refresh();
|
|
516
|
+
refreshOffload();
|
|
517
|
+
setInterval(refresh, 2500);
|
|
518
|
+
setInterval(refreshOffload, 5000);
|
|
519
|
+
</script>
|
|
520
|
+
</body>
|
|
521
|
+
</html>
|