-
Notifications
You must be signed in to change notification settings - Fork 26
/
admin_option2.html
177 lines (160 loc) · 6.86 KB
/
admin_option2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="admin.css">
<title>Admin Portal</title>
</head>
<body>
<div class="container">
<nav>
<div class="logo">
<h1>Admin Portal</h1>
</div>
<ul class="nav-links">
<li><a href="#requests">Pending Requests</a></li>
<li><a href="#interns">Employee List</a></li>
</ul>
</nav>
<header>
<h2>Welcome to the Admin Portal</h2>
</header>
<div class="sections-container">
<section id="requests">
<h2>Pending Requests</h2>
<div class="requests-container">
<table id="requests-table">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>Jane Smith</td>
<td>Intern</td>
<td>
<button class="accept-button">Accept</button>
<button class="deny-button">Deny</button>
</td>
</tr>
<!-- Add more rows as needed -->
</tbody>
</table>
</div>
</section>
<section id="interns">
<h2>Employee and Intern List</h2>
<div class="interns-container">
<table id="interns-table">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
<th>Project</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="profile.html?id=1">John Doe</a></td>
<td>Full Stack Developer</td>
<td>Project A</td>
<td>Active</td>
</tr>
<tr>
<td><a href="profile.html?id=2">Jane Smith</a></td>
<td>Intern</td>
<td>Project B</td>
<td>Active</td>
</tr>
<!-- Add more rows as needed -->
</tbody>
</table>
</div>
<button id="add-button">Add New Employee/Intern</button>
<div class="table-container" id="form-container" style="display:none;">
<form id="add-form">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" required>
</div>
<div class="form-group">
<label for="role">Role:</label>
<select id="role" required>
<option value="Backend">Backend</option>
<option value="Frontend">Frontend</option>
<option value="Full Stack">Full Stack</option>
</select>
</div>
<div class="form-group">
<label for="project">Project:</label>
<input type="text" id="project" required>
</div>
<div class="form-group">
<label for="status">Status:</label>
<input type="text" id="status" required>
</div>
<button type="submit">Add</button>
<button type="button" id="cancel-button">Cancel</button>
</form>
</div>
</section>
</div>
<footer>
<p>© 2023 Admin Portal. All rights reserved.</p>
</footer>
</div>
<script>
// Event listener for the "Add" button to display the form
document.getElementById('add-button').addEventListener('click', function() {
document.getElementById('form-container').style.display = 'block';
});
// Event listener for the "Cancel" button to hide the form
document.getElementById('cancel-button').addEventListener('click', function() {
document.getElementById('form-container').style.display = 'none';
});
// Event listener for the form submission
document.getElementById('add-form').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission
// Get the values from the form fields
const name = document.getElementById('name').value;
const role = document.getElementById('role').value;
const project = document.getElementById('project').value;
const status = document.getElementById('status').value;
// Mock function to simulate saving to the database
saveToDatabase(name, role, project, status)
.then(response => {
if (response.success) {
// Add the new entry to the table
const tableBody = document.querySelector('#overview-table tbody');
const newRow = tableBody.insertRow();
newRow.innerHTML = `<td>${name}</td><td>${role}</td><td>${project}</td><td>${status}</td>`;
// Reset the form and hide it
document.getElementById('add-form').reset();
document.getElementById('form-container').style.display = 'none';
} else {
alert('Error saving data: ' + response.message);
}
})
.catch(error => {
alert('Error: ' + error.message);
});
});
// Mock function to simulate saving data to a database
function saveToDatabase(name, role, project, status) {
return new Promise((resolve) => {
// Simulating a database save with a timeout
setTimeout(() => {
// Here you would typically make an API call to save the data
// For this example, we just resolve the promise as successful
resolve({ success: true });
}, 500); // Simulate a delay of 500ms
});
}
</script>
</body>
</html>