mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-04-29 10:10:57 +00:00
further tried on read and write the config
This commit is contained in:
parent
4882b82529
commit
dd954dc760
@ -7,28 +7,36 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button id="extract">Extract ZIP</button>
|
<button id="extract">Extract ZIP</button>
|
||||||
|
|
||||||
<p>Input URL</p>
|
|
||||||
<input type="text" id="urlBox" name="name" size="80" readonly />
|
|
||||||
<p>Input Directory</p>
|
<p>Input Directory</p>
|
||||||
<input type="text" id="dirBox" name="name" size="80" readonly />
|
<input type="text" id="dirBox" name="name" size="80" readonly />
|
||||||
<progress id="progressbar" max="100" value="0"></progress>
|
<progress id="progressbar" max="100" value="0"></progress>
|
||||||
|
|
||||||
<button id="update">Check for update</button>
|
<button id="update">Check for update</button>
|
||||||
|
|
||||||
<select name="Dropme Down" id="gng"></select>
|
<select id="gng"></select>
|
||||||
<select name="Dropme Down #2" id="files"></select>
|
<select id="files"></select>
|
||||||
|
|
||||||
<button id="test">Test BTN</button>
|
<button id="test">Test BTN</button>
|
||||||
|
|
||||||
<div id="login">
|
<div id="login">
|
||||||
|
<p>Username</p>
|
||||||
|
<input type="text" id="username" />
|
||||||
|
<input type="checkbox" id="saveuser" />
|
||||||
<div class="tooltip">
|
<div class="tooltip">
|
||||||
<p>Username</p>
|
|
||||||
<input type="text" id="username" />
|
|
||||||
<input type="checkbox" id="saveuser" />
|
|
||||||
<p>Password</p>
|
<p>Password</p>
|
||||||
<input type="password" id="password" />
|
<input type="password" id="password" />
|
||||||
<input type="checkbox" id="savepw" />
|
<input type="checkbox" id="savepw" />
|
||||||
|
<span class="tooltiptext"
|
||||||
|
>Please be aware that the password you enter will be stored in plain
|
||||||
|
text in our system. This means that it will not be encrypted or
|
||||||
|
otherwise secured. We recommend that you do not use a password that
|
||||||
|
you also use for other important accounts, such as your email or
|
||||||
|
banking. Please use caution when entering your password and consider
|
||||||
|
using a unique and strong password specifically for this
|
||||||
|
account.</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="tooltip">
|
||||||
<p>Password Hoppie</p>
|
<p>Password Hoppie</p>
|
||||||
<input type="password" id="passwordhoppie" />
|
<input type="password" id="passwordhoppie" />
|
||||||
<input type="checkbox" id="savepwhoppie" />
|
<input type="checkbox" id="savepwhoppie" />
|
||||||
@ -42,6 +50,7 @@
|
|||||||
account.</span
|
account.</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<button id="savecred">Save your Credentials</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="./renderer.js"></script>
|
<script src="./renderer.js"></script>
|
||||||
|
@ -62,7 +62,6 @@ const createWindow = () => {
|
|||||||
filepath = await dialog.showOpenDialog(mainWindow, {
|
filepath = await dialog.showOpenDialog(mainWindow, {
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
});
|
});
|
||||||
console.log('directories selected', filepath.filePaths);
|
|
||||||
mainWindow.webContents.send("app-path", filepath.filePaths);
|
mainWindow.webContents.send("app-path", filepath.filePaths);
|
||||||
// Save directory to file
|
// Save directory to file
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
const { ipcRenderer, dialog, app } = require('electron');
|
const { ipcRenderer, app } = require('electron');
|
||||||
const superagent = require('superagent').agent();
|
const superagent = require('superagent').agent();
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var DecompressZip = require('decompress-zip');
|
var DecompressZip = require('decompress-zip');
|
||||||
const { version } = require('os');
|
|
||||||
|
|
||||||
// Global Variabels
|
// Global Variabels
|
||||||
let dirBox = document.getElementById('dirs');
|
let dirBox = document.getElementById('dirBox');
|
||||||
let usernameInput = document.getElementById('username');
|
let usernameInput = document.getElementById('username');
|
||||||
let passwordInput = document.getElementById('password');
|
let passwordInput = document.getElementById('password');
|
||||||
let passwordhoppieInput = document.getElementById('passwordhoppie');
|
let passwordhoppieInput = document.getElementById('passwordhoppie');
|
||||||
|
let saveCredBtn = document.getElementById('savecred');
|
||||||
|
|
||||||
// CheckBox Events
|
// CheckBox Events
|
||||||
let checkBoxUsername = document.getElementById('saveuser');
|
let checkBoxUsername = document.getElementById('saveuser');
|
||||||
@ -16,8 +16,6 @@ let checkBoxPassword = document.getElementById('savepw');
|
|||||||
let checkBoxSavepwhoppie = document.getElementById('savepwhoppie');
|
let checkBoxSavepwhoppie = document.getElementById('savepwhoppie');
|
||||||
|
|
||||||
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
let systempath = "systemfile.json"; // soll weg
|
|
||||||
let userFile = "userfile.json"; // soll weg
|
|
||||||
var systemstructure = {
|
var systemstructure = {
|
||||||
path: ""
|
path: ""
|
||||||
};
|
};
|
||||||
@ -46,58 +44,65 @@ document.addEventListener('DOMContentLoaded', function() { // Seems to work (tm)
|
|||||||
firstStart();
|
firstStart();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
let systemsettings = "system.json";
|
let systemsettings = "systemfile.json";
|
||||||
let settings = "settings.json";
|
let settings = "settings.json";
|
||||||
var filepath;
|
var filepath = "F:\\02 Benutzer\\Chef\\Dokumente\\00 Git\\sectorfileupdater\\updater"; // Set to exe path ex: app.getPath('exe') + '\\' + systemsettings;
|
||||||
async function firstStart() {
|
async function firstStart() {
|
||||||
await ipcRenderer.send('app-path');
|
// await ipcRenderer.send('app-path');
|
||||||
await ipcRenderer.on("app-path", async(event, path) => {
|
// await ipcRenderer.on("app-path", async(event, path) => {
|
||||||
filepath = path;
|
// filepath = path;
|
||||||
// await delay(2000); // Not the best solution
|
// });
|
||||||
// filepath = await app.getPath('home') + '\\' + systemsettings;
|
// await delay(2000); // Not the best solution
|
||||||
await console.log(filepath + "\\" + systemsettings);
|
// filepath = await app.getPath('home') + '\\' + systemsettings;
|
||||||
if (await fs.existsSync(filepath + "\\" + systemsettings)) {
|
await console.log(filepath + "\\" + systemsettings);
|
||||||
systemstructure = JSON.parse(fs.readFileSync(filepath + "\\" + systemsettings, 'utf8'));
|
if (await fs.existsSync(filepath + "\\" + systemsettings)) {
|
||||||
} else {
|
systemstructure = JSON.parse(fs.readFileSync(filepath + "\\" + systemsettings, 'utf8'));
|
||||||
await changeUserpath();
|
} else {
|
||||||
|
await changeUserpath();
|
||||||
|
}
|
||||||
|
if (await fs.existsSync(systemstructure.path + "\\" + settings)) {
|
||||||
|
structure = JSON.parse(fs.readFileSync(systemstructure.path + "\\" + settings, 'utf8'));
|
||||||
|
if (structure.cid.save == true) {
|
||||||
|
usernameInput.value = structure.cid.id;
|
||||||
}
|
}
|
||||||
await console.log(systemstructure);
|
if (structure.password.save == true) {
|
||||||
await console.log("test");
|
passwordInput.value = structure.password.pass;
|
||||||
if (await fs.existsSync(systemstructure.path + "\\" + settings)) {
|
|
||||||
structure = JSON.parse(fs.readFileSync(systemstructure.path + "\\" + settings, 'utf8'));
|
|
||||||
if (structure.cid.save == true) {
|
|
||||||
usernameInput.value = structure.cid.id;
|
|
||||||
}
|
|
||||||
if (structure.password.save == true) {
|
|
||||||
passwordInput.value = structure.password.pass;
|
|
||||||
}
|
|
||||||
if (structure.passwordhoppie.save == true) {
|
|
||||||
passwordhoppieInput.value = structure.passwordhoppie.pass;
|
|
||||||
}
|
|
||||||
dirBox.value = systemstructure.path;
|
|
||||||
// GET INFO
|
|
||||||
|
|
||||||
} else {
|
|
||||||
fs.writeFileSync(systemstructure.path + "\\" + settings, JSON.stringify(structure, null, 4), 'utf8');
|
|
||||||
gng.selectedIndex = structure.region;
|
|
||||||
if (files.selectedIndex < 0) {
|
|
||||||
files.selectedIndex = 0;
|
|
||||||
} else {
|
|
||||||
files.selectedIndex = structure.file;
|
|
||||||
}
|
|
||||||
// Broken
|
|
||||||
|
|
||||||
}
|
}
|
||||||
await getUpdates();
|
if (structure.passwordhoppie.save == true) {
|
||||||
|
passwordhoppieInput.value = structure.passwordhoppie.pass;
|
||||||
|
}
|
||||||
|
if (structure.cid.save == true) {
|
||||||
|
checkBoxUsername.checked = true;
|
||||||
|
}
|
||||||
|
if (structure.password.save == true) {
|
||||||
|
checkBoxPassword.checked = true;
|
||||||
|
}
|
||||||
|
if (structure.passwordhoppie.save == true) {
|
||||||
|
checkBoxSavepwhoppie.checked = true;
|
||||||
|
}
|
||||||
|
dirBox.value = systemstructure.path;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fs.writeFileSync(systemstructure.path + "\\" + settings, JSON.stringify(structure, null, 4), 'utf8');
|
||||||
gng.selectedIndex = structure.region;
|
gng.selectedIndex = structure.region;
|
||||||
if (files.selectedIndex < 0) {
|
if (files.selectedIndex < 0) {
|
||||||
files.selectedIndex = 0;
|
files.selectedIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
files.selectedIndex = structure.file;
|
files.selectedIndex = structure.file;
|
||||||
}
|
}
|
||||||
await getFiles();
|
// Broken
|
||||||
save();
|
|
||||||
});
|
}
|
||||||
|
await getUpdates();
|
||||||
|
gng.selectedIndex = structure.region;
|
||||||
|
if (files.selectedIndex < 0) {
|
||||||
|
files.selectedIndex = 0;
|
||||||
|
} else {
|
||||||
|
files.selectedIndex = structure.file;
|
||||||
|
}
|
||||||
|
await removeFileItems();
|
||||||
|
await getFiles();
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Event
|
// Save Event
|
||||||
@ -112,7 +117,7 @@ files.addEventListener("change", () => {
|
|||||||
function save() {
|
function save() {
|
||||||
// WORK HERE, new files
|
// WORK HERE, new files
|
||||||
// Read config
|
// Read config
|
||||||
structure = JSON.parse(fs.readFileSync(systempath.path + userFile, 'utf8'));
|
structure = JSON.parse(fs.readFileSync(systemstructure.path + "\\" + settings, 'utf8'));
|
||||||
structure.region = gng.selectedIndex;
|
structure.region = gng.selectedIndex;
|
||||||
structure.file = files.selectedIndex;
|
structure.file = files.selectedIndex;
|
||||||
if (checkBoxUsername.checked == true) {
|
if (checkBoxUsername.checked == true) {
|
||||||
@ -140,7 +145,7 @@ function save() {
|
|||||||
//structure.currentInstalledAirac = currentAirac;
|
//structure.currentInstalledAirac = currentAirac;
|
||||||
//structure.version = airacversion;
|
//structure.version = airacversion;
|
||||||
// Save config
|
// Save config
|
||||||
fs.writeFileSync(systemstructure.path + "\\" + userFile, JSON.stringify(structure, null, 4), 'utf8');
|
fs.writeFileSync(systemstructure.path + "\\" + settings, JSON.stringify(structure, null, 4), 'utf8');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check update
|
// Check update
|
||||||
@ -193,7 +198,7 @@ async function getUpdates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getFiles() {
|
async function getFiles() {
|
||||||
removeFileItems();
|
await removeFileItems();
|
||||||
// Get all GNG Package Options
|
// Get all GNG Package Options
|
||||||
let region = "https://files.aero-nav.com/" + dropDownGNG.options[dropDownGNG.selectedIndex].text;
|
let region = "https://files.aero-nav.com/" + dropDownGNG.options[dropDownGNG.selectedIndex].text;
|
||||||
let courses = await superagent.get(region);
|
let courses = await superagent.get(region);
|
||||||
@ -300,6 +305,7 @@ function changeUserpath() {
|
|||||||
|
|
||||||
ipcRenderer.on("app-path", (event, value) => {
|
ipcRenderer.on("app-path", (event, value) => {
|
||||||
systemstructure.path = value[0];
|
systemstructure.path = value[0];
|
||||||
|
dirBox.value = value[0];
|
||||||
fs.writeFileSync(systemstructure.path + "\\" + settings, JSON.stringify(structure, null, 4), 'utf8');
|
fs.writeFileSync(systemstructure.path + "\\" + settings, JSON.stringify(structure, null, 4), 'utf8');
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -310,13 +316,17 @@ ipcRenderer.on("download progress", (event, progress) => {
|
|||||||
|
|
||||||
// let downloadBtn = document.getElementById('download');
|
// let downloadBtn = document.getElementById('download');
|
||||||
// downloadBtn.addEventListener('click', (e) => {
|
// downloadBtn.addEventListener('click', (e) => {
|
||||||
// var systemReadJson = JSON.parse(fs.readFileSync(systempath, 'utf8'));
|
// var systemReadJson = JSON.parse(fs.readFileSync(systemsettings, 'utf8'));
|
||||||
// var userReadJson = JSON.parse(fs.readFileSync(systemReadJson.path + userFile, 'utf8'));
|
// var userReadJson = JSON.parse(fs.readFileSync(systemReadJson.path + settings, 'utf8'));
|
||||||
// downloadFile(files.options[files.selectedIndex].href, systemReadJson.path);
|
// downloadFile(files.options[files.selectedIndex].href, systemReadJson.path);
|
||||||
// });
|
// });
|
||||||
let testBtn = document.getElementById('test');
|
let testBtn = document.getElementById('test');
|
||||||
testBtn.addEventListener('click', (e) => {
|
testBtn.addEventListener('click', (e) => {
|
||||||
var systemReadJson = JSON.parse(fs.readFileSync(systempath, 'utf8'));
|
var systemReadJson = JSON.parse(fs.readFileSync(systemsettings, 'utf8'));
|
||||||
var userReadJson = JSON.parse(fs.readFileSync(systemReadJson.path + userFile, 'utf8'));
|
var userReadJson = JSON.parse(fs.readFileSync(systemReadJson.path + settings, 'utf8'));
|
||||||
decompress(files.options[files.selectedIndex].href, systemReadJson.path)
|
decompress(files.options[files.selectedIndex].href, systemReadJson.path)
|
||||||
|
});
|
||||||
|
|
||||||
|
saveCredBtn.addEventListener('click', (e) => {
|
||||||
|
save();
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user