@wandelbots/wandelbots-js-react-components 1.16.0 → 1.16.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "1.16.0",
3
+ "version": "1.16.1",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -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
- window.addEventListener("blur", store.deactivate)
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", store.deactivate)
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 jogging
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 jogging"
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
  }