Skip to content

Commit 8c597d6

Browse files
committed
Newprojectpagecomplete
1 parent 6121145 commit 8c597d6

File tree

14 files changed

+973
-305
lines changed

14 files changed

+973
-305
lines changed

backend/server.js

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -38,81 +38,81 @@ app.post('/register', async (req, res) => {
3838
const { username, password, role, lastLogin } = req.body;
3939

4040
if (!username || !password || !role) {
41-
return res.status(400).json({ message: 'Username, password, and role are required' });
41+
return res.status(400).json({ message: 'Username, password, and role are required' });
4242
}
4343

4444
try {
45-
const existingUser = await User.findOne({ username });
46-
if (existingUser) {
47-
return res.status(400).json({ message: 'Username already exists' });
48-
}
49-
50-
// Hash the password before saving
51-
const hashedPassword = await bcrypt.hash(password, 10); // 10 rounds of hashing
52-
const newUser = new User({
53-
username,
54-
password: hashedPassword,
55-
role,
56-
lastLogin: lastLogin || new Date()
57-
});
58-
59-
await newUser.save();
60-
res.json({ message: 'User registered successfully!', user: newUser });
45+
const existingUser = await User.findOne({ username });
46+
if (existingUser) {
47+
return res.status(400).json({ message: 'Username already exists' });
48+
}
49+
50+
// Hash the password before saving
51+
const hashedPassword = await bcrypt.hash(password, 10); // 10 rounds of hashing
52+
const newUser = new User({
53+
username,
54+
password: hashedPassword,
55+
role,
56+
lastLogin: lastLogin || new Date()
57+
});
58+
59+
await newUser.save();
60+
res.json({ message: 'User registered successfully!', user: newUser });
6161
} catch (err) {
62-
console.error('Error while registering:', err);
63-
res.status(500).json({ message: 'Error registering user', error: err });
62+
console.error('Error while registering:', err);
63+
res.status(500).json({ message: 'Error registering user', error: err });
6464
}
6565
});
6666

6767
// Login route
6868
app.post('/login', async (req, res) => {
69-
const { username, password } = req.body;
70-
71-
try {
72-
const user = await User.findOne({ username });
73-
if (!user) {
74-
return res.status(401).json({ message: 'Invalid username or password' });
75-
}
76-
77-
// Compare the hashed password with the input password
78-
const isMatch = await bcrypt.compare(password, user.password);
79-
if (!isMatch) {
80-
return res.status(401).json({ message: 'Invalid username or password' });
81-
}
82-
83-
// Update lastLogin to the current timestamp
84-
user.lastLogin = new Date();
85-
await user.save();
86-
87-
const token = jwt.sign(
88-
{ userId: user._id, role: user.role },
89-
process.env.SECRET_KEY,
90-
{ expiresIn: '1h' }
91-
);
92-
93-
res.json({ message: 'Login successful', token });
94-
} catch (err) {
95-
console.error('Login error:', err);
96-
res.status(500).json({ message: 'Server error' });
69+
const { username, password } = req.body;
70+
71+
try {
72+
const user = await User.findOne({ username });
73+
if (!user) {
74+
return res.status(401).json({ message: 'Invalid username or password' });
9775
}
76+
77+
// Compare the hashed password with the input password
78+
const isMatch = await bcrypt.compare(password, user.password);
79+
if (!isMatch) {
80+
return res.status(401).json({ message: 'Invalid username or password' });
81+
}
82+
83+
// Update lastLogin to the current timestamp
84+
user.lastLogin = new Date();
85+
await user.save();
86+
87+
const token = jwt.sign(
88+
{ userId: user._id, role: user.role },
89+
process.env.SECRET_KEY,
90+
{ expiresIn: '1h' }
91+
);
92+
93+
res.json({ message: 'Login successful', token });
94+
} catch (err) {
95+
console.error('Login error:', err);
96+
res.status(500).json({ message: 'Server error' });
97+
}
9898
});
9999

100100
// `/me` route to get the current user’s profile based on JWT token
101101
app.get('/me', verifyToken, async (req, res) => {
102-
try {
103-
const user = await User.findById(req.user.userId).select('-password'); // Exclude the password from the response
104-
if (!user) {
105-
return res.status(404).json({ message: 'User not found' });
106-
}
107-
res.json(user); // Send back the user's details
108-
} catch (err) {
109-
console.error('Error fetching user data:', err);
110-
res.status(500).json({ message: 'Server error' });
102+
try {
103+
const user = await User.findById(req.user.userId).select('-password'); // Exclude the password from the response
104+
if (!user) {
105+
return res.status(404).json({ message: 'User not found' });
111106
}
107+
res.json(user); // Send back the user's details
108+
} catch (err) {
109+
console.error('Error fetching user data:', err);
110+
res.status(500).json({ message: 'Server error' });
111+
}
112112
});
113113

114114
// Start the server
115-
const PORT = process.env.PORT || 3001;
115+
const PORT = process.env.PORT || 3002;
116116
app.listen(PORT, () => {
117-
console.log(`Server is running on port ${PORT}`);
117+
console.log(`Server is running on port ${PORT}`);
118118
});

main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ function createWindow() {
2828
}
2929

3030
function startBackend() {
31-
// Start the Node.js backend server
3231
backendProcess = spawn('node', ['backend/server.js'], {
33-
cwd: __dirname, // Set the current working directory
34-
shell: true, // Required for Windows compatibility
32+
cwd: __dirname,
33+
shell: true,
3534
});
3635

3736
backendProcess.stdout.on('data', (data) => {
3837
console.log(`[Backend]: ${data}`);
38+
if (data.includes('Connected to MongoDB')) {
39+
createWindow(); // Create Electron window once the backend is ready
40+
}
3941
});
4042

4143
backendProcess.stderr.on('data', (data) => {
@@ -47,9 +49,9 @@ function startBackend() {
4749
});
4850
}
4951

52+
5053
app.on('ready', () => {
5154
startBackend(); // Start the backend server
52-
createWindow();
5355
});
5456

5557
app.on('window-all-closed', () => {

src/AfterLogin/Dashboard.css

Lines changed: 23 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,24 @@
1-
/* Dashboard.css */
2-
3-
/* Base styles */
4-
body {
5-
margin: 0;
6-
font-family: Arial, sans-serif;
7-
background-color: #1d1d1d;
8-
color: white;
9-
}
10-
111
/* Layout */
122
.dashboard {
133
display: flex;
4+
flex-direction: column;
145
height: 100vh;
6+
background-color: #1e1e1e; /* Dark background for the whole dashboard */
7+
overflow: hidden;
158
}
169

17-
/* Sidebar */
18-
.sidebar {
19-
width: 280px;
20-
background-color: #0D2620;
21-
padding: 20px;
10+
/* Main Content */
11+
.mct {
2212
display: flex;
23-
flex-direction: column;
13+
flex-direction: row;
2414
gap: 20px;
15+
height: calc(100vh - 60px); /* Adjusted height to account for potential header */
2516
}
2617

27-
.sidebar-header h2 {
28-
font-size: 18px;
29-
margin: 0;
30-
color: #e6e6e6;
31-
}
32-
33-
.nav-list {
34-
list-style: none;
35-
padding: 0;
36-
margin: 0;
37-
38-
}
39-
40-
.nav-list li {
41-
padding: 8px 0;
42-
cursor: pointer;
43-
transition: color 0.2s;
44-
}
45-
46-
.nav-list li:hover {
47-
color: #0078d4;
48-
}
49-
50-
.nav-list.secondary li {
51-
color: #b3b3b3;
52-
font-size: 14px;
53-
}
54-
55-
.project-buttons {
56-
display: flex;
57-
flex-direction: column;
58-
gap: 12px;
59-
}
60-
61-
/* Header */
62-
/* Previous CSS remains the same until header styles */
63-
64-
/* Header Container */
65-
.header-container {
66-
background-color: #0D2620;
67-
border-radius: 8px;
68-
padding: 20px;
69-
margin-bottom: 32px;
70-
border: 1px solid #2b622d;
71-
}
72-
73-
.header {
74-
display: flex;
75-
justify-content: space-between;
76-
align-items: center;
77-
margin: 0;
78-
}
79-
80-
81-
82-
.header-right {
83-
display: flex;
84-
align-items: center;
85-
gap: 24px;
86-
}
87-
88-
/* Search */
89-
.search-container {
90-
position: relative;
91-
display: flex;
92-
align-items: center;
93-
}
94-
95-
.search-icon {
96-
position: absolute;
97-
left: 12px;
98-
color: #b3b3b3;
99-
}
100-
101-
.search-input {
102-
padding: 8px 12px 8px 40px;
103-
border: 1px solid #2b622d;
104-
border-radius: 4px;
105-
background-color: #0D2620;
106-
color: white;
107-
width: 250px;
108-
font-size: 14px;
109-
}
110-
111-
.search-input:focus {
112-
outline: none;
113-
border-color: #0078d4;
114-
}
115-
116-
/* Profile */
117-
.profile {
118-
display: flex;
119-
align-items: center;
120-
gap: 8px;
121-
cursor: pointer;
122-
background-color: white;
123-
border-radius: 50%;
124-
padding: 10px;
125-
}
126-
127-
.profile-image {
128-
width: 32px;
129-
height: 32px;
130-
border-radius: 50%;
131-
object-fit: cover;
132-
}
133-
134-
.profile-icon {
135-
color: #b3b3b3;
136-
}
137-
138-
/* Buttons */
139-
.primary-btn {
140-
padding: 12px 20px;
141-
border: none;
142-
border-radius: 4px;
143-
cursor: pointer;
144-
font-size: 14px;
145-
background-color: #0078d4;
146-
color: white;
147-
transition: background-color 0.2s, box-shadow 0.2s;
148-
}
149-
150-
.primary-btn:hover {
151-
background-color: #0086ef;
152-
box-shadow: 0 0 10px rgba(0, 120, 212, 0.5);
153-
}
154-
155-
/* Main Content */
15618
.main-content {
15719
flex: 1;
15820
padding: 32px;
159-
}
160-
161-
.header h1 {
162-
margin: 0;
163-
font-size: 24px;
164-
color: #e6e6e6;
21+
overflow-y: auto;
16522
}
16623

16724
/* Recent Projects */
@@ -172,33 +29,39 @@ body {
17229
.recent-projects h2 {
17330
margin-bottom: 16px;
17431
font-size: 18px;
32+
color: #e6e6e6;
17533
}
17634

35+
/* New Projects Table Layout */
17736
.projects-table {
17837
width: 100%;
17938
border-collapse: collapse;
180-
background-color: #0D2620;
39+
background-color: #2a2a2a;
18140
border-radius: 8px;
18241
overflow: hidden;
18342
}
18443

18544
.projects-table th,
18645
.projects-table td {
18746
text-align: left;
188-
padding: 12px 16px;
189-
border-bottom: 1px solid #163617;
47+
padding: 16px;
19048
}
19149

19250
.projects-table th {
193-
background-color: #2b622d;
194-
font-weight: 500;
195-
color: #e6e6e6;
51+
background-color: #3a3a3a;
52+
font-weight: 600;
53+
color: #ffffff;
19654
}
19755

19856
.projects-table td {
199-
color: #b3b3b3;
57+
background-color: #2a2a2a;
58+
color: #d1d1d1;
59+
}
60+
61+
.projects-table tr:nth-child(even) td {
62+
background-color: #333333;
20063
}
20164

20265
.projects-table tr:hover td {
203-
background-color: #2b622d;
204-
}
66+
background-color: #3a3a3a;
67+
}

0 commit comments

Comments
 (0)