backup + decriptare toate fisiere done

This commit is contained in:
andrei-mihnea-cerbu
2024-04-19 16:48:10 +03:00
parent ffeebf1177
commit 869305a491
55 changed files with 1073 additions and 265 deletions
+41 -2
View File
@@ -6,7 +6,7 @@ async function readKeyFromFile(filePath) {
try {
await fs.promises.access(filePath, fs.constants.F_OK);
return fs.promises.readFile(filePath); // Use asynchronous readFile
} catch(error) {
} catch (error) {
console.error('Error reading key file:', error);
return null;
}
@@ -70,7 +70,46 @@ async function decryptFileInPlace(filePath) {
});
}
function cryptForKey(content, key, decrypt = false) {
const algorithm = 'aes-256-ctr';
const secretKey = crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
let cipher;
if (decrypt) {
cipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.alloc(16, 0)); // Using a zeroed IV for CTR
} else {
cipher = crypto.createCipheriv(algorithm, secretKey, Buffer.alloc(16, 0));
}
return Buffer.concat([cipher.update(content), cipher.final()]);
}
// Encrypts a file in place with a given key
async function encryptFileWithKey(filePath, key) {
try {
const fileContent = await fs.promises.readFile(filePath);
const encryptedContent = cryptForKey(fileContent, key, false);
await fs.promises.writeFile(filePath, encryptedContent);
console.log(`File encrypted successfully: ${filePath}`);
} catch (error) {
console.error(`Error encrypting file: ${error.message}`);
}
}
async function decryptFileWithKey(filePath, key) {
try {
const fileContent = await fs.promises.readFile(filePath);
const decryptedContent = cryptForKey(fileContent, key, true);
await fs.promises.writeFile(filePath, decryptedContent);
console.log(`File decrypted successfully: ${filePath}`);
} catch (error) {
console.error(`Error decrypting file: ${error.message}`);
}
}
module.exports = {
encryptFileInPlace,
decryptFileInPlace
decryptFileInPlace,
encryptFileWithKey,
decryptFileWithKey,
}
+23 -61
View File
@@ -1,10 +1,11 @@
const { app, BrowserWindow, screen, ipcMain, dialog } = require('electron');
const {app, BrowserWindow, screen, ipcMain, dialog} = require('electron');
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const { fork } = require('child_process');
const {fork} = require('child_process');
const {encryptFileInPlace, decryptFileInPlace} = require('./aes_encrypt');
const {lockFile, unlockFile} = require("../../helpers/lock_mechanism");
const isMac = process.platform === 'darwin';
let html_page = undefined;
@@ -117,8 +118,8 @@ function showAlert(message) {
if (alertWindow === undefined) {
const title = 'Alert';
const mainScreen = screen.getPrimaryDisplay();
const { width, height } = mainScreen.size;
createAlertWindow(title, width/4, height/4);
const {width, height} = mainScreen.size;
createAlertWindow(title, width / 4, height / 4);
}
alertWindow.webContents.once('dom-ready', () => {
@@ -129,11 +130,11 @@ function showAlert(message) {
app.whenReady().then(() => {
const title = "Application";
const mainScreen = screen.getPrimaryDisplay();
const { width, height } = mainScreen.size;
const {width, height} = mainScreen.size;
createMainWindow(title, width / 1.5, height / 1.5);
app.on('activate', () => {
if(BrowserWindow.getAllWindows().length === 0){
if (BrowserWindow.getAllWindows().length === 0) {
createMainWindow(title, width, height);
}
});
@@ -152,7 +153,7 @@ app.on('before-quit', () => {
});
app.on('window-all-closed', () => {
if(!isMac){
if (!isMac) {
app.quit();
}
});
@@ -160,40 +161,45 @@ app.on('window-all-closed', () => {
ipcMain.handle('write-file', async (event, fileName, content) => {
try {
let filePath = path.join(__dirname, '..', '..', fileName);
await lockFile(filePath);
await fs.promises.writeFile(filePath, content);
await encryptFileInPlace(filePath);
await unlockFile(filePath)
console.log(`File successfully written to ${filePath}`);
return { success: true };
return {success: true};
} catch (error) {
console.error('Failed to write file:', error);
return { success: false, error: error.message };
return {success: false, error: error.message};
}
});
ipcMain.handle('delete-file', async (event, fileName) => {
try {
let filePath = path.join(__dirname, '..', '..', fileName);
console.log(filePath);
await fs.promises.unlink(filePath);
console.log(`File ${filePath} successfully deleted`);
return { success: true };
return {success: true};
} catch (error) {
console.error('Failed to delete file:', error);
return { success: false, error: error.message };
return {success: false, error: error.message};
}
});
ipcMain.handle('read-file', async (event, fileName) => {
try {
let filePath = path.join(__dirname, '..', '..', fileName);
await lockFile(filePath);
await decryptFileInPlace(filePath);
const content = await fs.promises.readFile(filePath, 'utf-8');
await encryptFileInPlace(filePath);
return { success: true, content };
await unlockFile(filePath);
return {success: true, content};
} catch (error) {
console.error('Error reading file:', error);
return { success: false, error: error.message };
return {success: false, error: error.message};
}
});
@@ -229,7 +235,7 @@ ipcMain.handle('open-backup-dir-dialog', async (event) => {
return true;
} catch (error) {
console.error('Error opening file dialog:', error);
return { error: error.message };
return {error: error.message};
}
});
@@ -253,7 +259,7 @@ ipcMain.handle('check-file-exists', async (event, fileName) => {
}
});
ipcMain.handle('show-alert', async (event, message) =>{
ipcMain.handle('show-alert', async (event, message) => {
showAlert(message);
});
@@ -265,10 +271,9 @@ ipcMain.on('close-alert-window', () => {
});
//External processes
ipcMain.handle('start-fetcher', async (event, args) => {
if (fetcherProcess === null) {
fetcherProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'fetcher.js'), args, { silent: false });
fetcherProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'fetcher.js'), args, {silent: false});
fetcherProcess.on('exit', () => {
fetcherProcess = null;
// Optionally, notify the renderer process that the fetcher has finished
@@ -276,46 +281,3 @@ ipcMain.handle('start-fetcher', async (event, args) => {
}
return true; // Indicate that the operation has started
});
// Handler to start the backup process
ipcMain.handle('start-backup', async (event, args) => {
if (backupProcess === null) { // Should this be a unique variable for backupProcess instead?
backupProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'backup.js'), args, { silent: false });
backupProcess.on('exit', () => {
backupProcess = null;
// Optionally, notify the renderer process that the backup has finished
});
}
return true; // Indicate that the operation has started
});
// Handler to start the decrypt-files process
ipcMain.handle('start-decrypt-files', async (event, args) => {
const decryptFilesProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'decrypt_files.js'), args, { silent: false });
decryptFilesProcess.on('exit', () => {
event.sender.send('decrypt-files-finished', true); // Notify renderer process
});
return true; // Indicate that the operation has started
});
// Handler to start the send_files process
ipcMain.handle('start-send_files', async (event, args) => {
// This seems to duplicate the 'start-decrypt-files' process; assuming a different script is intended
const sendFilesProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'send_files.js'), args, { silent: false });
sendFilesProcess.on('exit', () => {
event.sender.send('send-files-finished', true); // Notify renderer process
});
return true; // Indicate that the operation has started
});
// Handler to start the receiver process
ipcMain.handle('start-receiver', async (event, args) => {
if (receiverProcess === null) {
receiverProcess = fork(path.join(__dirname, '..', '..', 'jobs', 'receiver.js'), args, { silent: false });
receiverProcess.on('exit', () => {
receiverProcess = null;
// Optionally, notify the renderer process that the receiver has finished
});
}
return true; // Indicate that the operation has started
});
+1 -1
View File
@@ -1,4 +1,4 @@
const { contextBridge, ipcRenderer } = require('electron');
const {contextBridge, ipcRenderer} = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
writeFile: (fileName, content) => ipcRenderer.invoke('write-file', fileName, content),
+4 -4
View File
@@ -22,12 +22,12 @@ body, html {
min-height: 100vh;
}
h1{
h1 {
margin: 0;
padding: 0;
}
.main_component{
.main_component {
display: flex;
flex-wrap: wrap;
flex-direction: column;
@@ -43,7 +43,7 @@ h1{
height: 80vh;
}
.header{
.header {
color: #1B1A55;
font-size: 0.8rem;
text-align: center;
@@ -61,7 +61,7 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
+6 -6
View File
@@ -33,7 +33,7 @@ body, html {
width: 25%;
}
.department-form-title{
.department-form-title {
margin-bottom: 5vh;
color: #FFFFFF;
text-align: center;
@@ -46,11 +46,11 @@ body, html {
font-size: 5vh;
}
.department-form-title hr{
.department-form-title hr {
width: 65%;
}
.department-form-content{
.department-form-content {
display: flex;
margin-left: 2rem;
flex-direction: column;
@@ -60,11 +60,11 @@ body, html {
font-weight: bold;
}
.department-form-content input{
.department-form-content input {
margin: 0.7rem;
}
.department-form-footer{
.department-form-footer {
margin-top: 7vh;
display: flex;
flex-wrap: wrap;
@@ -84,7 +84,7 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
+6 -6
View File
@@ -34,23 +34,23 @@ body, html {
width: 25%;
}
.ip-form-title{
.ip-form-title {
margin: 0 0 5vh 0;
text-align: center;
}
.ip-form-title h2{
.ip-form-title h2 {
color: #FFFFFF;
font-size: 5vh;
margin: 0;
padding: 0;
}
.ip-form hr{
.ip-form hr {
width: 40%;
}
.ip-form-content{
.ip-form-content {
display: flex;
flex-wrap: wrap;
justify-content: center;
@@ -79,11 +79,11 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
.ip-form-footer{
.ip-form-footer {
margin-top: 3vh;
display: flex;
flex-wrap: wrap;
+8 -8
View File
@@ -16,7 +16,7 @@ body, html {
.container {
opacity: 0;
display: flex;
flex-direction: row;
justify-content: space-evenly;
@@ -24,7 +24,7 @@ body, html {
min-height: 100vh;
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
@@ -41,23 +41,23 @@ body, html {
width: 25%;
}
.login-form-title{
.login-form-title {
margin: 0 0 5vh 0;
text-align: center;
}
.login-form-title h2{
.login-form-title h2 {
color: #FFFFFF;
font-size: 5vh;
margin: 0;
padding: 0;
}
.login-form hr{
.login-form hr {
width: 40%;
}
.login-form-content{
.login-form-content {
display: flex;
flex-wrap: wrap;
justify-content: center;
@@ -86,11 +86,11 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
.login-form-footer{
.login-form-footer {
margin-top: 3vh;
display: flex;
flex-wrap: wrap;
+15 -15
View File
@@ -95,7 +95,7 @@ input {
text-align: center;
}
.left_block{
.left_block {
display: flex;
flex-direction: column;
background-color: #535C91;
@@ -106,29 +106,29 @@ input {
color: white;
}
.left_block_top{
.left_block_top {
display: flex;
flex-direction: row;
justify-content: space-between;
text-align: left;
}
.left_block_top h1{
.left_block_top h1 {
padding: 0;
margin: 0;
}
.left_block_top img{
.left_block_top img {
margin: 0 3vw 0 5vw;
width: 8vw;
height: 8vw;
}
.left_block_content{
.left_block_content {
margin: 2rem 0 2rem 0;
}
.left_block_buttons{
.left_block_buttons {
display: flex;
flex-direction: row;
align-content: center;
@@ -136,7 +136,7 @@ input {
justify-content: center;
}
button{
button {
margin: 0 1rem 0 1rem;
width: 15vw;
height: 10vh;
@@ -155,17 +155,17 @@ button{
transition: background-color 0.3s ease;
}
button:hover{
button:hover {
filter: brightness(85%);
}
.left_block_footer{
.left_block_footer {
display: flex;
align-items: center;
justify-content: end;
}
.right_block{
.right_block {
display: flex;
flex-direction: column;
background-color: #535C91;
@@ -176,7 +176,7 @@ button:hover{
color: white;
}
.notifications{
.notifications {
display: flex;
margin: 1rem 2rem 2rem 3rem;
flex-direction: column;
@@ -208,7 +208,7 @@ button:hover{
background: #555; /* Updated handle color on hover */
}
button[name="logout"]{
button[name="logout"] {
margin: 0;
padding: 0;
width: 10vw;
@@ -216,17 +216,17 @@ button[name="logout"]{
background-color: #F44336;
}
button[name="alert"]{
button[name="alert"] {
margin: 0.7rem;
background-color: #F44336;
}
button[name="notification"]{
button[name="notification"] {
margin: 0.7rem;
background-color: #23BDEE;
}
button[name="menu_button"]{
button[name="menu_button"] {
margin: 0.7rem;
background-color: #1B1A55;
}
+6 -6
View File
@@ -25,7 +25,7 @@ body, html {
text-align: center; /* Center the text for all child elements */
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
@@ -42,11 +42,11 @@ body, html {
width: 25%;
}
.profile-form-title{
.profile-form-title {
margin-bottom: 5vh;
}
.profile-form hr{
.profile-form hr {
width: 40%;
}
@@ -58,13 +58,13 @@ body, html {
font-size: 5vh;
}
.profile-form-content{
.profile-form-content {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.profile-form-footer{
.profile-form-footer {
margin-top: 7vh;
display: flex;
flex-direction: row;
@@ -94,7 +94,7 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
@@ -25,7 +25,7 @@ body, html {
text-align: center; /* Center the text for all child elements */
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
@@ -33,7 +33,7 @@ body, html {
margin-bottom: 10rem;
}
img{
width:20%;
img {
width: 20%;
height: 20%;
}
+19 -19
View File
@@ -25,16 +25,16 @@ body, html {
text-align: center;
}
h1, h2{
h1, h2 {
padding: 0;
margin: 0;
}
h2{
h2 {
font-size: 1rem;
}
.left_block{
.left_block {
display: flex;
flex-direction: column;
background-color: #535C91;
@@ -45,25 +45,25 @@ h2{
color: white;
}
.left_block_top{
.left_block_top {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.left_block_top_left{
.left_block_top_left {
display: flex;
flex-direction: column;
justify-content: start;
text-align: left;
}
.left_block_top_left hr{
.left_block_top_left hr {
margin: 0 0 1rem 0;
width: 45%;
}
.left_block_top_right{
.left_block_top_right {
width: 10vw;
display: flex;
@@ -77,14 +77,14 @@ h2{
border-radius: 1rem;
}
.left_block_content{
.left_block_content {
display: flex;
justify-content: start;
align-items: center;
margin: 2rem 0 2rem 0;
}
.left_block_buttons{
.left_block_buttons {
display: flex;
flex-direction: row;
align-content: center;
@@ -92,7 +92,7 @@ h2{
justify-content: center;
}
button{
button {
margin: 0 1rem 0 1rem;
width: 10vw;
height: 5vh;
@@ -111,17 +111,17 @@ button{
transition: background-color 0.3s ease;
}
button:hover{
button:hover {
filter: brightness(85%);
}
.left_block_footer{
.left_block_footer {
display: flex;
align-items: center;
justify-content: end;
}
.right_block{
.right_block {
display: flex;
flex-direction: column;
background-color: #535C91;
@@ -132,7 +132,7 @@ button:hover{
color: white;
}
.choose_user_form_title{
.choose_user_form_title {
display: flex;
flex-wrap: wrap;
flex-direction: column;
@@ -140,11 +140,11 @@ button:hover{
align-content: start;
}
.choose_user_form_title hr{
.choose_user_form_title hr {
width: 80%;
}
.choose_user_form_content{
.choose_user_form_content {
display: flex;
margin: 1rem 7rem 2rem 0.5rem;
flex-direction: column;
@@ -176,15 +176,15 @@ button:hover{
background: #555; /* Updated handle color on hover */
}
button[name="back"]{
button[name="back"] {
background-color: #23BDEE;
}
button[name="submit"]{
button[name="submit"] {
background-color: #F44336;
}
button[name="select_file"]{
button[name="select_file"] {
margin: 0;
width: 8vw;
background-color: #1B1A55;
@@ -25,7 +25,7 @@ body, html {
text-align: center; /* Center the text for all child elements */
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
+7 -7
View File
@@ -25,7 +25,7 @@ body, html {
text-align: center;
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
@@ -42,7 +42,7 @@ body, html {
width: 25%;
}
.signup-form-title{
.signup-form-title {
margin-bottom: 5vh;
}
@@ -54,15 +54,15 @@ body, html {
font-size: 5vh;
}
.signup-form hr{
.signup-form hr {
width: 65%;
}
input{
input {
margin: 0 0 1rem 0;
}
.signup-form-content{
.signup-form-content {
display: flex;
margin: 1rem 2rem 2rem 3rem;
flex-direction: column;
@@ -94,7 +94,7 @@ input{
background: #555; /* Updated handle color on hover */
}
.signup-form-footer{
.signup-form-footer {
margin-top: 5vh;
display: flex;
flex-wrap: wrap;
@@ -114,7 +114,7 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
+5 -5
View File
@@ -25,7 +25,7 @@ body, html {
text-align: center;
}
.header{
.header {
color: #1B1A55;
font-size: 4vh;
text-transform: uppercase;
@@ -42,7 +42,7 @@ body, html {
width: 25%;
}
.signup-form-title{
.signup-form-title {
margin-bottom: 5vh;
}
@@ -54,7 +54,7 @@ body, html {
font-size: 5vh;
}
.signup-form hr{
.signup-form hr {
width: 40%;
}
@@ -70,7 +70,7 @@ input {
border-radius: 10px;
}
.signup-form-footer{
.signup-form-footer {
margin-top: 3vh;
display: flex;
flex-wrap: wrap;
@@ -90,7 +90,7 @@ button {
cursor: pointer;
}
button:hover{
button:hover {
filter: brightness(85%);
}
+9 -9
View File
@@ -2,20 +2,20 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/alert_modal.css">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../css/alert_modal.css" rel="stylesheet">
<script src="../js/alert_modal.js"></script>
<title>Alert Modal</title>
</head>
<body>
<div id="myModal" class="container">
<div class="main_component">
<div class="header">
<!--Here goes the message-->
<h1 id="modal-message"></h1>
</div>
<button id="closeButton" name="close">Close</button>
<div class="container" id="myModal">
<div class="main_component">
<div class="header">
<!--Here goes the message-->
<h1 id="modal-message"></h1>
</div>
<button id="closeButton" name="close">Close</button>
</div>
</div>
</body>
</html>
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/change_department.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/change_department.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/change_department.js"></script>
<script src="../js/transition.js"></script>
@@ -15,7 +15,7 @@
</head>
<body onload="fadeIn()">
<div class="container">
<form id="departmentForm" class="department-form">
<form class="department-form" id="departmentForm">
<div class="department-form-title">
<h2>Choose your department</h2>
<hr>
@@ -24,8 +24,8 @@
</div>
<div class="department-form-footer">
<button id="back" type="button" name="back">Back</button>
<button id="submit" type="submit" name="submit">Submit</button>
<button id="back" name="back" type="button">Back</button>
<button id="submit" name="submit" type="submit">Submit</button>
</div>
</form>
</div>
+5 -5
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/sending_file_confirmation.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/sending_file_confirmation.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/transition.js"></script>
@@ -17,7 +17,7 @@
<div class="header">
<h1>SENDING THE FILE!</h1>
<h2>PlEASE WAIT</h2>
<img src="../assets/loading.gif" alt="Description of GIF">
<img alt="Description of GIF" src="../assets/loading.gif">
</div>
</div>
+7 -7
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/ip_submit.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/ip_submit.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/ip_submit.js"></script>
<script src="../js/transition.js"></script>
@@ -15,16 +15,16 @@
</head>
<body onload="fadeIn()">
<div class="container">
<form id="ipForm" class="ip-form">
<form class="ip-form" id="ipForm">
<div class="ip-form-title">
<h2>IP Config</h2>
<hr>
</div>
<div class="ip-form-content">
<input id="ipInput" type="text" name="ip" placeholder="192.168.x.x : Port">
<input id="ipInput" name="ip" placeholder="192.168.x.x : Port" type="text">
</div>
<div class="ip-form-footer">
<button id="submit" type="submit" name="submit">Submit</button>
<button id="submit" name="submit" type="submit">Submit</button>
</div>
</form>
</div>
+9 -9
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/login.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/login.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/login.js"></script>
<script src="../js/transition.js"></script>
@@ -19,18 +19,18 @@
<h1>DO WE KNOW</h1>
<h1>EACH OTHER?</h1>
</div>
<form id="loginForm" class="login-form">
<form class="login-form" id="loginForm">
<div class="login-form-title">
<h2>Login</h2>
<hr>
</div>
<div class="login-form-content">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input name="email" placeholder="Email" type="email">
<input name="password" placeholder="Password" type="password">
</div>
<div class="login-form-footer">
<button id="signup" type="submit" name="signup">Sign Up</button>
<button id="submit" type="submit" name="submit">Submit</button>
<button id="signup" name="signup" type="submit">Sign Up</button>
<button id="submit" name="submit" type="submit">Submit</button>
</div>
</form>
</div>
+11 -11
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/main_menu.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/main_menu.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/main_menu.js"></script>
<script src="../js/transition.js"></script>
@@ -15,13 +15,13 @@
</head>
<body onload="fadeIn()">
<div id="overlay" class="overlay">
<form id="ceo_validation" class="ceo-validation-form">
<div class="overlay" id="overlay">
<form class="ceo-validation-form" id="ceo_validation">
<h2>CEO Authentication</h2>
<input type="password" id="ceo_password" placeholder="Enter CEO's password" required>
<input id="ceo_password" placeholder="Enter CEO's password" required type="password">
<div class="form-actions">
<button type="button" id="back_button">Back</button>
<button type="submit" id="submit_button">Submit</button>
<button id="back_button" type="button">Back</button>
<button id="submit_button" type="submit">Submit</button>
</div>
</form>
</div>
@@ -33,7 +33,7 @@
<h1 id="username_field"></h1>
<h2>Hope you have a productive day!</h2>
</div>
<img src="../assets/user_1144760.png" alt="">
<img alt="" src="../assets/user_1144760.png">
</div>
<div class="left_block_content">
<div class="left_block_buttons">
@@ -57,7 +57,7 @@
<h1>NOTIFICATIONS</h1>
<hr>
</div>
<div id="notifications" class="notifications">
<div class="notifications" id="notifications">
</div>
</div>
+10 -10
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/profile.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/profile.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/profile.js"></script>
<script src="../js/transition.js"></script>
@@ -15,19 +15,19 @@
</head>
<body onload="fadeIn()">
<div class="container">
<form id="profileForm" class="profile-form">
<form class="profile-form" id="profileForm">
<div class="profile-form-title">
<h2>Profile</h2>
<hr>
</div>
<div class="profile-form-content">
<input type="email" name="email" placeholder="Email">
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input name="email" placeholder="Email" type="email">
<input name="username" placeholder="Username" type="text">
<input name="password" placeholder="Password" type="password">
</div>
<div class="profile-form-footer">
<button type="button" name="login">Back</button>
<button type="submit" name="submit">Submit</button>
<button name="login" type="button">Back</button>
<button name="submit" type="submit">Submit</button>
</div>
</form>
</div>
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/sending_file_confirmation.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/sending_file_confirmation.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/transition.js"></script>
@@ -17,7 +17,7 @@
<div class="header">
<h1>SENDING THE FILE!</h1>
<h2>PlEASE WAIT</h2>
<img src="../assets/loading.gif" alt="Description of GIF">
<img alt="Description of GIF" src="../assets/loading.gif">
</div>
</div>
+8 -8
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/share_file.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/share_file.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/share_file.js"></script>
<script src="../js/transition.js"></script>
@@ -28,14 +28,14 @@
</div>
</div>
<div class="left_block_content">
<button id="selectFile" type="button" name="select_file">Select</button>
<button id="selectFile" name="select_file" type="button">Select</button>
</div>
<div class="left_block_footer">
<button id="backButton" type="button" name="back">Back</button>
<button id="submitButton" type="submit" name="submit">Submit</button>
<button id="backButton" name="back" type="button">Back</button>
<button id="submitButton" name="submit" type="submit">Submit</button>
</div>
</div>
<form id="userDestForm" class="right_block">
<form class="right_block" id="userDestForm">
<div class="choose_user_form_title">
<h1>USERS</h1>
<hr>
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/sign_up_confirmation.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/sign_up_confirmation.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/sign_up_confirmation.js"></script>
<script src="../js/transition.js"></script>
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/sign_up_department.css">
<link rel="stylesheet" href="../css/transition.css">
<link href="../css/sign_up_department.css" rel="stylesheet">
<link href="../css/transition.css" rel="stylesheet">
<script src="../js/sign_up_departments.js"></script>
<script src="../js/transition.js"></script>
@@ -20,7 +20,7 @@
<h1>ABOUT</h1>
<h1>YOUR WORK</h1>
</div>
<form id="signupForm" class="signup-form">
<form class="signup-form" id="signupForm">
<div class="signup-form-title">
<h2>Choose your department</h2>
<hr>
@@ -29,8 +29,8 @@
<!-- add the list query for departments-->
</div>
<div class="signup-form-footer">
<button id="back" type="button" name="back">Back</button>
<button id="submit" type="submit" name="submit">Submit</button>
<button id="back" name="back" type="button">Back</button>
<button id="submit" name="submit" type="submit">Submit</button>
</div>
</form>
</div>
+10 -10
View File
@@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../assets/hard-disk.ico" type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="../assets/hard-disk.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="../css/transition.css">
<link rel="stylesheet" href="../css/sing_up_profile.css">
<link href="../css/transition.css" rel="stylesheet">
<link href="../css/sing_up_profile.css" rel="stylesheet">
<script src="../js/sign_up_profile.js"></script>
<script src="../js/transition.js"></script>
@@ -19,19 +19,19 @@
<h1>LET US MEET</h1>
<h1>EACH OTHER</h1>
</div>
<form id="signupForm" class="signup-form">
<form class="signup-form" id="signupForm">
<div class="signup-form-title">
<h2>Sign Up</h2>
<hr>
</div>
<div>
<input type="email" name="email" placeholder="Email">
<input type="text" name="name" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input name="email" placeholder="Email" type="email">
<input name="name" placeholder="Username" type="text">
<input name="password" placeholder="Password" type="password">
</div>
<div class="signup-form-footer">
<button id="login" type="button" name="login">Login</button>
<button id="continue" type="submit" name="submit">Continue</button>
<button id="login" name="login" type="button">Login</button>
<button id="continue" name="submit" type="submit">Continue</button>
</div>
</form>
</div>
+10 -4
View File
@@ -3,7 +3,7 @@ document.addEventListener('DOMContentLoaded', async function () {
const submitButton = document.getElementById('submit');
const signupDataExists = await window.electronAPI.checkFileExists('signupData.json');
if(signupDataExists){
if (signupDataExists) {
await window.electronAPI.deleteFile('signupData.json');
}
@@ -32,9 +32,11 @@ document.addEventListener('DOMContentLoaded', async function () {
email: email,
password: password
})
}).then(response => {
}).then(async response => {
if (response.ok) {
fadeOut('main_menu.html');
} else {
await window.electronAPI.deleteFile('loginData.json');
}
}).catch(error => {
console.error(error);
@@ -80,8 +82,8 @@ document.addEventListener('DOMContentLoaded', async function () {
return response.json();
}).then(async data => {
console.log(data)
await window.electronAPI.writeFile('loginData.json', JSON.stringify(responseBody.message, null, 2));
data.data.password = password
await window.electronAPI.writeFile('loginData.json', JSON.stringify(data.data, null, 2));
fadeOut('main_menu.html');
})
.catch(async error => {
@@ -90,4 +92,8 @@ document.addEventListener('DOMContentLoaded', async function () {
.catch(error => console.error('Error showing alert:', error));
})
});
function delayWithTimeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
});
+4 -4
View File
@@ -34,11 +34,11 @@ document.addEventListener('DOMContentLoaded', async function () {
handleOverlayOpen('decrypt');
});
ceoBackButton.addEventListener('click', function() {
ceoBackButton.addEventListener('click', function () {
overlay.style.display = 'none';
});
ceoSubmitButton.addEventListener('click', async function(event) {
ceoSubmitButton.addEventListener('click', async function (event) {
event.preventDefault();
const password = document.getElementById('ceo_password').value;
@@ -53,12 +53,12 @@ document.addEventListener('DOMContentLoaded', async function () {
})
}).then(async result => {
const data = await result.json();
if(!result.ok){
if (!result.ok) {
throw new Error(data.message);
}
if (triggerSource === 'change_department') {
fadeOut('change_department.html');
}else if (triggerSource === 'decrypt'){
} else if (triggerSource === 'decrypt') {
fadeOut('decrypting_files.html');
}
})
+2 -2
View File
@@ -1,4 +1,4 @@
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
let pathToFile = '';
function updateFileName() {
@@ -83,7 +83,7 @@ document.addEventListener("DOMContentLoaded", function() {
}
});
if(selectedUserIds === []){
if (selectedUserIds === []) {
await window.electronAPI.showAlert('No user selected!')
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error changing content:', error));
+1 -1
View File
@@ -1,4 +1,4 @@
document.addEventListener('DOMContentLoaded', async function() {
document.addEventListener('DOMContentLoaded', async function () {
await new Promise(resolve => setTimeout(resolve, 2000));
fadeOut('login.html');
});
+5 -5
View File
@@ -3,7 +3,7 @@ document.addEventListener('DOMContentLoaded', async function () {
const continueButton = document.getElementById('continue');
const signupDataExists = await window.electronAPI.checkFileExists('signupData.json');
if(signupDataExists){
if (signupDataExists) {
await window.electronAPI.readFile('signupData.json')
.then(result => {
const signupData = JSON.parse(result.content);
@@ -63,9 +63,9 @@ document.addEventListener('DOMContentLoaded', async function () {
await window.electronAPI.writeFile('signupData.json', JSON.stringify(formDataJSON));
fadeOut('sign_up_departments.html');
}).catch(async error => {
await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error changing content:', error));
})
await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error changing content:', error));
})
});
});