Ex 7 Project Management
Ex 7 Project Management
DATE :
AIM:
To create a web application for managing the status of a project modules using
Express.js as the web framework and SQLite as the database.
PROCEDURE:
Step 1: Setup Your Project
First, make sure you have Node.js installed. Create a new directory for your project and
initialize it with npm (Node Package Manager).
➢ mkdir project-dashboard
➢ cd project-dashboard
➢ npm init -y
Step 2: Create the Database (Install SQLite and SQLite Viewer, SQLite3 Editor as
extension in VS code)
Create an SQLite database named tasks.db for storing task data and use an SQLite client
or execute SQL commands in your application to create tables.
Type the query for table creation in Query Editor window and to execute the query use
Shift+Enter for statement processing which in turn will pop up a notification for the same.
(or) Right click on db visible in the project folder and edit the query in query editor
window.
// Middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.static('public'));
app.set('view engine', 'ejs');
// Routes
app.get('/', (req, res) => {
db.all('SELECT * FROM tasks', (err, rows) => {
if (err) {
console.error(err);
res.status(500).send('Internal Server Error');
return;
}
res.render('index', { tasks: rows });
});
});
<h2>Task List</h2>
<ul>
<% tasks.forEach(task => { %>
<li>
<%= task.name %>
<form action="/update-status/<%= task.id %>" method="post">
<select name="status">
<option value="Pending" <%= task.status === 'Pending' ? 'selected' : '' %>>
Pending</option>
<option value="InProgress" <%= task.status === 'InProgress' ? 'selected' : '' %>>In
Progress</option>
<option value="Completed" <%= task.status === 'Completed' ? 'selected' : '' %>>
Completed</option>
</select>
<button type="submit">Update Status</button>
</form>
</li>
<% }); %>
</ul>
</body>
</html>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
text-align: center;
}
h1 {
background-color: #333;
color: #fff;
padding: 10px;
}
h2 {
margin-top: 20px;
}
/* Form styles */
form {
margin-top: 10px;
}
input[type="text"] {
width: 300px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
margin-right: 10px;
}
button {
padding: 5px 10px;
background-color: #333;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
li {
background-color: #fff;
margin: 10px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}
select {
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
}
/* Status-specific styles */
li[data-status="Pending"] {
background-color: #ffcccb;
}
li[data-status="InProgress"] {
background-color: #ffedb3;
}
li[data-status="Completed"] {
background-color: #c2f0c2; }
Run your Node.js application with the following command: node app.js
OUTPUT:
RESULT:
Thus, a simple project status tracking web application was implemented and
simulated successfully.