-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.tsx
More file actions
281 lines (265 loc) · 11.6 KB
/
app.tsx
File metadata and controls
281 lines (265 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import React, { useState } from 'react';
import { Download, History, Settings, Link, Folder, CheckCircle, XCircle, Loader, Trash2, Copy } from 'lucide-react';
export default function WgetGUI() {
const [activeTab, setActiveTab] = useState('download');
const [url, setUrl] = useState('');
const [outputPath, setOutputPath] = useState('~/Downloads');
const [options, setOptions] = useState({
continue: true,
recursive: false,
limit: false,
timestamping: false,
noCache: false,
userAgent: false
});
const [downloadHistory, setDownloadHistory] = useState([
{ id: 1, url: 'https://example.com/file.pdf', status: 'completed', time: '2 hours ago', size: '2.4 MB' },
{ id: 2, url: 'https://example.com/archive.zip', status: 'completed', time: '5 hours ago', size: '15.8 MB' }
]);
const [currentDownload, setCurrentDownload] = useState(null);
const generateCommand = () => {
let cmd = 'wget';
if (options.continue) cmd += ' -c';
if (options.recursive) cmd += ' -r';
if (options.timestamping) cmd += ' -N';
if (options.noCache) cmd += ' --no-cache';
if (options.userAgent) cmd += ' --user-agent="Mozilla/5.0"';
if (outputPath !== '~/Downloads') cmd += ` -P ${outputPath}`;
cmd += ` "${url}"`;
return cmd;
};
const handleDownload = () => {
if (!url) return;
setCurrentDownload({
url: url,
progress: 0,
status: 'downloading'
});
// Simulate download progress
let progress = 0;
const interval = setInterval(() => {
progress += Math.random() * 15;
if (progress >= 100) {
progress = 100;
clearInterval(interval);
setTimeout(() => {
setDownloadHistory([
{
id: Date.now(),
url: url,
status: 'completed',
time: 'just now',
size: `${(Math.random() * 50 + 1).toFixed(1)} MB`
},
...downloadHistory
]);
setCurrentDownload(null);
setUrl('');
}, 500);
}
setCurrentDownload(prev => ({...prev, progress: Math.min(progress, 100)}));
}, 300);
};
const copyCommand = () => {
navigator.clipboard.writeText(generateCommand());
};
const deleteHistoryItem = (id) => {
setDownloadHistory(downloadHistory.filter(item => item.id !== id));
};
return (
<div className="min-h-screen bg-gradient-to-br from-blue-50 via-white to-purple-50">
<div className="max-w-5xl mx-auto p-6">
{/* Header */}
<div className="mb-8">
<div className="flex items-center gap-3 mb-2">
<div className="p-3 bg-gradient-to-br from-blue-600 to-purple-600 rounded-xl shadow-lg">
<Download className="text-white" size={28} />
</div>
<div>
<h1 className="text-3xl font-bold text-gray-900">wget Manager</h1>
<p className="text-gray-600">Modern download interface for wget</p>
</div>
</div>
</div>
{/* Tabs */}
<div className="flex gap-2 mb-6 bg-white rounded-xl p-1 shadow-sm">
<button
onClick={() => setActiveTab('download')}
className={`flex items-center gap-2 px-6 py-3 rounded-lg font-medium transition-all ${
activeTab === 'download'
? 'bg-gradient-to-r from-blue-600 to-purple-600 text-white shadow-md'
: 'text-gray-600 hover:bg-gray-50'
}`}
>
<Download size={18} />
Download
</button>
<button
onClick={() => setActiveTab('history')}
className={`flex items-center gap-2 px-6 py-3 rounded-lg font-medium transition-all ${
activeTab === 'history'
? 'bg-gradient-to-r from-blue-600 to-purple-600 text-white shadow-md'
: 'text-gray-600 hover:bg-gray-50'
}`}
>
<History size={18} />
History
</button>
</div>
{/* Download Tab */}
{activeTab === 'download' && (
<div className="space-y-6">
{/* URL Input */}
<div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100">
<label className="flex items-center gap-2 text-sm font-semibold text-gray-700 mb-3">
<Link size={16} />
Download URL
</label>
<input
type="text"
value={url}
onChange={(e) => setUrl(e.target.value)}
placeholder="https://example.com/file.zip"
className="w-full px-4 py-3 border-2 border-gray-200 rounded-lg focus:border-blue-500 focus:outline-none transition-colors"
/>
</div>
{/* Output Path */}
<div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100">
<label className="flex items-center gap-2 text-sm font-semibold text-gray-700 mb-3">
<Folder size={16} />
Save Location
</label>
<input
type="text"
value={outputPath}
onChange={(e) => setOutputPath(e.target.value)}
className="w-full px-4 py-3 border-2 border-gray-200 rounded-lg focus:border-blue-500 focus:outline-none transition-colors"
/>
</div>
{/* Options */}
<div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100">
<label className="flex items-center gap-2 text-sm font-semibold text-gray-700 mb-4">
<Settings size={16} />
Download Options
</label>
<div className="grid grid-cols-2 gap-4">
{Object.entries({
continue: 'Continue partial downloads (-c)',
recursive: 'Recursive download (-r)',
timestamping: 'Use timestamping (-N)',
noCache: 'Bypass cache (--no-cache)',
userAgent: 'Custom user agent',
limit: 'Limit download speed'
}).map(([key, label]) => (
<label key={key} className="flex items-center gap-3 cursor-pointer group">
<input
type="checkbox"
checked={options[key]}
onChange={(e) => setOptions({...options, [key]: e.target.checked})}
className="w-5 h-5 text-blue-600 rounded focus:ring-2 focus:ring-blue-500 cursor-pointer"
/>
<span className="text-sm text-gray-700 group-hover:text-gray-900">{label}</span>
</label>
))}
</div>
</div>
{/* Generated Command */}
<div className="bg-gradient-to-r from-gray-900 to-gray-800 rounded-xl shadow-lg p-6 border border-gray-700">
<div className="flex items-center justify-between mb-3">
<label className="text-sm font-semibold text-gray-300">Generated Command</label>
<button
onClick={copyCommand}
className="flex items-center gap-2 px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded-lg transition-colors"
>
<Copy size={14} />
Copy
</button>
</div>
<code className="block text-green-400 font-mono text-sm break-all">
{generateCommand()}
</code>
</div>
{/* Current Download */}
{currentDownload && (
<div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100">
<div className="flex items-center gap-3 mb-4">
<Loader className="text-blue-600 animate-spin" size={20} />
<span className="font-semibold text-gray-900">Downloading...</span>
</div>
<div className="mb-2">
<div className="text-sm text-gray-600 mb-2 truncate">{currentDownload.url}</div>
<div className="w-full bg-gray-200 rounded-full h-3 overflow-hidden">
<div
className="bg-gradient-to-r from-blue-600 to-purple-600 h-full rounded-full transition-all duration-300"
style={{width: `${currentDownload.progress}%`}}
/>
</div>
<div className="text-right text-sm text-gray-600 mt-1">
{Math.round(currentDownload.progress)}%
</div>
</div>
</div>
)}
{/* Download Button */}
<button
onClick={handleDownload}
disabled={!url || currentDownload}
className="w-full bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 disabled:from-gray-300 disabled:to-gray-400 text-white font-semibold py-4 rounded-xl shadow-lg transition-all disabled:cursor-not-allowed flex items-center justify-center gap-2"
>
<Download size={20} />
{currentDownload ? 'Downloading...' : 'Start Download'}
</button>
</div>
)}
{/* History Tab */}
{activeTab === 'history' && (
<div className="bg-white rounded-xl shadow-lg border border-gray-100">
<div className="p-6 border-b border-gray-100">
<h2 className="text-xl font-bold text-gray-900">Download History</h2>
<p className="text-sm text-gray-600 mt-1">{downloadHistory.length} downloads</p>
</div>
<div className="divide-y divide-gray-100">
{downloadHistory.length === 0 ? (
<div className="p-12 text-center text-gray-500">
<History size={48} className="mx-auto mb-3 opacity-30" />
<p>No downloads yet</p>
</div>
) : (
downloadHistory.map((item) => (
<div key={item.id} className="p-6 hover:bg-gray-50 transition-colors">
<div className="flex items-start justify-between gap-4">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1">
{item.status === 'completed' ? (
<CheckCircle size={18} className="text-green-600 flex-shrink-0" />
) : (
<XCircle size={18} className="text-red-600 flex-shrink-0" />
)}
<span className="text-sm font-medium text-gray-900 truncate">
{item.url.split('/').pop() || item.url}
</span>
</div>
<p className="text-sm text-gray-600 truncate mb-1">{item.url}</p>
<div className="flex items-center gap-3 text-xs text-gray-500">
<span>{item.time}</span>
<span>•</span>
<span>{item.size}</span>
</div>
</div>
<button
onClick={() => deleteHistoryItem(item.id)}
className="p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors"
>
<Trash2 size={18} />
</button>
</div>
</div>
))
)}
</div>
</div>
)}
</div>
</div>
);
}