This commit is contained in:
parent
f7e77f895c
commit
be819cd1bb
|
|
@ -64,7 +64,7 @@ export const handleLogin = async (credentials: { email: string, password: string
|
|||
try {
|
||||
console.log("➡️ Calling API...");
|
||||
const response = await axios.post(
|
||||
'https://wired-terminally-muskrat.ngrok-free.app/api/v1/va/login',
|
||||
'https://dreadingly-unfighting-pandora.ngrok-free.dev/api/v1/va/login',
|
||||
{ userDetails: { ...credentials } },
|
||||
{ headers: { "ngrok-skip-browser-warning": 69420 } }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -247,81 +247,6 @@ const DashboardLayout = () => {
|
|||
|
||||
};
|
||||
|
||||
// Connect and start sending
|
||||
const handleConnect = async () => {
|
||||
|
||||
const token = await window.electron.getToken("ACCESS_TOKEN");
|
||||
|
||||
if (socketRef.current) {
|
||||
console.warn("Already connected");
|
||||
return;
|
||||
}
|
||||
if(!selectedProject?.projectId) return
|
||||
|
||||
console.log(selectedProject?.projectId, "SelectedProject ID")
|
||||
socketRef.current = io("https://wired-terminally-muskrat.ngrok-free.app", {
|
||||
transports: ["websocket"],
|
||||
secure: true,
|
||||
auth: {
|
||||
token: token,
|
||||
projectId: selectedProject?.projectId,
|
||||
userType: "va"
|
||||
},
|
||||
});
|
||||
|
||||
socketRef.current.on("connect", () => {
|
||||
console.log("🟢 Connected:", socketRef.current?.id);
|
||||
setIsConnected(true);
|
||||
|
||||
// Start sending every 5 seconds
|
||||
intervalRef.current = setInterval(async () => {
|
||||
const apps = await window.electron.getRunningApps()
|
||||
socketRef.current?.emit("getVisibleApps", { token: await token, apps });
|
||||
|
||||
// const base64String = await window.electron.captureAppScreenShot("Screen 1");
|
||||
// if (base64String) {
|
||||
// socketRef.current?.emit("sendImage", {token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5MGIzMjhkMDkxMDFmNzRjZjUyNGMwNyIsImVtYWlsIjoiYmhhZ3dhbi5yQGhpY2dsb2JhbHNvbHV0aW9ucy5jb20iLCJuYW1lIjoiUm9oaXQiLCJpYXQiOjE3NjI4NTgxOTMsImV4cCI6MTc2Mjk0NDU5M30.UlHy3RU9W5LOid7smG7WzyNT7dnqhQT4qqzRrN1axmU", image: base64String, title: "Screen 1"});
|
||||
// }
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
socketRef.current.on("appToCapture", async ({ appTitle }) => {
|
||||
console.log("📸 Capture requested for:", appTitle);
|
||||
|
||||
const base64String = await window.electron.captureAppScreenShot(appTitle);
|
||||
if (base64String && socketRef.current) {
|
||||
socketRef.current.emit("sendImage", {
|
||||
token: token,
|
||||
image: base64String,
|
||||
title: appTitle
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socketRef.current.on("disconnect", () => {
|
||||
console.log("🔴 Disconnected");
|
||||
setIsConnected(false);
|
||||
if (intervalRef.current) {
|
||||
clearInterval(intervalRef.current);
|
||||
intervalRef.current = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleDisconnect = () => {
|
||||
if (intervalRef.current) {
|
||||
clearInterval(intervalRef.current);
|
||||
intervalRef.current = null;
|
||||
}
|
||||
|
||||
if (socketRef.current) {
|
||||
socketRef.current.disconnect();
|
||||
socketRef.current = null;
|
||||
setIsConnected(false);
|
||||
console.log("🔌 Disconnected manually");
|
||||
}
|
||||
};
|
||||
|
||||
// Sync global states with selected project tracking data
|
||||
useEffect(() => {
|
||||
if (selectedProject) {
|
||||
|
|
@ -620,7 +545,7 @@ const DashboardLayout = () => {
|
|||
{isTracking &&
|
||||
<header className="w-full flex justify-between items-center h-12 px-6 bg-base-100 border-b border-base-300 sticky top-0 z-30">
|
||||
{/* Left Section */}
|
||||
{!isConnected ? (
|
||||
{/* {!isConnected ? (
|
||||
<button
|
||||
onClick={handleConnect}
|
||||
className="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded"
|
||||
|
|
@ -634,7 +559,7 @@ const DashboardLayout = () => {
|
|||
>
|
||||
Disconnect
|
||||
</button>
|
||||
)}
|
||||
)} */}
|
||||
<div className="flex items-center space-x-3">
|
||||
{selectedProject ? (
|
||||
isTracking ? (
|
||||
|
|
|
|||
Loading…
Reference in New Issue