Updating LiveTracker
This commit is contained in:
parent
8254fab09a
commit
e9ff5ec612
|
|
@ -22,6 +22,18 @@ const app = express();
|
||||||
const server = new createServer(app);
|
const server = new createServer(app);
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
|
|
||||||
|
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||||
|
console.log("⚠️ Certificate error:", url);
|
||||||
|
|
||||||
|
// Allow for ngrok only
|
||||||
|
if (url.includes("ngrok")) {
|
||||||
|
event.preventDefault();
|
||||||
|
callback(true); // approve the certificate
|
||||||
|
} else {
|
||||||
|
callback(false); // reject others
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
const PORT = process.env.PORT || 8000;
|
const PORT = process.env.PORT || 8000;
|
||||||
|
|
||||||
|
|
@ -64,25 +76,25 @@ app.get("/client/forgot-password", (req, res) => {
|
||||||
|
|
||||||
// Client Dashboard Routes with new file names
|
// Client Dashboard Routes with new file names
|
||||||
app.get('/client/dashboard', async (req, res) => {
|
app.get('/client/dashboard', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// const dashboardData = await dashboardService.getClientDashboard(req.user.id);
|
// const dashboardData = await dashboardService.getClientDashboard(req.user.id);
|
||||||
// res.render('client/dashboard-dashboard', dashboardData);
|
// res.render('client/dashboard-dashboard', dashboardData);
|
||||||
res.render('client/dashboard-dashboard');
|
res.render('client/dashboard-dashboard');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Dashboard error:', error);
|
console.error('Dashboard error:', error);
|
||||||
res.status(500).render('client/dashboard-dashboard', { error: 'Failed to load dashboard' });
|
res.status(500).render('client/dashboard-dashboard', { error: 'Failed to load dashboard' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/client/virtual-assistants', async (req, res) => {
|
app.get('/client/virtual-assistants', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// const vaData = await virtualAssistantService.getClientVAs(req.user.id);
|
// const vaData = await virtualAssistantService.getClientVAs(req.user.id);
|
||||||
res.render('client/dashboard-virtual-assistants');
|
res.render('client/dashboard-virtual-assistants');
|
||||||
// res.render('client/dashboard-virtual-assistants', vaData);
|
// res.render('client/dashboard-virtual-assistants', vaData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Virtual assistants error:', error);
|
console.error('Virtual assistants error:', error);
|
||||||
res.status(500).render('client/dashboard-virtual-assistants', { error: 'Failed to load virtual assistants' });
|
res.status(500).render('client/dashboard-virtual-assistants', { error: 'Failed to load virtual assistants' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// app.get('/client/timesheets', async (req, res) => {
|
// app.get('/client/timesheets', async (req, res) => {
|
||||||
|
|
@ -115,9 +127,14 @@ app.get('/client/virtual-assistants', async (req, res) => {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
app.get("/live/:projectId/:vaId", (req, res) => {
|
app.get("/live/:projectId/:clientId", (req, res) => {
|
||||||
const { projectId } = req.params;
|
const { projectId, clientId } = req.params;
|
||||||
res.render("va_live_tracker", { title: "VA Live Tracker", projectId })
|
|
||||||
|
if(!projectId || !clientId){
|
||||||
|
return res.status(400).send({"message": "Page not found"});
|
||||||
|
}
|
||||||
|
|
||||||
|
res.render("va_live_tracker", { title: "VA Live Tracker", projectId, clientId })
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handling Socket
|
// Handling Socket
|
||||||
|
|
@ -145,7 +162,7 @@ io.use(async (socket, next) => {
|
||||||
return next(new Error("Invalid token payload"));
|
return next(new Error("Invalid token payload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------- 1⃣ Check if VA ---------------------- */
|
/* ---------------------- 1⃣ Check if VA ---------------------- */
|
||||||
let vaUser = null;
|
let vaUser = null;
|
||||||
let clientData = null;
|
let clientData = null;
|
||||||
|
|
||||||
|
|
@ -176,7 +193,7 @@ io.use(async (socket, next) => {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------- 2⃣ Check if Client ---------------------- */
|
/* ---------------------- 2⃣ Check if Client ---------------------- */
|
||||||
// const clientUser = await ClientModel.findOne({ "userDetails.email": decoded.email });
|
// const clientUser = await ClientModel.findOne({ "userDetails.email": decoded.email });
|
||||||
|
|
||||||
// if (clientUser) {
|
// if (clientUser) {
|
||||||
|
|
@ -342,11 +359,6 @@ app.get("/client/forgot-password", (req, res) => {
|
||||||
res.render("forgot_password")
|
res.render("forgot_password")
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/live/:projectId", (req, res) => {
|
|
||||||
const { projectId } = req.params;
|
|
||||||
res.render("va_live_tracker", { title: "VA Live Tracker", projectId })
|
|
||||||
})
|
|
||||||
|
|
||||||
// Handling Socket
|
// Handling Socket
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,13 @@
|
||||||
|
|
||||||
<script src="/socket.io/socket.io.js"></script>
|
<script src="/socket.io/socket.io.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const clientId = "691311fece83c986eb8a4e89";
|
|
||||||
|
const clientId = "<%= clientId %>";
|
||||||
|
const token = window.localStorage.getItem("knoptpq");
|
||||||
|
|
||||||
const socket = io({
|
const socket = io({
|
||||||
auth: {
|
auth: {
|
||||||
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5MTQ2NTFkODM2NDZhOTAwN2EzNDI4MCIsImVtYWlsIjoiYmhhZ3dhbi5yQGhpY2dsb2JhbHNvbHV0aW9ucy5jb20iLCJuYW1lIjoiYmhhZ3dhbiIsImlhdCI6MTc2Mjk0ODk3NSwiZXhwIjoxNzYzMDM1Mzc1fQ.WvmTvfOf8DvbqKsbvfyzda1ClP8qfllKFeJINtU6mnE",
|
token: token,
|
||||||
userType: "client",
|
userType: "client",
|
||||||
projectId: "<%= projectId %>"
|
projectId: "<%= projectId %>"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue