@iobroker/adapter-react-v5 7.0.2 → 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 +3 -2
- 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 +135 -152
- 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 +21 -18
- 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 +20 -7
- package/Components/Loaders/Vendor.d.ts +2 -2
- package/Components/Loaders/Vendor.js +15 -7
- package/Components/Logo.js +16 -18
- package/Components/MDUtils.d.ts +1 -1
- package/Components/MDUtils.js +8 -4
- package/Components/ObjectBrowser.d.ts +40 -39
- package/Components/ObjectBrowser.js +550 -435
- 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 +25 -21
- 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 +128 -85
- package/LegacyConnection.d.ts +240 -248
- package/LegacyConnection.js +500 -525
- package/README.md +1234 -1170
- package/Theme.d.ts +1 -1
- package/Theme.js +9 -12
- package/assets/devices.json +1 -0
- package/assets/rooms.json +1 -0
- package/craco-module-federation.js +3 -12
- package/i18n/de.json +434 -434
- package/i18n/en.json +434 -434
- package/i18n/es.json +434 -434
- package/i18n/fr.json +434 -434
- package/i18n/it.json +434 -434
- package/i18n/nl.json +434 -434
- package/i18n/pl.json +434 -434
- package/i18n/pt.json +434 -434
- package/i18n/ru.json +434 -434
- package/i18n/uk.json +434 -434
- package/i18n/zh-cn.json +434 -434
- 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 +3 -2
- package/package.json +1 -1
- package/src/Components/404.tsx +32 -31
- package/src/Components/ColorPicker.tsx +142 -114
- package/src/Components/ComplexCron.tsx +174 -137
- package/src/Components/CopyToClipboard.tsx +22 -9
- package/src/Components/CustomModal.tsx +76 -69
- package/src/Components/FileBrowser.tsx +959 -852
- package/src/Components/FileViewer.tsx +146 -127
- package/src/Components/Icon.tsx +80 -52
- package/src/Components/IconPicker.tsx +83 -67
- package/src/Components/IconSelector.tsx +159 -141
- package/src/Components/Image.tsx +43 -26
- package/src/Components/Loader.tsx +56 -32
- package/src/Components/Logo.tsx +62 -52
- package/src/Components/MDUtils.tsx +10 -6
- package/src/Components/ObjectBrowser.tsx +3198 -2478
- package/src/Components/Router.tsx +11 -11
- package/src/Components/SaveCloseButtons.tsx +43 -39
- package/src/Components/Schedule.tsx +1091 -853
- package/src/Components/SelectWithIcon.tsx +135 -93
- package/src/Components/TabContainer.tsx +21 -19
- package/src/Components/TabContent.tsx +13 -12
- package/src/Components/TabHeader.tsx +10 -9
- package/src/Components/TableResize.tsx +52 -37
- package/src/Components/TextWithIcon.tsx +30 -19
- package/src/Components/ToggleThemeMenu.tsx +31 -13
- package/src/Components/TreeTable.tsx +468 -385
- package/src/Components/UploadImage.tsx +153 -121
- package/src/Components/Utils.tsx +135 -127
- package/src/Components/loader.css +40 -31
- package/src/Components/withWidth.tsx +23 -12
- package/src/Connection.tsx +1 -3
- package/src/Dialogs/ComplexCron.tsx +55 -61
- package/src/Dialogs/Confirm.tsx +88 -65
- package/src/Dialogs/Cron.tsx +122 -112
- package/src/Dialogs/Error.tsx +37 -42
- package/src/Dialogs/Message.tsx +39 -37
- package/src/Dialogs/SelectFile.tsx +95 -85
- package/src/Dialogs/SelectID.tsx +141 -129
- package/src/Dialogs/SimpleCron.tsx +44 -44
- package/src/Dialogs/TextInput.tsx +60 -68
- package/src/GenericApp.tsx +342 -242
- package/src/LegacyConnection.tsx +972 -842
- package/src/Prompt.tsx +3 -1
- package/src/Theme.tsx +19 -26
- package/src/icons/IconAdapter.tsx +16 -14
- package/src/icons/IconAlias.tsx +16 -14
- package/src/icons/IconChannel.tsx +55 -16
- package/src/icons/IconClearFilter.tsx +17 -15
- package/src/icons/IconClosed.tsx +16 -11
- package/src/icons/IconCopy.tsx +16 -11
- package/src/icons/IconDevice.tsx +121 -22
- package/src/icons/IconDocument.tsx +16 -11
- package/src/icons/IconDocumentReadOnly.tsx +21 -12
- package/src/icons/IconExpert.tsx +20 -12
- package/src/icons/IconFx.tsx +16 -14
- package/src/icons/IconInstance.tsx +16 -14
- package/src/icons/IconLogout.tsx +20 -18
- package/src/icons/IconNoIcon.tsx +16 -14
- package/src/icons/IconOpen.tsx +17 -12
- package/src/icons/IconProps.tsx +4 -3
- package/src/icons/IconState.tsx +34 -13
- package/src/index.css +3 -2
- package/tasks.js +91 -0
- package/types.d.ts +141 -0
- 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) {
|
|
@@ -426,14 +426,17 @@ class FileBrowserClass extends react_1.Component {
|
|
|
426
426
|
this._tempTimeout[folder] = setTimeout(() => {
|
|
427
427
|
delete this._tempTimeout[folder];
|
|
428
428
|
this.browseFolder(folder, null, false, true)
|
|
429
|
-
.then(folders => this.setState({ folders }))
|
|
429
|
+
.then(folders => this.setState({ folders }))
|
|
430
|
+
.catch(e => console.error(`Cannot read folder: ${e.message}`));
|
|
430
431
|
}, 300);
|
|
431
432
|
}
|
|
432
433
|
};
|
|
433
434
|
this.setStateBackgroundImage = () => {
|
|
434
435
|
const array = ['light', 'dark', 'colored', 'delete'];
|
|
435
436
|
this.setState(({ backgroundImage }) => {
|
|
436
|
-
if (backgroundImage &&
|
|
437
|
+
if (backgroundImage &&
|
|
438
|
+
array.indexOf(backgroundImage) !== -1 &&
|
|
439
|
+
array.length - 1 !== array.indexOf(backgroundImage)) {
|
|
437
440
|
this.localStorage.setItem('files.backgroundImage', array[array.indexOf(backgroundImage) + 1]);
|
|
438
441
|
return { backgroundImage: array[array.indexOf(backgroundImage) + 1] };
|
|
439
442
|
}
|
|
@@ -456,7 +459,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
456
459
|
return null;
|
|
457
460
|
}
|
|
458
461
|
};
|
|
459
|
-
this.localStorage =
|
|
462
|
+
this.localStorage = window._localStorage || window.localStorage;
|
|
460
463
|
const expandedStr = this.localStorage.getItem('files.expanded') || '[]';
|
|
461
464
|
if (this.props.limitPath) {
|
|
462
465
|
const parts = this.props.limitPath.split('/');
|
|
@@ -473,7 +476,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
473
476
|
expanded = expanded.filter(id => {
|
|
474
477
|
var _a;
|
|
475
478
|
return id.startsWith(`${this.limitToPath}/`) ||
|
|
476
|
-
id === this.limitToPath ||
|
|
479
|
+
id === this.limitToPath ||
|
|
480
|
+
((_a = this.limitToPath) === null || _a === void 0 ? void 0 : _a.startsWith(`${id}/`));
|
|
477
481
|
});
|
|
478
482
|
}
|
|
479
483
|
}
|
|
@@ -487,9 +491,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
487
491
|
else {
|
|
488
492
|
viewType = TABLE;
|
|
489
493
|
}
|
|
490
|
-
let selected = this.props.selected ||
|
|
491
|
-
this.localStorage.getItem('files.selected') ||
|
|
492
|
-
USER_DATA;
|
|
494
|
+
let selected = this.props.selected || this.localStorage.getItem('files.selected') || USER_DATA;
|
|
493
495
|
let currentDir;
|
|
494
496
|
if (props.restrictToFolder) {
|
|
495
497
|
selected = props.restrictToFolder;
|
|
@@ -598,8 +600,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
598
600
|
}
|
|
599
601
|
async componentDidMount() {
|
|
600
602
|
this.mounted = true;
|
|
601
|
-
this.loadFolders()
|
|
602
|
-
.catch(error => console.error(`Cannot load folders: ${error}`));
|
|
603
|
+
this.loadFolders().catch(error => console.error(`Cannot load folders: ${error}`));
|
|
603
604
|
this.supportSubscribes = await this.props.socket.checkFeatureSupported('BINARY_STATE_EVENT');
|
|
604
605
|
if (this.supportSubscribes) {
|
|
605
606
|
await this.props.socket.subscribeFiles('*', '*', this.onFileChange);
|
|
@@ -612,8 +613,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
612
613
|
this.mounted = false;
|
|
613
614
|
this.browseList = null;
|
|
614
615
|
this.browseListRunning = false;
|
|
615
|
-
Object.values(this._tempTimeout)
|
|
616
|
-
.forEach(timer => timer && clearTimeout(timer));
|
|
616
|
+
Object.values(this._tempTimeout).forEach(timer => timer && clearTimeout(timer));
|
|
617
617
|
this._tempTimeout = {};
|
|
618
618
|
}
|
|
619
619
|
browseFoldersCb(foldersList, newFoldersNotNull, cb) {
|
|
@@ -623,8 +623,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
623
623
|
else {
|
|
624
624
|
const folder = foldersList.shift();
|
|
625
625
|
if (folder) {
|
|
626
|
-
this.browseFolder(folder, newFoldersNotNull)
|
|
627
|
-
.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}`))
|
|
628
628
|
.then(() => {
|
|
629
629
|
setTimeout(() => this.browseFoldersCb(foldersList, newFoldersNotNull, cb), 0);
|
|
630
630
|
});
|
|
@@ -759,10 +759,11 @@ class FileBrowserClass extends react_1.Component {
|
|
|
759
759
|
if (newFoldersNotNull[folderId] && !force) {
|
|
760
760
|
if (!_checkEmpty) {
|
|
761
761
|
return new Promise((resolve, reject) => {
|
|
762
|
-
Promise.all(newFoldersNotNull[folderId]
|
|
763
|
-
.
|
|
762
|
+
Promise.all(newFoldersNotNull[folderId]
|
|
763
|
+
.filter(item => item.folder)
|
|
764
|
+
.map(item => this.browseFolder(item.id, newFoldersNotNull, true).catch(() => undefined)))
|
|
764
765
|
.then(() => resolve(newFoldersNotNull))
|
|
765
|
-
.catch(error => reject(error));
|
|
766
|
+
.catch(error => reject(new Error(error)));
|
|
766
767
|
});
|
|
767
768
|
}
|
|
768
769
|
return Promise.resolve(newFoldersNotNull);
|
|
@@ -810,7 +811,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
810
811
|
_folders.push(item);
|
|
811
812
|
}
|
|
812
813
|
});
|
|
813
|
-
_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));
|
|
814
815
|
if (!this.limitToObjectID || this.limitToObjectID === USER_DATA) {
|
|
815
816
|
if (userData) {
|
|
816
817
|
_folders.unshift(userData);
|
|
@@ -818,15 +819,15 @@ class FileBrowserClass extends react_1.Component {
|
|
|
818
819
|
}
|
|
819
820
|
newFoldersNotNull[folderId || '/'] = _folders;
|
|
820
821
|
if (!_checkEmpty) {
|
|
821
|
-
return Promise.all(_folders
|
|
822
|
-
.
|
|
823
|
-
.catch(() => undefined)))
|
|
824
|
-
.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);
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
catch (e) {
|
|
828
|
+
const knownError = e;
|
|
828
829
|
if (this.initialReadFinished) {
|
|
829
|
-
window.alert(`Cannot read meta items: ${
|
|
830
|
+
window.alert(`Cannot read meta items: ${knownError.message}`);
|
|
830
831
|
}
|
|
831
832
|
newFoldersNotNull[folderId || '/'] = [];
|
|
832
833
|
}
|
|
@@ -883,13 +884,13 @@ class FileBrowserClass extends react_1.Component {
|
|
|
883
884
|
if (!_checkEmpty) {
|
|
884
885
|
return Promise.all(_folders
|
|
885
886
|
.filter(item => item.folder)
|
|
886
|
-
.map(item => this.browseFolder(item.id, newFoldersNotNull, true)))
|
|
887
|
-
.then(() => newFoldersNotNull);
|
|
887
|
+
.map(item => this.browseFolder(item.id, newFoldersNotNull, true))).then(() => newFoldersNotNull);
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
890
|
catch (e) {
|
|
891
|
+
const knownError = e;
|
|
891
892
|
if (this.initialReadFinished) {
|
|
892
|
-
window.alert(`Cannot read ${adapter}${relPath ? `/${relPath}` : ''}: ${
|
|
893
|
+
window.alert(`Cannot read ${adapter}${relPath ? `/${relPath}` : ''}: ${knownError === null || knownError === void 0 ? void 0 : knownError.message}`);
|
|
893
894
|
}
|
|
894
895
|
newFoldersNotNull[folderId] = [];
|
|
895
896
|
}
|
|
@@ -934,14 +935,16 @@ class FileBrowserClass extends react_1.Component {
|
|
|
934
935
|
return this.setState({ selected: _folder });
|
|
935
936
|
}
|
|
936
937
|
if (_folder && !this.state.folders[_folder]) {
|
|
937
|
-
|
|
938
|
+
this.browseFolder(_folder)
|
|
938
939
|
.then(folders => this.setState({
|
|
939
940
|
folders,
|
|
940
941
|
path: _folder,
|
|
941
942
|
currentDir: _folder,
|
|
942
943
|
selected: _folder,
|
|
943
944
|
pathFocus: false,
|
|
944
|
-
}, () => 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;
|
|
945
948
|
}
|
|
946
949
|
return this.setState({
|
|
947
950
|
currentDir: _folder,
|
|
@@ -994,21 +997,21 @@ class FileBrowserClass extends react_1.Component {
|
|
|
994
997
|
const padding = this.state.viewType === TABLE ? item.level * this.levelPadding : 0;
|
|
995
998
|
const isUserData = item.name === USER_DATA;
|
|
996
999
|
const isSpecialData = isUserData || item.name === 'vis.0' || item.name === 'vis-2.0';
|
|
997
|
-
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 : {}) },
|
|
998
|
-
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 }),
|
|
999
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),
|
|
1000
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]
|
|
1001
1006
|
? this.state.folders[item.id].length
|
|
1002
1007
|
: ''),
|
|
1003
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),
|
|
1004
|
-
this.state.viewType === TABLE && this.props.expertMode ?
|
|
1005
|
-
|
|
1006
|
-
this.state.viewType === TABLE && this.props.allowDownload ?
|
|
1007
|
-
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,
|
|
1008
1011
|
this.state.viewType === TABLE &&
|
|
1009
1012
|
this.props.allowDelete &&
|
|
1010
1013
|
this.state.folders[item.id] &&
|
|
1011
|
-
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 => {
|
|
1012
1015
|
e.stopPropagation();
|
|
1013
1016
|
if (this.suppressDeleteConfirm > Date.now()) {
|
|
1014
1017
|
this.deleteItem(item.id);
|
|
@@ -1017,21 +1020,19 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1017
1020
|
this.setState({ deleteItem: item.id });
|
|
1018
1021
|
}
|
|
1019
1022
|
}, sx: styles[`itemDeleteButton${this.state.viewType}`], size: "large" },
|
|
1020
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" })) :
|
|
1021
|
-
this.state.viewType === TABLE && this.props.allowDelete ?
|
|
1022
|
-
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));
|
|
1023
1024
|
}
|
|
1024
1025
|
renderBackFolder() {
|
|
1025
|
-
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}`]) },
|
|
1026
1027
|
react_1.default.createElement(IconClosed_1.default, { style: styles[`itemFolderIcon${this.state.viewType}`] }),
|
|
1027
1028
|
react_1.default.createElement(icons_material_1.ArrowBack, { sx: styles.itemFolderIconBack }),
|
|
1028
|
-
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}`]) }, "..")));
|
|
1029
1030
|
}
|
|
1030
1031
|
formatSize(size) {
|
|
1031
|
-
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) : ''));
|
|
1032
1033
|
}
|
|
1033
1034
|
formatAcl(acl) {
|
|
1034
|
-
const access = acl ?
|
|
1035
|
+
const access = acl ? acl.permissions || acl.file : 0;
|
|
1035
1036
|
let accessStr;
|
|
1036
1037
|
if (access) {
|
|
1037
1038
|
accessStr = access.toString(16).padStart(3, '0');
|
|
@@ -1039,7 +1040,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1039
1040
|
else {
|
|
1040
1041
|
accessStr = '';
|
|
1041
1042
|
}
|
|
1042
|
-
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 || '---')));
|
|
1043
1044
|
}
|
|
1044
1045
|
getFileIcon(ext) {
|
|
1045
1046
|
switch (ext) {
|
|
@@ -1082,7 +1083,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1082
1083
|
renderFile(item) {
|
|
1083
1084
|
const padding = this.state.viewType === TABLE ? item.level * this.levelPadding : 0;
|
|
1084
1085
|
const ext = Utils_1.default.getFileExtension(item.name);
|
|
1085
|
-
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 => {
|
|
1086
1087
|
e.stopPropagation();
|
|
1087
1088
|
if (!this.props.onSelect) {
|
|
1088
1089
|
this.setState({ viewer: this.imagePrefix + item.id, formatEditFile: ext });
|
|
@@ -1094,46 +1095,38 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1094
1095
|
this.props.onSelect(item.id, true, !!this.state.folders[item.id]);
|
|
1095
1096
|
}
|
|
1096
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) },
|
|
1097
|
-
ext && FileViewer_1.EXTENSIONS.images.includes(ext) ?
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
this.setState({ fileErrors });
|
|
1106
|
-
}
|
|
1107
|
-
}, style: Object.assign(Object.assign({}, styles[`itemImage${this.state.viewType}`]), this.getStyleBackgroundImage()), src: this.imagePrefix + item.id, alt: item.name })
|
|
1108
|
-
:
|
|
1109
|
-
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)),
|
|
1110
1106
|
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemName${this.state.viewType}`] }, item.name),
|
|
1111
1107
|
react_1.default.createElement(material_1.Box, { component: "div", sx: { display: { md: 'inline-block', sm: 'none' } } }, this.formatSize(item.size)),
|
|
1112
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),
|
|
1113
|
-
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) ?
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
(
|
|
1122
|
-
(item.ext
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
:
|
|
1129
|
-
react_1.default.createElement(material_1.Box, { component: "div", sx: styles[`itemDeleteButton${this.state.viewType}`] })),
|
|
1130
|
-
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() },
|
|
1131
|
-
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,
|
|
1132
1125
|
this.state.viewType === TABLE &&
|
|
1133
1126
|
this.props.allowDelete &&
|
|
1134
1127
|
item.id !== 'vis.0/' &&
|
|
1135
1128
|
item.id !== 'vis-2.0/' &&
|
|
1136
|
-
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 => {
|
|
1137
1130
|
e.stopPropagation();
|
|
1138
1131
|
if (this.suppressDeleteConfirm > Date.now()) {
|
|
1139
1132
|
this.deleteItem(item.id);
|
|
@@ -1142,10 +1135,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1142
1135
|
this.setState({ deleteItem: item.id });
|
|
1143
1136
|
}
|
|
1144
1137
|
}, sx: styles[`itemDeleteButton${this.state.viewType}`], size: "large" },
|
|
1145
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))
|
|
1146
|
-
:
|
|
1147
|
-
(this.state.viewType === TABLE && this.props.allowDelete ?
|
|
1148
|
-
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));
|
|
1149
1139
|
}
|
|
1150
1140
|
renderItems(folderId) {
|
|
1151
1141
|
if (this.state.folders && this.state.folders[folderId]) {
|
|
@@ -1198,7 +1188,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1198
1188
|
});
|
|
1199
1189
|
return totalResult;
|
|
1200
1190
|
}
|
|
1201
|
-
return react_1.default.createElement("div", { style: { position: 'relative' } },
|
|
1191
|
+
return (react_1.default.createElement("div", { style: { position: 'relative' } },
|
|
1202
1192
|
react_1.default.createElement(material_1.CircularProgress, { key: folderId, color: "secondary", size: 24 }),
|
|
1203
1193
|
react_1.default.createElement("div", { style: {
|
|
1204
1194
|
position: 'absolute',
|
|
@@ -1206,25 +1196,24 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1206
1196
|
top: 4,
|
|
1207
1197
|
width: 24,
|
|
1208
1198
|
textAlign: 'center',
|
|
1209
|
-
} }, this.state.queueLength));
|
|
1199
|
+
} }, this.state.queueLength)));
|
|
1210
1200
|
}
|
|
1211
1201
|
renderToolbar() {
|
|
1212
1202
|
const IconType = this.props.showTypeSelector
|
|
1213
|
-
? FILE_TYPE_ICONS[this.state.filterByType || 'all'] ||
|
|
1214
|
-
FILE_TYPE_ICONS.all
|
|
1203
|
+
? FILE_TYPE_ICONS[this.state.filterByType || 'all'] || FILE_TYPE_ICONS.all
|
|
1215
1204
|
: null;
|
|
1216
1205
|
const isInFolder = this.findFirstFolder(this.state.selected);
|
|
1217
|
-
return react_1.default.createElement(material_1.Toolbar, { key: "toolbar", variant: "dense" },
|
|
1218
|
-
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
|
|
1219
1208
|
? this.props.t('ra_Show all folders')
|
|
1220
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({
|
|
1221
1210
|
restrictToFolder: (this.state.restrictToFolder ? '' : this.props.restrictToFolder) || '',
|
|
1222
1211
|
loadAllFolders: true,
|
|
1223
1212
|
}), size: "small" },
|
|
1224
|
-
react_1.default.createElement(icons_material_1.FolderSpecial, { fontSize: "small" })) : null,
|
|
1225
|
-
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" },
|
|
1226
|
-
react_1.default.createElement(IconExpert_1.default, null)) : null,
|
|
1227
|
-
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: () => {
|
|
1228
1217
|
const viewType = this.state.viewType === TABLE ? TILE : TABLE;
|
|
1229
1218
|
this.localStorage.setItem('files.viewType', viewType);
|
|
1230
1219
|
let currentDir = this.state.selected;
|
|
@@ -1236,7 +1225,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1236
1225
|
this.scrollToSelected();
|
|
1237
1226
|
}
|
|
1238
1227
|
});
|
|
1239
|
-
}, 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,
|
|
1240
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: () => {
|
|
1241
1230
|
this.localStorage.setItem('file.empty', this.state.filterEmpty ? 'false' : 'true');
|
|
1242
1231
|
this.setState({ filterEmpty: !this.state.filterEmpty });
|
|
@@ -1244,24 +1233,24 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1244
1233
|
react_1.default.createElement(icons_material_1.FolderOpen, { fontSize: "small" })),
|
|
1245
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" },
|
|
1246
1235
|
react_1.default.createElement(icons_material_1.Refresh, { fontSize: "small" })),
|
|
1247
|
-
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 ||
|
|
1248
1237
|
!isInFolder ||
|
|
1249
1238
|
(!!this.limitToPath &&
|
|
1250
1239
|
!this.state.selected.startsWith(`${this.limitToPath}/`) &&
|
|
1251
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" },
|
|
1252
|
-
react_1.default.createElement(icons_material_1.CreateNewFolder, { fontSize: "small" })) : null,
|
|
1253
|
-
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 ||
|
|
1254
1243
|
!isInFolder ||
|
|
1255
1244
|
(!!this.limitToPath &&
|
|
1256
1245
|
!this.state.selected.startsWith(`${this.limitToPath}/`) &&
|
|
1257
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" },
|
|
1258
|
-
react_1.default.createElement(icons_material_1.Publish, { fontSize: "small" })) : null,
|
|
1259
|
-
this.props.showTypeSelector && IconType ? react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Filter files'), slotProps: { popper: { sx: styles.tooltip } } },
|
|
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 } } },
|
|
1260
1249
|
react_1.default.createElement(material_1.IconButton, { size: "small", onClick: e => this.setState({ showTypesMenu: e.target }) },
|
|
1261
|
-
react_1.default.createElement(IconType, { fontSize: "small" }))) : null,
|
|
1262
|
-
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 => {
|
|
1263
1252
|
const MyIcon = FILE_TYPE_ICONS[type];
|
|
1264
|
-
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: () => {
|
|
1265
1254
|
if (type === 'all') {
|
|
1266
1255
|
this.localStorage.removeItem('files.filterByType');
|
|
1267
1256
|
this.setState({ filterByType: '', showTypesMenu: null });
|
|
@@ -1273,12 +1262,12 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1273
1262
|
} },
|
|
1274
1263
|
react_1.default.createElement(material_1.ListItemIcon, null,
|
|
1275
1264
|
react_1.default.createElement(MyIcon, { fontSize: "small" })),
|
|
1276
|
-
react_1.default.createElement(material_1.ListItemText, null, this.props.t(`ra_fileType_${type}`)));
|
|
1277
|
-
})) : null,
|
|
1265
|
+
react_1.default.createElement(material_1.ListItemText, null, this.props.t(`ra_fileType_${type}`))));
|
|
1266
|
+
}))) : null,
|
|
1278
1267
|
react_1.default.createElement(material_1.Tooltip, { title: this.props.t('ra_Background image'), slotProps: { popper: { sx: styles.tooltip } } },
|
|
1279
1268
|
react_1.default.createElement(material_1.IconButton, { color: "inherit", edge: "start", style: styles.menuButton, onClick: this.setStateBackgroundImage, size: "small" },
|
|
1280
1269
|
react_1.default.createElement(icons_material_1.Brightness6, { fontSize: "small" }))),
|
|
1281
|
-
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 } } },
|
|
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 } } },
|
|
1282
1271
|
react_1.default.createElement("span", null,
|
|
1283
1272
|
react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", disabled: !this.state.selected ||
|
|
1284
1273
|
this.state.selected === 'vis.0/' ||
|
|
@@ -1292,7 +1281,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1292
1281
|
this.setState({ deleteItem: this.state.selected });
|
|
1293
1282
|
}
|
|
1294
1283
|
}, size: "small" },
|
|
1295
|
-
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" })))) : null);
|
|
1284
|
+
react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))))) : null));
|
|
1296
1285
|
}
|
|
1297
1286
|
findItem(id, folders) {
|
|
1298
1287
|
folders = folders || this.state.folders;
|
|
@@ -1305,7 +1294,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1305
1294
|
if (!folders[parentFolder]) {
|
|
1306
1295
|
return null;
|
|
1307
1296
|
}
|
|
1308
|
-
return folders[parentFolder].find(item => item.id === id);
|
|
1297
|
+
return folders[parentFolder].find(item => item.id === id) || null;
|
|
1309
1298
|
}
|
|
1310
1299
|
renderInputDialog() {
|
|
1311
1300
|
if (this.state.addFolder) {
|
|
@@ -1314,9 +1303,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1314
1303
|
window.alert(this.props.t('ra_Invalid parent folder!'));
|
|
1315
1304
|
return null;
|
|
1316
1305
|
}
|
|
1317
|
-
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)
|
|
1318
1307
|
? ''
|
|
1319
|
-
: this.props.t('ra_Duplicate name')
|
|
1308
|
+
: this.props.t('ra_Duplicate name'), onClose: (name) => {
|
|
1320
1309
|
if (name) {
|
|
1321
1310
|
const folders = {};
|
|
1322
1311
|
Object.keys(this.state.folders).forEach(folder => (folders[folder] = this.state.folders[folder]));
|
|
@@ -1342,7 +1331,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1342
1331
|
else {
|
|
1343
1332
|
this.setState({ addFolder: false });
|
|
1344
1333
|
}
|
|
1345
|
-
}, replace: (text) => text.replace(/[^-_\w]/, '_') });
|
|
1334
|
+
}, replace: (text) => text.replace(/[^-_\w]/, '_') }));
|
|
1346
1335
|
}
|
|
1347
1336
|
return null;
|
|
1348
1337
|
}
|
|
@@ -1387,7 +1376,8 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1387
1376
|
await this.props.socket.writeFile64(adapterName || '', parts.join('/'), data);
|
|
1388
1377
|
}
|
|
1389
1378
|
catch (e) {
|
|
1390
|
-
|
|
1379
|
+
const knownError = e;
|
|
1380
|
+
window.alert(`Cannot write file: ${knownError === null || knownError === void 0 ? void 0 : knownError.message}`);
|
|
1391
1381
|
}
|
|
1392
1382
|
}
|
|
1393
1383
|
renderUpload() {
|
|
@@ -1408,8 +1398,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1408
1398
|
}
|
|
1409
1399
|
else {
|
|
1410
1400
|
const id = `${parentFolder}/${file.name}`;
|
|
1411
|
-
this.uploadFile(id, reader.result)
|
|
1412
|
-
.then(() => {
|
|
1401
|
+
void this.uploadFile(id, reader.result).then(() => {
|
|
1413
1402
|
if (!--count) {
|
|
1414
1403
|
this.setState({ uploadFile: false }, () => {
|
|
1415
1404
|
if (this.supportSubscribes) {
|
|
@@ -1423,8 +1412,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1423
1412
|
this.setState({ expanded }, () => this.select(id));
|
|
1424
1413
|
}
|
|
1425
1414
|
else {
|
|
1426
|
-
setTimeout(() => this.browseFolder(parentFolder, null, false, true)
|
|
1427
|
-
.then(folders => {
|
|
1415
|
+
setTimeout(() => this.browseFolder(parentFolder, null, false, true).then(folders => {
|
|
1428
1416
|
// open current folder
|
|
1429
1417
|
const expanded = [...this.state.expanded];
|
|
1430
1418
|
if (!expanded.includes(parentFolder)) {
|
|
@@ -1442,14 +1430,14 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1442
1430
|
};
|
|
1443
1431
|
reader.readAsArrayBuffer(file);
|
|
1444
1432
|
});
|
|
1445
|
-
} }, ({ 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()),
|
|
1446
1434
|
react_1.default.createElement("input", Object.assign({}, getInputProps())),
|
|
1447
1435
|
react_1.default.createElement(material_1.Box, { component: "div", sx: styles.uploadCenterDiv },
|
|
1448
1436
|
react_1.default.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
1449
1437
|
react_1.default.createElement(icons_material_1.Publish, { style: styles.uploadCenterIcon }),
|
|
1450
1438
|
react_1.default.createElement("div", { style: styles.uploadCenterText }, this.state.uploadFile === 'dragging'
|
|
1451
1439
|
? this.props.t('ra_Drop file here')
|
|
1452
|
-
: 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'))))))),
|
|
1453
1441
|
];
|
|
1454
1442
|
}
|
|
1455
1443
|
return null;
|
|
@@ -1459,13 +1447,12 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1459
1447
|
if (item === null || item === void 0 ? void 0 : item.folder) {
|
|
1460
1448
|
return (this.state.folders[id]
|
|
1461
1449
|
? Promise.all(this.state.folders[id].map(_item => this.deleteRecursive(_item.id)))
|
|
1462
|
-
: Promise.resolve())
|
|
1463
|
-
.then(() => {
|
|
1450
|
+
: Promise.resolve()).then(() => {
|
|
1464
1451
|
// If it is a folder of second level
|
|
1465
1452
|
if (item.level >= 1) {
|
|
1466
1453
|
const parts = id.split('/');
|
|
1467
1454
|
const adapter = parts.shift();
|
|
1468
|
-
this.props.socket.deleteFolder(adapter || '', parts.join('/')).then(() => {
|
|
1455
|
+
void this.props.socket.deleteFolder(adapter || '', parts.join('/')).then(() => {
|
|
1469
1456
|
// remove this folder
|
|
1470
1457
|
const folders = JSON.parse(JSON.stringify(this.state.folders));
|
|
1471
1458
|
delete folders[item.id];
|
|
@@ -1494,8 +1481,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1494
1481
|
}
|
|
1495
1482
|
deleteItem(deleteItem) {
|
|
1496
1483
|
deleteItem = deleteItem || this.state.deleteItem;
|
|
1497
|
-
this.setState({ deleteItem: '' }, () => this.deleteRecursive(deleteItem)
|
|
1498
|
-
.then(() => {
|
|
1484
|
+
this.setState({ deleteItem: '' }, () => this.deleteRecursive(deleteItem).then(() => {
|
|
1499
1485
|
const newState = {};
|
|
1500
1486
|
const pos = this.state.expanded.indexOf(deleteItem);
|
|
1501
1487
|
if (pos !== -1) {
|
|
@@ -1520,18 +1506,18 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1520
1506
|
newState.folders = folders;
|
|
1521
1507
|
this.setState(newState, () => setTimeout(() => {
|
|
1522
1508
|
this.browseFolders([...this.state.expanded], folders)
|
|
1523
|
-
.then(_folders => this.setState({ folders: _folders }))
|
|
1509
|
+
.then(_folders => this.setState({ folders: _folders }))
|
|
1510
|
+
.catch(e => console.error(e));
|
|
1524
1511
|
}, 200));
|
|
1525
1512
|
}
|
|
1526
1513
|
else {
|
|
1527
|
-
// @ts-expect-error fix later
|
|
1528
1514
|
this.setState(newState);
|
|
1529
1515
|
}
|
|
1530
1516
|
}));
|
|
1531
1517
|
}
|
|
1532
1518
|
renderDeleteDialog() {
|
|
1533
1519
|
if (this.state.deleteItem) {
|
|
1534
|
-
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" },
|
|
1535
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())),
|
|
1536
1522
|
react_1.default.createElement(material_1.DialogContent, null,
|
|
1537
1523
|
react_1.default.createElement(material_1.DialogContentText, null, this.props.t('ra_Are you sure?'))),
|
|
@@ -1541,16 +1527,16 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1541
1527
|
this.deleteItem('');
|
|
1542
1528
|
} }, this.props.t('ra_Delete (no confirm for 5 mins)')),
|
|
1543
1529
|
react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.deleteItem(''), color: "primary", autoFocus: true }, this.props.t('ra_Delete')),
|
|
1544
|
-
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')))));
|
|
1545
1531
|
}
|
|
1546
|
-
return
|
|
1532
|
+
return null;
|
|
1547
1533
|
}
|
|
1548
1534
|
renderViewDialog() {
|
|
1549
|
-
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;
|
|
1550
1536
|
}
|
|
1551
1537
|
renderError() {
|
|
1552
1538
|
if (this.state.errorText) {
|
|
1553
|
-
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: '' }) }));
|
|
1554
1540
|
}
|
|
1555
1541
|
return null;
|
|
1556
1542
|
}
|
|
@@ -1599,7 +1585,9 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1599
1585
|
resolve(true);
|
|
1600
1586
|
}
|
|
1601
1587
|
})
|
|
1602
|
-
.then(result => result &&
|
|
1588
|
+
.then(result => result &&
|
|
1589
|
+
this.setState({ selected: this.state.path, currentDir: folder, pathFocus: false }))
|
|
1590
|
+
.catch(e => console.error(e));
|
|
1603
1591
|
}
|
|
1604
1592
|
else if (!this.lastSelect || Date.now() - this.lastSelect > 100) {
|
|
1605
1593
|
this.setState({ pathFocus: false });
|
|
@@ -1611,30 +1599,27 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1611
1599
|
? this.state.currentDir.split('/')
|
|
1612
1600
|
: `/${this.state.currentDir}`.split('/');
|
|
1613
1601
|
const p = [];
|
|
1614
|
-
return react_1.default.createElement(material_1.Breadcrumbs, { style: { paddingLeft: 8 } }, parts.map((part, i) => {
|
|
1602
|
+
return (react_1.default.createElement(material_1.Breadcrumbs, { style: { paddingLeft: 8 } }, parts.map((part, i) => {
|
|
1615
1603
|
if (part) {
|
|
1616
1604
|
p.push(part);
|
|
1617
1605
|
}
|
|
1618
1606
|
const path = p.join('/');
|
|
1619
1607
|
if (i < parts.length - 1) {
|
|
1620
|
-
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')));
|
|
1621
1609
|
}
|
|
1622
|
-
return react_1.default.createElement("div", { style: styles.pathDivBreadcrumbSelected, key: `${this.state.selected}_${i}`, onClick: () => this.setState({ pathFocus: true }) }, part);
|
|
1623
|
-
}));
|
|
1610
|
+
return (react_1.default.createElement("div", { style: styles.pathDivBreadcrumbSelected, key: `${this.state.selected}_${i}`, onClick: () => this.setState({ pathFocus: true }) }, part));
|
|
1611
|
+
})));
|
|
1624
1612
|
}
|
|
1625
1613
|
renderPath() {
|
|
1626
|
-
return react_1.default.createElement(material_1.Box, { component: "div", key: "path", sx: styles.pathDiv }, this.state.pathFocus ?
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
react_1.default.createElement(icons_material_1.KeyboardReturn, null)), onBlur: () => this.changeToPath(), onChange: e => this.setState({ path: e.target.value }), style: styles.pathDivInput })
|
|
1636
|
-
:
|
|
1637
|
-
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())));
|
|
1638
1623
|
}
|
|
1639
1624
|
render() {
|
|
1640
1625
|
if (!this.props.ready) {
|
|
@@ -1645,12 +1630,11 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1645
1630
|
setTimeout(() => {
|
|
1646
1631
|
this.setState({ loadAllFolders: false, folders: {} }, () => {
|
|
1647
1632
|
this.foldersLoading = false;
|
|
1648
|
-
this.loadFolders()
|
|
1649
|
-
.catch(error => console.error(`Cannot load folders: ${error}`));
|
|
1633
|
+
this.loadFolders().catch(error => console.error(`Cannot load folders: ${error}`));
|
|
1650
1634
|
});
|
|
1651
1635
|
}, 300);
|
|
1652
1636
|
}
|
|
1653
|
-
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 },
|
|
1654
1638
|
this.props.showToolbar ? this.renderToolbar() : null,
|
|
1655
1639
|
this.state.viewType === TILE ? this.renderPath() : null,
|
|
1656
1640
|
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.filesDiv), styles[`filesDiv${this.state.viewType}`]), onClick: e => {
|
|
@@ -1666,8 +1650,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1666
1650
|
this.state.viewType === TABLE
|
|
1667
1651
|
? this.renderItems('/')
|
|
1668
1652
|
: this.renderItems(this.state.currentDir || '/'),
|
|
1669
|
-
this.state.viewType !== TABLE ?
|
|
1670
|
-
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),
|
|
1671
1654
|
this.props.allowUpload ? this.renderInputDialog() : null,
|
|
1672
1655
|
this.props.allowUpload ? this.renderUpload() : null,
|
|
1673
1656
|
this.props.allowDelete ? this.renderDeleteDialog() : null,
|
|
@@ -1675,7 +1658,7 @@ class FileBrowserClass extends react_1.Component {
|
|
|
1675
1658
|
this.state.modalEditOfAccess && this.props.modalEditOfAccessControl
|
|
1676
1659
|
? this.props.modalEditOfAccessControl(this)
|
|
1677
1660
|
: null,
|
|
1678
|
-
this.renderError());
|
|
1661
|
+
this.renderError()));
|
|
1679
1662
|
}
|
|
1680
1663
|
}
|
|
1681
1664
|
exports.FileBrowserClass = FileBrowserClass;
|