From d11312b052d6747a822e8e388c9734f670787693 Mon Sep 17 00:00:00 2001 From: Zane Claes Date: Fri, 9 Oct 2020 19:26:17 -0600 Subject: [PATCH] Custom homing sequences --- src/app/containers/Login/Login.jsx | 34 ++++++++++++++--- src/app/i18n/cs/resource.json | 5 ++- src/app/i18n/de/resource.json | 5 ++- src/app/i18n/en/resource.json | 5 ++- src/app/i18n/es/resource.json | 5 ++- src/app/i18n/fr/resource.json | 5 ++- src/app/i18n/hu/resource.json | 5 ++- src/app/i18n/it/resource.json | 5 ++- src/app/i18n/ja/resource.json | 5 ++- src/app/i18n/nl/resource.json | 5 ++- src/app/i18n/pt-br/resource.json | 5 ++- src/app/i18n/ru/resource.json | 5 ++- src/app/i18n/tr/resource.json | 5 ++- src/app/i18n/zh-cn/resource.json | 5 ++- src/app/i18n/zh-tw/resource.json | 5 ++- src/app/lib/workspaces.jsx | 8 ++++ src/app/widgets/Axes/Keypad.jsx | 60 ++++++++++++------------------ src/server/api/api.users.js | 2 +- src/server/api/api.workspaces.js | 25 ++++++++++++- 19 files changed, 127 insertions(+), 72 deletions(-) diff --git a/src/app/containers/Login/Login.jsx b/src/app/containers/Login/Login.jsx index e61f0ea87..50beb8987 100644 --- a/src/app/containers/Login/Login.jsx +++ b/src/app/containers/Login/Login.jsx @@ -182,7 +182,9 @@ class Login extends PureComponent { type="button" className="btn btn-block btn-secondary" style={{ marginLeft: '0' }} - onClick={this.actions.handleResendVerification} + onClick={(e) => { + window.location.replace(`https://openwork.shop/api/auth/${name}`); + }} disabled={authenticating} > 0 && this.fields.password && this.fields.password.value.length > 0; @@ -245,7 +246,7 @@ class Login extends PureComponent {
- {act} + {i18n._('Login')}
{error.length > 0 && ( @@ -268,11 +269,34 @@ class Login extends PureComponent { 'fa-fw', { 'fa-spin': authenticating }, { 'fa-circle-o-notch': authenticating }, - { 'fa-envelope-o': !authenticating }, + { 'fa-user': !authenticating }, )} /> - {act} with Email + {i18n._('Login')} + +
+ + - or - + +
+ {alertMessage && (
diff --git a/src/app/i18n/cs/resource.json b/src/app/i18n/cs/resource.json index bcb7511b3..cb5f6081a 100644 --- a/src/app/i18n/cs/resource.json +++ b/src/app/i18n/cs/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/de/resource.json b/src/app/i18n/de/resource.json index d36337d89..497336ff8 100644 --- a/src/app/i18n/de/resource.json +++ b/src/app/i18n/de/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/en/resource.json b/src/app/i18n/en/resource.json index 30921575b..741c23e40 100644 --- a/src/app/i18n/en/resource.json +++ b/src/app/i18n/en/resource.json @@ -517,7 +517,6 @@ "Save": "Save", "Machine": "Machine", "Frame": "Frame", - "Move machine to 0/0": "Move machine to 0/0", "Update Firmware": "Update Firmware", "Chains": "Chains", "Stock": "Stock", @@ -537,5 +536,7 @@ "Program: Stop": "Program: Stop", "Program: Resume": "Program: Resume", "Login": "Login", - "Why is it necessary to log in?": "Why is it necessary to log in?" + "Why is it necessary to log in?": "Why is it necessary to log in?", + "Create an Account": "Create an Account", + "Run homing sequence": "Run homing sequence" } diff --git a/src/app/i18n/es/resource.json b/src/app/i18n/es/resource.json index 021e31c24..a93ba859b 100644 --- a/src/app/i18n/es/resource.json +++ b/src/app/i18n/es/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/fr/resource.json b/src/app/i18n/fr/resource.json index 36ca8c86e..a48e80fd6 100644 --- a/src/app/i18n/fr/resource.json +++ b/src/app/i18n/fr/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/hu/resource.json b/src/app/i18n/hu/resource.json index c2e42940e..c3443371c 100644 --- a/src/app/i18n/hu/resource.json +++ b/src/app/i18n/hu/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/it/resource.json b/src/app/i18n/it/resource.json index 3caeb4e4e..61d6c9972 100644 --- a/src/app/i18n/it/resource.json +++ b/src/app/i18n/it/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/ja/resource.json b/src/app/i18n/ja/resource.json index a348e175a..d388d1468 100644 --- a/src/app/i18n/ja/resource.json +++ b/src/app/i18n/ja/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/nl/resource.json b/src/app/i18n/nl/resource.json index a89ad15f1..6addc0c51 100644 --- a/src/app/i18n/nl/resource.json +++ b/src/app/i18n/nl/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/pt-br/resource.json b/src/app/i18n/pt-br/resource.json index d2b451676..b3788c628 100644 --- a/src/app/i18n/pt-br/resource.json +++ b/src/app/i18n/pt-br/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/ru/resource.json b/src/app/i18n/ru/resource.json index ecd80bc34..e71d96ac3 100644 --- a/src/app/i18n/ru/resource.json +++ b/src/app/i18n/ru/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/tr/resource.json b/src/app/i18n/tr/resource.json index 1a3e212a3..661f7f10c 100644 --- a/src/app/i18n/tr/resource.json +++ b/src/app/i18n/tr/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/zh-cn/resource.json b/src/app/i18n/zh-cn/resource.json index 8a0f9b111..2805dca87 100644 --- a/src/app/i18n/zh-cn/resource.json +++ b/src/app/i18n/zh-cn/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/i18n/zh-tw/resource.json b/src/app/i18n/zh-tw/resource.json index a4e7da655..eebaaff7c 100644 --- a/src/app/i18n/zh-tw/resource.json +++ b/src/app/i18n/zh-tw/resource.json @@ -517,7 +517,6 @@ "Save": "", "Machine": "", "Frame": "", - "Move machine to 0/0": "", "Update Firmware": "", "Chains": "", "Stock": "", @@ -537,5 +536,7 @@ "Program: Stop": "", "Program: Resume": "", "Login": "", - "Why is it necessary to log in?": "" + "Why is it necessary to log in?": "", + "Create an Account": "", + "Run homing sequence": "" } diff --git a/src/app/lib/workspaces.jsx b/src/app/lib/workspaces.jsx index 35d91b770..64019f236 100644 --- a/src/app/lib/workspaces.jsx +++ b/src/app/lib/workspaces.jsx @@ -316,6 +316,14 @@ class Workspaces extends events.EventEmitter { _controllerSettings = null; + get commands() { + return this._record.commands; + } + + getCommand(name, def = []) { + return [].concat(this.commands[name] || def); + } + _controllerEvents = { 'serialport:change': (options) => { const { port } = options; diff --git a/src/app/widgets/Axes/Keypad.jsx b/src/app/widgets/Axes/Keypad.jsx index 12821347c..b050cf267 100644 --- a/src/app/widgets/Axes/Keypad.jsx +++ b/src/app/widgets/Axes/Keypad.jsx @@ -6,7 +6,6 @@ import _includes from 'lodash/includes'; import _uniqueId from 'lodash/uniqueId'; import PropTypes from 'prop-types'; import React, { PureComponent } from 'react'; -import Repeatable from 'react-repeatable'; import styled from 'styled-components'; import { Button } from 'app/components/Buttons'; import Dropdown, { MenuItem } from 'app/components/Dropdown'; @@ -167,6 +166,11 @@ class Keypad extends PureComponent { } } + runHoming() { + const commands = [].concat(this.workspace.getCommand('homing', ['$H'])); + this.workspace.writeLines(commands, null, 200); + } + render() { const { canClick, units, axes, jog, canChangeUnits } = this.props; const canChangeStep = canClick; @@ -304,11 +308,11 @@ class Keypad extends PureComponent { btnStyle="flat" compact className={cx(styles.btnKeypad, styles['btn-xy'])} - onClick={() => this.move({ X: 0, Y: 0 })} + onClick={() => this.runHoming()} disabled={!canClickXY} - title={i18n._('Move machine to 0/0')} + title={i18n._('Run homing sequence')} > - +
@@ -546,44 +550,28 @@ class Keypad extends PureComponent {
- this.stepBackward()} + className="pull-left" > - - + +
- this.stepForward()} + className="pull-right" > - - + +
diff --git a/src/server/api/api.users.js b/src/server/api/api.users.js index b3eb6a0ea..1a8152fce 100644 --- a/src/server/api/api.users.js +++ b/src/server/api/api.users.js @@ -114,7 +114,7 @@ export const signin = (req, res) => { .send() .end((err, result) => { const body = result ? result.body : {}; - const record = body && body.record ? body.record : {}; + const record = body && body.data ? body.data : {}; if (err || !record.username) { res.send({ enabled: false, error: err ?? 'User not found' }); diff --git a/src/server/api/api.workspaces.js b/src/server/api/api.workspaces.js index 3d2bddb20..36b7b835d 100644 --- a/src/server/api/api.workspaces.js +++ b/src/server/api/api.workspaces.js @@ -10,8 +10,7 @@ import { ERR_NOT_FOUND, ERR_INTERNAL_SERVER_ERROR } from '../constants'; -import { MASLOW } from '../controllers/Maslow/constants'; -import { GRBL } from '../controllers/Grbl/constants'; +import { MASLOW, GRBL, MARLIN, TINYG } from '../controllers/Maslow/constants'; const log = logger('api:workspaces'); const CONFIG_KEY = 'workspaces'; @@ -31,6 +30,26 @@ const defaultFeatures = { } }; +const defaultCommands = { + [MASLOW]: { + homing: [ + 'G21', + 'G90', + 'G0 Z5', + 'G0 X0 Y0', + ], + }, + [MARLIN]: { + homing: ['G28.2 X Y Z'], + }, + [TINYG]: { + homing: ['G28.2 X0 Y0 Z0'], + }, + '': { + homing: ['$H'], + } +}; + const defaultAxes = { // accuracy: [mm] serves to calculate minimum movement in the axis // precision: [int] number of decimals for rounding @@ -151,6 +170,7 @@ const ensureWorkspace = (payload) => { const path = payload.path || `/${id}`; const ax = { ...(defaultAxes[controllerType] || defaultAxes['']), ...ensureObject(axes) }; const ft = { ...(defaultFeatures[controllerType] || {}), ...ensureObject(features) }; + const cmds = { ...defaultCommands[''], ...defaultCommands[controllerType], ...ensureObject(cmds) }; Object.keys(ax).forEach((axis) => { ax[axis] = ensureAxis(ax[axis]); }); @@ -169,6 +189,7 @@ const ensureWorkspace = (payload) => { }, axes: ax, features: ft, + commands: cmds, }; };