@wandelbots/wandelbots-js-react-components 1.16.0 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LoadingCover.d.ts +4 -0
- package/dist/components/LoadingCover.d.ts.map +1 -1
- package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
- package/dist/components/jogging/JoggingStore.d.ts +11 -2
- package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1501 -1477
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/LoadingCover.tsx +13 -4
- package/src/components/jogging/JoggingPanel.tsx +20 -5
- package/src/components/jogging/JoggingStore.tsx +19 -2
- package/src/i18n/locales/de/translations.json +3 -1
- package/src/i18n/locales/en/translations.json +3 -1
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { makeErrorMessage } from "./utils/errorHandling"
|
|
2
|
-
import { CircularProgress, Stack, useTheme } from "@mui/material"
|
|
2
|
+
import { capitalize, CircularProgress, Stack, useTheme } from "@mui/material"
|
|
3
|
+
import { lowerFirst } from "lodash-es"
|
|
3
4
|
import { useEffect, useState } from "react"
|
|
4
5
|
|
|
5
6
|
export const LoadingCover = (props: {
|
|
@@ -27,7 +28,10 @@ export const LoadingCover = (props: {
|
|
|
27
28
|
justifyContent="center"
|
|
28
29
|
>
|
|
29
30
|
{props.error ? (
|
|
30
|
-
<LoadingErrorMessage
|
|
31
|
+
<LoadingErrorMessage
|
|
32
|
+
loadingMessage={props.message}
|
|
33
|
+
error={props.error}
|
|
34
|
+
/>
|
|
31
35
|
) : (
|
|
32
36
|
<>
|
|
33
37
|
<CircularProgress sx={{ marginBottom: "24px" }} />
|
|
@@ -47,7 +51,10 @@ export const LoadingCover = (props: {
|
|
|
47
51
|
)
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
const LoadingErrorMessage = (props: {
|
|
54
|
+
export const LoadingErrorMessage = (props: {
|
|
55
|
+
loadingMessage?: string
|
|
56
|
+
error: unknown
|
|
57
|
+
}) => {
|
|
51
58
|
const errorMessage = makeErrorMessage(props.error)
|
|
52
59
|
const stack = props.error instanceof Error ? props.error.stack : null
|
|
53
60
|
const theme = useTheme()
|
|
@@ -67,7 +74,9 @@ const LoadingErrorMessage = (props: { message?: string; error: unknown }) => {
|
|
|
67
74
|
},
|
|
68
75
|
}}
|
|
69
76
|
>
|
|
70
|
-
{
|
|
77
|
+
{(props.loadingMessage
|
|
78
|
+
? `Error while ${lowerFirst(capitalize(props.loadingMessage))} - `
|
|
79
|
+
: "") + errorMessage}
|
|
71
80
|
<br />
|
|
72
81
|
{stack && <pre>{stack}</pre>}
|
|
73
82
|
</Stack>
|
|
@@ -11,6 +11,7 @@ import { NovaClient } from "@wandelbots/wandelbots-js"
|
|
|
11
11
|
import { externalizeComponent } from "../../externalizeComponent"
|
|
12
12
|
import { isString } from "lodash-es"
|
|
13
13
|
import { useReaction } from "../utils/hooks"
|
|
14
|
+
import { useTranslation } from "react-i18next"
|
|
14
15
|
|
|
15
16
|
export type JoggingPanelProps = {
|
|
16
17
|
/** Either an existing NovaClient or the base url of a deployed Nova instance */
|
|
@@ -30,6 +31,8 @@ export type JoggingPanelProps = {
|
|
|
30
31
|
*/
|
|
31
32
|
export const JoggingPanel = externalizeComponent(
|
|
32
33
|
observer((props: JoggingPanelProps) => {
|
|
34
|
+
const { t } = useTranslation()
|
|
35
|
+
|
|
33
36
|
const nova = isString(props.nova)
|
|
34
37
|
? new NovaClient({ instanceUrl: props.nova })
|
|
35
38
|
: props.nova
|
|
@@ -116,12 +119,24 @@ const JoggingPanelInner = observer(
|
|
|
116
119
|
store: JoggingStore
|
|
117
120
|
children?: React.ReactNode
|
|
118
121
|
}) => {
|
|
122
|
+
const { t } = useTranslation()
|
|
123
|
+
|
|
119
124
|
// Jogger is only active as long as the tab is focused
|
|
120
125
|
useEffect(() => {
|
|
121
|
-
|
|
126
|
+
function deactivate() {
|
|
127
|
+
store.deactivate()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function activate() {
|
|
131
|
+
store.activate()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
window.addEventListener("blur", deactivate)
|
|
135
|
+
window.addEventListener("focus", activate)
|
|
122
136
|
|
|
123
137
|
return () => {
|
|
124
|
-
window.removeEventListener("blur",
|
|
138
|
+
window.removeEventListener("blur", deactivate)
|
|
139
|
+
window.removeEventListener("focus", activate)
|
|
125
140
|
}
|
|
126
141
|
})
|
|
127
142
|
|
|
@@ -145,10 +160,10 @@ const JoggingPanelInner = observer(
|
|
|
145
160
|
<Button
|
|
146
161
|
color="primary"
|
|
147
162
|
variant="contained"
|
|
148
|
-
onClick={store.activate}
|
|
163
|
+
onClick={() => store.activate({ manual: true })}
|
|
149
164
|
disabled={store.isLocked}
|
|
150
165
|
>
|
|
151
|
-
Activate
|
|
166
|
+
{t("Jogging.Activate.bt")}
|
|
152
167
|
</Button>
|
|
153
168
|
</TransparentOverlay>
|
|
154
169
|
)
|
|
@@ -156,7 +171,7 @@ const JoggingPanelInner = observer(
|
|
|
156
171
|
return (
|
|
157
172
|
<TransparentOverlay>
|
|
158
173
|
<LoadingCover
|
|
159
|
-
message="Activating
|
|
174
|
+
message={t("Jogging.Activating.lb")}
|
|
160
175
|
error={store.activationError}
|
|
161
176
|
/>
|
|
162
177
|
</TransparentOverlay>
|
|
@@ -33,6 +33,12 @@ export type IncrementOptionId = IncrementOption["id"]
|
|
|
33
33
|
export class JoggingStore {
|
|
34
34
|
selectedTabId: "cartesian" | "joint" | "debug" = "cartesian"
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Whether the user must manually interact to activate jogging, or
|
|
38
|
+
* if it can be done automatically
|
|
39
|
+
*/
|
|
40
|
+
manualActivationRequired: boolean = true
|
|
41
|
+
|
|
36
42
|
/**
|
|
37
43
|
* State of the jogging panel. Starts as "inactive"
|
|
38
44
|
*/
|
|
@@ -160,7 +166,7 @@ export class JoggingStore {
|
|
|
160
166
|
this.jogger.dispose()
|
|
161
167
|
}
|
|
162
168
|
|
|
163
|
-
async deactivate() {
|
|
169
|
+
async deactivate(opts: { requireManualReactivation?: boolean } = {}) {
|
|
164
170
|
if (this.activationState === "inactive") return
|
|
165
171
|
const websocket = this.jogger.activeWebsocket
|
|
166
172
|
|
|
@@ -170,10 +176,16 @@ export class JoggingStore {
|
|
|
170
176
|
if (websocket) {
|
|
171
177
|
await websocket.closed()
|
|
172
178
|
}
|
|
179
|
+
|
|
180
|
+
if (opts.requireManualReactivation) {
|
|
181
|
+
runInAction(() => {
|
|
182
|
+
this.manualActivationRequired = true
|
|
183
|
+
})
|
|
184
|
+
}
|
|
173
185
|
}
|
|
174
186
|
|
|
175
187
|
/** Activate the jogger with current settings */
|
|
176
|
-
async activate() {
|
|
188
|
+
async activate(opts: { manual?: boolean } = {}) {
|
|
177
189
|
const {
|
|
178
190
|
currentTab,
|
|
179
191
|
selectedTcpId,
|
|
@@ -184,6 +196,8 @@ export class JoggingStore {
|
|
|
184
196
|
|
|
185
197
|
if (this.activationState === "loading") return
|
|
186
198
|
|
|
199
|
+
if (this.manualActivationRequired && !opts.manual) return
|
|
200
|
+
|
|
187
201
|
runInAction(() => {
|
|
188
202
|
this.activationState = "loading"
|
|
189
203
|
this.activationError = null
|
|
@@ -219,6 +233,9 @@ export class JoggingStore {
|
|
|
219
233
|
|
|
220
234
|
runInAction(() => {
|
|
221
235
|
this.activationState = "active"
|
|
236
|
+
if (opts.manual) {
|
|
237
|
+
this.manualActivationRequired = false
|
|
238
|
+
}
|
|
222
239
|
})
|
|
223
240
|
}
|
|
224
241
|
|
|
@@ -9,5 +9,7 @@
|
|
|
9
9
|
"Jogging.Cartesian.Rotation.bt": "Rotation",
|
|
10
10
|
"Jogging.Joints.JointValues.lb": "Gelenkwerte",
|
|
11
11
|
"Jogging.Increment.Continuous.dd": "Fortlaufend",
|
|
12
|
-
"Jogging.Cartesian.Orientation.lb": "Orientierung"
|
|
12
|
+
"Jogging.Cartesian.Orientation.lb": "Orientierung",
|
|
13
|
+
"Jogging.Activate.bt": "Jogging activieren",
|
|
14
|
+
"Jogging.Activating.lb": "Jogging wird aktivieren"
|
|
13
15
|
}
|
|
@@ -9,5 +9,7 @@
|
|
|
9
9
|
"Jogging.Cartesian.Rotation.bt": "Rotation",
|
|
10
10
|
"Jogging.Joints.JointValues.lb": "Joint values",
|
|
11
11
|
"Jogging.Increment.Continuous.dd": "Continuous",
|
|
12
|
-
"Jogging.Cartesian.Orientation.lb": "Orientation"
|
|
12
|
+
"Jogging.Cartesian.Orientation.lb": "Orientation",
|
|
13
|
+
"Jogging.Activate.bt": "Activate jogging",
|
|
14
|
+
"Jogging.Activating.lb": "Activating jogging"
|
|
13
15
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,4 +11,5 @@ export * from "./components/VelocitySlider"
|
|
|
11
11
|
export * from "./components/modal/NoMotionGroupModal"
|
|
12
12
|
export * from "./components/utils/hooks"
|
|
13
13
|
export * from "./components/robots/AxisConfig"
|
|
14
|
+
export * from "./components/LoadingCover"
|
|
14
15
|
export { createNovaMuiTheme } from "./themes/theming"
|