diff --git a/app-el.js b/app-el.js index 4f6a84ab..0a34d466 100644 --- a/app-el.js +++ b/app-el.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron'); +const { app, shell, BrowserWindow } = require('electron'); const path = require('path'); const server = require('@gridspace/app-server'); @@ -8,8 +8,8 @@ const appDir = path.join(usrDir, 'gapp'); const cnfDir = path.join(appDir, 'conf'); const logDir = path.join(appDir, 'logs'); const datDir = path.join(appDir, 'data'); -const debug = process.argv.slice(2).map(v => v.replaceAll('-','')).contains('debugg'); -const devel = process.argv.slice(2).map(v => v.replaceAll('-','')).contains('devel'); +const debug = process.argv.slice(2).map(v => v.replaceAll('-', '')).contains('debugg'); +const devel = process.argv.slice(2).map(v => v.replaceAll('-', '')).contains('devel'); // console.log({ appDir, usrDir, logDir, datDir, basDir }); // console.log({ argv: process.argv, debug, devel }); @@ -21,12 +21,13 @@ const devel = process.argv.slice(2).map(v => v.replaceAll('-','')).contains('dev // }); server({ - single: true, + port: 5309, apps: basDir, data: datDir, conf: cnfDir, logs: logDir, - cache: path.join(basDir,"data","cache"), + cache: path.join(basDir, "data", "cache"), + single: true, electron: true, debug }); @@ -40,7 +41,12 @@ function createWindow() { } }); - mainWindow.loadURL('http://localhost:8080/kiri'); + mainWindow.loadURL('http://localhost:5309/kiri'); + + mainWindow.webContents.setWindowOpenHandler((details) => { + shell.openExternal(details.url); + return { action: 'deny' } + }); if (devel) { console.log("opening developer tools"); @@ -49,11 +55,13 @@ function createWindow() { } app.on('ready', createWindow); + app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } }); + app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 1262ee7f..f4de5f4e 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -1688,12 +1688,13 @@ function createPopOp(type, map) { const { divid, noteid } = op.note; const div = $(divid); if (div) div.onclick = () => { - let note = op.x = prompt('Edit Note for Operation', poppedRec.note || ''); - if (note !== undefined && note !== null) { - $(noteid).innerText = poppedRec.note = note; - API.conf.save(); - } - func.opRender(); + API.uc.prompt('Edit Note for Operation', poppedRec.note || '').then(note => { + if (note !== undefined && note !== null) { + poppedRec.note = op.x = note; + API.conf.save(); + } + func.opRender(); + }); }; const note = $(noteid); if (note) note.innerText = poppedRec.note || ''; diff --git a/src/kiri/init.js b/src/kiri/init.js index 6a77e3a1..b488c8c8 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -537,13 +537,14 @@ gapp.register("kiri.init", [], (root, exports) => { api.show.alert("select object to rotate"); return; } - let coord = (prompt("Enter X,Y,Z degrees of rotation") || '').split(','), - prod = Math.PI / 180, - x = parseFloat(coord[0] || 0.0) * prod, - y = parseFloat(coord[1] || 0.0) * prod, - z = parseFloat(coord[2] || 0.0) * prod; - - api.selection.rotate(x, y, z); + api.uc.prompt("Enter X,Y,Z degrees of rotation","").then(coord => { + coord = (coord || '').split(','); + let prod = Math.PI / 180, + x = parseFloat(coord[0] || 0.0) * prod, + y = parseFloat(coord[1] || 0.0) * prod, + z = parseFloat(coord[2] || 0.0) * prod; + api.selection.rotate(x, y, z); + }); } function positionSelection() { @@ -554,18 +555,21 @@ gapp.register("kiri.init", [], (root, exports) => { let current = settings(), { device, process} = current, center = process.ctOriginCenter || process.camOriginCenter || device.bedRound || device.originCenter, - bounds = boundsSelection(), - coord = prompt("Enter X,Y coordinates for selection").split(','), - x = parseFloat(coord[0] || 0.0), - y = parseFloat(coord[1] || 0.0), - z = parseFloat(coord[2] || 0.0); + bounds = boundsSelection(); - if (!center) { - x = x - device.bedWidth/2 + (bounds.max.x - bounds.min.x)/2; - y = y - device.bedDepth/2 + (bounds.max.y - bounds.min.y)/2 - } + api.uc.prompt("Enter X,Y coordinates for selection","").then(coord => { + coord = (coord || '').split(','); + let x = parseFloat(coord[0] || 0.0), + y = parseFloat(coord[1] || 0.0), + z = parseFloat(coord[2] || 0.0); - api.selection.move(x, y, z, true); + if (!center) { + x = x - device.bedWidth/2 + (bounds.max.x - bounds.min.x)/2; + y = y - device.bedDepth/2 + (bounds.max.y - bounds.min.y)/2 + } + + api.selection.move(x, y, z, true); + }); } function deviceExport(exp, name) { @@ -1018,8 +1022,14 @@ gapp.register("kiri.init", [], (root, exports) => { showDevices(); }; ui.deviceRename.onclick = function() { - const newname = prompt(`Rename "${selected}`, selected); - if (newname) updateDeviceName(newname); + api.uc.prompt(`Rename "${selected}`, selected).then(newname => { + if (newname) { + updateDeviceName(newname); + showDevices(); + } else { + showDevices(); + } + }); }; ui.deviceExport.onclick = function(event) { const record = { @@ -1430,12 +1440,13 @@ gapp.register("kiri.init", [], (root, exports) => { renm.setAttribute('title', 'rename file'); renm.innerHTML = ''; renm.onclick = () => { - let newname = prompt(`rename file`, short); - if (newname && newname !== short) { - catalog.rename(name, `${newname}${ext}`, then => { - catalog.refresh(); - }); - } + api.uc.prompt(`rename file`, short).then(newname => { + if (newname && newname !== short) { + catalog.rename(name, `${newname}${ext}`, then => { + api.modal.show('files'); + }); + } + }); }; load.setAttribute('load', name); diff --git a/src/kiri/main.js b/src/kiri/main.js index 9a84ddbf..eef00a9e 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -687,19 +687,22 @@ gapp.register("kiri.main", [], (root, exports) => { mode = getMode(), name = e.target.getAttribute("name"), load = current.sproc[mode][name], - edit = prompt(`settings for "${name}"`, JSON.stringify(load)); - if (edit) { - try { - current.sproc[mode][name] = JSON.parse(edit); - if (name === current.proc().processName) { - api.conf.load(null, name); + loadstr = JSON.stringify(load,null,4).split('\n'); + UC.prompt(`settings for "${name}"`, loadstr).then(edit => { + if (edit) { + try { + current.sproc[mode][name] = JSON.parse(edit); + if (name === settings.proc().processName) { + api.conf.load(null, name); + } + api.conf.save(); + api.settings.sync.put(); + } catch (e) { + console.log({ malformed_settings: e }); + UC.alert('malformed settings object'); } - api.conf.save(); - api.settings.sync.put(); - } catch (e) { - UC.alert('malformed settings object'); } - } + }); } function exportSettings(e) { diff --git a/src/kiri/ui.js b/src/kiri/ui.js index ff393bf1..adf49b14 100644 --- a/src/kiri/ui.js +++ b/src/kiri/ui.js @@ -111,9 +111,12 @@ gapp.register("kiri.ui", [], (root, exports) => { html = opt.pre.appendAll(html); } let iid; - if (input !== undefined) { + if (typeof(input) === 'string') { iid = `confirm-input-${rnd}`; - html.append(`
`); + html.append(``); + } else if (Array.isArray(input)) { + iid = `confirm-input-${rnd}`; + html.append(``); } html.append(`