CEO updated

This commit is contained in:
andrei-mihnea-cerbu
2024-04-20 03:18:44 +03:00
parent 869305a491
commit 57c2c7ec55
81 changed files with 3517 additions and 1035 deletions
+73 -34
View File
@@ -1,5 +1,9 @@
document.addEventListener('DOMContentLoaded', async function () {
await insertUsername();
const backupButton = document.getElementById('backup');
const shareButton = document.getElementById('share_dir');
const manageDepartmentButton = document.getElementById('manage_department');
const manageUsersButton = document.getElementById('manage_users');
const changeInfoButton = document.getElementById('change_info');
@@ -7,66 +11,70 @@ document.addEventListener('DOMContentLoaded', async function () {
const decryptButton = document.getElementById('decrypt');
const logoutButton = document.getElementById('logout');
await insertUsername();
checkDirBackupFileExists()
.then(() => console.log('verificare facuta'));
.then(() => console.log('verificare backupDir facuta'));
manageUsersButton.addEventListener('click', async function(){
window.electronAPI.changeContent('manage_users.html')
.then(() => console.log('Navigated to dashboard'))
.catch(error => console.error('Error navigating:', error));
});
manageDepartmentButton.addEventListener('click', async function(){
window.electronAPI.changeContent('manage_departments.html')
.then(() => console.log('Navigated to dashboard'))
.catch(error => console.error('Error navigating:', error));
});
checkShareDirFileExists()
.then(() => console.log('verificare ShareDir facuta'));
backupButton.addEventListener('click', function () {
console.log('Set backup directory button clicked!');
window.electronAPI.openBackupDirDialog()
window.electronAPI.openJsonDirConfigDialog('dirBackup.json')
.then(() => console.log('Back-up directory set'))
.catch(async error => await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error showing alert:', error)));
});
shareButton.addEventListener('click', function () {
console.log('Set backup directory button clicked!');
window.electronAPI.openJsonDirConfigDialog('dirShare.json')
.then(() => console.log('Back-up directory set'))
.catch(async error => await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error showing alert:', error)));
});
manageUsersButton.addEventListener('click', async function(){
fadeOut('manage_users.html');
});
changeInfoButton.addEventListener('click', function () {
console.log('Change your info button clicked!');
fadeOut('profile.html');
});
window.electronAPI.changeContent('profile.html')
.then(() => console.log('Navigated to dashboard'))
.catch(error => console.error('Error navigating:', error));
decryptButton.addEventListener('click', function () {
fadeOut('decrypting_backup.html');
});
changeInfoButton.addEventListener('click', function () {
console.log('Change your info button clicked!');
fadeOut('profile.html');
});
shareFileButton.addEventListener('click', function () {
console.log('Share a file button clicked!');
window.electronAPI.changeContent('share_file.html')
.then(() => console.log('Navigated to dashboard'))
.catch(error => console.error('Error navigating:', error));
fadeOut('share_file.html');
});
manageDepartmentButton.addEventListener('click', function() {
fadeOut('manage_departments.html');
})
logoutButton.addEventListener('click', async function () {
console.log('Logout button clicked!');
await window.electronAPI.killBeforeLogout();
await window.electronAPI.deleteFile('loginData.json');
window.electronAPI.changeContent('login.html')
.then(() => console.log('Navigated to dashboard'))
.catch(error => console.error('Error navigating:', error));
fadeOut('login.html');
});
decryptButton.addEventListener('click', async function (){
});
async function decryptFiles(){
}
async function checkDirBackupFileExists() {
try {
// Make an IPC call to check file existence
@@ -78,7 +86,7 @@ document.addEventListener('DOMContentLoaded', async function () {
button.id = 'backup_alert';
button.name = 'alert';
button.textContent = 'Set your backup directory!';
button.addEventListener('click', handleButtonClick);
button.addEventListener('click', handleBackupButtonPressed);
notificationsDiv.appendChild(button);
}
} catch (error) {
@@ -86,10 +94,28 @@ document.addEventListener('DOMContentLoaded', async function () {
}
}
async function handleButtonClick() {
async function checkShareDirFileExists() {
try {
const fileExists = await window.electronAPI.checkFileExists('dirShare.json');
if (!fileExists) {
const notificationsDiv = document.getElementById('notifications');
const button = document.createElement('button');
button.id = 'share_file_alert';
button.name = 'alert';
button.textContent = 'Set your share directory!';
button.addEventListener('click', handleShareButtonPressed);
notificationsDiv.appendChild(button);
}
} catch (error) {
console.error('Error checking file existence:', error);
}
}
async function handleBackupButtonPressed() {
console.log('Button clicked!');
await window.electronAPI.openBackupDirDialog()
await window.electronAPI.openJsonDirConfigDialog('dirBackup.json')
.then(() => console.log('Back-up directory set'))
.catch(async error => await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
@@ -99,6 +125,19 @@ document.addEventListener('DOMContentLoaded', async function () {
button.remove();
}
async function handleShareButtonPressed() {
console.log('Button clicked!');
await window.electronAPI.openJsonDirConfigDialog('dirShare.json')
.then(() => console.log('Share directory set'))
.catch(async error => await window.electronAPI.showAlert(error.message)
.then(() => console.log('Alert window opened'))
.catch(error => console.error('Error showing alert:', error)));
const button = document.getElementById('backup_alert');
button.remove();
}
async function insertUsername() {
try {
const userData = await window.electronAPI.readFile('loginData.json');