File size: 11,993 Bytes
aec80be | 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 | // Main React App
const App = () => {
const [darkMode, setDarkMode] = React.useState(true);
const [activeTab, setActiveTab] = React.useState('dashboard');
const [buckets, setBuckets] = React.useState([]);
const [selectedBucket, setSelectedBucket] = React.useState(null);
const [files, setFiles] = React.useState([]);
const [storageStats, setStorageStats] = React.useState({
total: 1024,
used: 256,
available: 768,
files: 42
});
React.useEffect(() => {
// Mock data for development
setBuckets([
{ id: 1, name: 'media', files: 18, size: 120, lastModified: new Date() },
{ id: 2, name: 'documents', files: 24, size: 136, lastModified: new Date() },
]);
setFiles([
{ id: 1, name: 'report.pdf', size: 2.4, type: 'pdf', lastModified: new Date() },
{ id: 2, name: 'presentation.pptx', size: 5.7, type: 'ppt', lastModified: new Date() },
{ id: 3, name: 'image.jpg', size: 3.2, type: 'image', lastModified: new Date() },
]);
}, []);
const toggleDarkMode = () => {
setDarkMode(!darkMode);
document.documentElement.classList.toggle('dark', !darkMode);
};
const Dashboard = () => {
return (
<div className="animate-fadeIn">
<h2 className="text-2xl font-bold mb-6">Storage Overview</h2>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div className="card p-6 rounded-lg">
<h3 className="text-lg font-semibold mb-2">Total Storage</h3>
<p className="text-3xl font-bold">{storageStats.total} GB</p>
</div>
<div className="card p-6 rounded-lg">
<h3 className="text-lg font-semibold mb-2">Used Storage</h3>
<p className="text-3xl font-bold">{storageStats.used} GB</p>
</div>
<div className="card p-6 rounded-lg">
<h3 className="text-lg font-semibold mb-2">Files</h3>
<p className="text-3xl font-bold">{storageStats.files}</p>
</div>
</div>
<div className="card p-6 rounded-lg mb-8">
<h3 className="text-lg font-semibold mb-4">Storage Usage</h3>
<canvas id="storageChart" height="100"></canvas>
</div>
<div className="card p-6 rounded-lg">
<h3 className="text-lg font-semibold mb-4">Recent Activity</h3>
<div className="space-y-4">
{files.slice(0, 5).map(file => (
<div key={file.id} className="flex items-center justify-between p-3 hover:bg-gray-800 rounded">
<div className="flex items-center">
<div className="file-icon mr-3">
{file.type === 'pdf' ? 'π' : file.type === 'ppt' ? 'π' : 'πΌοΈ'}
</div>
<div>
<p className="font-medium">{file.name}</p>
<p className="text-sm text-gray-400">{file.size} MB</p>
</div>
</div>
<span className="text-sm text-gray-400">
{file.lastModified.toLocaleDateString()}
</span>
</div>
))}
</div>
</div>
</div>
);
};
const BucketManager = () => {
return (
<div className="animate-fadeIn">
<div className="flex justify-between items-center mb-6">
<h2 className="text-2xl font-bold">Buckets</h2>
<button className="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg">
Create Bucket
</button>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{buckets.map(bucket => (
<div key={bucket.id} className="card p-6 rounded-lg cursor-pointer hover:border-indigo-500 transition-all" onClick={() => setSelectedBucket(bucket)}>
<div className="flex justify-between items-start">
<h3 className="text-xl font-bold">{bucket.name}</h3>
<span className="bg-indigo-900 text-indigo-300 px-2 py-1 rounded text-xs">
{bucket.files} files
</span>
</div>
<p className="mt-2 text-gray-400">{bucket.size} MB</p>
<div className="mt-4">
<div className="w-full bg-gray-700 rounded-full h-1.5">
<div className="bg-indigo-500 h-1.5 rounded-full" style={{ width: `${(bucket.size / storageStats.total) * 100}%` }}></div>
</div>
<p className="text-xs mt-1 text-right text-gray-400">
Last modified: {bucket.lastModified.toLocaleDateString()}
</p>
</div>
</div>
))}
</div>
</div>
);
};
const FileBrowser = () => {
const onDrop = React.useCallback(acceptedFiles => {
// Handle file upload
console.log(acceptedFiles);
}, []);
const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop});
return (
<div className="animate-fadeIn">
<div className="flex justify-between items-center mb-6">
<h2 className="text-2xl font-bold">Files in {selectedBucket?.name || 'No bucket selected'}</h2>
<div className="flex space-x-2">
<button className="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg">
New Folder
</button>
<div {...getRootProps()} className="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg cursor-pointer">
<input {...getInputProps()} />
{isDragActive ? 'Drop files here' : 'Upload Files'}
</div>
</div>
</div>
{isDragActive && (
<div className="dropzone active mb-6">
<p className="text-lg">Drop your files here</p>
<p className="text-sm text-gray-400">Files will be uploaded to {selectedBucket?.name || 'selected bucket'}</p>
</div>
)}
<div className="card p-6 rounded-lg">
<div className="overflow-x-auto">
<table className="min-w-full">
<thead>
<tr className="text-left text-gray-400">
<th className="pb-3">Name</th>
<th className="pb-3">Size</th>
<th className="pb-3">Last Modified</th>
<th className="pb-3">Actions</th>
</tr>
</thead>
<tbody>
{files.map(file => (
<tr key={file.id} className="border-b border-gray-800 hover:bg-gray-800 transition-colors">
<td className="py-3">
<div className="flex items-center">
<span className="mr-2">
{file.type === 'pdf' ? 'π' : file.type === 'ppt' ? 'π' : 'πΌοΈ'}
</span>
{file.name}
</div>
</td>
<td className="py-3">{file.size} MB</td>
<td className="py-3">{file.lastModified.toLocaleDateString()}</td>
<td className="py-3">
<div className="flex space-x-2">
<button className="text-indigo-400 hover:text-indigo-300">
Download
</button>
<button className="text-gray-400 hover:text-gray-300">
Share
</button>
<button className="text-red-400 hover:text-red-300">
Delete
</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
);
};
const renderContent = () => {
switch (activeTab) {
case 'dashboard':
return <Dashboard />;
case 'buckets':
return <BucketManager />;
case 'files':
return selectedBucket ? <FileBrowser /> : <BucketManager />;
default:
return <Dashboard />;
}
};
return (
<div className="flex min-h-screen">
<custom-sidebar></custom-sidebar>
<div className="flex-1 p-8">
<custom-navbar onToggleDarkMode={toggleDarkMode} darkMode={darkMode}></custom-navbar>
<div className="mt-8">
{renderContent()}
</div>
<custom-footer></custom-footer>
</div>
</div>
);
};
// Render the app
ReactDOM.render(<App />, document.getElementById('root'));
// Initialize charts
const initCharts = () => {
const ctx = document.getElementById('storageChart');
if (ctx) {
new Chart(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
datasets: [{
label: 'Storage Used (GB)',
data: [120, 150, 180, 210, 240, 210, 256],
borderColor: '#6366f1',
backgroundColor: 'rgba(99, 102, 241, 0.1)',
borderWidth: 2,
fill: true,
tension: 0.3
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
},
scales: {
y: {
beginAtZero: true
}
}
}
});
}
};
// Initialize charts when component mounts
document.addEventListener('DOMContentLoaded', initCharts); |