@adcops/autocore-react 3.0.34 → 3.0.38

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.
Files changed (173) hide show
  1. package/dist/assets/BlocklyLogo.js +1 -9
  2. package/dist/assets/Distance.js +1 -5
  3. package/dist/assets/JogLong.js +1 -3
  4. package/dist/assets/JogMedium.js +1 -3
  5. package/dist/assets/JogShort.js +1 -3
  6. package/dist/assets/PythonLogo.js +1 -21
  7. package/dist/assets/Rotation3D.js +1 -3
  8. package/dist/assets/RotationCcw.js +1 -10
  9. package/dist/assets/RotationCcwA.js +1 -16
  10. package/dist/assets/RotationCcwB.js +1 -16
  11. package/dist/assets/RotationCcwC.js +1 -16
  12. package/dist/assets/RotationCw.js +1 -10
  13. package/dist/assets/RotationCwA.js +1 -16
  14. package/dist/assets/RotationCwB.js +1 -16
  15. package/dist/assets/RotationCwC.js +1 -16
  16. package/dist/assets/Run.js +1 -3
  17. package/dist/assets/Speed.js +1 -5
  18. package/dist/assets/SpeedFast.js +1 -3
  19. package/dist/assets/SpeedMedium.js +1 -3
  20. package/dist/assets/SpeedNone.js +1 -3
  21. package/dist/assets/SpeedSlow.js +1 -3
  22. package/dist/assets/Walk.js +1 -3
  23. package/dist/assets/index.js +1 -22
  24. package/dist/components/BlocklyEditor.css +71 -2
  25. package/dist/components/BlocklyEditor.js +1 -508
  26. package/dist/components/CodeEditor.js +1 -108
  27. package/dist/components/FileList.js +1 -218
  28. package/dist/components/FileSelect.js +1 -63
  29. package/dist/components/FitText.js +1 -13
  30. package/dist/components/Indicator.js +1 -113
  31. package/dist/components/IndicatorButton.js +1 -187
  32. package/dist/components/IndicatorRect.js +1 -93
  33. package/dist/components/JogPanel.js +1 -295
  34. package/dist/components/Lamp.js +1 -161
  35. package/dist/components/Osk.js +1 -125
  36. package/dist/components/OskDialog.js +1 -128
  37. package/dist/components/ProgressBarWithValue.js +1 -18
  38. package/dist/components/TextInput.js +1 -139
  39. package/dist/components/ToggleGroup.js +1 -204
  40. package/dist/components/ValueDisplay.js +1 -160
  41. package/dist/components/ValueIndicator.js +1 -38
  42. package/dist/components/ValueInput.js +1 -158
  43. package/dist/core/ActionMode.js +1 -18
  44. package/dist/core/EventEmitterContext.js +1 -252
  45. package/dist/core/IndicatorButtonState.js +1 -9
  46. package/dist/core/IndicatorColor.js +1 -36
  47. package/dist/core/MaskPatterns.js +1 -80
  48. package/dist/core/NumerableTypes.js +1 -10
  49. package/dist/core/PositionContext.js +1 -24
  50. package/dist/core/UniqueId.js +1 -32
  51. package/dist/core/ValueSimulator.js +1 -233
  52. package/dist/core/hoc.js +1 -44
  53. package/dist/hooks/adsHooks.js +1 -253
  54. package/dist/hooks/commandHooks.js +1 -252
  55. package/dist/hooks/index.js +1 -10
  56. package/dist/hooks/useScaledValue.js +1 -86
  57. package/dist/hub/CommandMessage.js +1 -9
  58. package/dist/hub/HubBase.js +1 -310
  59. package/dist/hub/HubSimulate.js +1 -46
  60. package/dist/hub/HubTauri.js +1 -130
  61. package/dist/hub/HubWebSocket.js +1 -240
  62. package/dist/hub/index.js +1 -57
  63. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-Italic-VariableFont_wght.ttf +0 -0
  64. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-VariableFont_wght.ttf +0 -0
  65. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf +0 -0
  66. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Regular.woff2 +0 -0
  67. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-RegularItalic.woff2 +0 -0
  68. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf +0 -0
  69. package/dist/themes/adc-dark/blue/theme.css +7097 -0
  70. package/dist/themes/adc-dark/blue/theme.css.map +1 -0
  71. package/package.json +8 -2
  72. package/src/components/BlocklyEditor.css +71 -2
  73. package/src/themes/adc-dark/_extensions.scss +166 -0
  74. package/src/themes/adc-dark/_variables.scss +913 -0
  75. package/src/themes/adc-dark/blue/_fonts.scss +24 -0
  76. package/src/themes/adc-dark/blue/adc_theme.scss +32 -0
  77. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-Italic-VariableFont_wght.ttf +0 -0
  78. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-VariableFont_wght.ttf +0 -0
  79. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf +0 -0
  80. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Regular.woff2 +0 -0
  81. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-RegularItalic.woff2 +0 -0
  82. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf +0 -0
  83. package/src/themes/adc-dark/blue/theme.scss +14 -0
  84. package/src/themes/theme-base/_colors.scss +18 -0
  85. package/src/themes/theme-base/_common.scss +75 -0
  86. package/src/themes/theme-base/_components.scss +111 -0
  87. package/src/themes/theme-base/_mixins.scss +243 -0
  88. package/src/themes/theme-base/components/button/_button.scss +644 -0
  89. package/src/themes/theme-base/components/button/_speeddial.scss +91 -0
  90. package/src/themes/theme-base/components/button/_splitbutton.scss +359 -0
  91. package/src/themes/theme-base/components/data/_carousel.scss +39 -0
  92. package/src/themes/theme-base/components/data/_datascroller.scss +47 -0
  93. package/src/themes/theme-base/components/data/_datatable.scss +389 -0
  94. package/src/themes/theme-base/components/data/_dataview.scss +47 -0
  95. package/src/themes/theme-base/components/data/_filter.scss +138 -0
  96. package/src/themes/theme-base/components/data/_orderlist.scss +86 -0
  97. package/src/themes/theme-base/components/data/_organizationchart.scss +50 -0
  98. package/src/themes/theme-base/components/data/_paginator.scss +91 -0
  99. package/src/themes/theme-base/components/data/_picklist.scss +74 -0
  100. package/src/themes/theme-base/components/data/_timeline.scss +38 -0
  101. package/src/themes/theme-base/components/data/_tree.scss +184 -0
  102. package/src/themes/theme-base/components/data/_treetable.scss +431 -0
  103. package/src/themes/theme-base/components/file/_fileupload.scss +41 -0
  104. package/src/themes/theme-base/components/input/_autocomplete.scss +95 -0
  105. package/src/themes/theme-base/components/input/_calendar.scss +251 -0
  106. package/src/themes/theme-base/components/input/_cascadeselect.scss +107 -0
  107. package/src/themes/theme-base/components/input/_checkbox.scss +181 -0
  108. package/src/themes/theme-base/components/input/_chips.scss +102 -0
  109. package/src/themes/theme-base/components/input/_colorpicker.scss +18 -0
  110. package/src/themes/theme-base/components/input/_dropdown.scss +252 -0
  111. package/src/themes/theme-base/components/input/_editor.scss +122 -0
  112. package/src/themes/theme-base/components/input/_iconfield.scss +10 -0
  113. package/src/themes/theme-base/components/input/_inputgroup.scss +74 -0
  114. package/src/themes/theme-base/components/input/_inputicon.scss +15 -0
  115. package/src/themes/theme-base/components/input/_inputnumber.scss +5 -0
  116. package/src/themes/theme-base/components/input/_inputotp.scss +10 -0
  117. package/src/themes/theme-base/components/input/_inputswitch.scss +100 -0
  118. package/src/themes/theme-base/components/input/_inputtext.scss +101 -0
  119. package/src/themes/theme-base/components/input/_listbox.scss +139 -0
  120. package/src/themes/theme-base/components/input/_mention.scss +31 -0
  121. package/src/themes/theme-base/components/input/_multiselect.scss +278 -0
  122. package/src/themes/theme-base/components/input/_password.scss +33 -0
  123. package/src/themes/theme-base/components/input/_radiobutton.scss +170 -0
  124. package/src/themes/theme-base/components/input/_rating.scss +81 -0
  125. package/src/themes/theme-base/components/input/_selectbutton.scss +50 -0
  126. package/src/themes/theme-base/components/input/_slider.scss +49 -0
  127. package/src/themes/theme-base/components/input/_togglebutton.scss +99 -0
  128. package/src/themes/theme-base/components/input/_treeselect.scss +151 -0
  129. package/src/themes/theme-base/components/input/_tristatecheckbox.scss +46 -0
  130. package/src/themes/theme-base/components/menu/_breadcrumb.scss +42 -0
  131. package/src/themes/theme-base/components/menu/_contextmenu.scss +39 -0
  132. package/src/themes/theme-base/components/menu/_dock.scss +109 -0
  133. package/src/themes/theme-base/components/menu/_megamenu.scss +141 -0
  134. package/src/themes/theme-base/components/menu/_menu.scss +33 -0
  135. package/src/themes/theme-base/components/menu/_menubar.scss +216 -0
  136. package/src/themes/theme-base/components/menu/_panelmenu.scss +153 -0
  137. package/src/themes/theme-base/components/menu/_slidemenu.scss +60 -0
  138. package/src/themes/theme-base/components/menu/_steps.scss +57 -0
  139. package/src/themes/theme-base/components/menu/_tabmenu.scss +50 -0
  140. package/src/themes/theme-base/components/menu/_tieredmenu.scss +43 -0
  141. package/src/themes/theme-base/components/messages/_inlinemessage.scss +69 -0
  142. package/src/themes/theme-base/components/messages/_message.scss +107 -0
  143. package/src/themes/theme-base/components/messages/_toast.scss +100 -0
  144. package/src/themes/theme-base/components/misc/_avatar.scss +34 -0
  145. package/src/themes/theme-base/components/misc/_badge.scss +77 -0
  146. package/src/themes/theme-base/components/misc/_blockui.scss +0 -0
  147. package/src/themes/theme-base/components/misc/_chip.scss +39 -0
  148. package/src/themes/theme-base/components/misc/_inplace.scss +17 -0
  149. package/src/themes/theme-base/components/misc/_metergroup.scss +81 -0
  150. package/src/themes/theme-base/components/misc/_progressbar.scss +17 -0
  151. package/src/themes/theme-base/components/misc/_scrolltop.scss +25 -0
  152. package/src/themes/theme-base/components/misc/_skeleton.scss +8 -0
  153. package/src/themes/theme-base/components/misc/_tag.scss +40 -0
  154. package/src/themes/theme-base/components/misc/_terminal.scss +12 -0
  155. package/src/themes/theme-base/components/multimedia/_galleria.scss +153 -0
  156. package/src/themes/theme-base/components/multimedia/_image.scss +54 -0
  157. package/src/themes/theme-base/components/overlay/_confirmpopup.scss +72 -0
  158. package/src/themes/theme-base/components/overlay/_dialog.scss +78 -0
  159. package/src/themes/theme-base/components/overlay/_overlaypanel.scss +64 -0
  160. package/src/themes/theme-base/components/overlay/_sidebar.scss +23 -0
  161. package/src/themes/theme-base/components/overlay/_tooltip.scss +33 -0
  162. package/src/themes/theme-base/components/panel/_accordion.scss +118 -0
  163. package/src/themes/theme-base/components/panel/_card.scss +30 -0
  164. package/src/themes/theme-base/components/panel/_divider.scss +31 -0
  165. package/src/themes/theme-base/components/panel/_fieldset.scss +47 -0
  166. package/src/themes/theme-base/components/panel/_panel.scss +47 -0
  167. package/src/themes/theme-base/components/panel/_scrollpanel.scss +10 -0
  168. package/src/themes/theme-base/components/panel/_splitter.scss +23 -0
  169. package/src/themes/theme-base/components/panel/_stepper.scss +136 -0
  170. package/src/themes/theme-base/components/panel/_tabview.scss +147 -0
  171. package/src/themes/theme-base/components/panel/_toolbar.scss +11 -0
  172. package/tools/build-themes.cjs +66 -0
  173. package/tools/copy-distribution-files.cjs +20 -16
@@ -1,218 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /*
3
- * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
4
- * Created Date: 2024-04-24 16:01:53
5
- * -----
6
- * Last Modified: 2025-01-20 19:15:50
7
- * -----
8
- *
9
- */
10
- /** @file FileList
11
- * FileList allows a user to view the contents of a DataStore in the autocore-server.
12
- * Files can be downloaded, deleted and optionally uploaded (if enabled).
13
- *
14
- * The FileList requires the autocore-server to be the backend, as files are transferred
15
- * using specific commands via websockets.
16
- */
17
- import React, { useState, useContext, useEffect } from 'react';
18
- import { DataTable } from 'primereact/datatable';
19
- import { Column } from 'primereact/column';
20
- import { Toolbar } from 'primereact/toolbar';
21
- import { Button } from 'primereact/button';
22
- import { confirmPopup } from 'primereact/confirmpopup';
23
- import { FileUpload } from 'primereact/fileupload';
24
- import { EventEmitterContext } from '../core/EventEmitterContext';
25
- /**
26
- * `FileList` is a React functional component that displays a list of files retrieved from a specified domain
27
- * in an autocore-server.
28
- * It allows users to download and delete files. The component also supports file uploads, if enabled.
29
- *
30
- * The component uses the `EventEmitterContext` to make API calls to a backend to list, download, and delete files.
31
- * It dynamically handles file operations based on the `domain` prop which determines the API endpoints for these actions.
32
- *
33
- * Requires
34
- * ```tsx
35
- * <ConfirmPopup />
36
- * ```
37
- * somewhere in a top-level page.
38
- *
39
- * Props:
40
- * - `domain` (string): The domain name assigned to the DATASTORE servelet containing the data.
41
- * Default: "DATASTORE"
42
- * - `enableUpload` (boolean): If true, enables an upload button allowing files to be uploaded to the datastore.
43
- * Default: false
44
- *
45
- * Example Usage:
46
- * ```tsx
47
- * <FileList domain="MyDomain" enableUpload={true} />
48
- * ```
49
- *
50
- * @param {FileListProps} props The properties passed to the component.
51
- */
52
- export const FileList = ({ domain = "DATASTORE", enableUpload = false, subdir, filter = ".json", onSuccess, onError }) => {
53
- const [uploadKey, setUploadKey] = useState(0);
54
- const { invoke } = useContext(EventEmitterContext);
55
- const [files, setFiles] = useState();
56
- const makeTargetName = (s) => {
57
- if (s !== null) {
58
- if (subdir !== undefined) {
59
- return `${subdir}/${s}`;
60
- }
61
- else {
62
- return s;
63
- }
64
- }
65
- else {
66
- return "";
67
- }
68
- };
69
- /**
70
- * Retrieve a list of files from an autocore-server DataStoreServelet.
71
- */
72
- const listFiles = async () => {
73
- try {
74
- const args = subdir !== undefined ? { "subdir": subdir } : {};
75
- let res = await invoke(domain, "list_files", args);
76
- let items = [];
77
- for (let i = 0; i < res.data.length; ++i) {
78
- const item = res.data[i];
79
- items.push({
80
- id: i + 1,
81
- name: item
82
- });
83
- }
84
- setFiles(items);
85
- }
86
- catch (error) {
87
- if (onError)
88
- onError(`Failed to upload file list: ${error}`);
89
- }
90
- };
91
- /**
92
- * Handles when the download button is clicked on a list item.
93
- * @param file The file item selected in the DataTable
94
- */
95
- const handleDownload = async (file) => {
96
- let target = makeTargetName(file.name);
97
- try {
98
- await invoke(domain, "download_file", { file_name: target });
99
- if (onSuccess)
100
- onSuccess(`Downloaded file: ${file.name}`);
101
- }
102
- catch (error) {
103
- if (onError)
104
- onError(`Failed downloading file: ${error}`);
105
- }
106
- };
107
- /**
108
- * Sends the command to the autocore-server domain to delete the file.
109
- * @param file_name Name of the file to delete.
110
- */
111
- const handleDelete = async (file_name) => {
112
- let target = makeTargetName(file_name);
113
- try {
114
- await invoke(domain, "delete_file", { file_name: target });
115
- if (onSuccess)
116
- onSuccess(`Deleted file: ${file_name}`);
117
- listFiles(); // Refresh the file list after successful upload
118
- }
119
- catch (error) {
120
- if (onError)
121
- onError(`Failed to delete file: ${error}`);
122
- }
123
- listFiles();
124
- };
125
- /**
126
- * Handles the upload of files selected through the PrimeReact FileUpload component.
127
- * This function is triggered when a user selects files for upload and it processes each file asynchronously.
128
- *
129
- * The function reads the selected file as an ArrayBuffer, converts it to a Base64-encoded string, and then
130
- * sends it to the server using a custom function `invoke` which interacts with the server via API calls.
131
- * Upon successful upload, a success message is dispatched to the application's notification system. If the
132
- * upload fails, an error message is similarly dispatched.
133
- *
134
- * Usage of this function requires that it be attached to a FileUpload component's event handler in the React component.
135
- *
136
- * @param {FileUploadSelectEvent} event - The event object provided by the FileUpload component, containing the files selected by the user.
137
- *
138
- * The `FileUploadSelectEvent` type should include:
139
- * - `files`: An array of `File` objects that the user has selected for upload.
140
- *
141
- * This function utilizes the `FileReader` API to read the contents of the file. It checks if the read result
142
- * is an instance of `ArrayBuffer` before proceeding to convert it to a Base64 string. Errors during file reading
143
- * or uploading are caught and appropriate actions are taken (e.g., logging the error, dispatching error notifications).
144
- *
145
- * Note:
146
- * - Ensure that the `invoke` function is properly implemented to handle the API request for file uploading.
147
- * - Adjust the maximum file size and the types of files accepted by the FileUpload component according to your application's requirements.
148
- * - This handler assumes a single file handling scenario. If multiple file uploads are needed, modifications to the iteration over `event.files` may be required.
149
- */
150
- const handleUpload = async (event) => {
151
- const files = event.files;
152
- const file = files[0]; // Assuming single file upload
153
- let target = makeTargetName(file.name);
154
- const reader = new FileReader();
155
- reader.onload = async (e) => {
156
- // Convert array buffer to base64
157
- const arrayBuffer = e.target?.result;
158
- const base64String = arrayBufferToBase64(arrayBuffer);
159
- try {
160
- await invoke(domain, "write_file", { file_name: target, value: base64String, options: { "base64": true } });
161
- if (onSuccess)
162
- onSuccess(`Uploaded file ${file.name}`);
163
- // Refresh the file list after successful upload
164
- listFiles();
165
- }
166
- catch (error) {
167
- if (onError)
168
- onError(`Failed to upload file: ${error}`);
169
- }
170
- // Reset upload state of button so it show the file upload dialog again.
171
- resetUpload();
172
- };
173
- reader.onerror = (error) => {
174
- if (onError)
175
- onError(`Error reading file: ${error}`);
176
- };
177
- reader.readAsArrayBuffer(file);
178
- };
179
- function arrayBufferToBase64(buffer) {
180
- let binary = '';
181
- let bytes = new Uint8Array(buffer);
182
- let len = bytes.byteLength;
183
- for (let i = 0; i < len; i++) {
184
- binary += String.fromCharCode(bytes[i]);
185
- }
186
- return window.btoa(binary);
187
- }
188
- const resetUpload = () => {
189
- setUploadKey(prevKey => prevKey + 1); // Increment key to force re-render
190
- };
191
- const title = `File Listing [/${subdir !== undefined ? subdir : ''}]`;
192
- const toolbarStartContents = (_jsx(React.Fragment, { children: _jsx("span", { style: { fontWeight: 600 }, children: title }) }));
193
- const toolbarEndContents = (_jsxs(React.Fragment, { children: [enableUpload && (_jsx(FileUpload, { customUpload: true, auto: true, uploadHandler: handleUpload, accept: filter, maxFileSize: 25000, mode: "basic", chooseLabel: "", chooseOptions: {
194
- icon: 'pi pi-upload',
195
- className: 'p-button-icon-only p-button-text p-button-rounded p-mr-2'
196
- } }, uploadKey)), _jsx(Button, { icon: "pi pi-refresh", onClick: () => { listFiles(); }, className: "p-button-rounded p-mr-2", "aria-label": "Refresh", size: "small", rounded: true, text: true })] }));
197
- /**
198
- * Confirm that the user really wants to delete.
199
- * @param event
200
- */
201
- const confirmDelete = (file, event) => {
202
- confirmPopup({
203
- target: event.currentTarget,
204
- message: `Are you want to delete file ${file.name}?\nWARNING: This cannot be undone.`,
205
- icon: 'pi pi-info-circle',
206
- defaultFocus: 'reject',
207
- acceptClassName: 'p-button-danger',
208
- accept: () => handleDelete(file.name)
209
- });
210
- };
211
- useEffect(() => {
212
- listFiles();
213
- return () => {
214
- };
215
- }, [domain, enableUpload]);
216
- return (_jsxs("div", { children: [_jsx(Toolbar, { start: toolbarStartContents, end: toolbarEndContents, style: { padding: "1mm" } }), _jsxs(DataTable, { value: files, children: [_jsx(Column, { field: "name", header: "Name" }), _jsx(Column, { body: (rowData) => (_jsxs(_Fragment, { children: [_jsx(Button, { icon: "pi pi-download", onClick: () => handleDownload(rowData), className: "p-button-rounded p-button-success p-mr-2", style: { marginRight: "2mm" }, size: "small" }), _jsx(Button, { icon: "pi pi-trash", onClick: (e) => confirmDelete(rowData, e), className: "p-button-rounded p-button-danger", size: "small" })] })), header: "Actions" })] })] }));
217
- };
218
- export default FileList;
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import React,{useState,useContext,useEffect}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Toolbar}from"primereact/toolbar";import{Button}from"primereact/button";import{confirmPopup}from"primereact/confirmpopup";import{FileUpload}from"primereact/fileupload";import{EventEmitterContext}from"../core/EventEmitterContext";export const FileList=({domain:e="DATASTORE",enableUpload:t=!1,subdir:o,filter:a=".json",onSuccess:n,onError:i})=>{const[r,l]=useState(0),{invoke:s}=useContext(EventEmitterContext),[c,d]=useState(),m=e=>null!==e?void 0!==o?`${o}/${e}`:e:"",p=async()=>{try{const t=void 0!==o?{subdir:o}:{};let a=await s(e,"list_files",t),n=[];for(let e=0;e<a.data.length;++e){const t=a.data[e];n.push({id:e+1,name:t})}d(n)}catch(e){i&&i(`Failed to upload file list: ${e}`)}};const u=()=>{l((e=>e+1))},f=`File Listing [/${void 0!==o?o:""}]`,x=_jsx(React.Fragment,{children:_jsx("span",{style:{fontWeight:600},children:f})}),b=_jsxs(React.Fragment,{children:[t&&_jsx(FileUpload,{customUpload:!0,auto:!0,uploadHandler:async t=>{const o=t.files[0];let a=m(o.name);const r=new FileReader;r.onload=async t=>{const r=t.target?.result,l=function c(e){let t="",o=new Uint8Array(e),a=o.byteLength;for(let e=0;e<a;e++)t+=String.fromCharCode(o[e]);return window.btoa(t)}(r);try{await s(e,"write_file",{file_name:a,value:l,options:{base64:!0}}),n&&n(`Uploaded file ${o.name}`),p()}catch(e){i&&i(`Failed to upload file: ${e}`)}u()},r.onerror=e=>{i&&i(`Error reading file: ${e}`)},r.readAsArrayBuffer(o)},accept:a,maxFileSize:25e3,mode:"basic",chooseLabel:"",chooseOptions:{icon:"pi pi-upload",className:"p-button-icon-only p-button-text p-button-rounded p-mr-2"}},r),_jsx(Button,{icon:"pi pi-refresh",onClick:()=>{p()},className:"p-button-rounded p-mr-2","aria-label":"Refresh",size:"small",rounded:!0,text:!0})]}),h=(t,o)=>{confirmPopup({target:o.currentTarget,message:`Are you want to delete file ${t.name}?\nWARNING: This cannot be undone.`,icon:"pi pi-info-circle",defaultFocus:"reject",acceptClassName:"p-button-danger",accept:()=>(async t=>{let o=m(t);try{await s(e,"delete_file",{file_name:o}),n&&n(`Deleted file: ${t}`),p()}catch(e){i&&i(`Failed to delete file: ${e}`)}p()})(t.name)})};return useEffect((()=>(p(),()=>{})),[e,t]),_jsxs("div",{children:[_jsx(Toolbar,{start:x,end:b,style:{padding:"1mm"}}),_jsxs(DataTable,{value:c,children:[_jsx(Column,{field:"name",header:"Name"}),_jsx(Column,{body:t=>_jsxs(_Fragment,{children:[_jsx(Button,{icon:"pi pi-download",onClick:()=>(async t=>{let o=m(t.name);try{await s(e,"download_file",{file_name:o}),n&&n(`Downloaded file: ${t.name}`)}catch(e){i&&i(`Failed downloading file: ${e}`)}})(t),className:"p-button-rounded p-button-success p-mr-2",style:{marginRight:"2mm"},size:"small"}),_jsx(Button,{icon:"pi pi-trash",onClick:e=>h(t,e),className:"p-button-rounded p-button-danger",size:"small"})]}),header:"Actions"})]})]})};export default FileList;
@@ -1,63 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /*
3
- * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
4
- * Created Date: 2024-04-28 16:06:59
5
- * -----
6
- * Last Modified: 2024-06-12 14:40:20
7
- * -----
8
- *
9
- */
10
- import { useState, useContext, useEffect } from 'react';
11
- import { DataTable } from 'primereact/datatable';
12
- import { Column } from 'primereact/column';
13
- import { Button } from 'primereact/button';
14
- import { EventEmitterContext } from "../core/EventEmitterContext";
15
- export const FileSelect = ({ domain = "DATASTORE", subdir, filter, onFileSelected, onAccept, onCancel }) => {
16
- const { invoke } = useContext(EventEmitterContext);
17
- const [files, setFiles] = useState([]);
18
- const [selectedFile, setSelectedFile] = useState(null);
19
- const listFiles = async () => {
20
- try {
21
- let args;
22
- if (filter !== undefined && filter !== null) {
23
- args = subdir ? { "subdir": subdir, options: { "filter": filter } } : { options: { "filter": filter } };
24
- }
25
- else {
26
- args = subdir ? { "subdir": subdir } : {};
27
- }
28
- const res = await invoke(domain, "list_files", args);
29
- const items = res.data.map((item, index) => ({
30
- id: index + 1,
31
- name: item
32
- }));
33
- setFiles(items);
34
- }
35
- catch (error) {
36
- console.error("Failed to list files:", error);
37
- }
38
- };
39
- const handleSelect = (file) => {
40
- setSelectedFile(file);
41
- if (onFileSelected)
42
- onFileSelected(file.name);
43
- };
44
- const makeReturnFileName = () => {
45
- if (selectedFile !== null) {
46
- if (subdir !== undefined) {
47
- return `${subdir}/${selectedFile.name}`;
48
- }
49
- else {
50
- return selectedFile.name;
51
- }
52
- }
53
- else {
54
- return "";
55
- }
56
- };
57
- useEffect(() => {
58
- listFiles();
59
- }, [domain, subdir]);
60
- return (_jsxs("div", { children: [_jsxs(DataTable, { value: files, selectionMode: "single", selection: selectedFile, onSelectionChange: e => handleSelect(e.value), children: [_jsx(Column, { field: "name", header: "File Name" }), _jsx(Column, { body: (rowData) => (_jsx(Button, { label: selectedFile?.name === rowData.name ? "Selected" : "Select", icon: selectedFile?.name === rowData.name ? "pi pi-check-circle" : "pi pi-circle-off", onClick: () => handleSelect(rowData), className: `p-button-rounded ${selectedFile?.name === rowData.name ? "p-button-success" : "p-button-outlined"}`, "aria-label": "Select", size: "small" })), header: "Select" })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end', marginTop: '10px' }, children: [_jsx(Button, { label: "Cancel", icon: "pi pi-times", className: "p-button-text", onClick: onCancel }), _jsx(Button, { label: "Accept", icon: "pi pi-check", className: "p-button", onClick: () => { if (onAccept !== undefined && selectedFile !== null)
61
- onAccept(makeReturnFileName()); }, disabled: !selectedFile })] })] }));
62
- };
63
- export default FileSelect;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useContext,useEffect}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{EventEmitterContext}from"../core/EventEmitterContext";export const FileSelect=({domain:e="DATASTORE",subdir:t,filter:n,onFileSelected:l,onAccept:i,onCancel:o})=>{const{invoke:a}=useContext(EventEmitterContext),[s,c]=useState([]),[r,m]=useState(null),u=e=>{m(e),l&&l(e.name)};return useEffect((()=>{(async()=>{try{let l;l=null!=n?t?{subdir:t,options:{filter:n}}:{options:{filter:n}}:t?{subdir:t}:{};const i=(await a(e,"list_files",l)).data.map(((e,t)=>({id:t+1,name:e})));c(i)}catch(e){}})()}),[e,t]),_jsxs("div",{children:[_jsxs(DataTable,{value:s,selectionMode:"single",selection:r,onSelectionChange:e=>u(e.value),children:[_jsx(Column,{field:"name",header:"File Name"}),_jsx(Column,{body:e=>_jsx(Button,{label:r?.name===e.name?"Selected":"Select",icon:r?.name===e.name?"pi pi-check-circle":"pi pi-circle-off",onClick:()=>u(e),className:"p-button-rounded "+(r?.name===e.name?"p-button-success":"p-button-outlined"),"aria-label":"Select",size:"small"}),header:"Select"})]}),_jsxs("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"10px"},children:[_jsx(Button,{label:"Cancel",icon:"pi pi-times",className:"p-button-text",onClick:o}),_jsx(Button,{label:"Accept",icon:"pi pi-check",className:"p-button",onClick:()=>{void 0!==i&&null!==r&&i(null!==r?void 0!==t?`${t}/${r.name}`:r.name:"")},disabled:!r})]})]})};export default FileSelect;
@@ -1,13 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import useFitText from 'use-fit-text';
3
- /**
4
- * FitText dynamically adjusts the font size of its children to fit the parent container.
5
- *
6
- * @param {FitTextProps} props The props for the FitText component.
7
- * @returns A div element that resizes its child text to fit.
8
- */
9
- export const FitText = ({ children }) => {
10
- const { fontSize, ref } = useFitText();
11
- return (_jsx("div", { ref: ref, style: { width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }, children: _jsx("p", { style: { fontSize }, children: children }) }));
12
- };
13
- export default FitText;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import useFitText from"use-fit-text";export const FitText=({children:t})=>{const{fontSize:e,ref:i}=useFitText();return _jsx("div",{ref:i,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:_jsx("p",{style:{fontSize:e},children:t})})};export default FitText;
@@ -1,113 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /*
3
- * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
4
- * Created Date: 2024-01-16 14:39:41
5
- * -----
6
- * Last Modified: 2024-03-12 21:53:48
7
- * -----
8
- *
9
- */
10
- import { Component } from 'react';
11
- //import clsx from 'clsx';
12
- import { EventEmitterContext } from '../core/EventEmitterContext';
13
- //import { IPositionContext } from '../core/PositionContext';
14
- import { IndicatorColor } from "../core/IndicatorColor";
15
- export { IndicatorColor };
16
- export class Indicator extends Component {
17
- constructor(props) {
18
- super(props);
19
- Object.defineProperty(this, "unsubscribeTopicId", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: null
24
- });
25
- this.state = {
26
- subscribedValue: props.value,
27
- fontSize: "100%"
28
- };
29
- }
30
- componentDidMount() {
31
- const { topic } = this.props;
32
- if (topic && this.unsubscribeTopicId === null) {
33
- const { subscribe } = this.context;
34
- this.unsubscribeTopicId = subscribe(topic, (value) => {
35
- this.setState({ subscribedValue: value });
36
- });
37
- }
38
- }
39
- componentDidUpdate(prevProps) {
40
- if (prevProps.value !== this.props.value) {
41
- this.setState({ subscribedValue: this.props.value });
42
- }
43
- }
44
- componentWillUnmount() {
45
- if (this.unsubscribeTopicId !== null) {
46
- const { unsubscribe } = this.context;
47
- unsubscribe(this.unsubscribeTopicId);
48
- this.unsubscribeTopicId = null;
49
- }
50
- }
51
- render() {
52
- const { label, value, onColor, offColor, invalidColor } = this.props;
53
- const { subscribedValue } = this.state;
54
- //
55
- // Load the value from the proper source.
56
- // If the `value` property is undefined, that takes precedence.
57
- //
58
- let displayValue = subscribedValue;
59
- if (value !== undefined) {
60
- displayValue = value;
61
- }
62
- let color;
63
- switch (displayValue) {
64
- case true:
65
- color = onColor;
66
- break;
67
- case false:
68
- color = offColor;
69
- break;
70
- default:
71
- color = invalidColor;
72
- break;
73
- }
74
- // const style: React.CSSProperties = {
75
- // position: useAbsolutePositioning ? 'absolute' : 'relative',
76
- // display: useAbsolutePositioning ? "" : "inline-block",
77
- // verticalAlign: 'middle',
78
- // top: useAbsolutePositioning && y ? `${yOffset + adjScale * y}px` : undefined,
79
- // left: useAbsolutePositioning && x ? `${xOffset + adjScale * x}px` : undefined,
80
- // width: adjWidth ? `${adjWidth * adjScale}px` : undefined,
81
- // height: adjHeight ? `${adjHeight * adjScale}px` : undefined,
82
- // lineHeight: adjHeight ? `${adjHeight * adjScale}px` : undefined,
83
- // backgroundColor: color,
84
- // borderRadius: "20px"
85
- // };
86
- const groupStyle = {
87
- alignItems: "center !important"
88
- };
89
- const lampDivStyle = {
90
- backgroundColor: color,
91
- width: "22px"
92
- };
93
- return (_jsxs("div", { className: "p-inputgroup flex-1", style: groupStyle, children: [_jsx("span", { className: "p-inputgroup-addon", style: lampDivStyle, children: "\u00A0" }), _jsx("span", { className: "p-inputgroup-addon", children: label })] }));
94
- }
95
- }
96
- Object.defineProperty(Indicator, "contextType", {
97
- enumerable: true,
98
- configurable: true,
99
- writable: true,
100
- value: EventEmitterContext
101
- });
102
- // Define default properties
103
- Object.defineProperty(Indicator, "defaultProps", {
104
- enumerable: true,
105
- configurable: true,
106
- writable: true,
107
- value: {
108
- onColor: "green",
109
- offColor: "gray",
110
- invalidColor: "black"
111
- }
112
- });
113
- export default Indicator;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Component}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";import{IndicatorColor}from"../core/IndicatorColor";export{IndicatorColor};export class Indicator extends Component{constructor(e){super(e),Object.defineProperty(this,"unsubscribeTopicId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state={subscribedValue:e.value,fontSize:"100%"}}componentDidMount(){const{topic:e}=this.props;if(e&&null===this.unsubscribeTopicId){const{subscribe:t}=this.context;this.unsubscribeTopicId=t(e,(e=>{this.setState({subscribedValue:e})}))}}componentDidUpdate(e){e.value!==this.props.value&&this.setState({subscribedValue:this.props.value})}componentWillUnmount(){if(null!==this.unsubscribeTopicId){const{unsubscribe:e}=this.context;e(this.unsubscribeTopicId),this.unsubscribeTopicId=null}}render(){const{label:e,value:t,onColor:o,offColor:r,invalidColor:s}=this.props,{subscribedValue:i}=this.state;let n,a=i;switch(void 0!==t&&(a=t),a){case!0:n=o;break;case!1:n=r;break;default:n=s}return _jsxs("div",{className:"p-inputgroup flex-1",style:{alignItems:"center !important"},children:[_jsx("span",{className:"p-inputgroup-addon",style:{backgroundColor:n,width:"22px"},children:" "}),_jsx("span",{className:"p-inputgroup-addon",children:e})]})}}Object.defineProperty(Indicator,"contextType",{enumerable:!0,configurable:!0,writable:!0,value:EventEmitterContext}),Object.defineProperty(Indicator,"defaultProps",{enumerable:!0,configurable:!0,writable:!0,value:{onColor:"green",offColor:"gray",invalidColor:"black"}});export default Indicator;
@@ -1,187 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /*
3
- * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
4
- * Created Date: 2024-01-21 10:33:58
5
- * -----
6
- * Last Modified: 2024-03-12 20:55:17
7
- * Modified By: ADC
8
- * -----
9
- *
10
- */
11
- import { Component } from 'react';
12
- import { Button } from 'primereact/button';
13
- import { EventEmitterContext } from '../core/EventEmitterContext';
14
- import { IndicatorColor } from "../core/IndicatorColor";
15
- export { IndicatorColor };
16
- import { ActionMode } from '../core/ActionMode';
17
- export { ActionMode };
18
- export class IndicatorButton extends Component {
19
- constructor(props) {
20
- super(props);
21
- /**
22
- * Handles updates for the main topic.
23
- */
24
- Object.defineProperty(this, "handleTopicUpdate", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: (value) => {
29
- this.setState({ currentValue: value });
30
- }
31
- });
32
- /**
33
- * Handles updates for the disable topic.
34
- */
35
- Object.defineProperty(this, "handleDisableTopicUpdate", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: (value) => {
40
- this.setState({ isDisabled: value });
41
- }
42
- });
43
- /**
44
- * Handles updates for the invisible topic.
45
- */
46
- Object.defineProperty(this, "handleInvisibleTopicUpdate", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: (value) => {
51
- this.setState({ isInvisible: value });
52
- }
53
- });
54
- this.state = {
55
- currentValue: undefined,
56
- isDisabled: false,
57
- isInvisible: false,
58
- isPressed: false
59
- };
60
- }
61
- componentDidMount() {
62
- this.setupSubscriptions();
63
- }
64
- componentDidUpdate(prevProps) {
65
- prevProps;
66
- // Logic to handle updates in props, if necessary
67
- }
68
- componentWillUnmount() {
69
- // Unsubscribe logic if needed
70
- }
71
- /**
72
- * Sets up subscriptions based on provided topics.
73
- */
74
- setupSubscriptions() {
75
- const { topic, disableTopic, invisibleTopic } = this.props;
76
- const { subscribe } = this.context;
77
- if (topic) {
78
- // Subscribe to the main topic
79
- subscribe(topic, this.handleTopicUpdate);
80
- }
81
- if (disableTopic) {
82
- // Subscribe to the disable topic
83
- subscribe(disableTopic, this.handleDisableTopicUpdate);
84
- }
85
- if (invisibleTopic) {
86
- // Subscribe to the invisible topic
87
- subscribe(invisibleTopic, this.handleInvisibleTopicUpdate);
88
- }
89
- }
90
- /**
91
- * Handle the button being pressed down. Used for TAP and PRESSED action modes.
92
- */
93
- handleOnPressed() {
94
- const { isPressed } = this.state;
95
- const { actionMode } = this.props;
96
- if (!isPressed) {
97
- this.setState({ isPressed: true });
98
- if (actionMode === ActionMode.Tap || actionMode === ActionMode.Pressed) {
99
- this.dispatchCommand(true);
100
- }
101
- }
102
- }
103
- /**
104
- * Handle the button being released. Used for TAP and RELEASED action modes.
105
- */
106
- handleOnReleased() {
107
- const { isPressed } = this.state;
108
- const { actionMode } = this.props;
109
- if (isPressed) {
110
- this.setState({ isPressed: false });
111
- if (actionMode === ActionMode.Tap) {
112
- this.dispatchCommand(false);
113
- }
114
- else if (actionMode === ActionMode.Released) {
115
- this.dispatchCommand(true);
116
- }
117
- }
118
- }
119
- /**
120
- * Dispatch a value to any listeners.
121
- * @param value The value to dispatch as part of the payload.
122
- */
123
- dispatchCommand(value) {
124
- const { command, commandTopic, commandArgs } = this.props;
125
- const { dispatch } = this.context;
126
- if (command !== undefined && command !== null && command.length > 0) {
127
- const payload = {
128
- topic: commandTopic,
129
- value: value,
130
- ...commandArgs
131
- };
132
- dispatch({
133
- topic: command,
134
- payload: payload
135
- });
136
- }
137
- }
138
- render() {
139
- const { currentValue, isDisabled, isInvisible } = this.state;
140
- const { className, severity, label, raised, value, onColor, offColor, options, topic, command, commandArgs, disableTopic, invisibleTopic, inputMode, invert, onIcon, offIcon, icon, ...restProps } = this.props;
141
- //
142
- // Load the value from the proper source.
143
- // If the `value` property is undefined, that takes precedence.
144
- //
145
- let displayValue = currentValue;
146
- if (value !== undefined) {
147
- displayValue = value;
148
- }
149
- // Determine the label and color based on the current state
150
- let btnLabel = undefined;
151
- if (options !== undefined && options !== null) {
152
- btnLabel = displayValue ? options[1] : options[0];
153
- if (btnLabel === undefined || btnLabel === null || btnLabel.length === 0)
154
- btnLabel = label;
155
- }
156
- else {
157
- btnLabel = label;
158
- }
159
- let btnIcon = displayValue ? onIcon : offIcon;
160
- if (btnIcon === undefined || btnIcon === null || btnIcon.length === 0)
161
- btnIcon = icon;
162
- let color = displayValue ? onColor : offColor;
163
- // Handle special cases like undefined state or specific input modes
164
- if (displayValue === undefined) {
165
- color = IndicatorColor.IndicatorInvalid;
166
- }
167
- return (_jsx(Button, { ...restProps, label: btnLabel, icon: `pi ${btnIcon}`, className: className, style: { color: "white", backgroundColor: color, display: isInvisible ? 'none' : 'block' }, disabled: isDisabled, onMouseDown: () => this.handleOnPressed(), onTouchStart: () => this.handleOnPressed(), onMouseUp: () => this.handleOnReleased(), onTouchEnd: () => this.handleOnReleased(), value: disableTopic, raised: true }));
168
- }
169
- }
170
- Object.defineProperty(IndicatorButton, "contextType", {
171
- enumerable: true,
172
- configurable: true,
173
- writable: true,
174
- value: EventEmitterContext
175
- });
176
- // Define default props
177
- Object.defineProperty(IndicatorButton, "defaultProps", {
178
- enumerable: true,
179
- configurable: true,
180
- writable: true,
181
- value: {
182
- onColor: IndicatorColor.IndicatorGreen,
183
- offColor: "gray", // Default offColor
184
- // ... other default values for props ...
185
- }
186
- });
187
- export default IndicatorButton;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";import{Button}from"primereact/button";import{EventEmitterContext}from"../core/EventEmitterContext";import{IndicatorColor}from"../core/IndicatorColor";export{IndicatorColor};import{ActionMode}from"../core/ActionMode";export{ActionMode};export class IndicatorButton extends Component{constructor(e){super(e),Object.defineProperty(this,"handleTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({currentValue:e})}}),Object.defineProperty(this,"handleDisableTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({isDisabled:e})}}),Object.defineProperty(this,"handleInvisibleTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({isInvisible:e})}}),this.state={currentValue:void 0,isDisabled:!1,isInvisible:!1,isPressed:!1}}componentDidMount(){this.setupSubscriptions()}componentDidUpdate(e){}componentWillUnmount(){}setupSubscriptions(){const{topic:e,disableTopic:t,invisibleTopic:o}=this.props,{subscribe:i}=this.context;e&&i(e,this.handleTopicUpdate),t&&i(t,this.handleDisableTopicUpdate),o&&i(o,this.handleInvisibleTopicUpdate)}handleOnPressed(){const{isPressed:e}=this.state,{actionMode:t}=this.props;e||(this.setState({isPressed:!0}),t!==ActionMode.Tap&&t!==ActionMode.Pressed||this.dispatchCommand(!0))}handleOnReleased(){const{isPressed:e}=this.state,{actionMode:t}=this.props;e&&(this.setState({isPressed:!1}),t===ActionMode.Tap?this.dispatchCommand(!1):t===ActionMode.Released&&this.dispatchCommand(!0))}dispatchCommand(e){const{command:t,commandTopic:o,commandArgs:i}=this.props,{dispatch:n}=this.context;if(null!=t&&t.length>0){n({topic:t,payload:{topic:o,value:e,...i}})}}render(){const{currentValue:e,isDisabled:t,isInvisible:o}=this.state,{className:i,severity:n,label:s,raised:a,value:r,onColor:l,offColor:d,options:c,topic:p,command:u,commandArgs:h,disableTopic:m,invisibleTopic:b,inputMode:f,invert:v,onIcon:C,offIcon:I,icon:T,...x}=this.props;let P,M=e;void 0!==r&&(M=r),null!=c?(P=M?c[1]:c[0],null!=P&&0!==P.length||(P=s)):P=s;let g=M?C:I;null!=g&&0!==g.length||(g=T);let y=M?l:d;return void 0===M&&(y=IndicatorColor.IndicatorInvalid),_jsx(Button,{...x,label:P,icon:`pi ${g}`,className:i,style:{color:"white",backgroundColor:y,display:o?"none":"block"},disabled:t,onMouseDown:()=>this.handleOnPressed(),onTouchStart:()=>this.handleOnPressed(),onMouseUp:()=>this.handleOnReleased(),onTouchEnd:()=>this.handleOnReleased(),value:m,raised:!0})}}Object.defineProperty(IndicatorButton,"contextType",{enumerable:!0,configurable:!0,writable:!0,value:EventEmitterContext}),Object.defineProperty(IndicatorButton,"defaultProps",{enumerable:!0,configurable:!0,writable:!0,value:{onColor:IndicatorColor.IndicatorGreen,offColor:"gray"}});export default IndicatorButton;