add better 404 logging. ui localization fixes

This commit is contained in:
Stewart Allen 2020-03-20 20:56:24 -04:00
commit 5659bc74b6
4 changed files with 74 additions and 15 deletions

View file

@ -1437,6 +1437,16 @@ var gs_kiri_init = exports;
gcodePauseLayers: UC.newInput(LANG.ag_paws_s, {title:LANG.ag_paws_l, modes:FDM, expert:true})
});
if (!lang_set) {
// for english only, add underlined labels for hotkeys
UI.setupDevices.innerHTML = "D<u>e</u>vices";
UI.setupTools.innerHTML = "T<u>o</u>ols";
UI.modeArrange.innerHTML = "<u>A</u>rrange";
UI.modeSlice.innerHTML = "<u>S</u>lice";
UI.modePreview.innerHTML = "<u>P</u>review";
UI.modeExport.innerHTML = "E<u>x</u>port";
}
SPACE.addEventHandlers(self, [
'keyup', keyUpHandler,
'keydown', keyDownHandler,
@ -1464,14 +1474,6 @@ var gs_kiri_init = exports;
UI.toolTaperTip, updateTool,
]);
UI.setupDevices.innerHTML = "D<u>e</u>vices";
UI.setupTools.innerHTML = "T<u>o</u>ols";
UI.modeArrange.innerHTML = "<u>A</u>rrange";
UI.modeSlice.innerHTML = "<u>S</u>lice";
UI.modePreview.innerHTML = "<u>P</u>review";
UI.modeExport.innerHTML = "E<u>x</u>port";
UI.layerID.convert = UC.toFloat.bind(UI.layerID);
UI.layerSpan.convert = UC.toFloat.bind(UI.layerSpan);
UI.layerRange.onclick = function() {

View file

@ -189,7 +189,8 @@ THREE.Face3.prototype.mVisible = function(show) {
specular: 0x111111,
transparent: true,
shininess: 100,
opacity: 0.8
opacity: 0.8,
depthFunc: THREE.LessDepth
}).motoSetup(),
faceMaterialSlide = new THREE.MeshPhongMaterial({
side:THREE.DoubleSide,
@ -227,7 +228,8 @@ THREE.Face3.prototype.mVisible = function(show) {
color: 0x0,
opacity: 0.75,
transparent: true,
side: THREE.DoubleSide
side: THREE.DoubleSide,
depthFunc: THREE.LessDepth
}).motoSetup(),
// ---------------
UI = {},
@ -730,6 +732,9 @@ THREE.Face3.prototype.mVisible = function(show) {
case cca('x'):
downloadSelection();
break;
case cca('X'):
downloadSelection2()
break;
case cca('1'): // toggle control left
if (evt.ctrlKey) {
style = ctrlLeft.style;
@ -1325,7 +1330,7 @@ THREE.Face3.prototype.mVisible = function(show) {
// mark inside if adjacent to cube that has no mesh
face.inside = adj && !adjm;
cube.setFaceMaterial(face.set.mi, mat);
cube.showFace(face.set.mi, !mesh && (mark || sel || !face.inside));
cube.showFace(face.set.mi, !face.inside && (!mesh || mark || sel));
}
SPACE.update();
};
@ -1599,6 +1604,41 @@ THREE.Face3.prototype.mVisible = function(show) {
return {vertices: vertices, normals: null};
}
function selectionToGeometry2(scale) {
let vertices = [],
normals = [],
i = 0, cube, j, k, face, pos, off, fix, arr;
selected.forEach(cube => {
FACES.forEach(face_key => {
let cube_face = cube.faces[face_key];
let face_adj = cube.adjacentCube(cube_face) ? 1 : 0;
console.log(cube.key, face_key, face_adj);
});
});
while (i < selected.length) {
cube = selected[i++];
pos = cube.pos;
if (cube.mesh) {
let k = 0, arr = cube.mesh.geometry.attributes.position.array;
while (k < arr.length) {
vertices.push(arr[k++] + pos.x);
vertices.push(arr[k++] + pos.y);
vertices.push(arr[k++] + pos.z);
}
continue;
}
}
if (scale) {
for (i = 0; i < vertices.length; i++) {
vertices[i] *= scale;
}
}
return {vertices: vertices, normals: null};
}
function unitsToMM(units) {
let num = parseFloat(units),
scale = 10.0;
@ -1679,6 +1719,17 @@ THREE.Face3.prototype.mVisible = function(show) {
save = saveAs(blob, name+".stl");
}
function downloadSelection2() {
// if (selected.length === 0) return alert("make a selection to export");
// let name = prompt("Download Name", spaceName);
// if (!name) return;
let scale = unitsToMM(spaceUnits),
geo = selectionToGeometry2(scale);//,
// stl = new moto.STL().encode(geo.vertices, geo.normals),
// blob = new Blob([stl], {type: 'application/octet-binary'}),
// save = saveAs(blob, name+".stl");
}
function selectAll() {
selected = [];
for (let i = 0; i < selectable.length; i++) {

View file

@ -285,7 +285,12 @@ function quickReply(res, code, msg) {
* @param {Object} res
*/
function reply404(req, res) {
log({"404":req.url, ip:req.gs.ip});
logger.emit([
'404',
req.url,
req.socket.remoteAddress,
req.headers
]);
res.writeHead(404);
res.end("[404]");
}
@ -386,7 +391,7 @@ function setup(req, res, next) {
// log request
logger.emit([
req.method,
req.headers['host'],
req.headers['host'] || '',
req.url,
req.socket.remoteAddress,
req.headers['origin'] || '',
@ -1272,6 +1277,7 @@ handler.use(fullpath({
.use(fixedmap("/api/", api))
.use(compression)
.use(handleStatic(currentDir + "/web/"))
.use(reply404)
.listen(port)
.on('upgrade', (request, socket, head) => {
let handler = wss_roots[request.url];

View file

@ -31,7 +31,7 @@
"connect": "^3.7.0",
"earcut": "^2.2.2",
"express-useragent": "^1.0.13",
"level": "^6.0.0",
"level": "^6.0.1",
"leveldown": "^5.5.1",
"levelup": "^4.3.2",
"moment": "^2.24.0",
@ -41,6 +41,6 @@
"tween.js": "^0.14.0",
"uglify-es": "^3.3.10",
"validator": "^8.2.0",
"ws": "^7.2.1"
"ws": "^7.2.3"
}
}