@iobroker/adapter-react-v5 7.0.1 → 7.1.0
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/Components/404.d.ts +3 -2
- package/Components/404.js +16 -15
- package/Components/ColorPicker.d.ts +22 -8
- package/Components/ColorPicker.js +34 -17
- package/Components/ComplexCron.js +24 -24
- package/Components/CopyToClipboard.d.ts +10 -1
- package/Components/CopyToClipboard.js +17 -8
- package/Components/CustomModal.d.ts +1 -1
- package/Components/CustomModal.js +8 -8
- package/Components/FileBrowser.d.ts +11 -11
- package/Components/FileBrowser.js +173 -164
- package/Components/FileViewer.js +34 -23
- package/Components/Icon.d.ts +16 -2
- package/Components/Icon.js +19 -8
- package/Components/IconPicker.js +10 -14
- package/Components/IconSelector.d.ts +1 -1
- package/Components/IconSelector.js +64 -74
- package/Components/Image.d.ts +8 -4
- package/Components/Image.js +13 -32
- package/Components/Loader.d.ts +2 -2
- package/Components/Loader.js +244 -241
- package/Components/Loaders/MV.d.ts +6 -1
- package/Components/Loaders/MV.js +23 -7
- package/Components/Loaders/PT.d.ts +7 -2
- package/Components/Loaders/PT.js +123 -110
- package/Components/Loaders/Vendor.d.ts +2 -2
- package/Components/Loaders/Vendor.js +22 -14
- package/Components/Logo.js +16 -18
- package/Components/MDUtils.d.ts +1 -1
- package/Components/MDUtils.js +8 -4
- package/Components/ObjectBrowser.d.ts +49 -38
- package/Components/ObjectBrowser.js +757 -494
- package/Components/Router.d.ts +1 -3
- package/Components/Router.js +3 -1
- package/Components/SaveCloseButtons.d.ts +3 -3
- package/Components/SaveCloseButtons.js +3 -3
- package/Components/Schedule.d.ts +15 -15
- package/Components/Schedule.js +177 -154
- package/Components/SelectWithIcon.d.ts +2 -2
- package/Components/SelectWithIcon.js +45 -34
- package/Components/SimpleCron/index.js +83 -43
- package/Components/TabContainer.js +2 -2
- package/Components/TabContent.js +1 -1
- package/Components/TabHeader.js +1 -1
- package/Components/TableResize.d.ts +2 -2
- package/Components/TableResize.js +5 -5
- package/Components/TextWithIcon.d.ts +1 -1
- package/Components/TextWithIcon.js +10 -8
- package/Components/ToggleThemeMenu.d.ts +2 -2
- package/Components/ToggleThemeMenu.js +3 -3
- package/Components/TreeTable.d.ts +18 -18
- package/Components/TreeTable.js +76 -72
- package/Components/UploadImage.d.ts +2 -2
- package/Components/UploadImage.js +330 -326
- package/Components/Utils.d.ts +42 -22
- package/Components/Utils.js +66 -65
- package/Components/withWidth.d.ts +2 -2
- package/Components/withWidth.js +10 -6
- package/Dialogs/ComplexCron.d.ts +2 -2
- package/Dialogs/ComplexCron.js +3 -3
- package/Dialogs/Confirm.d.ts +4 -4
- package/Dialogs/Confirm.js +18 -8
- package/Dialogs/Cron.d.ts +3 -3
- package/Dialogs/Cron.js +21 -17
- package/Dialogs/Error.d.ts +3 -3
- package/Dialogs/Error.js +6 -4
- package/Dialogs/Message.d.ts +3 -3
- package/Dialogs/Message.js +6 -4
- package/Dialogs/SelectFile.d.ts +4 -4
- package/Dialogs/SelectFile.js +6 -4
- package/Dialogs/SelectID.d.ts +12 -10
- package/Dialogs/SelectID.js +12 -8
- package/Dialogs/SimpleCron.d.ts +2 -2
- package/Dialogs/SimpleCron.js +2 -2
- package/Dialogs/TextInput.d.ts +2 -2
- package/Dialogs/TextInput.js +3 -3
- package/GenericApp.d.ts +19 -13
- package/GenericApp.js +177 -134
- package/LICENSE +22 -22
- package/LegacyConnection.d.ts +240 -248
- package/LegacyConnection.js +500 -525
- package/Prompt.js +7 -7
- package/README.md +1239 -1166
- package/Theme.d.ts +1 -1
- package/Theme.js +9 -12
- package/assets/devices.json +1 -0
- package/assets/lamp_ceiling.svg +8 -8
- package/assets/lamp_table.svg +7 -7
- package/assets/no_icon.svg +9 -9
- package/assets/rooms.json +1 -0
- package/craco-module-federation.js +62 -71
- package/i18n/de.json +434 -431
- package/i18n/en.json +434 -431
- package/i18n/es.json +434 -431
- package/i18n/fr.json +434 -431
- package/i18n/it.json +434 -431
- package/i18n/nl.json +434 -431
- package/i18n/pl.json +434 -431
- package/i18n/pt.json +434 -431
- package/i18n/ru.json +434 -431
- package/i18n/uk.json +434 -431
- package/i18n/zh-cn.json +434 -431
- package/i18n.d.ts +26 -19
- package/i18n.js +28 -22
- package/icons/IconAdapter.js +2 -2
- package/icons/IconAlias.js +2 -2
- package/icons/IconChannel.js +2 -2
- package/icons/IconClearFilter.js +2 -2
- package/icons/IconClosed.js +2 -2
- package/icons/IconCopy.js +2 -2
- package/icons/IconDevice.js +2 -2
- package/icons/IconDocument.js +2 -2
- package/icons/IconDocumentReadOnly.js +2 -2
- package/icons/IconExpert.js +2 -2
- package/icons/IconFx.js +2 -2
- package/icons/IconInstance.js +2 -2
- package/icons/IconLogout.js +2 -2
- package/icons/IconNoIcon.js +2 -2
- package/icons/IconOpen.d.ts +2 -2
- package/icons/IconOpen.js +2 -2
- package/icons/IconProps.d.ts +4 -3
- package/icons/IconState.d.ts +2 -2
- package/icons/IconState.js +2 -2
- package/index.css +56 -55
- package/modulefederation.admin.config.js +31 -31
- package/package.json +5 -5
- package/src/AdminConnection.tsx +3 -3
- package/src/Components/404.tsx +122 -121
- package/src/Components/ColorPicker.tsx +343 -315
- package/src/Components/ComplexCron.tsx +544 -507
- package/src/Components/CopyToClipboard.tsx +178 -165
- package/src/Components/CustomModal.tsx +170 -163
- package/src/Components/FileBrowser.tsx +2550 -2414
- package/src/Components/FileViewer.tsx +412 -393
- package/src/Components/Icon.tsx +238 -210
- package/src/Components/IconPicker.tsx +165 -149
- package/src/Components/IconSelector.tsx +2220 -2202
- package/src/Components/Image.tsx +193 -176
- package/src/Components/Loader.tsx +328 -304
- package/src/Components/Logo.tsx +176 -166
- package/src/Components/MDUtils.tsx +104 -100
- package/src/Components/ObjectBrowser.tsx +8935 -8032
- package/src/Components/Router.tsx +90 -90
- package/src/Components/SaveCloseButtons.tsx +117 -113
- package/src/Components/Schedule.tsx +1962 -1724
- package/src/Components/SelectWithIcon.tsx +239 -197
- package/src/Components/TabContainer.tsx +57 -55
- package/src/Components/TabContent.tsx +38 -37
- package/src/Components/TabHeader.tsx +20 -19
- package/src/Components/TableResize.tsx +274 -259
- package/src/Components/TextWithIcon.tsx +159 -148
- package/src/Components/ToggleThemeMenu.tsx +52 -34
- package/src/Components/TreeTable.tsx +1002 -919
- package/src/Components/UploadImage.tsx +631 -599
- package/src/Components/Utils.tsx +1802 -1794
- package/src/Components/loader.css +231 -222
- package/src/Components/withWidth.tsx +32 -21
- package/src/Connection.tsx +5 -7
- package/src/Dialogs/ComplexCron.tsx +123 -129
- package/src/Dialogs/Confirm.tsx +185 -162
- package/src/Dialogs/Cron.tsx +192 -182
- package/src/Dialogs/Error.tsx +67 -72
- package/src/Dialogs/Message.tsx +73 -71
- package/src/Dialogs/SelectFile.tsx +280 -270
- package/src/Dialogs/SelectID.tsx +310 -298
- package/src/Dialogs/SimpleCron.tsx +100 -100
- package/src/Dialogs/TextInput.tsx +99 -107
- package/src/GenericApp.tsx +1076 -976
- package/src/LegacyConnection.tsx +3719 -3589
- package/src/Prompt.tsx +22 -20
- package/src/Theme.tsx +472 -479
- package/src/icons/IconAdapter.tsx +22 -20
- package/src/icons/IconAlias.tsx +22 -20
- package/src/icons/IconChannel.tsx +60 -21
- package/src/icons/IconClearFilter.tsx +24 -22
- package/src/icons/IconClosed.tsx +22 -17
- package/src/icons/IconCopy.tsx +21 -16
- package/src/icons/IconDevice.tsx +126 -27
- package/src/icons/IconDocument.tsx +22 -17
- package/src/icons/IconDocumentReadOnly.tsx +27 -18
- package/src/icons/IconExpert.tsx +26 -18
- package/src/icons/IconFx.tsx +38 -36
- package/src/icons/IconInstance.tsx +22 -20
- package/src/icons/IconLogout.tsx +32 -30
- package/src/icons/IconNoIcon.tsx +21 -19
- package/src/icons/IconOpen.tsx +22 -17
- package/src/icons/IconProps.tsx +16 -15
- package/src/icons/IconState.tsx +38 -17
- package/src/index.css +56 -55
- package/tasks.js +91 -0
- package/types.d.ts +141 -134
- package/Components/Loaders/PT.css +0 -109
- package/Components/Loaders/Vendor.css +0 -13
- package/Components/loader.css +0 -222
- package/Components/types.d.ts +0 -82
- package/assets/devices/Alarm Systems.svg +0 -19
- package/assets/devices/Amplifier.svg +0 -22
- package/assets/devices/Awnings.svg +0 -5
- package/assets/devices/Battery Status.svg +0 -5
- package/assets/devices/Ceiling Spotlights.svg +0 -16
- package/assets/devices/Chandelier.svg +0 -7
- package/assets/devices/Climate.svg +0 -12
- package/assets/devices/Coffee Makers.svg +0 -6
- package/assets/devices/Cold Water.svg +0 -31
- package/assets/devices/Computer.svg +0 -21
- package/assets/devices/Consumption.svg +0 -8
- package/assets/devices/Curtains.svg +0 -43
- package/assets/devices/Dishwashers.svg +0 -12
- package/assets/devices/Doors.svg +0 -6
- package/assets/devices/Doorstep.svg +0 -35
- package/assets/devices/Dryer.svg +0 -14
- package/assets/devices/Fan.svg +0 -20
- package/assets/devices/Floor Lamps.svg +0 -5
- package/assets/devices/Garage Doors.svg +0 -9
- package/assets/devices/Gates.svg +0 -32
- package/assets/devices/Hairdryer.svg +0 -23
- package/assets/devices/Handle.svg +0 -6
- package/assets/devices/Hanging Lamps.svg +0 -9
- package/assets/devices/Heater.svg +0 -44
- package/assets/devices/Hoods.svg +0 -12
- package/assets/devices/Hot Water.svg +0 -10
- package/assets/devices/Humidity.svg +0 -41
- package/assets/devices/Iron.svg +0 -5
- package/assets/devices/Irrigation.svg +0 -23
- package/assets/devices/Led Strip.svg +0 -31
- package/assets/devices/Light.svg +0 -30
- package/assets/devices/Lightings.svg +0 -46
- package/assets/devices/Lock.svg +0 -19
- package/assets/devices/Louvre.svg +0 -7
- package/assets/devices/Mowing Machine.svg +0 -9
- package/assets/devices/Music.svg +0 -13
- package/assets/devices/Outdoor Blinds.svg +0 -7
- package/assets/devices/People.svg +0 -19
- package/assets/devices/Pool.svg +0 -8
- package/assets/devices/Power Consumption.svg +0 -13
- package/assets/devices/Printer.svg +0 -10
- package/assets/devices/Pump.svg +0 -10
- package/assets/devices/Receiver.svg +0 -19
- package/assets/devices/Sconces.svg +0 -10
- package/assets/devices/Security.svg +0 -34
- package/assets/devices/Shading.svg +0 -5
- package/assets/devices/Shutters.svg +0 -11
- package/assets/devices/SmokeDetector.svg +0 -13
- package/assets/devices/Sockets.svg +0 -13
- package/assets/devices/Speaker.svg +0 -35
- package/assets/devices/Stove.svg +0 -12
- package/assets/devices/Table Lamps.svg +0 -12
- package/assets/devices/Temperature Sensors.svg +0 -28
- package/assets/devices/Tv.svg +0 -8
- package/assets/devices/Vacuum Cleaner.svg +0 -16
- package/assets/devices/Ventilation.svg +0 -12
- package/assets/devices/Washing Machines.svg +0 -16
- package/assets/devices/Water Consumption.svg +0 -6
- package/assets/devices/Water Heater.svg +0 -8
- package/assets/devices/Water.svg +0 -40
- package/assets/devices/Weather.svg +0 -28
- package/assets/devices/Window.svg +0 -8
- package/assets/rooms/Anteroom.svg +0 -53
- package/assets/rooms/Attic.svg +0 -21
- package/assets/rooms/Balcony.svg +0 -13
- package/assets/rooms/Barn.svg +0 -6
- package/assets/rooms/Basement.svg +0 -5
- package/assets/rooms/Bathroom.svg +0 -38
- package/assets/rooms/Bedroom.svg +0 -5
- package/assets/rooms/Boiler Room.svg +0 -13
- package/assets/rooms/Carport.svg +0 -17
- package/assets/rooms/Cellar.svg +0 -89
- package/assets/rooms/Chamber.svg +0 -9
- package/assets/rooms/Corridor.svg +0 -53
- package/assets/rooms/Dining Area.svg +0 -37
- package/assets/rooms/Dining Room.svg +0 -37
- package/assets/rooms/Dining.svg +0 -37
- package/assets/rooms/Dressing Room.svg +0 -5
- package/assets/rooms/Driveway.svg +0 -15
- package/assets/rooms/Entrance.svg +0 -44
- package/assets/rooms/Equipment Room.svg +0 -15
- package/assets/rooms/Front Yard.svg +0 -64
- package/assets/rooms/Gallery.svg +0 -14
- package/assets/rooms/Garage.svg +0 -20
- package/assets/rooms/Garden.svg +0 -13
- package/assets/rooms/Ground Floor.svg +0 -95
- package/assets/rooms/Guest Bathroom.svg +0 -33
- package/assets/rooms/Guest Room.svg +0 -5
- package/assets/rooms/Gym.svg +0 -5
- package/assets/rooms/Hall.svg +0 -19
- package/assets/rooms/Home Theater.svg +0 -8
- package/assets/rooms/Kitchen.svg +0 -18
- package/assets/rooms/Laundry Room.svg +0 -12
- package/assets/rooms/Living Area.svg +0 -11
- package/assets/rooms/Living Room.svg +0 -10
- package/assets/rooms/Locker Room.svg +0 -17
- package/assets/rooms/Nursery.svg +0 -5
- package/assets/rooms/Office.svg +0 -8
- package/assets/rooms/Outdoors.svg +0 -7
- package/assets/rooms/Playroom.svg +0 -6
- package/assets/rooms/Pool.svg +0 -8
- package/assets/rooms/Rear Wall.svg +0 -30
- package/assets/rooms/Second Floor.svg +0 -95
- package/assets/rooms/Shed.svg +0 -16
- package/assets/rooms/Sleeping Area.svg +0 -22
- package/assets/rooms/Stairway.svg +0 -5
- package/assets/rooms/Stairwell.svg +0 -15
- package/assets/rooms/Storeroom.svg +0 -5
- package/assets/rooms/Summer House.svg +0 -27
- package/assets/rooms/Swimming Pool.svg +0 -21
- package/assets/rooms/Terrace.svg +0 -7
- package/assets/rooms/Toilet.svg +0 -10
- package/assets/rooms/Upstairs.svg +0 -6
- package/assets/rooms/Wardrobe.svg +0 -60
- package/assets/rooms/Washroom.svg +0 -20
- package/assets/rooms/Wc.svg +0 -10
- package/assets/rooms/Windscreen.svg +0 -60
- package/assets/rooms/Workshop.svg +0 -23
- package/assets/rooms/Workspace.svg +0 -8
|
@@ -32,7 +32,7 @@ exports.FileBrowserClass = void 0;
|
|
|
32
32
|
*
|
|
33
33
|
* MIT License
|
|
34
34
|
*
|
|
35
|
-
|
|
35
|
+
*/
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const react_dropzone_1 = __importDefault(require("react-dropzone"));
|
|
38
38
|
const material_1 = require("@mui/material");
|
|
@@ -394,7 +394,7 @@ const TABLE = 'Table';
|
|
|
394
394
|
const TILE = 'Tile';
|
|
395
395
|
function sortFolders(a, b) {
|
|
396
396
|
if (a.folder && b.folder) {
|
|
397
|
-
return a.name > b.name ? 1 :
|
|
397
|
+
return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
|
|
398
398
|
}
|
|
399
399
|
if (a.folder) {
|
|
400
400
|
return -1;
|
|
@@ -402,7 +402,7 @@ function sortFolders(a, b) {
|
|
|
402
402
|
if (b.folder) {
|
|
403
403
|
return 1;
|
|
404
404
|
}
|
|
405
|
-
return a.name > b.name ? 1 :
|
|
405
|
+
return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
|
|
406
406
|
}
|
|
407
407
|
class FileBrowserClass extends react_1.Component {
|
|
408
408
|
constructor(props) {
|
|
@@ -420,18 +420,23 @@ class FileBrowserClass extends react_1.Component {
|
|
|
420
420
|
const folder = key.substring(0, pos);
|
|
421
421
|
console.log(`File changed ${key}[${size}]`);
|
|
422
422
|
if (this.state.folders[folder]) {
|
|
423
|
-
|
|
423
|
+
if (this._tempTimeout[folder]) {
|
|
424
|
+
clearTimeout(this._tempTimeout[folder]);
|
|
425
|
+
}
|
|
424
426
|
this._tempTimeout[folder] = setTimeout(() => {
|
|
425
427
|
delete this._tempTimeout[folder];
|
|
426
428
|
this.browseFolder(folder, null, false, true)
|
|
427
|
-
.then(folders => this.setState({ folders }))
|
|
429
|
+
.then(folders => this.setState({ folders }))
|
|
430
|
+
.catch(e => console.error(`Cannot read folder: ${e.message}`));
|
|
428
431
|
}, 300);
|
|
429
432
|
}
|
|
430
433
|
};
|
|
431
434
|
this.setStateBackgroundImage = () => {
|
|
432
435
|
const array = ['light', 'dark', 'colored', 'delete'];
|
|
433
436
|
this.setState(({ backgroundImage }) => {
|
|
434
|
-
if (backgroundImage &&
|
|
437
|
+
if (backgroundImage &&
|
|
438
|
+
array.indexOf(backgroundImage) !== -1 &&
|
|
439
|
+
array.length - 1 !== array.indexOf(backgroundImage)) {
|
|
435
440
|
this.localStorage.setItem('files.backgroundImage', array[array.indexOf(backgroundImage) + 1]);
|
|
436
441
|
return { backgroundImage: array[array.indexOf(backgroundImage) + 1] };
|
|
437
442
|
}
|
|
@@ -454,7 +459,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
454
459
|
return null;
|
|
455
460
|
}
|
|
456
461
|
};
|
|
457
|
-
this.localStorage =
|
|
462
|
+
this.localStorage = window._localStorage || window.localStorage;
|
|
458
463
|
const expandedStr = this.localStorage.getItem('files.expanded') || '[]';
|
|
459
464
|
if (this.props.limitPath) {
|
|
460
465
|
const parts = this.props.limitPath.split('/');
|
|
@@ -471,7 +476,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
471
476
|
expanded = expanded.filter(id => {
|
|
472
477
|
var _a;
|
|
473
478
|
return id.startsWith(`${this.limitToPath}/`) ||
|
|
474
|
-
id === this.limitToPath ||
|
|
479
|
+
id === this.limitToPath ||
|
|
480
|
+
((_a = this.limitToPath) === null || _a === void 0 ? void 0 : _a.startsWith(`${id}/`));
|
|
475
481
|
});
|
|
476
482
|
}
|
|
477
483
|
}
|
|
@@ -485,9 +491,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
485
491
|
else {
|
|
486
492
|
viewType = TABLE;
|
|
487
493
|
}
|
|
488
|
-
let selected = this.props.selected ||
|
|
489
|
-
this.localStorage.getItem('files.selected') ||
|
|
490
|
-
USER_DATA;
|
|
494
|
+
let selected = this.props.selected || this.localStorage.getItem('files.selected') || USER_DATA;
|
|
491
495
|
let currentDir;
|
|
492
496
|
if (props.restrictToFolder) {
|
|
493
497
|
selected = props.restrictToFolder;
|
|
@@ -596,20 +600,20 @@ class FileBrowserClass extends react_1.Component {
|
|
|
596
600
|
}
|
|
597
601
|
async componentDidMount() {
|
|
598
602
|
this.mounted = true;
|
|
599
|
-
this.loadFolders()
|
|
600
|
-
.catch(error => console.error(`Cannot load folders: ${error}`));
|
|
603
|
+
this.loadFolders().catch(error => console.error(`Cannot load folders: ${error}`));
|
|
601
604
|
this.supportSubscribes = await this.props.socket.checkFeatureSupported('BINARY_STATE_EVENT');
|
|
602
605
|
if (this.supportSubscribes) {
|
|
603
606
|
await this.props.socket.subscribeFiles('*', '*', this.onFileChange);
|
|
604
607
|
}
|
|
605
608
|
}
|
|
606
609
|
componentWillUnmount() {
|
|
607
|
-
|
|
610
|
+
if (this.supportSubscribes) {
|
|
611
|
+
this.props.socket.unsubscribeFiles('*', '*', this.onFileChange);
|
|
612
|
+
}
|
|
608
613
|
this.mounted = false;
|
|
609
614
|
this.browseList = null;
|
|
610
615
|
this.browseListRunning = false;
|
|
611
|
-
Object.values(this._tempTimeout)
|
|
612
|
-
.forEach(timer => timer && clearTimeout(timer));
|
|
616
|
+
Object.values(this._tempTimeout).forEach(timer => timer && clearTimeout(timer));
|
|
613
617
|
this._tempTimeout = {};
|
|
614
618
|
}
|
|
615
619
|
browseFoldersCb(foldersList, newFoldersNotNull, cb) {
|
|
@@ -619,8 +623,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
619
623
|
else {
|
|
620
624
|
const folder = foldersList.shift();
|
|
621
625
|
if (folder) {
|
|
622
|
-
this.browseFolder(folder, newFoldersNotNull)
|
|
623
|
-
.catch((e) => console.error(`Cannot read folder ${folder}: ${e}`))
|
|
626
|
+
void this.browseFolder(folder, newFoldersNotNull)
|
|
627
|
+
.catch((e) => console.error(`Cannot read folder ${folder}: ${e.message}`))
|
|
624
628
|
.then(() => {
|
|
625
629
|
setTimeout(() => this.browseFoldersCb(foldersList, newFoldersNotNull, cb), 0);
|
|
626
630
|
});
|
|
@@ -687,7 +691,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
687
691
|
item.reject = null;
|
|
688
692
|
item.adapter = null;
|
|
689
693
|
item.relPath = null;
|
|
690
|
-
|
|
694
|
+
if (resolve) {
|
|
695
|
+
resolve(files);
|
|
696
|
+
}
|
|
691
697
|
this.browseListRunning = false;
|
|
692
698
|
if (this.browseList.length) {
|
|
693
699
|
if (level < 5) {
|
|
@@ -716,7 +722,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
716
722
|
item.reject = null;
|
|
717
723
|
item.adapter = null;
|
|
718
724
|
item.relPath = null;
|
|
719
|
-
|
|
725
|
+
if (reject) {
|
|
726
|
+
reject(e);
|
|
727
|
+
}
|
|
720
728
|
this.browseListRunning = false;
|
|
721
729
|
if (this.browseList.length) {
|
|
722
730
|
if (level < 5) {
|
|
@@ -751,10 +759,11 @@ class FileBrowserClass extends react_1.Component {
|
|
|
751
759
|
if (newFoldersNotNull[folderId] && !force) {
|
|
752
760
|
if (!_checkEmpty) {
|
|
753
761
|
return new Promise((resolve, reject) => {
|
|
754
|
-
Promise.all(newFoldersNotNull[folderId]
|
|
755
|
-
.
|
|
762
|
+
Promise.all(newFoldersNotNull[folderId]
|
|
763
|
+
.filter(item => item.folder)
|
|
764
|
+
.map(item => this.browseFolder(item.id, newFoldersNotNull, true).catch(() => undefined)))
|
|
756
765
|
.then(() => resolve(newFoldersNotNull))
|
|
757
|
-
.catch(error => reject(error));
|
|
766
|
+
.catch(error => reject(new Error(error)));
|
|
758
767
|
});
|
|
759
768
|
}
|
|
760
769
|
return Promise.resolve(newFoldersNotNull);
|
|
@@ -802,20 +811,24 @@ class FileBrowserClass extends react_1.Component {
|
|
|
802
811
|
_folders.push(item);
|
|
803
812
|
}
|
|
804
813
|
});
|
|
805
|
-
_folders.sort((a, b) => (a.id > b.id ? 1 :
|
|
814
|
+
_folders.sort((a, b) => (a.id > b.id ? 1 : a.id < b.id ? -1 : 0));
|
|
806
815
|
if (!this.limitToObjectID || this.limitToObjectID === USER_DATA) {
|
|
807
|
-
|
|
816
|
+
if (userData) {
|
|
817
|
+
_folders.unshift(userData);
|
|
818
|
+
}
|
|
808
819
|
}
|
|
809
820
|
newFoldersNotNull[folderId || '/'] = _folders;
|
|
810
821
|
if (!_checkEmpty) {
|
|
811
|
-
return Promise.all(_folders
|
|
812
|
-
.
|
|
813
|
-
.catch(() => undefined)))
|
|
814
|
-
.then(() => newFoldersNotNull);
|
|
822
|
+
return Promise.all(_folders
|
|
823
|
+
.filter(item => item.folder)
|
|
824
|
+
.map(item => this.browseFolder(item.id, newFoldersNotNull, true).catch(() => undefined))).then(() => newFoldersNotNull);
|
|
815
825
|
}
|
|
816
826
|
}
|
|
817
827
|
catch (e) {
|
|
818
|
-
|
|
828
|
+
const knownError = e;
|
|
829
|
+
if (this.initialReadFinished) {
|
|
830
|
+
window.alert(`Cannot read meta items: ${knownError.message}`);
|
|
831
|
+
}
|
|
819
832
|
newFoldersNotNull[folderId || '/'] = [];
|
|
820
833
|
}
|
|
821
834
|
return newFoldersNotNull;
|
|
@@ -871,12 +884,14 @@ class FileBrowserClass extends react_1.Component {
|
|
|
871
884
|
if (!_checkEmpty) {
|
|
872
885
|
return Promise.all(_folders
|
|
873
886
|
.filter(item => item.folder)
|
|
874
|
-
.map(item => this.browseFolder(item.id, newFoldersNotNull, true)))
|
|
875
|
-
.then(() => newFoldersNotNull);
|
|
887
|
+
.map(item => this.browseFolder(item.id, newFoldersNotNull, true))).then(() => newFoldersNotNull);
|
|
876
888
|
}
|
|
877
889
|
}
|
|
878
890
|
catch (e) {
|
|
879
|
-
|
|
891
|
+
const knownError = e;
|
|
892
|
+
if (this.initialReadFinished) {
|
|
893
|
+
window.alert(`Cannot read ${adapter}${relPath ? `/${relPath}` : ''}: ${knownError === null || knownError === void 0 ? void 0 : knownError.message}`);
|
|
894
|
+
}
|
|
880
895
|
newFoldersNotNull[folderId] = [];
|
|
881
896
|
}
|
|
882
897
|
return newFoldersNotNull;
|
|
@@ -907,7 +922,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
907
922
|
}
|
|
908
923
|
}
|
|
909
924
|
changeFolder(e, folder) {
|
|
910
|
-
|
|
925
|
+
if (e) {
|
|
926
|
+
e.stopPropagation();
|
|
927
|
+
}
|
|
911
928
|
this.lastSelect = Date.now();
|
|
912
929
|
let _folder = folder || getParentDir(this.state.currentDir);
|
|
913
930
|
if (_folder === '/') {
|
|
@@ -918,14 +935,16 @@ class FileBrowserClass extends react_1.Component {
|
|
|
918
935
|
return this.setState({ selected: _folder });
|
|
919
936
|
}
|
|
920
937
|
if (_folder && !this.state.folders[_folder]) {
|
|
921
|
-
|
|
938
|
+
this.browseFolder(_folder)
|
|
922
939
|
.then(folders => this.setState({
|
|
923
940
|
folders,
|
|
924
941
|
path: _folder,
|
|
925
942
|
currentDir: _folder,
|
|
926
943
|
selected: _folder,
|
|
927
944
|
pathFocus: false,
|
|
928
|
-
}, () => this.props.onSelect && this.props.onSelect('')))
|
|
945
|
+
}, () => this.props.onSelect && this.props.onSelect('')))
|
|
946
|
+
.catch(_e => console.error(`Cannot read folder: ${_e.message}`));
|
|
947
|
+
return;
|
|
929
948
|
}
|
|
930
949
|
return this.setState({
|
|
931
950
|
currentDir: _folder,
|
|
@@ -935,7 +954,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
935
954
|
}, () => this.props.onSelect && this.props.onSelect(''));
|
|
936
955
|
}
|
|
937
956
|
select(id, e, cb) {
|
|
938
|
-
|
|
957
|
+
if (e) {
|
|
958
|
+
e.stopPropagation();
|
|
959
|
+
}
|
|
939
960
|
this.lastSelect = Date.now();
|
|
940
961
|
this.localStorage.setItem('files.selected', id);
|
|
941
962
|
this.setState({ selected: id, path: id, pathFocus: false }, () => {
|
|
@@ -950,7 +971,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
950
971
|
this.props.onSelect('');
|
|
951
972
|
}
|
|
952
973
|
}
|
|
953
|
-
|
|
974
|
+
if (cb) {
|
|
975
|
+
cb();
|
|
976
|
+
}
|
|
954
977
|
});
|
|
955
978
|
}
|
|
956
979
|
getText(text) {
|
|
@@ -974,21 +997,21 @@ class FileBrowserClass extends react_1.Component {
|
|
|
974
997
|
const padding = this.state.viewType === TABLE ? item.level * this.levelPadding : 0;
|
|
975
998
|
const isUserData = item.name === USER_DATA;
|
|
976
999
|
const isSpecialData = isUserData || item.name === 'vis.0' || item.name === 'vis-2.0';
|
|
977
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: item.id, id: item.id, style: this.state.viewType === TABLE ? { marginLeft: padding, width: `calc(100% - ${padding}px` } : {}, onClick: e => (this.state.viewType === TABLE ? this.select(item.id, e) : this.changeFolder(e, item.id)), onDoubleClick: e => this.state.viewType === TABLE && this.toggleFolder(item, e), title: this.getText(item.title), className: "browserItem", sx: Utils_1.default.getStyle(this.props.theme, styles[`item${this.state.viewType}`], styles[`itemFolder${this.state.viewType}`], this.state.selected === item.id ? styles.itemSelected : {}, item.temp ? styles.itemFolderTemp : {}) },
|
|
978
|
-
react_1.default.createElement(IconEl, { style: Utils_1.default.getStyle(this.props.theme, styles[`itemFolderIcon${this.state.viewType}`], isSpecialData && styles.specialFolder), onClick: this.state.viewType === TABLE
|
|
1000
|
+
return (react_1.default.createElement(material_1.Box, { component: "div", key: item.id, id: item.id, style: this.state.viewType === TABLE ? { marginLeft: padding, width: `calc(100% - ${padding}px` } : {}, onClick: e => (this.state.viewType === TABLE ? this.select(item.id, e) : this.changeFolder(e, item.id)), onDoubleClick: e => this.state.viewType === TABLE && this.toggleFolder(item, e), title: this.getText(item.title), className: "browserItem", sx: Utils_1.default.getStyle(this.props.theme, styles[`item${this.state.viewType}`], styles[`itemFolder${this.state.viewType}`], this.state.selected === item.id ? styles.itemSelected : {}, item.temp ? styles.itemFolderTemp : {}) },
|
|
1001
|
+
react_1.default.createElement(IconEl, { style: Utils_1.default.getStyle(this.props.theme, styles[`itemFolderIcon${this.state.viewType}`], isSpecialData && styles.specialFolder), onClick: this.state.viewType === TABLE
|
|
1002
|
+
? (e) => this.toggleFolder(item, e)
|
|
1003
|
+
: undefined }),
|
|
979
1004
|
react_1.default.createElement(material_1.Box, { component: "div", sx: Utils_1.default.getStyle(this.props.theme, styles[`itemName${this.state.viewType}`], styles[`itemNameFolder${this.state.viewType}`]) }, isUserData ? this.props.t('ra_User files') : item.name),
|
|
980
1005
|
react_1.default.createElement(material_1.Box, { component: "div", style: styles[`itemSize${this.state.viewType}`], sx: { display: { md: 'inline-block', sm: 'none' } } }, this.state.viewType === TABLE && this.state.folders[item.id]
|
|
981
1006
|
? this.state.folders[item.id].length
|
|
982
1007
|
: ''),
|
|
983
1008
|
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.state.viewType === TABLE && this.props.expertMode ? this.formatAcl(item.acl) : null),
|
|
984
|
-
this.state.viewType === TABLE && this.props.expertMode ?
|
|
985
|
-
|
|
986
|
-
this.state.viewType === TABLE && this.props.allowDownload ?
|
|
987
|
-
react_1.default.createElement("div", { style: styles[`itemDownloadEmpty${this.state.viewType}`] }) : null,
|
|
1009
|
+
this.state.viewType === TABLE && this.props.expertMode ? (react_1.default.createElement(material_1.Box, { component: "div", sx: Object.assign(Object.assign({}, styles.itemDeleteButtonTable), { display: { md: 'inline-block', sm: 'none' } }) })) : null,
|
|
1010
|
+
this.state.viewType === TABLE && this.props.allowDownload ? (react_1.default.createElement("div", { style: styles[`itemDownloadEmpty${this.state.viewType}`] })) : null,
|
|
988
1011
|
this.state.viewType === TABLE &&
|
|
989
1012
|
this.props.allowDelete &&
|
|
990
1013
|
this.state.folders[item.id] &&
|
|
991
|
-
this.state.folders[item.id].length ? react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
|
|
1014
|
+
this.state.folders[item.id].length ? (react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
|
|
992
1015
|
e.stopPropagation();
|
|
993
1016
|
if (this.suppressDeleteConfirm > Date.now()) {
|
|
994
1017
|
this.deleteItem(item.id);
|
|
@@ -997,21 +1020,19 @@ class FileBrowserClass extends react_1.Component {
|
|
|
997
1020
|
this.setState({ deleteItem: item.id });
|
|
998
1021
|
}
|
|
999
1022
|
}, sx: styles[`itemDeleteButton${this.state.viewType}`], size: "large" },
|
|
1000
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" })) :
|
|
1001
|
-
this.state.viewType === TABLE && this.props.allowDelete ?
|
|
1002
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] }) : null);
|
|
1023
|
+
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))) : this.state.viewType === TABLE && this.props.allowDelete ? (react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] })) : null));
|
|
1003
1024
|
}
|
|
1004
1025
|
renderBackFolder() {
|
|
1005
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: this.state.currentDir, id: this.state.currentDir, onClick: e => this.changeFolder(e), title: this.props.t('ra_Back to %s', getParentDir(this.state.currentDir)), className: "browserItem", sx: Utils_1.default.getStyle(this.props.theme, styles[`item${this.state.viewType}`], styles[`itemFolder${this.state.viewType}`]) },
|
|
1026
|
+
return (react_1.default.createElement(material_1.Box, { component: "div", key: this.state.currentDir, id: this.state.currentDir, onClick: e => this.changeFolder(e), title: this.props.t('ra_Back to %s', getParentDir(this.state.currentDir)), className: "browserItem", sx: Utils_1.default.getStyle(this.props.theme, styles[`item${this.state.viewType}`], styles[`itemFolder${this.state.viewType}`]) },
|
|
1006
1027
|
react_1.default.createElement(IconClosed_1.default, { style: styles[`itemFolderIcon${this.state.viewType}`] }),
|
|
1007
1028
|
react_1.default.createElement(icons_material_1.ArrowBack, { sx: styles.itemFolderIconBack }),
|
|
1008
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: Utils_1.default.getStyle(this.props.theme, styles[`itemName${this.state.viewType}`], styles[`itemNameFolder${this.state.viewType}`]) }, ".."));
|
|
1029
|
+
react_1.default.createElement(material_1.Box, { component: "div", sx: Utils_1.default.getStyle(this.props.theme, styles[`itemName${this.state.viewType}`], styles[`itemNameFolder${this.state.viewType}`]) }, "..")));
|
|
1009
1030
|
}
|
|
1010
1031
|
formatSize(size) {
|
|
1011
|
-
return react_1.default.createElement("div", { style: styles[`itemSize${this.state.viewType}`] }, size || size === 0 ? Utils_1.default.formatBytes(size) : '');
|
|
1032
|
+
return (react_1.default.createElement("div", { style: styles[`itemSize${this.state.viewType}`] }, size || size === 0 ? Utils_1.default.formatBytes(size) : ''));
|
|
1012
1033
|
}
|
|
1013
1034
|
formatAcl(acl) {
|
|
1014
|
-
const access = acl ?
|
|
1035
|
+
const access = acl ? acl.permissions || acl.file : 0;
|
|
1015
1036
|
let accessStr;
|
|
1016
1037
|
if (access) {
|
|
1017
1038
|
accessStr = access.toString(16).padStart(3, '0');
|
|
@@ -1019,7 +1040,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1019
1040
|
else {
|
|
1020
1041
|
accessStr = '';
|
|
1021
1042
|
}
|
|
1022
|
-
return react_1.default.createElement("div", { style: styles[`itemAccess${this.state.viewType}`] }, this.props.modalEditOfAccessControl ? react_1.default.createElement(material_1.IconButton, { size: "large", onClick: () => this.setState({ modalEditOfAccess: true }), sx: styles[`itemAclButton${this.state.viewType}`] }, accessStr || '---') : accessStr || '---');
|
|
1043
|
+
return (react_1.default.createElement("div", { style: styles[`itemAccess${this.state.viewType}`] }, this.props.modalEditOfAccessControl ? (react_1.default.createElement(material_1.IconButton, { size: "large", onClick: () => this.setState({ modalEditOfAccess: true }), sx: styles[`itemAclButton${this.state.viewType}`] }, accessStr || '---')) : (accessStr || '---')));
|
|
1023
1044
|
}
|
|
1024
1045
|
getFileIcon(ext) {
|
|
1025
1046
|
switch (ext) {
|
|
@@ -1062,7 +1083,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1062
1083
|
renderFile(item) {
|
|
1063
1084
|
const padding = this.state.viewType === TABLE ? item.level * this.levelPadding : 0;
|
|
1064
1085
|
const ext = Utils_1.default.getFileExtension(item.name);
|
|
1065
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: item.id, id: item.id, onDoubleClick: e => {
|
|
1086
|
+
return (react_1.default.createElement(material_1.Box, { component: "div", key: item.id, id: item.id, onDoubleClick: e => {
|
|
1066
1087
|
e.stopPropagation();
|
|
1067
1088
|
if (!this.props.onSelect) {
|
|
1068
1089
|
this.setState({ viewer: this.imagePrefix + item.id, formatEditFile: ext });
|
|
@@ -1074,46 +1095,38 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1074
1095
|
this.props.onSelect(item.id, true, !!this.state.folders[item.id]);
|
|
1075
1096
|
}
|
|
1076
1097
|
}, onClick: e => this.select(item.id, e), style: this.state.viewType === TABLE ? { marginLeft: padding, width: `calc(100% - ${padding}px)` } : {}, className: "browserItem", sx: Utils_1.default.getStyle(this.props.theme, styles[`item${this.state.viewType}`], styles[`itemFile${this.state.viewType}`], this.state.selected === item.id ? styles.itemSelected : undefined) },
|
|
1077
|
-
ext && FileViewer_1.EXTENSIONS.images.includes(ext) ?
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
this.setState({ fileErrors });
|
|
1086
|
-
}
|
|
1087
|
-
}, style: Object.assign(Object.assign({}, styles[`itemImage${this.state.viewType}`]), this.getStyleBackgroundImage()), src: this.imagePrefix + item.id, alt: item.name })
|
|
1088
|
-
:
|
|
1089
|
-
this.getFileIcon(ext),
|
|
1098
|
+
ext && FileViewer_1.EXTENSIONS.images.includes(ext) ? (this.state.fileErrors.includes(item.id) ? (react_1.default.createElement(IconNoIcon_1.default, { style: Object.assign(Object.assign(Object.assign({}, styles[`itemImage${this.state.viewType}`]), this.getStyleBackgroundImage()), styles[`itemNoImage${this.state.viewType}`]) })) : (react_1.default.createElement(Icon_1.default, { onError: e => {
|
|
1099
|
+
e.target.onerror = null;
|
|
1100
|
+
const fileErrors = [...this.state.fileErrors];
|
|
1101
|
+
if (!fileErrors.includes(item.id)) {
|
|
1102
|
+
fileErrors.push(item.id);
|
|
1103
|
+
this.setState({ fileErrors });
|
|
1104
|
+
}
|
|
1105
|
+
}, style: Object.assign(Object.assign({}, styles[`itemImage${this.state.viewType}`]), this.getStyleBackgroundImage()), src: this.imagePrefix + item.id, alt: item.name }))) : (this.getFileIcon(ext)),
|
|
1090
1106
|
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemName${this.state.viewType}`] }, item.name),
|
|
1091
1107
|
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.formatSize(item.size)),
|
|
1092
1108
|
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.state.viewType === TABLE && this.props.expertMode ? this.formatAcl(item.acl) : null),
|
|
1093
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.state.viewType === TABLE && this.props.expertMode && FileBrowserClass.getEditFile(ext) ?
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
(
|
|
1102
|
-
(item.ext
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
:
|
|
1109
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] })),
|
|
1110
|
-
this.state.viewType === TABLE && this.props.allowDownload ? react_1.default.createElement(material_1.Box, { component: "a", className: "MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge", sx: styles.itemDownloadButtonTable, tabIndex: 0, download: item.id, href: this.imagePrefix + item.id, onClick: e => e.stopPropagation() },
|
|
1111
|
-
react_1.default.createElement(icons_material_1.SaveAlt, null)) : null,
|
|
1109
|
+
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.state.viewType === TABLE && this.props.expertMode && FileBrowserClass.getEditFile(ext) ? (react_1.default.createElement(material_1.IconButton, { "aria-label": "edit", onClick: e => {
|
|
1110
|
+
e.stopPropagation();
|
|
1111
|
+
if (!this.props.onSelect) {
|
|
1112
|
+
this.setState({ viewer: this.imagePrefix + item.id, formatEditFile: ext });
|
|
1113
|
+
}
|
|
1114
|
+
else if ((!this.props.filterFiles ||
|
|
1115
|
+
(item.ext && this.props.filterFiles.includes(item.ext))) &&
|
|
1116
|
+
(!this.state.filterByType ||
|
|
1117
|
+
(item.ext &&
|
|
1118
|
+
FileViewer_1.EXTENSIONS[this.state.filterByType].includes(item.ext)))) {
|
|
1119
|
+
this.props.onSelect(item.id, true, !!this.state.folders[item.id]);
|
|
1120
|
+
}
|
|
1121
|
+
}, sx: styles.itemDeleteButtonTable, size: "large" },
|
|
1122
|
+
react_1.default.createElement(icons_material_1.Edit, { fontSize: "small" }))) : (react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] }))),
|
|
1123
|
+
this.state.viewType === TABLE && this.props.allowDownload ? (react_1.default.createElement(material_1.Box, { component: "a", className: "MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge", sx: styles.itemDownloadButtonTable, tabIndex: 0, download: item.id, href: this.imagePrefix + item.id, onClick: e => e.stopPropagation() },
|
|
1124
|
+
react_1.default.createElement(icons_material_1.SaveAlt, null))) : null,
|
|
1112
1125
|
this.state.viewType === TABLE &&
|
|
1113
1126
|
this.props.allowDelete &&
|
|
1114
1127
|
item.id !== 'vis.0/' &&
|
|
1115
1128
|
item.id !== 'vis-2.0/' &&
|
|
1116
|
-
item.id !== USER_DATA ? react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
|
|
1129
|
+
item.id !== USER_DATA ? (react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
|
|
1117
1130
|
e.stopPropagation();
|
|
1118
1131
|
if (this.suppressDeleteConfirm > Date.now()) {
|
|
1119
1132
|
this.deleteItem(item.id);
|
|
@@ -1122,10 +1135,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1122
1135
|
this.setState({ deleteItem: item.id });
|
|
1123
1136
|
}
|
|
1124
1137
|
}, sx: styles[`itemDeleteButton${this.state.viewType}`], size: "large" },
|
|
1125
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))
|
|
1126
|
-
:
|
|
1127
|
-
(this.state.viewType === TABLE && this.props.allowDelete ?
|
|
1128
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] }) : null));
|
|
1138
|
+
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))) : this.state.viewType === TABLE && this.props.allowDelete ? (react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] })) : null));
|
|
1129
1139
|
}
|
|
1130
1140
|
renderItems(folderId) {
|
|
1131
1141
|
if (this.state.folders && this.state.folders[folderId]) {
|
|
@@ -1178,7 +1188,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1178
1188
|
});
|
|
1179
1189
|
return totalResult;
|
|
1180
1190
|
}
|
|
1181
|
-
return react_1.default.createElement("div", { style: { position: 'relative' } },
|
|
1191
|
+
return (react_1.default.createElement("div", { style: { position: 'relative' } },
|
|
1182
1192
|
react_1.default.createElement(material_1.CircularProgress, { key: folderId, color: "secondary", size: 24 }),
|
|
1183
1193
|
react_1.default.createElement("div", { style: {
|
|
1184
1194
|
position: 'absolute',
|
|
@@ -1186,25 +1196,24 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1186
1196
|
top: 4,
|
|
1187
1197
|
width: 24,
|
|
1188
1198
|
textAlign: 'center',
|
|
1189
|
-
} }, this.state.queueLength));
|
|
1199
|
+
} }, this.state.queueLength)));
|
|
1190
1200
|
}
|
|
1191
1201
|
renderToolbar() {
|
|
1192
1202
|
const IconType = this.props.showTypeSelector
|
|
1193
|
-
? FILE_TYPE_ICONS[this.state.filterByType || 'all'] ||
|
|
1194
|
-
FILE_TYPE_ICONS.all
|
|
1203
|
+
? FILE_TYPE_ICONS[this.state.filterByType || 'all'] || FILE_TYPE_ICONS.all
|
|
1195
1204
|
: null;
|
|
1196
1205
|
const isInFolder = this.findFirstFolder(this.state.selected);
|
|
1197
|
-
return react_1.default.createElement(material_1.Toolbar, { key: "toolbar", variant: "dense" },
|
|
1198
|
-
this.props.allowNonRestricted && this.props.restrictToFolder ? react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.state.restrictToFolder
|
|
1206
|
+
return (react_1.default.createElement(material_1.Toolbar, { key: "toolbar", variant: "dense" },
|
|
1207
|
+
this.props.allowNonRestricted && this.props.restrictToFolder ? (react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.state.restrictToFolder
|
|
1199
1208
|
? this.props.t('ra_Show all folders')
|
|
1200
1209
|
: this.props.t('ra_Restrict to folder'), style: Object.assign(Object.assign({}, styles.menuButton), (this.state.restrictToFolder ? styles.menuButtonRestrictActive : undefined)), "aria-label": "restricted to folder", onClick: () => this.setState({
|
|
1201
1210
|
restrictToFolder: (this.state.restrictToFolder ? '' : this.props.restrictToFolder) || '',
|
|
1202
1211
|
loadAllFolders: true,
|
|
1203
1212
|
}), size: "small" },
|
|
1204
|
-
react_1.default.createElement(icons_material_1.FolderSpecial, { fontSize: "small" })) : null,
|
|
1205
|
-
this.props.showExpertButton ? react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Toggle expert mode'), style: Object.assign(Object.assign({}, styles.menuButton), (this.state.expertMode ? styles.menuButtonExpertActive : undefined)), "aria-label": "expert mode", onClick: () => this.setState({ expertMode: !this.state.expertMode }), size: "small" },
|
|
1206
|
-
react_1.default.createElement(IconExpert_1.default, null)) : null,
|
|
1207
|
-
this.props.showViewTypeButton ? react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Toggle view mode'), style: styles.menuButton, "aria-label": "view mode", onClick: () => {
|
|
1213
|
+
react_1.default.createElement(icons_material_1.FolderSpecial, { fontSize: "small" }))) : null,
|
|
1214
|
+
this.props.showExpertButton ? (react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Toggle expert mode'), style: Object.assign(Object.assign({}, styles.menuButton), (this.state.expertMode ? styles.menuButtonExpertActive : undefined)), "aria-label": "expert mode", onClick: () => this.setState({ expertMode: !this.state.expertMode }), size: "small" },
|
|
1215
|
+
react_1.default.createElement(IconExpert_1.default, null))) : null,
|
|
1216
|
+
this.props.showViewTypeButton ? (react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Toggle view mode'), style: styles.menuButton, "aria-label": "view mode", onClick: () => {
|
|
1208
1217
|
const viewType = this.state.viewType === TABLE ? TILE : TABLE;
|
|
1209
1218
|
this.localStorage.setItem('files.viewType', viewType);
|
|
1210
1219
|
let currentDir = this.state.selected;
|
|
@@ -1216,7 +1225,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1216
1225
|
this.scrollToSelected();
|
|
1217
1226
|
}
|
|
1218
1227
|
});
|
|
1219
|
-
}, size: "small" }, this.state.viewType !== TABLE ? react_1.default.createElement(icons_material_1.List, { fontSize: "small" }) : react_1.default.createElement(icons_material_1.ViewModule, { fontSize: "small" })) : null,
|
|
1228
|
+
}, size: "small" }, this.state.viewType !== TABLE ? react_1.default.createElement(icons_material_1.List, { fontSize: "small" }) : react_1.default.createElement(icons_material_1.ViewModule, { fontSize: "small" }))) : null,
|
|
1220
1229
|
react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Hide empty folders'), style: styles.menuButton, color: this.state.filterEmpty ? 'secondary' : 'inherit', "aria-label": "filter empty", onClick: () => {
|
|
1221
1230
|
this.localStorage.setItem('file.empty', this.state.filterEmpty ? 'false' : 'true');
|
|
1222
1231
|
this.setState({ filterEmpty: !this.state.filterEmpty });
|
|
@@ -1224,24 +1233,24 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1224
1233
|
react_1.default.createElement(icons_material_1.FolderOpen, { fontSize: "small" })),
|
|
1225
1234
|
react_1.default.createElement(material_1.IconButton, { edge: "start", title: this.props.t('ra_Reload files'), style: styles.menuButton, color: "inherit", "aria-label": "reload files", onClick: () => this.setState({ folders: {} }, () => this.loadFolders()), size: "small" },
|
|
1226
1235
|
react_1.default.createElement(icons_material_1.Refresh, { fontSize: "small" })),
|
|
1227
|
-
this.props.allowCreateFolder ? react_1.default.createElement(material_1.IconButton, { edge: "start", disabled: !this.state.selected ||
|
|
1236
|
+
this.props.allowCreateFolder ? (react_1.default.createElement(material_1.IconButton, { edge: "start", disabled: !this.state.selected ||
|
|
1228
1237
|
!isInFolder ||
|
|
1229
1238
|
(!!this.limitToPath &&
|
|
1230
1239
|
!this.state.selected.startsWith(`${this.limitToPath}/`) &&
|
|
1231
1240
|
this.limitToPath !== this.state.selected), title: this.props.t('ra_Create folder'), style: styles.menuButton, color: "inherit", "aria-label": "add folder", onClick: () => this.setState({ addFolder: true }), size: "small" },
|
|
1232
|
-
react_1.default.createElement(icons_material_1.CreateNewFolder, { fontSize: "small" })) : null,
|
|
1233
|
-
this.props.allowUpload ? react_1.default.createElement(material_1.IconButton, { edge: "start", disabled: !this.state.selected ||
|
|
1241
|
+
react_1.default.createElement(icons_material_1.CreateNewFolder, { fontSize: "small" }))) : null,
|
|
1242
|
+
this.props.allowUpload ? (react_1.default.createElement(material_1.IconButton, { edge: "start", disabled: !this.state.selected ||
|
|
1234
1243
|
!isInFolder ||
|
|
1235
1244
|
(!!this.limitToPath &&
|
|
1236
1245
|
!this.state.selected.startsWith(`${this.limitToPath}/`) &&
|
|
1237
1246
|
this.limitToPath !== this.state.selected), title: this.props.t('ra_Upload file'), style: styles.menuButton, color: "inherit", "aria-label": "upload file", onClick: () => this.setState({ uploadFile: true }), size: "small" },
|
|
1238
|
-
react_1.default.createElement(icons_material_1.Publish, { fontSize: "small" })) : null,
|
|
1239
|
-
this.props.showTypeSelector && IconType ? react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Filter files'),
|
|
1247
|
+
react_1.default.createElement(icons_material_1.Publish, { fontSize: "small" }))) : null,
|
|
1248
|
+
this.props.showTypeSelector && IconType ? (react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Filter files'), slotProps: { popper: { sx: styles.tooltip } } },
|
|
1240
1249
|
react_1.default.createElement(material_1.IconButton, { size: "small", onClick: e => this.setState({ showTypesMenu: e.target }) },
|
|
1241
|
-
react_1.default.createElement(IconType, { fontSize: "small" }))) : null,
|
|
1242
|
-
this.state.showTypesMenu ? react_1.default.createElement(material_1.Menu, { open: !0, anchorEl: this.state.showTypesMenu, onClose: () => this.setState({ showTypesMenu: null }) }, Object.keys(FILE_TYPE_ICONS).map(type => {
|
|
1250
|
+
react_1.default.createElement(IconType, { fontSize: "small" })))) : null,
|
|
1251
|
+
this.state.showTypesMenu ? (react_1.default.createElement(material_1.Menu, { open: !0, anchorEl: this.state.showTypesMenu, onClose: () => this.setState({ showTypesMenu: null }) }, Object.keys(FILE_TYPE_ICONS).map(type => {
|
|
1243
1252
|
const MyIcon = FILE_TYPE_ICONS[type];
|
|
1244
|
-
return react_1.default.createElement(material_1.MenuItem, { key: type, selected: this.state.filterByType === type, onClick: () => {
|
|
1253
|
+
return (react_1.default.createElement(material_1.MenuItem, { key: type, selected: this.state.filterByType === type, onClick: () => {
|
|
1245
1254
|
if (type === 'all') {
|
|
1246
1255
|
this.localStorage.removeItem('files.filterByType');
|
|
1247
1256
|
this.setState({ filterByType: '', showTypesMenu: null });
|
|
@@ -1253,12 +1262,12 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1253
1262
|
} },
|
|
1254
1263
|
react_1.default.createElement(material_1.ListItemIcon, null,
|
|
1255
1264
|
react_1.default.createElement(MyIcon, { fontSize: "small" })),
|
|
1256
|
-
react_1.default.createElement(material_1.ListItemText, null, this.props.t(`ra_fileType_${type}`)));
|
|
1257
|
-
})) : null,
|
|
1258
|
-
react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Background image'),
|
|
1265
|
+
react_1.default.createElement(material_1.ListItemText, null, this.props.t(`ra_fileType_${type}`))));
|
|
1266
|
+
}))) : null,
|
|
1267
|
+
react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Background image'), slotProps: { popper: { sx: styles.tooltip } } },
|
|
1259
1268
|
react_1.default.createElement(material_1.IconButton, { color: "inherit", edge: "start", style: styles.menuButton, onClick: this.setStateBackgroundImage, size: "small" },
|
|
1260
1269
|
react_1.default.createElement(icons_material_1.Brightness6, { fontSize: "small" }))),
|
|
1261
|
-
this.state.viewType !== TABLE && this.props.allowDelete ? react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Delete'),
|
|
1270
|
+
this.state.viewType !== TABLE && this.props.allowDelete ? (react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Delete'), slotProps: { popper: { sx: styles.tooltip } } },
|
|
1262
1271
|
react_1.default.createElement("span", null,
|
|
1263
1272
|
react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", disabled: !this.state.selected ||
|
|
1264
1273
|
this.state.selected === 'vis.0/' ||
|
|
@@ -1272,7 +1281,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1272
1281
|
this.setState({ deleteItem: this.state.selected });
|
|
1273
1282
|
}
|
|
1274
1283
|
}, size: "small" },
|
|
1275
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" })))) : null);
|
|
1284
|
+
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))))) : null));
|
|
1276
1285
|
}
|
|
1277
1286
|
findItem(id, folders) {
|
|
1278
1287
|
folders = folders || this.state.folders;
|
|
@@ -1285,7 +1294,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1285
1294
|
if (!folders[parentFolder]) {
|
|
1286
1295
|
return null;
|
|
1287
1296
|
}
|
|
1288
|
-
return folders[parentFolder].find(item => item.id === id);
|
|
1297
|
+
return folders[parentFolder].find(item => item.id === id) || null;
|
|
1289
1298
|
}
|
|
1290
1299
|
renderInputDialog() {
|
|
1291
1300
|
if (this.state.addFolder) {
|
|
@@ -1294,9 +1303,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1294
1303
|
window.alert(this.props.t('ra_Invalid parent folder!'));
|
|
1295
1304
|
return null;
|
|
1296
1305
|
}
|
|
1297
|
-
return react_1.default.createElement(TextInput_1.default, { key: "inputDialog", applyText: this.props.t('ra_Create'), cancelText: this.props.t('ra_Cancel'), titleText: this.props.t('ra_Create new folder in %s', this.state.selected), promptText: this.props.t('ra_If no file will be created in the folder, it will disappear after the browser closed'), labelText: this.props.t('ra_Folder name'), verify: (text) =>
|
|
1306
|
+
return (react_1.default.createElement(TextInput_1.default, { key: "inputDialog", applyText: this.props.t('ra_Create'), cancelText: this.props.t('ra_Cancel'), titleText: this.props.t('ra_Create new folder in %s', this.state.selected), promptText: this.props.t('ra_If no file will be created in the folder, it will disappear after the browser closed'), labelText: this.props.t('ra_Folder name'), verify: (text) => this.state.folders[parentFolder].find(item => item.name === text)
|
|
1298
1307
|
? ''
|
|
1299
|
-
: this.props.t('ra_Duplicate name')
|
|
1308
|
+
: this.props.t('ra_Duplicate name'), onClose: (name) => {
|
|
1300
1309
|
if (name) {
|
|
1301
1310
|
const folders = {};
|
|
1302
1311
|
Object.keys(this.state.folders).forEach(folder => (folders[folder] = this.state.folders[folder]));
|
|
@@ -1322,12 +1331,14 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1322
1331
|
else {
|
|
1323
1332
|
this.setState({ addFolder: false });
|
|
1324
1333
|
}
|
|
1325
|
-
}, replace: (text) => text.replace(/[^-_\w]/, '_') });
|
|
1334
|
+
}, replace: (text) => text.replace(/[^-_\w]/, '_') }));
|
|
1326
1335
|
}
|
|
1327
1336
|
return null;
|
|
1328
1337
|
}
|
|
1329
1338
|
componentDidUpdate( /* prevProps , prevState, snapshot */) {
|
|
1330
|
-
|
|
1339
|
+
if (this.setOpacityTimer) {
|
|
1340
|
+
clearTimeout(this.setOpacityTimer);
|
|
1341
|
+
}
|
|
1331
1342
|
this.setOpacityTimer = setTimeout(() => {
|
|
1332
1343
|
this.setOpacityTimer = null;
|
|
1333
1344
|
const items = window.document.getElementsByClassName('browserItem');
|
|
@@ -1365,7 +1376,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1365
1376
|
await this.props.socket.writeFile64(adapterName || '', parts.join('/'), data);
|
|
1366
1377
|
}
|
|
1367
1378
|
catch (e) {
|
|
1368
|
-
|
|
1379
|
+
const knownError = e;
|
|
1380
|
+
window.alert(`Cannot write file: ${knownError === null || knownError === void 0 ? void 0 : knownError.message}`);
|
|
1369
1381
|
}
|
|
1370
1382
|
}
|
|
1371
1383
|
renderUpload() {
|
|
@@ -1386,8 +1398,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1386
1398
|
}
|
|
1387
1399
|
else {
|
|
1388
1400
|
const id = `${parentFolder}/${file.name}`;
|
|
1389
|
-
this.uploadFile(id, reader.result)
|
|
1390
|
-
.then(() => {
|
|
1401
|
+
void this.uploadFile(id, reader.result).then(() => {
|
|
1391
1402
|
if (!--count) {
|
|
1392
1403
|
this.setState({ uploadFile: false }, () => {
|
|
1393
1404
|
if (this.supportSubscribes) {
|
|
@@ -1401,8 +1412,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1401
1412
|
this.setState({ expanded }, () => this.select(id));
|
|
1402
1413
|
}
|
|
1403
1414
|
else {
|
|
1404
|
-
setTimeout(() => this.browseFolder(parentFolder, null, false, true)
|
|
1405
|
-
.then(folders => {
|
|
1415
|
+
setTimeout(() => this.browseFolder(parentFolder, null, false, true).then(folders => {
|
|
1406
1416
|
// open current folder
|
|
1407
1417
|
const expanded = [...this.state.expanded];
|
|
1408
1418
|
if (!expanded.includes(parentFolder)) {
|
|
@@ -1420,14 +1430,14 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1420
1430
|
};
|
|
1421
1431
|
reader.readAsArrayBuffer(file);
|
|
1422
1432
|
});
|
|
1423
|
-
} }, ({ getRootProps, getInputProps }) => react_1.default.createElement("div", Object.assign({ style: Object.assign(Object.assign({}, styles.uploadDiv), (this.state.uploadFile === 'dragging' ? styles.uploadDivDragging : undefined)) }, getRootProps()),
|
|
1433
|
+
} }, ({ getRootProps, getInputProps }) => (react_1.default.createElement("div", Object.assign({ style: Object.assign(Object.assign({}, styles.uploadDiv), (this.state.uploadFile === 'dragging' ? styles.uploadDivDragging : undefined)) }, getRootProps()),
|
|
1424
1434
|
react_1.default.createElement("input", Object.assign({}, getInputProps())),
|
|
1425
1435
|
react_1.default.createElement(material_1.Box, { component: "div", sx: styles.uploadCenterDiv },
|
|
1426
1436
|
react_1.default.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
1427
1437
|
react_1.default.createElement(icons_material_1.Publish, { style: styles.uploadCenterIcon }),
|
|
1428
1438
|
react_1.default.createElement("div", { style: styles.uploadCenterText }, this.state.uploadFile === 'dragging'
|
|
1429
1439
|
? this.props.t('ra_Drop file here')
|
|
1430
|
-
: this.props.t('ra_Place your files here or click here to open the browse dialog')))))),
|
|
1440
|
+
: this.props.t('ra_Place your files here or click here to open the browse dialog'))))))),
|
|
1431
1441
|
];
|
|
1432
1442
|
}
|
|
1433
1443
|
return null;
|
|
@@ -1437,13 +1447,12 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1437
1447
|
if (item === null || item === void 0 ? void 0 : item.folder) {
|
|
1438
1448
|
return (this.state.folders[id]
|
|
1439
1449
|
? Promise.all(this.state.folders[id].map(_item => this.deleteRecursive(_item.id)))
|
|
1440
|
-
: Promise.resolve())
|
|
1441
|
-
.then(() => {
|
|
1450
|
+
: Promise.resolve()).then(() => {
|
|
1442
1451
|
// If it is a folder of second level
|
|
1443
1452
|
if (item.level >= 1) {
|
|
1444
1453
|
const parts = id.split('/');
|
|
1445
1454
|
const adapter = parts.shift();
|
|
1446
|
-
this.props.socket.deleteFolder(adapter || '', parts.join('/')).then(() => {
|
|
1455
|
+
void this.props.socket.deleteFolder(adapter || '', parts.join('/')).then(() => {
|
|
1447
1456
|
// remove this folder
|
|
1448
1457
|
const folders = JSON.parse(JSON.stringify(this.state.folders));
|
|
1449
1458
|
delete folders[item.id];
|
|
@@ -1472,8 +1481,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1472
1481
|
}
|
|
1473
1482
|
deleteItem(deleteItem) {
|
|
1474
1483
|
deleteItem = deleteItem || this.state.deleteItem;
|
|
1475
|
-
this.setState({ deleteItem: '' }, () => this.deleteRecursive(deleteItem)
|
|
1476
|
-
.then(() => {
|
|
1484
|
+
this.setState({ deleteItem: '' }, () => this.deleteRecursive(deleteItem).then(() => {
|
|
1477
1485
|
const newState = {};
|
|
1478
1486
|
const pos = this.state.expanded.indexOf(deleteItem);
|
|
1479
1487
|
if (pos !== -1) {
|
|
@@ -1498,18 +1506,18 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1498
1506
|
newState.folders = folders;
|
|
1499
1507
|
this.setState(newState, () => setTimeout(() => {
|
|
1500
1508
|
this.browseFolders([...this.state.expanded], folders)
|
|
1501
|
-
.then(_folders => this.setState({ folders: _folders }))
|
|
1509
|
+
.then(_folders => this.setState({ folders: _folders }))
|
|
1510
|
+
.catch(e => console.error(e));
|
|
1502
1511
|
}, 200));
|
|
1503
1512
|
}
|
|
1504
1513
|
else {
|
|
1505
|
-
// @ts-expect-error fix later
|
|
1506
1514
|
this.setState(newState);
|
|
1507
1515
|
}
|
|
1508
1516
|
}));
|
|
1509
1517
|
}
|
|
1510
1518
|
renderDeleteDialog() {
|
|
1511
1519
|
if (this.state.deleteItem) {
|
|
1512
|
-
return react_1.default.createElement(material_1.Dialog, { key: "deleteDialog", open: !0, onClose: () => this.setState({ deleteItem: '' }), "aria-labelledby": "ar_dialog_file_delete_title" },
|
|
1520
|
+
return (react_1.default.createElement(material_1.Dialog, { key: "deleteDialog", open: !0, onClose: () => this.setState({ deleteItem: '' }), "aria-labelledby": "ar_dialog_file_delete_title" },
|
|
1513
1521
|
react_1.default.createElement(material_1.DialogTitle, { id: "ar_dialog_file_delete_title" }, this.props.t('ra_Confirm deletion of %s', this.state.deleteItem.split('/').pop())),
|
|
1514
1522
|
react_1.default.createElement(material_1.DialogContent, null,
|
|
1515
1523
|
react_1.default.createElement(material_1.DialogContentText, null, this.props.t('ra_Are you sure?'))),
|
|
@@ -1519,16 +1527,16 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1519
1527
|
this.deleteItem('');
|
|
1520
1528
|
} }, this.props.t('ra_Delete (no confirm for 5 mins)')),
|
|
1521
1529
|
react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.deleteItem(''), color: "primary", autoFocus: true }, this.props.t('ra_Delete')),
|
|
1522
|
-
react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.setState({ deleteItem: '' }), color: "grey" }, this.props.t('ra_Cancel'))));
|
|
1530
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.setState({ deleteItem: '' }), color: "grey" }, this.props.t('ra_Cancel')))));
|
|
1523
1531
|
}
|
|
1524
|
-
return
|
|
1532
|
+
return null;
|
|
1525
1533
|
}
|
|
1526
1534
|
renderViewDialog() {
|
|
1527
|
-
return this.state.viewer ? react_1.default.createElement(FileViewer_1.default, { supportSubscribes: this.supportSubscribes, key: this.state.viewer, href: this.state.viewer, formatEditFile: this.state.formatEditFile, themeType: this.props.themeType, setStateBackgroundImage: this.setStateBackgroundImage, getStyleBackgroundImage: this.getStyleBackgroundImage, t: this.props.t, socket: this.props.socket, lang: this.props.lang, expertMode: this.state.expertMode, onClose: () => this.setState({ viewer: '', formatEditFile: '' }) }) : null;
|
|
1535
|
+
return this.state.viewer ? (react_1.default.createElement(FileViewer_1.default, { supportSubscribes: this.supportSubscribes, key: this.state.viewer, href: this.state.viewer, formatEditFile: this.state.formatEditFile, themeType: this.props.themeType, setStateBackgroundImage: this.setStateBackgroundImage, getStyleBackgroundImage: this.getStyleBackgroundImage, t: this.props.t, socket: this.props.socket, lang: this.props.lang, expertMode: this.state.expertMode, onClose: () => this.setState({ viewer: '', formatEditFile: '' }) })) : null;
|
|
1528
1536
|
}
|
|
1529
1537
|
renderError() {
|
|
1530
1538
|
if (this.state.errorText) {
|
|
1531
|
-
return react_1.default.createElement(Error_1.default, { key: "errorDialog", text: this.state.errorText, onClose: () => this.setState({ errorText: '' }) });
|
|
1539
|
+
return (react_1.default.createElement(Error_1.default, { key: "errorDialog", text: this.state.errorText, onClose: () => this.setState({ errorText: '' }) }));
|
|
1532
1540
|
}
|
|
1533
1541
|
return null;
|
|
1534
1542
|
}
|
|
@@ -1545,7 +1553,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1545
1553
|
}
|
|
1546
1554
|
});
|
|
1547
1555
|
if (changed) {
|
|
1548
|
-
|
|
1556
|
+
if (this.cacheFoldersTimeout) {
|
|
1557
|
+
clearTimeout(this.cacheFoldersTimeout);
|
|
1558
|
+
}
|
|
1549
1559
|
this.cacheFoldersTimeout = setTimeout(() => {
|
|
1550
1560
|
this.cacheFoldersTimeout = null;
|
|
1551
1561
|
const folders = this.cacheFolders || {};
|
|
@@ -1575,7 +1585,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1575
1585
|
resolve(true);
|
|
1576
1586
|
}
|
|
1577
1587
|
})
|
|
1578
|
-
.then(result => result &&
|
|
1588
|
+
.then(result => result &&
|
|
1589
|
+
this.setState({ selected: this.state.path, currentDir: folder, pathFocus: false }))
|
|
1590
|
+
.catch(e => console.error(e));
|
|
1579
1591
|
}
|
|
1580
1592
|
else if (!this.lastSelect || Date.now() - this.lastSelect > 100) {
|
|
1581
1593
|
this.setState({ pathFocus: false });
|
|
@@ -1587,28 +1599,27 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1587
1599
|
? this.state.currentDir.split('/')
|
|
1588
1600
|
: `/${this.state.currentDir}`.split('/');
|
|
1589
1601
|
const p = [];
|
|
1590
|
-
return react_1.default.createElement(material_1.Breadcrumbs, { style: { paddingLeft: 8 } }, parts.map((part, i) => {
|
|
1591
|
-
|
|
1602
|
+
return (react_1.default.createElement(material_1.Breadcrumbs, { style: { paddingLeft: 8 } }, parts.map((part, i) => {
|
|
1603
|
+
if (part) {
|
|
1604
|
+
p.push(part);
|
|
1605
|
+
}
|
|
1592
1606
|
const path = p.join('/');
|
|
1593
1607
|
if (i < parts.length - 1) {
|
|
1594
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: `${this.state.selected}_${i}`, sx: styles.pathDivBreadcrumbDir, onClick: e => this.changeFolder(e, path || '/') }, part || this.props.t('ra_Root'));
|
|
1608
|
+
return (react_1.default.createElement(material_1.Box, { component: "div", key: `${this.state.selected}_${i}`, sx: styles.pathDivBreadcrumbDir, onClick: e => this.changeFolder(e, path || '/') }, part || this.props.t('ra_Root')));
|
|
1595
1609
|
}
|
|
1596
|
-
return react_1.default.createElement("div", { style: styles.pathDivBreadcrumbSelected, key: `${this.state.selected}_${i}`, onClick: () => this.setState({ pathFocus: true }) }, part);
|
|
1597
|
-
}));
|
|
1610
|
+
return (react_1.default.createElement("div", { style: styles.pathDivBreadcrumbSelected, key: `${this.state.selected}_${i}`, onClick: () => this.setState({ pathFocus: true }) }, part));
|
|
1611
|
+
})));
|
|
1598
1612
|
}
|
|
1599
1613
|
renderPath() {
|
|
1600
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: "path", sx: styles.pathDiv }, this.state.pathFocus ?
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
react_1.default.createElement(icons_material_1.KeyboardReturn, null)), onBlur: () => this.changeToPath(), onChange: e => this.setState({ path: e.target.value }), style: styles.pathDivInput })
|
|
1610
|
-
:
|
|
1611
|
-
this.renderBreadcrumb());
|
|
1614
|
+
return (react_1.default.createElement(material_1.Box, { component: "div", key: "path", sx: styles.pathDiv }, this.state.pathFocus ? (react_1.default.createElement(material_1.Input, { value: this.state.path, onKeyDown: e => {
|
|
1615
|
+
if (e.key === 'Enter') {
|
|
1616
|
+
this.changeToPath();
|
|
1617
|
+
}
|
|
1618
|
+
else if (e.key === 'Escape') {
|
|
1619
|
+
this.setState({ pathFocus: false });
|
|
1620
|
+
}
|
|
1621
|
+
}, endAdornment: react_1.default.createElement(material_1.IconButton, { size: "small", onClick: () => this.changeToPath() },
|
|
1622
|
+
react_1.default.createElement(icons_material_1.KeyboardReturn, null)), onBlur: () => this.changeToPath(), onChange: e => this.setState({ path: e.target.value }), style: styles.pathDivInput })) : (this.renderBreadcrumb())));
|
|
1612
1623
|
}
|
|
1613
1624
|
render() {
|
|
1614
1625
|
if (!this.props.ready) {
|
|
@@ -1619,12 +1630,11 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1619
1630
|
setTimeout(() => {
|
|
1620
1631
|
this.setState({ loadAllFolders: false, folders: {} }, () => {
|
|
1621
1632
|
this.foldersLoading = false;
|
|
1622
|
-
this.loadFolders()
|
|
1623
|
-
.catch(error => console.error(`Cannot load folders: ${error}`));
|
|
1633
|
+
this.loadFolders().catch(error => console.error(`Cannot load folders: ${error}`));
|
|
1624
1634
|
});
|
|
1625
1635
|
}, 300);
|
|
1626
1636
|
}
|
|
1627
|
-
return react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.root), this.props.style), className: this.props.className },
|
|
1637
|
+
return (react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.root), this.props.style), className: this.props.className },
|
|
1628
1638
|
this.props.showToolbar ? this.renderToolbar() : null,
|
|
1629
1639
|
this.state.viewType === TILE ? this.renderPath() : null,
|
|
1630
1640
|
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.filesDiv), styles[`filesDiv${this.state.viewType}`]), onClick: e => {
|
|
@@ -1640,8 +1650,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1640
1650
|
this.state.viewType === TABLE
|
|
1641
1651
|
? this.renderItems('/')
|
|
1642
1652
|
: this.renderItems(this.state.currentDir || '/'),
|
|
1643
|
-
this.state.viewType !== TABLE ?
|
|
1644
|
-
react_1.default.createElement("div", { style: styles.filesDivHint }, this.props.t('ra_select_folder_hint')) : null),
|
|
1653
|
+
this.state.viewType !== TABLE ? (react_1.default.createElement("div", { style: styles.filesDivHint }, this.props.t('ra_select_folder_hint'))) : null),
|
|
1645
1654
|
this.props.allowUpload ? this.renderInputDialog() : null,
|
|
1646
1655
|
this.props.allowUpload ? this.renderUpload() : null,
|
|
1647
1656
|
this.props.allowDelete ? this.renderDeleteDialog() : null,
|
|
@@ -1649,7 +1658,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1649
1658
|
this.state.modalEditOfAccess && this.props.modalEditOfAccessControl
|
|
1650
1659
|
? this.props.modalEditOfAccessControl(this)
|
|
1651
1660
|
: null,
|
|
1652
|
-
this.renderError());
|
|
1661
|
+
this.renderError()));
|
|
1653
1662
|
}
|
|
1654
1663
|
}
|
|
1655
1664
|
exports.FileBrowserClass = FileBrowserClass;
|