From d454919a91ade8cbf293a9a57f447fac2361413f Mon Sep 17 00:00:00 2001 From: Nigel Jacob Date: Sat, 23 Mar 2024 18:05:38 +0530 Subject: [PATCH 1/6] update task start button --- .DS_Store | Bin 10244 -> 10244 bytes Electron/main.js | 74 +- Frontend/src/App.jsx | 30 +- .../components/TaskComponent/TaskDetails.jsx | 56 +- package-lock.json | 2920 ++- package.json | 1 + yarn.lock | 21117 ++++++++-------- 7 files changed, 13669 insertions(+), 10529 deletions(-) diff --git a/.DS_Store b/.DS_Store index 13c4bd15f5e78dd0eee249bef87a9c96ef21c081..230ac4aa0034f8e671caca6b911d258d898bdc83 100644 GIT binary patch delta 316 zcmZn(XbG6$&nUSuU^hRbdU WASAN+j-V^gW_E>NESsf;nVA91u|!Y+ delta 42 zcmV+_0M-A5P=rvBPXQFMP`eKS6tfHvzX7wc6IKkdfaU?S2O# { + const permission = Notification.permission + + session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => { + console.log(permission) + return callback(false); + }) + + if(permission !== "granted") { + dialog.showMessageBox(win, { + type: 'warning', + icon: path.join(__dirname, 'icon.png'), + message: 'Notification permissions denied', + detail: 'To enable notifications, please go to your system settings. Click "Notifications" and enable notifications for SYNK.', + buttons: ['Open Settings', 'Dismiss'], + defaultId: 0 + }).then(({ response }) => { + if (response === 0) { + shell.openExternal('x-apple.systempreferences:com.apple.preference.notifications') + } + }); + } + }, 10000) + ipcMain.on("notification", (event, notification) => { const NOTIFICATION_TITLE = notification[0]; const NOTIFICATION_BODY = notification[1]; @@ -539,9 +566,29 @@ win.on("close", (e) => { }, 900000) appTrackingInterval = setInterval(() => { - let currentWindow = getFocusedWindow(); + + let currentWindow; + + try{ + currentWindow = getFocusedWindow(); + } catch(e) { + dialog.showMessageBox(win, { + type: 'error', + icon: path.join(__dirname, 'icon.png'), + message: 'Tracking Permission denied', + detail: 'Accept the permission to allow SYNK to track your task activity. Start the task again after successfull permission.', + buttons: ['Ok'], + defaultId: 0 + }) + clearInterval(idleTrackingInterval) + clearInterval(appTrackingInterval) + clearInterval(lastModifiedInterval) + + win.webContents.send("sendIntervalsPaused", {...TaskDetails, trackedApplications: trackedApplications}) + } if(!idleDetected) { - idleDetection("start", (data) => { + try{ + idleDetection("start", (data) => { console.log("detected"); idleDetected = true if(idlePopupShown) { @@ -549,6 +596,21 @@ win.on("close", (e) => { idlePopupShown = false } }) + } catch(e) { + dialog.showMessageBox(win, { + type: 'error', + icon: path.join(__dirname, 'icon.png'), + message: 'Tracking Permission denied', + detail: 'Accept the permission to allow SYNK to track your task activity. Start the task again after successfull permission.', + buttons: ['Ok'], + defaultId: 0 + }) + clearInterval(idleTrackingInterval) + clearInterval(appTrackingInterval) + clearInterval(lastModifiedInterval) + + win.webContents.send("sendIntervalsPaused", {...TaskDetails, trackedApplications: trackedApplications}) + } } else { idleDetection("stop", (data) => { // console.log("stopped") @@ -733,6 +795,8 @@ ipcMain.on("idleCloseClicked", (event, data) => { } }); +app.setAccessibilitySupportEnabled(true) + } app.on("ready", createWindow); diff --git a/Frontend/src/App.jsx b/Frontend/src/App.jsx index 11825ac..6e8e558 100644 --- a/Frontend/src/App.jsx +++ b/Frontend/src/App.jsx @@ -1,11 +1,12 @@ import { useEffect, useState } from "react"; import * as MDIcons from "react-icons/md"; -import { Route, BrowserRouter as Router, Routes, HashRouter } from "react-router-dom"; import { - getCurrentUser, - getStatus, - updateStatus, -} from "./utils/UserAccount"; + Route, + BrowserRouter as Router, + Routes, + HashRouter, +} from "react-router-dom"; +import { getCurrentUser, getStatus, updateStatus } from "./utils/UserAccount"; import { auth } from "./utils/firebase"; import "./App.css"; import CreateAccount from "./Pages/CreateAccount/CreateAccount"; @@ -290,6 +291,25 @@ function App() { useEffect(() => { if (user != null) { + + try{ + let taskDetails = + JSON.parse(localStorage.getItem("previousTask")) || null; + console.log(taskDetails); + if (taskDetails != "") { + PauseTask( + taskDetails.task, + parseInt(taskDetails.taskIndex - 1), + taskDetails.team, + taskDetails.teamMemberIndex, + {}, + (boolean) => {} + ); + } + } catch(e) { + + } + fetchNotification((notification) => { for (let i = 0; i < notification.length; i++) { if ( diff --git a/Frontend/src/components/TaskComponent/TaskDetails.jsx b/Frontend/src/components/TaskComponent/TaskDetails.jsx index 4ae81a4..19e6f9a 100644 --- a/Frontend/src/components/TaskComponent/TaskDetails.jsx +++ b/Frontend/src/components/TaskComponent/TaskDetails.jsx @@ -8,6 +8,7 @@ import "./TaskDetails.css"; import { startTask } from "../../utils/AssignTask/taskFunctions"; import { PauseTask } from "../../utils/AssignTask/taskFunctions"; import { updateTaskStatus } from "../../utils/AssignTask/taskFunctions"; +import { CircularProgress } from "@mui/material"; const electronApi = window?.electronApi; const TaskDetails = ({ @@ -180,7 +181,10 @@ const TaskDetails = ({ ) : Status === "Continue" || Status === "In Progress" ? (
{startButton ? ( - Status === "In Progress" ? ( + isLoading ? ( + + ) : ( + Status === "In Progress" ? ( ) + ) ) : (
{versions.length > 0 ? ( - + ) : (

No Versions Loaded

)} @@ -84,20 +139,55 @@ const ProgressVersionHistory = (props) => {
{versions.map((version, index) => { return index === selectedVersion ? ( -
-
-
-

- {version.date} at {version.time} -

+
+
+
+
+

+ {version.date} at {version.time} +

+
+

+ Currently viewing version +

-

- currently viewing version -

+ + {isLoading && downloadingVersion === index ? ( +
+ +
+ ) : ( +
+ { + setLoading(true); + setDownloadingVersion(index); + downloadZipFile( + version.filePath, + taskPath.split("/")[ + taskPath.split("/").length - 1 + ] + + "_" + + version.date.replace("_", "/") + + "_" + + version.time.replace("_", ":") + ); + }} + /> +
+ )} +
) : (
{ handleSelectedVersion(index); }} @@ -108,7 +198,7 @@ const ProgressVersionHistory = (props) => { {version.date} at {version.time}
-

+

Click to view this version

diff --git a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx index 6a72155..f058615 100644 --- a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx +++ b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx @@ -83,11 +83,14 @@ const TeamYourProgress = (props) => { } const handleVersionHistoryClick = () => { + props.elementStringTrigger("TEAM_PERSONAL_PROGRESS") props.elementTrigger( diff --git a/Frontend/src/components/FolderViewer/FolderViewer.jsx b/Frontend/src/components/FolderViewer/FolderViewer.jsx index a59d3e9..a2e129f 100644 --- a/Frontend/src/components/FolderViewer/FolderViewer.jsx +++ b/Frontend/src/components/FolderViewer/FolderViewer.jsx @@ -15,30 +15,12 @@ import { FaDownload } from "react-icons/fa6"; import { sendNotification } from "../../utils/teamFunctions"; import { auth } from "../../utils/firebase"; -function FolderViewer({ url }) { +function FolderViewer({ url, filePath, title }) { const [folderStructure, setFolderStructure] = useState([]); const [selectedFileContent, setSelectedFileContent] = useState(""); const [selectedFileName, setSelectedFileName] = useState(""); const [downloaded, setDownloaded] = useState(false); - const downloadZipFile = async (url, folderName) => { - try { - // Fetch the zip file from the URL - const response = await axios.get(url, { responseType: "blob" }); - - // Determine the filename from the URL or use a default name - const filename = url.substring(url.lastIndexOf("/") + 1) || "file.zip"; - - // Create a Blob object from the response data - const blob = new Blob([response.data]); - - // Use the downloadjs library to save the Blob as a file - download(blob, `${folderName}/${filename}`); - } catch (error) { - console.error("Error downloading zip file:", error); - } - }; - useEffect(() => { if (downloaded) { sendNotification( @@ -51,55 +33,6 @@ function FolderViewer({ url }) { } }, []); - // useEffect(() => { - // const fetchFolderData = async () => { - // try { - // // Fetch the zip file from the URL - // const response = await axios.get(url, { responseType: 'arraybuffer' }); - // const zip = await JSZip.loadAsync(response.data); - - // const zipFileName = url.substring(url.lastIndexOf('/') + 1).replace('.zip', ''); - // const folderStructure = { id: 'root', name: zipFileName, children: [] }; - - // // Iterate over each file in the zip - // Object.keys(zip.files).forEach(async (filename) => { - // const parts = filename.split('/'); - // let currentFolder = folderStructure; - - // // Iterate over each part to build the folder structure - // parts.forEach((part) => { - // if (part === '') { - // return; // Skip empty parts - // } - - // // Check if the current part already exists as a child - // let childFolder = currentFolder.children.find((folder) => folder.name === part); - // if (!childFolder) { - // // Create a new child folder if it doesn't exist - // childFolder = { id: `${currentFolder.id}-${part}`, name: part, children: [] }; - // currentFolder.children.push(childFolder); - // } - - // // Update current folder to the child folder for the next iteration - // currentFolder = childFolder; - // }); - - // // If it's the last part (i.e., the file), read its contents and add to the folder structure - // if (!zip.files[filename].dir) { - // const content = await zip.file(filename).async('string'); - // currentFolder.content = content; - // } - // }); - - // setFolderStructure(folderStructure); - // } catch (error) { - // console.error('Error fetching or extracting zip file:', error); - // } - // }; - - // fetchFolderData(); - // }, [url]); - useEffect(() => { const fetchFolderData = async () => { try { @@ -107,9 +40,8 @@ function FolderViewer({ url }) { const response = await axios.get(url, { responseType: "arraybuffer" }); const zip = await JSZip.loadAsync(response.data); - const zipFileName = url - .substring(url.lastIndexOf("/") + 1) - .replace(".zip", ""); + const zipFileName = + filePath.split("/")[filePath.split("/").length - 1] + " - " + title; const folderStructure = { id: "root", name: zipFileName, children: [] }; // Iterate over each file in the zip @@ -174,7 +106,7 @@ function FolderViewer({ url }) { key={nodes.id} nodeId={nodes.id} label={nodes.name} - onClick={() => handleFileClick(nodes.content, nodes.name)} + // onClick={() => handleFileClick(nodes.content, nodes.name)} > {Array.isArray(nodes.children) ? nodes.children.map((node) => renderTree(node)) @@ -195,18 +127,6 @@ function FolderViewer({ url }) { }} />

{selectedFileName}

-
-

- ⚠️ This is a preview. Download the file to view it properly. -

- { - downloadZipFile(url, "documents/SYNK_Files"); - setDownloaded(true); - }} - /> -
{selectedFileName.endsWith(".jpg") || diff --git a/Frontend/src/components/TeamProgressComponent/TeamProgressComponent.jsx b/Frontend/src/components/TeamProgressComponent/TeamProgressComponent.jsx index 39f4e91..8392e2f 100644 --- a/Frontend/src/components/TeamProgressComponent/TeamProgressComponent.jsx +++ b/Frontend/src/components/TeamProgressComponent/TeamProgressComponent.jsx @@ -11,6 +11,7 @@ const TeamProgressComponent = ({ tasks, currentTeam, elementTrigger, + elementStringTrigger }) => { const [status, setStatus] = useState("Offline"); const [profilePic, setProfilePic] = useState(""); @@ -145,6 +146,13 @@ const TeamProgressComponent = ({
time clock + {tasks[ + parseInt( + member.status.split(" ")[ + member.status.split(" ").length - 1 + ] - 1 + )] + .progress.lastApplication != "" && (

Lastly worked on{" "} @@ -159,6 +167,7 @@ const TeamProgressComponent = ({ }{" "}

+ )}
)} @@ -212,10 +221,12 @@ const TeamProgressComponent = ({ ); + elementStringTrigger("TEAM_MEMBER_PROGRESS"); }} > View Progress From c5e36ddedf70ea51e3a7b1943e165d380e07929c Mon Sep 17 00:00:00 2001 From: Nigel Jacob Date: Sun, 24 Mar 2024 05:09:38 +0530 Subject: [PATCH 6/6] fied notification issue and create account issue --- Frontend/src/App.css | 3 +- Frontend/src/App.jsx | 95 ++++++++++++++----- .../src/Pages/CreateAccount/CreateAccount.jsx | 6 +- Frontend/src/Pages/Login/Login.jsx | 1 + .../ProgressVersionHistory.jsx | 2 +- .../TeamPersonalProgress/TeamYourProgress.jsx | 2 +- Frontend/src/index.css | 1 - Frontend/src/utils/UserAccount.js | 6 +- 8 files changed, 83 insertions(+), 33 deletions(-) diff --git a/Frontend/src/App.css b/Frontend/src/App.css index e09e3a2..44aba48 100644 --- a/Frontend/src/App.css +++ b/Frontend/src/App.css @@ -13,7 +13,6 @@ body { z-index: -1000; display: flex; flex-direction: column; - scroll-behavior: smooth; } .background { @@ -24,11 +23,11 @@ body { rgba(30, 30, 30, 1) 100% ); background-repeat: none; + scroll-behavior: smooth; } *::-webkit-scrollbar { display: none; - scroll-behavior: smooth; } .titleBar { diff --git a/Frontend/src/App.jsx b/Frontend/src/App.jsx index 7bea100..3a38989 100644 --- a/Frontend/src/App.jsx +++ b/Frontend/src/App.jsx @@ -5,6 +5,8 @@ import { BrowserRouter as Router, Routes, HashRouter, + useNavigate, + Navigate, } from "react-router-dom"; import { getCurrentUser, getStatus, updateStatus } from "./utils/UserAccount"; import { auth } from "./utils/firebase"; @@ -99,6 +101,7 @@ function App() { }).then(() => { setUser(null); auth.signOut(); + handleSetLoading(); localStorage.setItem("loggedIN", "false"); setIsLoggedIn(false); handleItemClick(false); @@ -377,29 +380,38 @@ function App() { ); localStorage.setItem( - auth.currentUser.uid + "notifications", JSON.stringify(uniqueArray - )); + auth.currentUser.uid + "notifications", + JSON.stringify(uniqueArray) + ); } catch (e) { let uniqueArray = Notifications.filter( (value, index, self) => index === self.findIndex((t) => JSON.stringify(t) === JSON.stringify(value)) ); - localStorage.setItem(auth.currentUser.uid + "notifications", JSON.stringify(uniqueArray)); + localStorage.setItem( + auth.currentUser.uid + "notifications", + JSON.stringify(uniqueArray) + ); } try { let AllFeedList = Notifications.filter((notification) => notification.notificationType.includes("feed") ); - let feedList = JSON.parse(localStorage.getItem(auth.currentUser.uid + "feedList") || "[]"); + let feedList = JSON.parse( + localStorage.getItem(auth.currentUser.uid + "feedList") || "[]" + ); let newFeedList = [...new Set([...feedList, ...AllFeedList])]; let uniqueFeedList = newFeedList.filter( (value, index, self) => index === self.findIndex((t) => JSON.stringify(t) === JSON.stringify(value)) ); - localStorage.setItem(auth.currentUser.uid + "feedList", JSON.stringify(uniqueFeedList)); + localStorage.setItem( + auth.currentUser.uid + "feedList", + JSON.stringify(uniqueFeedList) + ); } catch (e) { let AllFeedList = Notifications.filter((notification) => notification.notificationType.includes("feed") @@ -409,7 +421,10 @@ function App() { index === self.findIndex((t) => JSON.stringify(t) === JSON.stringify(value)) ); - localStorage.setItem(auth.currentUser.uid + "feedList", JSON.stringify(uniqueFeedList)); + localStorage.setItem( + auth.currentUser.uid + "feedList", + JSON.stringify(uniqueFeedList) + ); } }); } @@ -463,7 +478,21 @@ function App() { } }; + let interval = setTimeout(() => { + if (user == null && loggedIn) { + localStorage.setItem("loggedIN", "false"); + setIsLoggedIn(false); + } + }, 7000); + + const handleSetLoading = () => { + setLoading(false); + }; + + const [isLoading, setLoading] = useState(false); + if (user == null && loggedIn) { + clearTimeout(interval); return ( <> @@ -473,29 +502,39 @@ function App() { return ( <>
- - - - } - /> - - } - /> - - + {isLoading ? ( + + ) : ( + + + + } + /> + + } + /> + + + )} ); } else if (user != null && isLoggedIn) { + clearTimeout(interval); return ( <> {isLogoutClicked ? ( @@ -531,6 +570,10 @@ function App() { /> } /> + } + />
diff --git a/Frontend/src/Pages/CreateAccount/CreateAccount.jsx b/Frontend/src/Pages/CreateAccount/CreateAccount.jsx index b2819cc..be5f206 100644 --- a/Frontend/src/Pages/CreateAccount/CreateAccount.jsx +++ b/Frontend/src/Pages/CreateAccount/CreateAccount.jsx @@ -1,17 +1,20 @@ import { useState } from "react"; -import { Link } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; import { createUser, getCurrentUser } from "../../utils/UserAccount"; import { auth } from "../../utils/firebase"; import "./CreateAccount.css"; import React, { useEffect } from "react"; + const CreateAccount = (props) => { const [firstName, setFirstName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); + const navigate = useNavigate(); + const handleSubmit = async (e) => { e.preventDefault(); // Prevent form submission @@ -35,6 +38,7 @@ const CreateAccount = (props) => { }); if (auth.currentUser != null) { + props.loadingTrigger(true) props.setIsLoggedIn(true); localStorage.setItem("loggedIN", "true"); localStorage.setItem("currentUser", getCurrentUser); diff --git a/Frontend/src/Pages/Login/Login.jsx b/Frontend/src/Pages/Login/Login.jsx index 3d385d5..9c60098 100644 --- a/Frontend/src/Pages/Login/Login.jsx +++ b/Frontend/src/Pages/Login/Login.jsx @@ -33,6 +33,7 @@ function Login(props) { }); if (auth.currentUser != null) { + props.loadingTrigger(true); props.setIsLoggedIn(true); localStorage.setItem("loggedIN", "true"); localStorage.setItem("currentUser", getCurrentUser); diff --git a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/ProgressVersionHistory.jsx b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/ProgressVersionHistory.jsx index 9256d85..c5047c0 100644 --- a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/ProgressVersionHistory.jsx +++ b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/ProgressVersionHistory.jsx @@ -96,7 +96,7 @@ const ProgressVersionHistory = (props) => { return (
-
+
{ diff --git a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx index f058615..febfb91 100644 --- a/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx +++ b/Frontend/src/Pages/TeamDashboard/TeamPersonalProgress/TeamYourProgress.jsx @@ -89,7 +89,7 @@ const TeamYourProgress = (props) => { setElement={props.elementTrigger} team={props.team} sideBarStatus={props.sideBarStatus} - previous={"TEAM_PERSONAL_PROGRESS"} + previous={"TEAM_PERSONAL_VERSION"} elementStringTrigger={props.elementStringTrigger} index={progressIndex} UID={props.UID} diff --git a/Frontend/src/index.css b/Frontend/src/index.css index 2c2a912..cfa995d 100644 --- a/Frontend/src/index.css +++ b/Frontend/src/index.css @@ -55,6 +55,5 @@ } body { @apply tw-bg-background tw-text-foreground; - scroll-behavior: smooth; } } \ No newline at end of file diff --git a/Frontend/src/utils/UserAccount.js b/Frontend/src/utils/UserAccount.js index 49257da..7661474 100644 --- a/Frontend/src/utils/UserAccount.js +++ b/Frontend/src/utils/UserAccount.js @@ -38,7 +38,11 @@ export const signOut = () => { }; export const getCurrentUser = () => { - return auth.currentUser; + try{ + return auth.currentUser; + } catch(e) { + return null + } }; export const updateStatus = (status) => {