diff --git a/electron/main.js b/electron/main.js index 71e1b9d..aaf311e 100644 --- a/electron/main.js +++ b/electron/main.js @@ -3,7 +3,35 @@ const isDev = require('electron-is-dev'); const path = require('path'); const fs = require('fs'); const crypto = require("crypto"); +const { shell } = require('electron'); let mainWindow; +const { Notification } = require('electron') + +function showNotification() { + const notification = { + title: 'Welcome to Crypt-It', + body: 'Get started with it and keep your files safe!' + } + new Notification(notification).show() +} + +app.whenReady().then(showNotification); + +function encryptNotification() { + const notification = { + title: 'Encryption Competed', + body: 'Your file has been encrypted successfully!!' + } + new Notification(notification).show() +} + +function decryptNotification(outFilePath) { + const notification = { + title: 'Decryption Competed', + body: 'Your file has been decrypted successfully and has been stored to ' + outFilePath + } + new Notification(notification).show() +} function createWindow() { mainWindow = new BrowserWindow({ @@ -21,9 +49,17 @@ function createWindow() { const startURL = isDev ? 'http://localhost:3000/' : `file://${path.join(__dirname, '../build/index.html')}`; mainWindow.loadURL(startURL); - + mainWindow.setIcon(path.join(__dirname, '../public/favicon.ico')); + mainWindow.maximize(); mainWindow.once('ready-to-show', () => mainWindow.show()); mainWindow.on('closed', () => { + try { + fs.rmdirSync(viewDir, { recursive: true }); + + console.log(`${viewDir} is deleted!`); + } catch (err) { + console.error(`Error while deleting ${viewDir}.`); + } mainWindow = null; }); } @@ -87,6 +123,7 @@ function Encrypt(key, inFilePath, outFilePath) { output.on('finish', function () { // ipcRenderer.send('encryption', output); console.log('Encrypted file written to disk!'); + encryptNotification(); }); fs.unlinkSync(inFilePath, (err) => { if (err) throw err; @@ -128,6 +165,7 @@ function Decrypt(key, inFilePath, outFilePath) { output.on('finish', function () { console.log(outFilePath); console.log('Decrypted file written to disk!'); + decryptNotification(outFilePath); }); // fs.unlinkSync(inFilepPath); @@ -172,16 +210,34 @@ function viewDecrypt(key, inFilePath, outFilePath) { console.log('Decrypted file written to disk!'); }); - shell.exec(outFilePath); + shell.openPath(outFilePath); + // del(outFilePath); + } -ipcMain.on('close', (event, arg) => { - try { - fs.rmdirSync(viewDir, { recursive: true }); +// var delInterval = setInterval(del(), 1000); + +// function del(filePath){ +// fs.open(filePath, 'r+', function(err, fd){ +// if (err && err.code === 'EBUSY'){ +// //do nothing till next loop +// } else if (err && err.code === 'ENOENT'){ +// console.log(filePath, 'deleted'); +// clearInterval(delInterval); +// } else { +// fs.close(fd, function(){ +// fs.unlink(filePath, function(err){ +// if(err){ +// } else { +// console.log(filePath, 'deleted'); +// clearInterval(delInterval); +// } +// }); +// }); +// } +// }); +// } - console.log(`${viewDir} is deleted!`); - } catch (err) { - console.error(`Error while deleting ${viewDir}.`); - } +ipcMain.on('close', (event, arg) => { app.quit(); }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 20b91ec..eb51fa0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8229,6 +8229,11 @@ "side-channel": "^1.0.4" } }, + "interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -13140,6 +13145,14 @@ "picomatch": "^2.2.1" } }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "requires": { + "resolve": "^1.1.6" + } + }, "recursive-readdir": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", @@ -14237,6 +14250,16 @@ "resolved": "https://registry.npmjs.org/shell.js/-/shell.js-3.2.3.tgz", "integrity": "sha512-FBy/2W05kbwlOCrKDCuVjbhHxs5IK20EjVp1dNxLBjsPggC4gS3BJWqexRbVrmzOJ4d0mS+FRmfVsBJJUasqxw==" }, + "shelljs": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", + "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + }, "shellwords": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", diff --git a/package.json b/package.json index b1a7ac3..f66d266 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "react-scripts": "4.0.3", "sass": "^1.32.8", "shell.js": "^3.2.3", + "shelljs": "^0.8.4", "styled-components": "^5.2.1", "wait-on": "^5.2.1", "web-vitals": "^1.1.0" diff --git a/public/favicon.ico b/public/favicon.ico index a11777c..a4124a1 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html index 4ff10b1..d9781ba 100644 --- a/public/index.html +++ b/public/index.html @@ -27,7 +27,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - CRYPT-IT - File Vault!! + CRYPT-IT diff --git a/public/logo192.png b/public/logo192.png index fc44b0a..4e2af0d 100644 Binary files a/public/logo192.png and b/public/logo192.png differ diff --git a/public/logo512.png b/public/logo512.png deleted file mode 100644 index a4e47a6..0000000 Binary files a/public/logo512.png and /dev/null differ diff --git a/public/manifest.json b/public/manifest.json index 080d6c7..9833b1e 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -13,7 +13,7 @@ "sizes": "192x192" }, { - "src": "logo512.png", + "src": "logo192.png", "type": "image/png", "sizes": "512x512" } diff --git a/src/App.js b/src/App.js index 17986de..95450fd 100644 --- a/src/App.js +++ b/src/App.js @@ -1,11 +1,11 @@ import React from 'react'; -//import Form from './components/registration/Form'; +import Form from './components/registration/Form'; import Files from './components/Files/Files'; function App() { - //return
; - return ; + return ; + // return ; } export default App; \ No newline at end of file diff --git a/src/components/Card/Card.jsx b/src/components/Card/Card.jsx index 26896ba..de8d45a 100644 --- a/src/components/Card/Card.jsx +++ b/src/components/Card/Card.jsx @@ -11,7 +11,7 @@ export default function Card(props) { const info_style = { borderBottomLeftRadius: "12px", borderBottomRightRadius: "12px", - padding: "16px 24px 24px 24px", + padding: "16px 24px 24px 24px" // objectFit: "contain" }; const card_category = { @@ -20,33 +20,20 @@ export default function Card(props) { fontSize: "1.5vh", letterSpacing: "2px", fontWeight: "500", - color: "#868686", + color: "#868686" }; const card_title = { marginTop: "5px", marginBottom: "20px", fontSize: "17px", fontFamily: "Arial, Helvetica, sans-serif", - maxHeight: "25px", - }; - const button = { - padding: "5px 8px", - textTransform: "uppercase", - fontSize: "2.5vh", - letterSpacing: "1px", - fontWeight: "500", - color: "#868686", - backgroundColor: "#fff", - outline: "none", - width: "100%", - border: "1px solid black", - borderRadius: "5px", - cursor: "pointer" + maxHeight: "25px" }; + const cards = { marginTop: "4.4em", - marginLeft: "6em", + marginLeft: "6em" }; function changeCursor(e) { e.target.style.cursor = 'pointer'; @@ -54,30 +41,17 @@ export default function Card(props) { function viewfile() { ipcRenderer.send('viewdecrypt', props.name); - + } return ( <>
-
+
diff --git a/src/components/Card/View.jsx b/src/components/Card/View.jsx index 710196d..809caa0 100644 --- a/src/components/Card/View.jsx +++ b/src/components/Card/View.jsx @@ -1,7 +1,6 @@ import React from 'react'; import { NavigationBar } from '../Dashboard/NavigationBar'; import Sidebar from '../Dashboard/Sidebar'; -import styled from 'styled-components'; import Card from './Card'; import ai from "../Images/ai.png"; @@ -40,21 +39,6 @@ import zip from "../Images/zip.png"; const { ipcRenderer } = window.require('electron'); - -const GridWrapper = styled.div` - ${'' /* display: grid; - grid-gap: 10px; */} - margin-top: 4.4em; - margin-left: 0em; - margin-right: 0em; - ${'' /* grid-template-columns: repeat(12, 1fr); - grid-auto-rows: minmax(25px, auto); - display: flex; - align-items: center; - justify-content: center; - min-height: 100vh; */} -`; - class View extends React.Component { constructor(props) { @@ -188,6 +172,7 @@ class View extends React.Component { this.setState({ CardList: cardList }); }) } + render() { return ( <> diff --git a/src/components/Dashboard/NavigationBar.jsx b/src/components/Dashboard/NavigationBar.jsx index 05c30ab..c1c0883 100644 --- a/src/components/Dashboard/NavigationBar.jsx +++ b/src/components/Dashboard/NavigationBar.jsx @@ -1,8 +1,6 @@ import React from 'react'; -import { Nav, Navbar, Form, FormControl, Button, Container } from 'react-bootstrap'; +import { Navbar, Form, FormControl} from 'react-bootstrap'; import styled from 'styled-components'; -const obrackets ="<"; -const cbrackets =">"; const { ipcRenderer } = window.require('electron'); const Styles = styled.div` .form-center { @@ -14,7 +12,7 @@ const Styles = styled.div` `; export const NavigationBar = () => ( - {ipcRenderer.send('close','none');}} style={{fontSize: '100px' } , {marginLeft: -7}}>Crypt-it + {ipcRenderer.send('close','none')}} style={{fontSize: '100px' } ,{marginLeft: -7}}>Crypt-it {/* X */} diff --git a/src/components/Dashboard/Sidebar.jsx b/src/components/Dashboard/Sidebar.jsx index d949309..7cbd58f 100644 --- a/src/components/Dashboard/Sidebar.jsx +++ b/src/components/Dashboard/Sidebar.jsx @@ -1,6 +1,6 @@ import React from 'react'; import styled from 'styled-components'; -import { BrowserRouter as Router, Route, Link, withRouter } from "react-router-dom"; +import { Link, withRouter } from "react-router-dom"; const StyledSideNav = styled.div` position: fixed; /* Fixed Sidebar (stay in place on scroll and position relative to viewport) */ diff --git a/src/components/Files/FileCard.jsx b/src/components/Files/FileCard.jsx index 96c7945..8a4de16 100644 --- a/src/components/Files/FileCard.jsx +++ b/src/components/Files/FileCard.jsx @@ -1,7 +1,5 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import "../Card/Display.css"; -import Sidebar from '../Dashboard/Sidebar'; -import { NavigationBar } from '../Dashboard/NavigationBar'; const electron = window.require('electron'); const remote = electron.remote const { dialog } = remote @@ -58,12 +56,12 @@ export default function Card(props) { return ( <>
-
+
mypic
{props.title}

{props.name}

- +