Updating LiveTracker
This commit is contained in:
parent
8254fab09a
commit
e9ff5ec612
|
|
@ -22,6 +22,18 @@ const app = express();
|
|||
const server = new createServer(app);
|
||||
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");
|
||||
const PORT = process.env.PORT || 8000;
|
||||
|
||||
|
|
@ -64,25 +76,25 @@ app.get("/client/forgot-password", (req, res) => {
|
|||
|
||||
// Client Dashboard Routes with new file names
|
||||
app.get('/client/dashboard', async (req, res) => {
|
||||
try {
|
||||
// const dashboardData = await dashboardService.getClientDashboard(req.user.id);
|
||||
// res.render('client/dashboard-dashboard', dashboardData);
|
||||
res.render('client/dashboard-dashboard');
|
||||
} catch (error) {
|
||||
console.error('Dashboard error:', error);
|
||||
res.status(500).render('client/dashboard-dashboard', { error: 'Failed to load dashboard' });
|
||||
}
|
||||
try {
|
||||
// const dashboardData = await dashboardService.getClientDashboard(req.user.id);
|
||||
// res.render('client/dashboard-dashboard', dashboardData);
|
||||
res.render('client/dashboard-dashboard');
|
||||
} catch (error) {
|
||||
console.error('Dashboard error:', error);
|
||||
res.status(500).render('client/dashboard-dashboard', { error: 'Failed to load dashboard' });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/client/virtual-assistants', async (req, res) => {
|
||||
try {
|
||||
// const vaData = await virtualAssistantService.getClientVAs(req.user.id);
|
||||
res.render('client/dashboard-virtual-assistants');
|
||||
// res.render('client/dashboard-virtual-assistants', vaData);
|
||||
} catch (error) {
|
||||
console.error('Virtual assistants error:', error);
|
||||
res.status(500).render('client/dashboard-virtual-assistants', { error: 'Failed to load virtual assistants' });
|
||||
}
|
||||
try {
|
||||
// const vaData = await virtualAssistantService.getClientVAs(req.user.id);
|
||||
res.render('client/dashboard-virtual-assistants');
|
||||
// res.render('client/dashboard-virtual-assistants', vaData);
|
||||
} catch (error) {
|
||||
console.error('Virtual assistants error:', error);
|
||||
res.status(500).render('client/dashboard-virtual-assistants', { error: 'Failed to load virtual assistants' });
|
||||
}
|
||||
});
|
||||
|
||||
// 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) => {
|
||||
const { projectId } = req.params;
|
||||
res.render("va_live_tracker", { title: "VA Live Tracker", projectId })
|
||||
app.get("/live/:projectId/:clientId", (req, res) => {
|
||||
const { projectId, clientId } = req.params;
|
||||
|
||||
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
|
||||
|
|
@ -145,7 +162,7 @@ io.use(async (socket, next) => {
|
|||
return next(new Error("Invalid token payload"));
|
||||
}
|
||||
|
||||
/* ---------------------- 1⃣ Check if VA ---------------------- */
|
||||
/* ---------------------- 1⃣ Check if VA ---------------------- */
|
||||
let vaUser = null;
|
||||
let clientData = null;
|
||||
|
||||
|
|
@ -163,7 +180,7 @@ io.use(async (socket, next) => {
|
|||
socket.data.role = "va";
|
||||
socket.data.vaId = vaUser._id.toString();
|
||||
socket.data.vaEmail = decoded.email;
|
||||
|
||||
|
||||
const a = vaProjClientId.toString();
|
||||
const b = clientData.clientId._id.toString();
|
||||
const c = JSON.stringify(clientData);
|
||||
|
|
@ -176,7 +193,7 @@ io.use(async (socket, next) => {
|
|||
return next();
|
||||
}
|
||||
|
||||
/* ---------------------- 2⃣ Check if Client ---------------------- */
|
||||
/* ---------------------- 2⃣ Check if Client ---------------------- */
|
||||
// const clientUser = await ClientModel.findOne({ "userDetails.email": decoded.email });
|
||||
|
||||
// if (clientUser) {
|
||||
|
|
@ -342,11 +359,6 @@ app.get("/client/forgot-password", (req, res) => {
|
|||
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
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
|
|
|
|||
|
|
@ -89,10 +89,13 @@
|
|||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
const clientId = "691311fece83c986eb8a4e89";
|
||||
|
||||
const clientId = "<%= clientId %>";
|
||||
const token = window.localStorage.getItem("knoptpq");
|
||||
|
||||
const socket = io({
|
||||
auth: {
|
||||
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5MTQ2NTFkODM2NDZhOTAwN2EzNDI4MCIsImVtYWlsIjoiYmhhZ3dhbi5yQGhpY2dsb2JhbHNvbHV0aW9ucy5jb20iLCJuYW1lIjoiYmhhZ3dhbiIsImlhdCI6MTc2Mjk0ODk3NSwiZXhwIjoxNzYzMDM1Mzc1fQ.WvmTvfOf8DvbqKsbvfyzda1ClP8qfllKFeJINtU6mnE",
|
||||
token: token,
|
||||
userType: "client",
|
||||
projectId: "<%= projectId %>"
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue