Better handeling of working path
This commit is contained in:
25
TrimSP.html
25
TrimSP.html
@@ -41,7 +41,7 @@
|
||||
<tr>
|
||||
<td><label>Save folder:</label></td>
|
||||
<td>
|
||||
<input type="text" style="width:70%" id="workPath" name="workPath" value="/tmp/test" readonly/>
|
||||
<input type="text" style="width:70%" id="workPath" name="workPath" readonly/>
|
||||
<input type="button" value="Browse"
|
||||
id="browseFolde" onclick="ipcRenderer.send('browseFolder');">
|
||||
</td>
|
||||
@@ -226,13 +226,21 @@
|
||||
});
|
||||
});
|
||||
|
||||
let foldername = document.getElementById("workPath").value;
|
||||
// If empty or undefined fill with default
|
||||
if (foldername == '' || foldername == undefined ) {foldername ="/tmp/test";}
|
||||
let workPath = document.getElementById("workPath");
|
||||
// If empty or undefined use local folder as default
|
||||
if (workPath.value == '' || workPath.value == undefined ) {
|
||||
workPath.value = process.cwd();
|
||||
// console.log("I am here",process.cwd());
|
||||
}
|
||||
|
||||
// Catch calls for selectfolder
|
||||
ipcRenderer.on('selectFolder', function(event, foldername) {
|
||||
document.getElementById("workPath").value = foldername;
|
||||
if (foldername.length != 0) {
|
||||
document.getElementById("workPath").value = foldername[0];
|
||||
// Change process directory
|
||||
process.chdir(foldername[0]);
|
||||
}
|
||||
console.log("currentdir",process.cwd());
|
||||
});
|
||||
// Catch calls for save as
|
||||
ipcRenderer.on('saveFile', function(event, filename) {
|
||||
@@ -263,8 +271,11 @@
|
||||
// Catch clicks for Browse button
|
||||
let browseBtn = document.getElementById('browseFolde');
|
||||
ipcRenderer.on('browseFolder', function(event, foldername) {
|
||||
document.getElementById("workPath").value = foldername;
|
||||
console.log("foldername="+foldername);
|
||||
if (foldername.length != 0) {
|
||||
document.getElementById("workPath").value = foldername[0];
|
||||
// Change process directory
|
||||
process.chdir(foldername[0]);
|
||||
}
|
||||
});
|
||||
|
||||
// Get the element with id="defaultOpen" and click on it
|
||||
|
||||
@@ -853,7 +853,7 @@ function CreateInpFile(All) {
|
||||
let rho = 1*All[Lrho];
|
||||
|
||||
// How to do this? All[Lrho]=sprintf("%6.2f",rho);
|
||||
if (rho=="") {Check++;console.log("rho",rho);}
|
||||
if (rho=="") {Check++;}
|
||||
|
||||
// Thickness of layers
|
||||
let Ld ="L"+i+"d";
|
||||
@@ -876,7 +876,6 @@ function CreateInpFile(All) {
|
||||
Sum=Sum+LElComp[key];
|
||||
}
|
||||
if (Sum==0) {Sum=1;}
|
||||
console.log("Sum=",Sum);
|
||||
|
||||
let Els = Object.keys(LElComp);
|
||||
|
||||
|
||||
11
main.js
11
main.js
@@ -1,5 +1,4 @@
|
||||
const { app, BrowserWindow, Menu, dialog, ipcMain, fs } = require('electron');
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 950,
|
||||
@@ -14,7 +13,7 @@ function createWindow () {
|
||||
})
|
||||
|
||||
|
||||
const template = [
|
||||
let template = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
@@ -24,7 +23,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showOpenDialog(win,
|
||||
{ title : "Load configuration file",
|
||||
defaultPath : "./",
|
||||
//defaultPath : "./",
|
||||
//buttonLabel : "Custom button",
|
||||
filters :[
|
||||
{name: 'Config file type', extensions: ['cfg']},
|
||||
@@ -48,7 +47,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showOpenDialog(win,
|
||||
{ title: "Select folder",
|
||||
defaultPath : "./",
|
||||
//defaultPath : "./",
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
console.log(result.filePaths)
|
||||
@@ -73,7 +72,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showSaveDialog(win,
|
||||
{ title : "Save configuration file",
|
||||
defaultPath : "./",
|
||||
//defaultPath : "./",
|
||||
filters :[
|
||||
{name: 'Config file type', extensions: ['cfg']},
|
||||
{name: 'All Files', extensions: ['*']}
|
||||
@@ -226,7 +225,7 @@ app.on('activate', () => {
|
||||
// Reply to calls from browser button
|
||||
ipcMain.on('browseFolder', (event) => {
|
||||
dialog.showOpenDialog({ title: "Select folder",
|
||||
defaultPath : "./",
|
||||
//defaultPath : "./",
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
console.log(result.filePaths)
|
||||
|
||||
Reference in New Issue
Block a user