diff --git a/src/main.js b/src/main.js
index 51b4242..7fdc6db 100644
--- a/src/main.js
+++ b/src/main.js
@@ -6,12 +6,28 @@ const { app, ipcMain, BrowserWindow } = require('electron')
const Window = require('./Window')
const DataStore = require('./DataStore')
const electronLocalshortcut = require('electron-localshortcut');
+const commandExists = require('command-exists');
+const { execSync } = require('child_process')
+const exec = require('child_process').exec;
require('electron-reload')(process.cwd())
// create a new todo store name "Todos Main"
const todosData = new DataStore({ name: 'Todos Main' })
+function getPythonInterpreter() {
+ var result = undefined;
+ var found = commandExists.sync('python3')
+ || commandExists.sync('python')
+ || commandExists.sync('python');
+ if (found) {
+ result = execSync("python -c 'import sys; print(sys.executable)'")
+ }
+
+ console.log('Returning: '.concat(result));
+ return result;
+}
+
function main () {
// todo list window
let mainWindow = new Window({
@@ -30,6 +46,14 @@ function main () {
mainWindow.webContents.send('todos', todosData.todos)
})
+ ipcMain.on('get-sys-cfg-jupyter-lab', (event) => {
+ console.log('get-sys-cfg-jupyter-lab() called')
+ var resp = (
+ getPythonInterpreter()
+ );
+ event.sender.send('asynchronous-reply', resp);
+ });
+
// create add todo window
ipcMain.on('open-url-window', () => {
// if addTodoWin does not already exist
diff --git a/src/package-lock.json b/src/package-lock.json
index 16dba4f..d938476 100644
--- a/src/package-lock.json
+++ b/src/package-lock.json
@@ -514,6 +514,11 @@
"delayed-stream": "~1.0.0"
}
},
+ "command-exists": {
+ "version": "1.2.9",
+ "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz",
+ "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w=="
+ },
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
diff --git a/src/package.json b/src/package.json
index 4e86868..d59cdbc 100644
--- a/src/package.json
+++ b/src/package.json
@@ -19,6 +19,7 @@
"standard": "^12.0.1"
},
"dependencies": {
+ "command-exists": "^1.2.9",
"electron": "^3.0.4",
"electron-localshortcut": "^3.2.1",
"electron-reload": "^1.2.5",
diff --git a/src/renderer/new_server/advanceduser.html b/src/renderer/new_server/advanceduser.html
index 7ca0338..9337574 100644
--- a/src/renderer/new_server/advanceduser.html
+++ b/src/renderer/new_server/advanceduser.html
@@ -11,7 +11,7 @@
@@ -22,19 +22,22 @@
Advanced configuration
+
+
rescan
+
@@ -42,6 +45,12 @@
Advanced configuration
+
+
diff --git a/src/renderer/new_server/advanceduser.js b/src/renderer/new_server/advanceduser.js
index 0b31196..c85c370 100644
--- a/src/renderer/new_server/advanceduser.js
+++ b/src/renderer/new_server/advanceduser.js
@@ -2,16 +2,96 @@
const { ipcRenderer } = require('electron')
const electron = require('electron')
-const path = require('path')
-const remote = electron.remote
+const remote = electron.remote;
+const app = remote.app;
+
+function updateUI(pythonInterpreterPath) {
+ console.log(pythonInterpreterPath);
+ document.getElementById('pythonInterpreterPath').value = pythonInterpreterPath;
+ document.getElementById('initialPath').value = app.getPath('home');
+}
+
+function getAndUpdateJLabCfg() {
+ return new Promise(resolve => {
+ ipcRenderer.send('get-sys-cfg-jupyter-lab', [])
+ ipcRenderer.on('asynchronous-reply', (event, result) => {
+ updateUI(result);
+ })
+ });
+}
+
+function focusFieldWithError(fieldId) {
+ switch (fieldId) {
+ case 1:
+ document.getElementById('pythonInterpreterPath').focus();
+ break;
+ case 2:
+ document.getElementById('initialPath').focus();
+ break;
+ case 2:
+ document.getElementById('portNum').focus();
+ break;
+ default:
+ console.warn('Unknown value ' + fieldId.toString())
+ break;
+ }
+}
+
+function displayMsg(type, msg) {
+ var resultElem = document.getElementById('resultBox');
+ if (type == 'error') {
+ console.error(msg);
+ resultElem.innerHTML = `
${msg}`
+ } else if (type == 'info') {
+ console.info(msg);
+ resultElem.innerHTML = `
${msg}`
+ }
+}
+
+// 0 = No issue
+// [1-] = First field id that is wrong
+function checkValues() {
+ var result = 0;
+
+ // Check the port number
+ var portNumStr = document.getElementById('portNum').value;
+ var portNum = parseInt(portNumStr);
+
+ if (isNaN(portNum) || portNum > 65535) {
+ console.warn('Cannot parse port number: ' + portNumStr);
+ displayMsg('error', `Port number ${portNumStr} is invalid.`);
+ result = 3;
+ } else {
+ console.log('using port ' + portNumStr + ' ' + portNum.toString());
+ }
+
+ return result;
+}
+
+function startServer() {
+ var retVal = checkValues();
+ if (retVal != 0) {
+ focusFieldWithError(retVal);
+ } else {
+ displayMsg('info', 'Everything looks good');
+ }
+}
document.getElementById('backBtn').addEventListener('click', (evt) => {
var window = remote.getCurrentWindow();
- window.webContents.goBack()
+ window.webContents.goBack();
})
document.getElementById('cancelBtn').addEventListener('click', (evt) => {
var window = remote.getCurrentWindow();
- window.close()
+ window.close();
+})
+
+document.getElementById('submitBtn').addEventListener('click', (evt) => {
+ startServer();
+})
+
+document.getElementById('refillBtn').addEventListener('click', (evt) => {
+ getAndUpdateJLabCfg();
})
\ No newline at end of file
diff --git a/src/renderer/new_server/newserver.css b/src/renderer/new_server/newserver.css
index 5a9dd5d..ceb55e6 100644
--- a/src/renderer/new_server/newserver.css
+++ b/src/renderer/new_server/newserver.css
@@ -12,6 +12,16 @@ body {
padding-bottom: 1%;
}
+.result-box {
+ font-size: small;
+ text-align: left;
+ position:absolute;
+ bottom:0;
+ left:0;
+ padding-left: 3%;
+ padding-bottom: 1%;
+}
+
.msg {
margin-top: 6%;
text-align: center;
@@ -27,12 +37,36 @@ body {
padding-right: 3%;
}
+.refill-btn {
+ margin-left: 0;
+ padding-left: 0;
+ margin-right: 1%;
+ /* float: right; */
+}
+
+.refill-btn-tool-tip {
+ margin-left: 0;
+ display:inline-block;
+ /* vertical-align: bottom; */
+ font-size: smaller;
+ opacity: 0;
+}
+
+.refill-btn:hover + .refill-btn-tool-tip {
+ opacity: 1;
+ transition-delay: 0.3s;
+}
+
+.refill-btn-tool-tip {
+}
+
.advanced-config-btn-grp {
+ display: inline;
margin-top: 7%;
}
.form-inline-link-div {
- width: 15%;
+ width: 8%;
display: flex;
justify-content: center;
}
@@ -46,6 +80,10 @@ body {
padding-bottom: 10%;
}
+#advanced-config-header-txt {
+ display: inline;
+}
+
.no-top-padding {
padding-top: 0%;
}
diff --git a/src/renderer/new_server/newserver.js b/src/renderer/new_server/newserver.js
index c3fe6e6..d3b0200 100644
--- a/src/renderer/new_server/newserver.js
+++ b/src/renderer/new_server/newserver.js
@@ -11,3 +11,4 @@ document.getElementById('advancedUser').addEventListener('click', (evt) => {
console.log(filePath);
remote.getCurrentWindow().loadFile(filePath);
})
+