@topconsultnpm/sdkui-react-beta 6.10.52 → 6.10.54
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import FileManager, { Column, Details, ItemView, Permissions, Notifications, ContextMenu, Toolbar, Item } from 'devextreme-react/file-manager';
|
|
4
4
|
import { FileDescriptor, FileFormats, FileTransferModes, SDK_Localizator, SDK_Globals } from '@topconsultnpm/sdk-ts-beta';
|
|
5
5
|
import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
|
|
@@ -7,12 +7,11 @@ import FileSystemError from "devextreme/file_management/error";
|
|
|
7
7
|
import Button from "devextreme/ui/button";
|
|
8
8
|
import { alert, confirm } from "devextreme/ui/dialog";
|
|
9
9
|
import { loadMessages } from 'devextreme/localization';
|
|
10
|
-
import { Globalization, IconAll, IconSelected, SDKUI_Localizator } from '../../helper';
|
|
10
|
+
import { Globalization, IconAll, IconCloud, IconSelected, SDKUI_Localizator } from '../../helper';
|
|
11
11
|
import { TMExceptionBoxManager } from './TMPopUp';
|
|
12
12
|
import ShowAlert from './TMAlert';
|
|
13
|
-
import { IconFolder, IconPdf, IconTxt, IconXls, IconDocx, IconImage, IconZip, IconXml, IconMp4, IconEmail, IconPpt, IconSigned, IconExe, IconHtml, IconDwg, IconDicom, IconSlddrw } from '../../assets/thumbnails';
|
|
14
13
|
import { TMLayoutWaitingContainer } from './TMWaitPanel';
|
|
15
|
-
import
|
|
14
|
+
import TMCounterContainer, { CounterItemKey } from './TMCounterContainer';
|
|
16
15
|
export class TMFileSystemItem {
|
|
17
16
|
constructor() {
|
|
18
17
|
this.name = "";
|
|
@@ -34,16 +33,18 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
34
33
|
const [areas, setAreas] = useState([]);
|
|
35
34
|
// State to maintain the Area Descriptor Name Set (Support area - left panel)
|
|
36
35
|
const [areasRoots, setAreasRoots] = useState(new Set());
|
|
36
|
+
// State to store the file system items of the current directory's parent
|
|
37
|
+
const [parentDirectoryFileSystemItems, setParentDirectoryFileSystemItems] = useState([]);
|
|
37
38
|
// State to maintain the selected area file (File System Item - right panel)
|
|
38
39
|
const [areaFile, setAreaFile] = useState('');
|
|
39
40
|
// State to maintain the selected area folder (File System Item - right panel)
|
|
40
41
|
const [areaFolder, setAreaFolder] = useState('');
|
|
41
42
|
// State to maintain the focused/clicked file system item (File System Item - right panel)
|
|
42
43
|
const [focusedFileSystemItem, setFocusedFileSystemItem] = useState(undefined);
|
|
43
|
-
// State to maintain the number of total item into selected support area
|
|
44
|
-
const [counter, setCounter] = useState(0);
|
|
45
44
|
// State to maintain the number of selected items)
|
|
46
45
|
const [selectedItemsCount, setSelectedItemsCount] = useState(0);
|
|
46
|
+
// State to maintain the counter values (total item into selected support area and selected items)
|
|
47
|
+
const [counterValues, setCounterValues] = useState(new Map());
|
|
47
48
|
// State to maintain the selection mode (File System Item - right panel)
|
|
48
49
|
const [selectionMode, setSelectionMode] = useState('single');
|
|
49
50
|
/* State to manage the Wait Panel */
|
|
@@ -72,6 +73,44 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
72
73
|
const fileManagerRef = useRef(null);
|
|
73
74
|
// Cache for uploaded file IDs, mapping file paths to their corresponding IDs
|
|
74
75
|
let _cacheUploadFileId = new Map();
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const defaultCounterItems = new Map([
|
|
78
|
+
[
|
|
79
|
+
String(SDKUI_Localizator.AllItems),
|
|
80
|
+
{
|
|
81
|
+
key: String(SDK_Localizator.Areas),
|
|
82
|
+
show: true,
|
|
83
|
+
caption: String(SDK_Localizator.Areas),
|
|
84
|
+
value: areasRoots.size,
|
|
85
|
+
icon: _jsx(IconCloud, {}),
|
|
86
|
+
order: 0
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
String(SDKUI_Localizator.All),
|
|
91
|
+
{
|
|
92
|
+
key: String(SDKUI_Localizator.AllFilesAndFoldersInSupportArea),
|
|
93
|
+
show: true,
|
|
94
|
+
caption: String(SDKUI_Localizator.AllFilesAndFoldersInSupportArea),
|
|
95
|
+
value: focusedFileSystemItem?.name === '' ? 0 : parentDirectoryFileSystemItems.length,
|
|
96
|
+
icon: _jsx(IconAll, {}),
|
|
97
|
+
order: 0
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
String(CounterItemKey.selectedItems),
|
|
102
|
+
{
|
|
103
|
+
key: String(CounterItemKey.selectedItems),
|
|
104
|
+
show: true,
|
|
105
|
+
caption: String(SDKUI_Localizator.SelectedItems),
|
|
106
|
+
value: selectedItemsCount,
|
|
107
|
+
icon: _jsx(IconSelected, {}),
|
|
108
|
+
order: 1
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
]);
|
|
112
|
+
setCounterValues(defaultCounterItems);
|
|
113
|
+
}, [areasRoots, focusedFileSystemItem, parentDirectoryFileSystemItems, selectedItemsCount]);
|
|
75
114
|
useEffect(() => {
|
|
76
115
|
// If areaProvider is already set, exit early to prevent reinitialization
|
|
77
116
|
if (areaProvider)
|
|
@@ -127,7 +166,6 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
127
166
|
const btnSearchFile = document.querySelector(".dx-filemanager-wrapper [aria-label='Carica i files']");
|
|
128
167
|
const instanceBtnSearchFile = Button.getInstance(btnSearchFile);
|
|
129
168
|
if (currentRoute === '') {
|
|
130
|
-
initCounter();
|
|
131
169
|
instanceBtnNewDir?.option("disabled", true);
|
|
132
170
|
instanceBtnSearchFile?.option("disabled", true);
|
|
133
171
|
}
|
|
@@ -165,12 +203,6 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
165
203
|
setSelectionMode('multiple');
|
|
166
204
|
fileManagerRef.current?.instance().refresh();
|
|
167
205
|
}, [props.areaStatus]);
|
|
168
|
-
const initCounter = async () => {
|
|
169
|
-
const tms = props.tmSession ?? SDK_Globals.tmSession;
|
|
170
|
-
const adlist = await tms?.NewAreaEngine().RetrieveAllAsync();
|
|
171
|
-
if (adlist)
|
|
172
|
-
setCounter(adlist.length);
|
|
173
|
-
};
|
|
174
206
|
const checkTargetDirectory = (operationType, e, data, resolve) => {
|
|
175
207
|
const fileExists = !!data.find((x) => x.name === (operationType === 'copyOrMove' ? e.item.name : e.fileData.name));
|
|
176
208
|
if (fileExists) {
|
|
@@ -434,6 +466,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
434
466
|
// Set the areas
|
|
435
467
|
setAreas(adlist);
|
|
436
468
|
setAreasRoots(areasRootsName);
|
|
469
|
+
setParentDirectoryFileSystemItems([]);
|
|
437
470
|
}
|
|
438
471
|
else {
|
|
439
472
|
// If the parent directory is not the root, retrieve files within the area
|
|
@@ -452,6 +485,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
452
485
|
fsi.size = file.size; // Store the file size
|
|
453
486
|
fileSystem.push(fsi); // Add the file system item to the list
|
|
454
487
|
});
|
|
488
|
+
setParentDirectoryFileSystemItems(fileSystem);
|
|
455
489
|
}
|
|
456
490
|
// Return the constructed list of file system items (directories or files)
|
|
457
491
|
return fileSystem;
|
|
@@ -515,7 +549,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
515
549
|
let subFolder = e.directory.path.replace(ad.name + '/', '').replace(ad.name, '');
|
|
516
550
|
setAreaFolder(getAreaPath(aid, subFolder));
|
|
517
551
|
e.component.option("fileSystemProvider").getItems(e.directory).then((items) => {
|
|
518
|
-
|
|
552
|
+
setParentDirectoryFileSystemItems(items);
|
|
519
553
|
});
|
|
520
554
|
};
|
|
521
555
|
const onSelectionChanged = async (e) => {
|
|
@@ -539,49 +573,49 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
539
573
|
}
|
|
540
574
|
setFocusedFileSystemItem(e.item);
|
|
541
575
|
};
|
|
542
|
-
const customizeIcon = useCallback((fileSystemItem) => {
|
|
576
|
+
/* const customizeIcon = useCallback((fileSystemItem: FileSystemItem) => {
|
|
543
577
|
if (fileSystemItem.isDirectory) {
|
|
544
|
-
return IconFolder
|
|
578
|
+
return IconFolder
|
|
545
579
|
}
|
|
546
580
|
else {
|
|
547
|
-
const fileExtension = fileSystemItem.getFileExtension()
|
|
581
|
+
const fileExtension = fileSystemItem.getFileExtension()
|
|
548
582
|
switch (fileExtension.toLowerCase()) {
|
|
549
583
|
case '.pdf':
|
|
550
|
-
return IconPdf
|
|
584
|
+
return IconPdf
|
|
551
585
|
case '.xls':
|
|
552
586
|
case '.xlsx':
|
|
553
587
|
case '.csv':
|
|
554
|
-
return IconXls
|
|
588
|
+
return IconXls
|
|
555
589
|
case '.txt':
|
|
556
|
-
return IconTxt
|
|
590
|
+
return IconTxt
|
|
557
591
|
case '.xml':
|
|
558
|
-
return IconXml
|
|
592
|
+
return IconXml
|
|
559
593
|
case '.dwg':
|
|
560
|
-
return IconDwg
|
|
594
|
+
return IconDwg
|
|
561
595
|
case '.dcm':
|
|
562
|
-
return IconDicom
|
|
596
|
+
return IconDicom
|
|
563
597
|
case '.slddrw':
|
|
564
|
-
return IconSlddrw
|
|
598
|
+
return IconSlddrw
|
|
565
599
|
case '.mp4':
|
|
566
|
-
return IconMp4
|
|
600
|
+
return IconMp4
|
|
567
601
|
case '.doc':
|
|
568
602
|
case '.docx':
|
|
569
603
|
case '.dotx':
|
|
570
604
|
case '.rtf':
|
|
571
|
-
return IconDocx
|
|
605
|
+
return IconDocx
|
|
572
606
|
case '.ppt':
|
|
573
607
|
case '.pptx':
|
|
574
|
-
return IconPpt
|
|
608
|
+
return IconPpt
|
|
575
609
|
case '.msg':
|
|
576
610
|
case '.eml':
|
|
577
|
-
return IconEmail
|
|
611
|
+
return IconEmail
|
|
578
612
|
case '.exe':
|
|
579
|
-
return IconExe
|
|
613
|
+
return IconExe
|
|
580
614
|
case '.htm':
|
|
581
615
|
case '.html':
|
|
582
|
-
return IconHtml
|
|
616
|
+
return IconHtml
|
|
583
617
|
case '.p7m':
|
|
584
|
-
return IconSigned
|
|
618
|
+
return IconSigned
|
|
585
619
|
case '.png':
|
|
586
620
|
case '.jpg':
|
|
587
621
|
case '.jpeg':
|
|
@@ -591,16 +625,16 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
591
625
|
case '.ico':
|
|
592
626
|
case '.gif':
|
|
593
627
|
case '.webp':
|
|
594
|
-
return IconImage
|
|
628
|
+
return IconImage
|
|
595
629
|
case '.zip':
|
|
596
630
|
case '.rar':
|
|
597
631
|
case '.7z':
|
|
598
|
-
return IconZip
|
|
632
|
+
return IconZip
|
|
599
633
|
default:
|
|
600
|
-
return IconTxt
|
|
634
|
+
return IconTxt
|
|
601
635
|
}
|
|
602
636
|
}
|
|
603
|
-
}, []);
|
|
637
|
+
}, []); */
|
|
604
638
|
const onSelectedFileOpened = async (e) => {
|
|
605
639
|
if (props.isPathChooser)
|
|
606
640
|
props.areaChoose();
|
|
@@ -632,7 +666,13 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
632
666
|
alert(`"${e.name}" ${SDKUI_Localizator.FolderExist}`, SDKUI_Localizator.Attention);
|
|
633
667
|
}
|
|
634
668
|
};
|
|
635
|
-
|
|
636
|
-
|
|
669
|
+
return (_jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: _jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsxs(FileManager, { width: props.width, ref: fileManagerRef, height: `calc(${props.height} - 30px)`, onItemMoving: onItemCopying, onItemCopying: onItemCopying, onFileUploading: onFileUploading, fileSystemProvider: areaProvider,
|
|
670
|
+
// customizeThumbnail={customizeIcon}
|
|
671
|
+
rootFolderName: SDK_Localizator.Areas, onSelectionChanged: onSelectionChanged, onDirectoryCreating: onDirectoryCreating, onFocusedItemChanged: onFocusedItemChanged, onSelectedFileOpened: onSelectedFileOpened, onContextMenuItemClick: onContextMenuItemClick,
|
|
672
|
+
/* onItemMoved={() => setCounter(counter => counter + 1)}
|
|
673
|
+
onItemCopied={() => setCounter(counter => counter + 1)}
|
|
674
|
+
onItemDeleted={() => setCounter(counter => counter - 1)}
|
|
675
|
+
onFileUploaded={() => setCounter(counter => counter + 1)} */
|
|
676
|
+
onCurrentDirectoryChanged: onCurrentDirectoryChanged, selectionMode: props.selectionMode === 'single' ? 'single' : selectionMode, children: [_jsxs(Toolbar, { children: [_jsx(Item, { name: "showNavPane", visible: true }), _jsx(Item, { name: "create", visible: true }), _jsx(Item, { name: "upload", visible: true }), _jsx(Item, { name: "separator", location: 'after' }), _jsx(Item, { name: "switchView", visible: true }), _jsx(Item, { name: "refresh", visible: true })] }), _jsx(ContextMenu, { items: ["create", "upload", "rename", "move", "copy", "delete", "refresh", "download"] }), _jsx(Permissions, { copy: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), move: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), create: focusedFileSystemItem && focusedFileSystemItem.name !== "", upload: focusedFileSystemItem && focusedFileSystemItem.name !== "", rename: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), delete: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), download: true }), _jsx(ItemView, { children: _jsxs(Details, { children: [_jsx(Column, { dataField: "thumbnail", cssClass: 'file-thumbnail' }, "thumbnail"), _jsx(Column, { dataField: "name", caption: SDKUI_Localizator.Name }, "name"), _jsx(Column, { dataField: 'size', width: '120px', alignment: 'center', dataType: 'number', caption: SDKUI_Localizator.File_Size }, "size"), _jsx(Column, { dataField: 'dateModified', width: '160px', alignment: 'center', dataType: 'datetime', caption: SDKUI_Localizator.Date_Modified }, "dateModified")] }) }), _jsx(Notifications, { showPopup: false })] }), _jsx("div", { style: { width: "100%", height: "30px", overflowY: "hidden" }, children: _jsx(TMCounterContainer, { items: counterValues }) })] }) }));
|
|
637
677
|
};
|
|
638
678
|
export default TMAreaManager;
|