Mehdi commited on
Commit
73e3315
·
verified ·
1 Parent(s): ceba883

Upload components/ProjectManager.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/ProjectManager.jsx +258 -0
components/ProjectManager.jsx ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react'
2
+ import { motion, AnimatePresence } from 'framer-motion'
3
+ import {
4
+ FaFolder, FaFolderOpen, FaFile, FaFileCode, FaFileAlt, FaImage,
5
+ FaVideo, FaMusic, FaArchive, FaDatabase, FaCloud, FaGitAlt,
6
+ FaPlus, FaMinus, FaEdit, FaTrash, FaCopy, FaMove, FaDownload,
7
+ FaUpload, FaSearch, FaFilter, FaSort, FaSortAmountDown,
8
+ FaSortAmountUp, FaEye, FaEyeSlash, FaLock, FaUnlock,
9
+ FaShare, FaLink, FaStar, FaRegStar, FaClock, FaCalendar,
10
+ FaUser, FaUsers, FaTag, FaTags, FaFlag, FaBookmark,
11
+ FaCheck, FaTimes, FaInfo, FaWarning, FaExclamationTriangle,
12
+ FaCheckCircle, FaTimesCircle, FaPlay, FaPause, FaStop,
13
+ FaRedo, FaUndo, FaSave, FaPrint, FaSync, FaRefresh,
14
+ FaSpinner, FaCog, Fa wrench, FaTools, FaMagic, FaRocket,
15
+ FaCode, FaDatabase, FaServer, FaCloud, FaShieldAlt,
16
+ FaChartLine, FaProjectDiagram, FaBug, FaTest, FaFlask,
17
+ FaBook, FaGraduationCap, FaLightbulb, FaLightbulbAlt,
18
+ FaFire, FaBolt, FaZap, FaAtom, FaDna, FaMicroscope,
19
+ FaTelescope, FaSatellite, FaRocket, FaSpace, FaGlobe,
20
+ FaMap, FaMapMarked, FaMapMarkedAlt, FaCompass, FaRoute,
21
+ FaNavigator, FaSailboat, FaShip, FaAnchor, FaBuoy,
22
+ FaWater, FaWind, FaCloudRain, FaCloudSun, FaSun,
23
+ FaMoon, FaStar, FaRegStar, FaStarHalf, FaStarAndCrescent,
24
+ FaMeteor, FaComet, FaPlanet, FaRing, FaOrbital,
25
+ FaBlackHole, FaGalaxy, FaNebula, FaConstellation, FaAstronomy
26
+ } from 'react-icons/fa'
27
+ import toast from 'react-hot-toast'
28
+
29
+ export default function ProjectManager({ language, theme }) {
30
+ const [projects, setProjects] = useState([])
31
+ const [selectedProject, setSelectedProject] = useState(null)
32
+ const [files, setFiles] = useState([])
33
+ const [viewMode, setViewMode] = useState('grid')
34
+ const [sortBy, setSortBy] = useState('name')
35
+ const [sortOrder, setSortOrder] = useState('asc')
36
+ const [searchQuery, setSearchQuery] = useState('')
37
+ const [showHidden, setShowHidden] = useState(false)
38
+ const [selectedFiles, setSelectedFiles] = useState(new Set())
39
+
40
+ useEffect(() => {
41
+ // Initialize with sample projects
42
+ setProjects([
43
+ {
44
+ id: 1,
45
+ name: 'E-Commerce Platform',
46
+ type: 'web',
47
+ status: 'active',
48
+ progress: 75,
49
+ lastModified: new Date(),
50
+ size: '125 MB',
51
+ files: 234,
52
+ stars: 5,
53
+ tags: ['react', 'nodejs', 'mongodb'],
54
+ description: 'Full-stack e-commerce solution'
55
+ },
56
+ {
57
+ id: 2,
58
+ name: 'Mobile Banking App',
59
+ type: 'mobile',
60
+ status: 'development',
61
+ progress: 45,
62
+ lastModified: new Date(),
63
+ size: '89 MB',
64
+ files: 156,
65
+ stars: 4,
66
+ tags: ['react-native', 'firebase', 'typescript'],
67
+ description: 'Secure mobile banking application'
68
+ },
69
+ {
70
+ id: 3,
71
+ name: 'AI Data Pipeline',
72
+ type: 'data',
73
+ status: 'testing',
74
+ progress: 90,
75
+ lastModified: new Date(),
76
+ size: '2.3 GB',
77
+ files: 412,
78
+ stars: 5,
79
+ tags: ['python', 'tensorflow', 'aws'],
80
+ description: 'Machine learning data processing pipeline'
81
+ }
82
+ ])
83
+ }, [])
84
+
85
+ const createProject = () => {
86
+ const newProject = {
87
+ id: Date.now(),
88
+ name: `New Project ${projects.length + 1}`,
89
+ type: 'web',
90
+ status: 'planning',
91
+ progress: 0,
92
+ lastModified: new Date(),
93
+ size: '0 MB',
94
+ files: 0,
95
+ stars: 0,
96
+ tags: [],
97
+ description: 'New project description'
98
+ }
99
+ setProjects([...projects, newProject])
100
+ setSelectedProject(newProject)
101
+ toast.success(language === 'fa' ? 'پروژه ایجاد شد' : 'Project created')
102
+ }
103
+
104
+ const deleteProject = (id) => {
105
+ setProjects(projects.filter(p => p.id !== id))
106
+ if (selectedProject?.id === id) {
107
+ setSelectedProject(null)
108
+ }
109
+ toast.success(language === 'fa' ? 'پروژه حذف شد' : 'Project deleted')
110
+ }
111
+
112
+ const duplicateProject = (project) => {
113
+ const duplicate = {
114
+ ...project,
115
+ id: Date.now(),
116
+ name: `${project.name} (Copy)`,
117
+ lastModified: new Date()
118
+ }
119
+ setProjects([...projects, duplicate])
120
+ toast.success(language === 'fa' ? 'پروژه کپی شد' : 'Project duplicated')
121
+ }
122
+
123
+ const getFileIcon = (fileName) => {
124
+ const ext = fileName.split('.').pop().toLowerCase()
125
+ if (['js', 'jsx', 'ts', 'tsx', 'py', 'java', 'cpp', 'c'].includes(ext)) return FaFileCode
126
+ if (['txt', 'md', 'doc', 'docx', 'pdf'].includes(ext)) return FaFileAlt
127
+ if (['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp'].includes(ext)) return FaImage
128
+ if (['mp4', 'avi', 'mov', 'webm'].includes(ext)) return FaVideo
129
+ if (['mp3', 'wav', 'ogg', 'm4a'].includes(ext)) return FaMusic
130
+ if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return FaArchive
131
+ if (['sql', 'db', 'sqlite'].includes(ext)) return FaDatabase
132
+ return FaFile
133
+ }
134
+
135
+ const getStatusColor = (status) => {
136
+ switch (status) {
137
+ case 'active': return 'text-green-400'
138
+ case 'development': return 'text-blue-400'
139
+ case 'testing': return 'text-yellow-400'
140
+ case 'planning': return 'text-purple-400'
141
+ case 'completed': return 'text-emerald-400'
142
+ default: return 'text-gray-400'
143
+ }
144
+ }
145
+
146
+ const sortProjects = (projects) => {
147
+ return [...projects].sort((a, b) => {
148
+ let comparison = 0
149
+ switch (sortBy) {
150
+ case 'name':
151
+ comparison = a.name.localeCompare(b.name)
152
+ break
153
+ case 'date':
154
+ comparison = a.lastModified - b.lastModified
155
+ break
156
+ case 'size':
157
+ comparison = parseFloat(a.size) - parseFloat(b.size)
158
+ break
159
+ case 'progress':
160
+ comparison = a.progress - b.progress
161
+ break
162
+ case 'files':
163
+ comparison = a.files - b.files
164
+ break
165
+ default:
166
+ comparison = 0
167
+ }
168
+ return sortOrder === 'asc' ? comparison : -comparison
169
+ })
170
+ }
171
+
172
+ const filteredProjects = sortProjects(projects).filter(project =>
173
+ project.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
174
+ project.description.toLowerCase().includes(searchQuery.toLowerCase()) ||
175
+ project.tags.some(tag => tag.toLowerCase().includes(searchQuery.toLowerCase()))
176
+ )
177
+
178
+ return (
179
+ <div className="flex flex-col h-full space-y-4">
180
+ {/* Header */}
181
+ <div className="flex items-center justify-between p-4 bg-gray-800 rounded-lg">
182
+ <div className="flex items-center space-x-reverse space-x-3">
183
+ <FaProjectDiagram className="w-6 h-6 text-primary-400" />
184
+ <h2 className="text-lg font-semibold">Project Manager</h2>
185
+ </div>
186
+ <div className="flex items-center space-x-reverse space-x-2">
187
+ <button
188
+ onClick={createProject}
189
+ className="px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-all flex items-center space-x-reverse space-x-2"
190
+ >
191
+ <FaPlus className="w-4 h-4" />
192
+ <span>{language === 'fa' ? 'پروژه جدید' : 'New Project'}</span>
193
+ </button>
194
+ </div>
195
+ </div>
196
+
197
+ <div className="flex-1 flex space-x-reverse space-x-4 min-h-0">
198
+ {/* Projects List */}
199
+ <div className="w-96 bg-gray-800 rounded-lg p-4 space-y-4 overflow-y-auto">
200
+ {/* Search and Filter */}
201
+ <div className="space-y-3">
202
+ <div className="relative">
203
+ <FaSearch className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
204
+ <input
205
+ type="text"
206
+ value={searchQuery}
207
+ onChange={(e) => setSearchQuery(e.target.value)}
208
+ placeholder="Search projects..."
209
+ className="w-full pr-10 px-3 py-2 bg-gray-700 text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
210
+ />
211
+ </div>
212
+
213
+ <div className="flex items-center space-x-reverse space-x-2">
214
+ <select
215
+ value={sortBy}
216
+ onChange={(e) => setSortBy(e.target.value)}
217
+ className="flex-1 px-3 py-2 bg-gray-700 text-white rounded-lg focus:outline-none"
218
+ >
219
+ <option value="name">Name</option>
220
+ <option value="date">Date</option>
221
+ <option value="size">Size</option>
222
+ <option value="progress">Progress</option>
223
+ <option value="files">Files</option>
224
+ </select>
225
+
226
+ <button
227
+ onClick={() => setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc')}
228
+ className="p-2 bg-gray-700 text-white rounded-lg hover:bg-gray-600 transition-all"
229
+ >
230
+ {sortOrder === 'asc' ? <FaSortAmountUp className="w-4 h-4" /> : <FaSortAmountDown className="w-4 h-4" />}
231
+ </button>
232
+ </div>
233
+ </div>
234
+
235
+ {/* Projects Grid */}
236
+ <div className="space-y-2">
237
+ <AnimatePresence>
238
+ {filteredProjects.map(project => (
239
+ <motion.div
240
+ key={project.id}
241
+ initial={{ opacity: 0, x: -20 }}
242
+ animate={{ opacity: 1, x: 0 }}
243
+ exit={{ opacity: 0, x: -20 }}
244
+ onClick={() => setSelectedProject(project)}
245
+ className={`p-3 rounded-lg cursor-pointer transition-all ${
246
+ selectedProject?.id === project.id
247
+ ? 'bg-primary-600 text-white'
248
+ : 'bg-gray-700 text-gray-300 hover:bg-gray-600'
249
+ }`}
250
+ >
251
+ <div className="flex items-start justify-between">
252
+ <div className="flex-1">
253
+ <div className="flex items-center space-x-reverse space-x-2">
254
+ <FaFolder className="w-4 h-4" />
255
+ <h3 className="font-medium text-sm">{project.name}</h3>
256
+ </div>
257
+ <p className="text-xs opacity-75 mt-1">{project.description}</p>
258
+ <div className="