@adcops/autocore-react 3.0.26 → 3.0.29
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.
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
type FileSelectProps = {
|
|
3
3
|
domain?: string;
|
|
4
4
|
subdir?: string;
|
|
5
|
+
/** Filter results using unix-style patterns. */
|
|
6
|
+
filter?: string | null;
|
|
5
7
|
onFileSelected?: (fileName: string) => void;
|
|
6
8
|
onAccept?: (fileName: string) => void;
|
|
7
9
|
onCancel?: () => void;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;
|
package/dist/hub/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";export function createHub(){return void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};
|
|
1
|
+
import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";let hubInstance=null;export function createHub(){return hubInstance||(hubInstance=void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket),hubInstance}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-04-28 16:06:59
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified: 2024-
|
|
5
|
+
* Last Modified: 2024-06-12 14:40:20
|
|
6
6
|
* -----
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -18,6 +18,8 @@ import { EventEmitterContext } from "../core/EventEmitterContext";
|
|
|
18
18
|
type FileSelectProps = {
|
|
19
19
|
domain?: string,
|
|
20
20
|
subdir?: string,
|
|
21
|
+
/** Filter results using unix-style patterns. */
|
|
22
|
+
filter?: string | null,
|
|
21
23
|
onFileSelected?: (fileName: string) => void,
|
|
22
24
|
onAccept?: (fileName: string) => void,
|
|
23
25
|
onCancel?: () => void
|
|
@@ -31,6 +33,7 @@ type FileItem = {
|
|
|
31
33
|
export const FileSelect: React.FC<FileSelectProps> = ({
|
|
32
34
|
domain = "DATASTORE",
|
|
33
35
|
subdir,
|
|
36
|
+
filter,
|
|
34
37
|
onFileSelected,
|
|
35
38
|
onAccept,
|
|
36
39
|
onCancel
|
|
@@ -41,7 +44,16 @@ export const FileSelect: React.FC<FileSelectProps> = ({
|
|
|
41
44
|
|
|
42
45
|
const listFiles = async () => {
|
|
43
46
|
try {
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
let args;
|
|
49
|
+
|
|
50
|
+
if (filter !== undefined && filter !== null) {
|
|
51
|
+
args = subdir ? { "subdir": subdir, options : {"filter" : filter }} : {options : {"filter" : filter }};
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
args = subdir ? { "subdir": subdir } : {};
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
const res = await invoke(domain, "list_files", args);
|
|
46
58
|
const items = res.data.map((item: string, index: number) => ({
|
|
47
59
|
id: index + 1,
|
package/src/hub/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-01-16 21:07:29
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified: 2024-
|
|
5
|
+
* Last Modified: 2024-05-31 07:51:19
|
|
6
6
|
* Modified By: ADC
|
|
7
7
|
* -----
|
|
8
8
|
*
|
|
@@ -14,35 +14,49 @@ import { HubWebSocket } from "./HubWebSocket";
|
|
|
14
14
|
import {HubSimulate} from "./HubSimulate"
|
|
15
15
|
import { CommandMessage, CommandMessageResult } from './CommandMessage';
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
let hubInstance: Hub | null = null;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* Creates a connection to the backend.
|
|
19
22
|
* @returns Hub
|
|
20
23
|
*/
|
|
21
24
|
export function createHub(): Hub {
|
|
22
25
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if (!hubInstance) {
|
|
27
|
+
if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
28
|
+
console.log("HUB: Starting link to Tauri backend.");
|
|
29
|
+
hubInstance = new HubTauri();
|
|
30
|
+
} else {
|
|
31
|
+
console.log("HUB: Starting websocket connection.");
|
|
32
|
+
hubInstance = new HubWebSocket();
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
+
return hubInstance;
|
|
36
|
+
|
|
37
|
+
// if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
38
|
+
// // Standalone Tauri application
|
|
39
|
+
// console.log("HUB: Starting link to Tauri backend.");
|
|
40
|
+
// return new HubTauri();
|
|
41
|
+
// }
|
|
42
|
+
// // else if (
|
|
43
|
+
// // window.location.port !== undefined
|
|
44
|
+
// // && window.location.port.length > 0
|
|
45
|
+
// // && window.location.port !== '80'
|
|
46
|
+
// // && window.location.port !== '8080'
|
|
47
|
+
// // && window.location.port !== '443'
|
|
48
|
+
// // ) {
|
|
35
49
|
|
|
36
|
-
// // We're loaded in some development environment
|
|
37
|
-
// console.log("HUB: Starting HUB SIMULATOR.");
|
|
38
|
-
// return new HubSimulate();
|
|
39
|
-
|
|
40
|
-
// }
|
|
41
|
-
else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
50
|
+
// // // We're loaded in some development environment
|
|
51
|
+
// // console.log("HUB: Starting HUB SIMULATOR.");
|
|
52
|
+
// // return new HubSimulate();
|
|
53
|
+
|
|
54
|
+
// // }
|
|
55
|
+
// else {
|
|
56
|
+
// // A web-app that must communicate with a backend in another process.
|
|
57
|
+
// console.log("HUB: Starting websocket connection.");
|
|
58
|
+
// return new HubWebSocket();
|
|
59
|
+
// }
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
|