@iobroker/gui-components 8.0.1
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/LICENSE +22 -0
- package/README.md +1450 -0
- package/build/AdminConnection.d.ts +1 -0
- package/build/AdminConnection.js +2 -0
- package/build/AdminConnection.js.map +1 -0
- package/build/Components/404.d.ts +4 -0
- package/build/Components/404.js +97 -0
- package/build/Components/404.js.map +1 -0
- package/build/Components/ColorPicker.d.ts +86 -0
- package/build/Components/ColorPicker.js +222 -0
- package/build/Components/ColorPicker.js.map +1 -0
- package/build/Components/ComplexCron.d.ts +40 -0
- package/build/Components/ComplexCron.js +401 -0
- package/build/Components/ComplexCron.js.map +1 -0
- package/build/Components/CopyToClipboard.d.ts +14 -0
- package/build/Components/CopyToClipboard.js +160 -0
- package/build/Components/CopyToClipboard.js.map +1 -0
- package/build/Components/CustomModal.d.ts +26 -0
- package/build/Components/CustomModal.js +62 -0
- package/build/Components/CustomModal.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeIcon.d.ts +29 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js +108 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeOptions.d.ts +2 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js +69 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeSelector.d.ts +20 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js +83 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.d.ts +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js +30 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js.map +1 -0
- package/build/Components/DeviceType/i18n/de.json +46 -0
- package/build/Components/DeviceType/i18n/en.json +46 -0
- package/build/Components/DeviceType/i18n/fr.json +46 -0
- package/build/Components/DeviceType/i18n/it.json +46 -0
- package/build/Components/DeviceType/i18n/nl.json +46 -0
- package/build/Components/DeviceType/i18n/pl.json +46 -0
- package/build/Components/DeviceType/i18n/pt.json +46 -0
- package/build/Components/DeviceType/i18n/ru.json +46 -0
- package/build/Components/DeviceType/i18n/uk.json +46 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +46 -0
- package/build/Components/DeviceType/icons/Cleaner.d.ts +3 -0
- package/build/Components/DeviceType/icons/Cleaner.js +14 -0
- package/build/Components/DeviceType/icons/Cleaner.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorClosed.js +7 -0
- package/build/Components/DeviceType/icons/DoorClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorOpened.js +7 -0
- package/build/Components/DeviceType/icons/DoorOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOff.js +8 -0
- package/build/Components/DeviceType/icons/FireOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOn.js +14 -0
- package/build/Components/DeviceType/icons/FireOn.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOff.js +11 -0
- package/build/Components/DeviceType/icons/FloodOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOn.js +18 -0
- package/build/Components/DeviceType/icons/FloodOn.js.map +1 -0
- package/build/Components/DeviceType/icons/Gate.d.ts +3 -0
- package/build/Components/DeviceType/icons/Gate.js +8 -0
- package/build/Components/DeviceType/icons/Gate.js.map +1 -0
- package/build/Components/DeviceType/icons/HeatValve.d.ts +3 -0
- package/build/Components/DeviceType/icons/HeatValve.js +6 -0
- package/build/Components/DeviceType/icons/HeatValve.js.map +1 -0
- package/build/Components/DeviceType/icons/Home.d.ts +3 -0
- package/build/Components/DeviceType/icons/Home.js +6 -0
- package/build/Components/DeviceType/icons/Home.js.map +1 -0
- package/build/Components/DeviceType/icons/Humidity.d.ts +3 -0
- package/build/Components/DeviceType/icons/Humidity.js +8 -0
- package/build/Components/DeviceType/icons/Humidity.js.map +1 -0
- package/build/Components/DeviceType/icons/IconHome.d.ts +5 -0
- package/build/Components/DeviceType/icons/IconHome.js +21 -0
- package/build/Components/DeviceType/icons/IconHome.js.map +1 -0
- package/build/Components/DeviceType/icons/Jalousie.d.ts +3 -0
- package/build/Components/DeviceType/icons/Jalousie.js +7 -0
- package/build/Components/DeviceType/icons/Jalousie.js.map +1 -0
- package/build/Components/DeviceType/icons/Material.d.ts +3 -0
- package/build/Components/DeviceType/icons/Material.js +8 -0
- package/build/Components/DeviceType/icons/Material.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOff.js +11 -0
- package/build/Components/DeviceType/icons/MotionOff.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOn.js +7 -0
- package/build/Components/DeviceType/icons/MotionOn.js.map +1 -0
- package/build/Components/DeviceType/icons/PushButton.d.ts +3 -0
- package/build/Components/DeviceType/icons/PushButton.js +9 -0
- package/build/Components/DeviceType/icons/PushButton.js.map +1 -0
- package/build/Components/DeviceType/icons/RGB.d.ts +3 -0
- package/build/Components/DeviceType/icons/RGB.js +43 -0
- package/build/Components/DeviceType/icons/RGB.js.map +1 -0
- package/build/Components/DeviceType/icons/RepairExpert.d.ts +3 -0
- package/build/Components/DeviceType/icons/RepairExpert.js +6 -0
- package/build/Components/DeviceType/icons/RepairExpert.js.map +1 -0
- package/build/Components/DeviceType/icons/Socket.d.ts +3 -0
- package/build/Components/DeviceType/icons/Socket.js +8 -0
- package/build/Components/DeviceType/icons/Socket.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermometer.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermometer.js +7 -0
- package/build/Components/DeviceType/icons/Thermometer.js.map +1 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.d.ts +3 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js +8 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermostat.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermostat.js +9 -0
- package/build/Components/DeviceType/icons/Thermostat.js.map +1 -0
- package/build/Components/DeviceType/icons/Valve.d.ts +3 -0
- package/build/Components/DeviceType/icons/Valve.js +7 -0
- package/build/Components/DeviceType/icons/Valve.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowClosed.js +8 -0
- package/build/Components/DeviceType/icons/WindowClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowOpened.js +9 -0
- package/build/Components/DeviceType/icons/WindowOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowTilted.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowTilted.js +8 -0
- package/build/Components/DeviceType/icons/WindowTilted.js.map +1 -0
- package/build/Components/DeviceType/icons/index.d.ts +28 -0
- package/build/Components/DeviceType/icons/index.js +28 -0
- package/build/Components/DeviceType/icons/index.js.map +1 -0
- package/build/Components/FileBrowser.d.ts +187 -0
- package/build/Components/FileBrowser.js +1711 -0
- package/build/Components/FileBrowser.js.map +1 -0
- package/build/Components/FileViewer.d.ts +49 -0
- package/build/Components/FileViewer.js +247 -0
- package/build/Components/FileViewer.js.map +1 -0
- package/build/Components/Icon.d.ts +35 -0
- package/build/Components/Icon.js +140 -0
- package/build/Components/Icon.js.map +1 -0
- package/build/Components/IconPicker.d.ts +25 -0
- package/build/Components/IconPicker.js +72 -0
- package/build/Components/IconPicker.js.map +1 -0
- package/build/Components/IconSelector.d.ts +33 -0
- package/build/Components/IconSelector.js +2086 -0
- package/build/Components/IconSelector.js.map +1 -0
- package/build/Components/Image.d.ts +31 -0
- package/build/Components/Image.js +126 -0
- package/build/Components/Image.js.map +1 -0
- package/build/Components/InfoBox.d.ts +37 -0
- package/build/Components/InfoBox.js +115 -0
- package/build/Components/InfoBox.js.map +1 -0
- package/build/Components/IobUri.d.ts +14 -0
- package/build/Components/IobUri.js +168 -0
- package/build/Components/IobUri.js.map +1 -0
- package/build/Components/Loader.d.ts +31 -0
- package/build/Components/Loader.js +265 -0
- package/build/Components/Loader.js.map +1 -0
- package/build/Components/Loaders/MV.d.ts +17 -0
- package/build/Components/Loaders/MV.js +61 -0
- package/build/Components/Loaders/MV.js.map +1 -0
- package/build/Components/Loaders/PT.d.ts +27 -0
- package/build/Components/Loaders/PT.js +150 -0
- package/build/Components/Loaders/PT.js.map +1 -0
- package/build/Components/Loaders/Vendor.d.ts +22 -0
- package/build/Components/Loaders/Vendor.js +52 -0
- package/build/Components/Loaders/Vendor.js.map +1 -0
- package/build/Components/Logo.d.ts +18 -0
- package/build/Components/Logo.js +109 -0
- package/build/Components/Logo.js.map +1 -0
- package/build/Components/MDUtils.d.ts +11 -0
- package/build/Components/MDUtils.js +99 -0
- package/build/Components/MDUtils.js.map +1 -0
- package/build/Components/ObjectBrowser.d.ts +665 -0
- package/build/Components/ObjectBrowser.js +6245 -0
- package/build/Components/ObjectBrowser.js.map +1 -0
- package/build/Components/Router.d.ts +21 -0
- package/build/Components/Router.js +77 -0
- package/build/Components/Router.js.map +1 -0
- package/build/Components/SaveCloseButtons.d.ts +20 -0
- package/build/Components/SaveCloseButtons.js +65 -0
- package/build/Components/SaveCloseButtons.js.map +1 -0
- package/build/Components/Schedule.d.ts +62 -0
- package/build/Components/Schedule.js +1266 -0
- package/build/Components/Schedule.js.map +1 -0
- package/build/Components/SelectWithIcon.d.ts +37 -0
- package/build/Components/SelectWithIcon.js +139 -0
- package/build/Components/SelectWithIcon.js.map +1 -0
- package/build/Components/SimpleCron/cronText.d.ts +10 -0
- package/build/Components/SimpleCron/cronText.js +14 -0
- package/build/Components/SimpleCron/cronText.js.map +1 -0
- package/build/Components/SimpleCron/index.d.ts +55 -0
- package/build/Components/SimpleCron/index.js +698 -0
- package/build/Components/SimpleCron/index.js.map +1 -0
- package/build/Components/TabContainer.d.ts +15 -0
- package/build/Components/TabContainer.js +23 -0
- package/build/Components/TabContainer.js.map +1 -0
- package/build/Components/TabContent.d.ts +11 -0
- package/build/Components/TabContent.js +20 -0
- package/build/Components/TabContent.js.map +1 -0
- package/build/Components/TabHeader.d.ts +6 -0
- package/build/Components/TabHeader.js +6 -0
- package/build/Components/TabHeader.js.map +1 -0
- package/build/Components/TableResize.d.ts +45 -0
- package/build/Components/TableResize.js +204 -0
- package/build/Components/TableResize.js.map +1 -0
- package/build/Components/TextWithIcon.d.ts +21 -0
- package/build/Components/TextWithIcon.js +113 -0
- package/build/Components/TextWithIcon.js.map +1 -0
- package/build/Components/ToggleThemeMenu.d.ts +12 -0
- package/build/Components/ToggleThemeMenu.js +13 -0
- package/build/Components/ToggleThemeMenu.js.map +1 -0
- package/build/Components/TreeTable.d.ts +79 -0
- package/build/Components/TreeTable.js +538 -0
- package/build/Components/TreeTable.js.map +1 -0
- package/build/Components/UploadImage.d.ts +23 -0
- package/build/Components/UploadImage.js +516 -0
- package/build/Components/UploadImage.js.map +1 -0
- package/build/Components/Utils.d.ts +331 -0
- package/build/Components/Utils.js +1605 -0
- package/build/Components/Utils.js.map +1 -0
- package/build/Components/withWidth.d.ts +2 -0
- package/build/Components/withWidth.js +22 -0
- package/build/Components/withWidth.js.map +1 -0
- package/build/Connection.d.ts +1 -0
- package/build/Connection.js +2 -0
- package/build/Connection.js.map +1 -0
- package/build/Dialogs/ComplexCron.d.ts +24 -0
- package/build/Dialogs/ComplexCron.js +85 -0
- package/build/Dialogs/ComplexCron.js.map +1 -0
- package/build/Dialogs/Confirm.d.ts +39 -0
- package/build/Dialogs/Confirm.js +83 -0
- package/build/Dialogs/Confirm.js.map +1 -0
- package/build/Dialogs/Cron.d.ts +29 -0
- package/build/Dialogs/Cron.js +72 -0
- package/build/Dialogs/Cron.js.map +1 -0
- package/build/Dialogs/Error.d.ts +18 -0
- package/build/Dialogs/Error.js +27 -0
- package/build/Dialogs/Error.js.map +1 -0
- package/build/Dialogs/Message.d.ts +20 -0
- package/build/Dialogs/Message.js +29 -0
- package/build/Dialogs/Message.js.map +1 -0
- package/build/Dialogs/SelectFile.d.ts +85 -0
- package/build/Dialogs/SelectFile.js +115 -0
- package/build/Dialogs/SelectFile.js.map +1 -0
- package/build/Dialogs/SelectID.d.ts +102 -0
- package/build/Dialogs/SelectID.js +151 -0
- package/build/Dialogs/SelectID.js.map +1 -0
- package/build/Dialogs/SimpleCron.d.ts +19 -0
- package/build/Dialogs/SimpleCron.js +46 -0
- package/build/Dialogs/SimpleCron.js.map +1 -0
- package/build/Dialogs/TextInput.d.ts +2 -0
- package/build/Dialogs/TextInput.js +31 -0
- package/build/Dialogs/TextInput.js.map +1 -0
- package/build/GenericApp.d.ts +209 -0
- package/build/GenericApp.js +842 -0
- package/build/GenericApp.js.map +1 -0
- package/build/LegacyConnection.d.ts +938 -0
- package/build/LegacyConnection.js +2849 -0
- package/build/LegacyConnection.js.map +1 -0
- package/build/Prompt.d.ts +5 -0
- package/build/Prompt.js +19 -0
- package/build/Prompt.js.map +1 -0
- package/build/Theme.d.ts +5 -0
- package/build/Theme.js +344 -0
- package/build/Theme.js.map +1 -0
- package/build/assets/devices/parseNames.d.ts +0 -0
- package/build/assets/devices/parseNames.js +35 -0
- package/build/assets/devices/parseNames.js.map +1 -0
- package/build/assets/devices.json +1 -0
- package/build/assets/lamp_ceiling.svg +9 -0
- package/build/assets/lamp_table.svg +8 -0
- package/build/assets/no_icon.svg +9 -0
- package/build/assets/rooms/parseNames.d.ts +0 -0
- package/build/assets/rooms/parseNames.js +35 -0
- package/build/assets/rooms/parseNames.js.map +1 -0
- package/build/assets/rooms.json +1 -0
- package/build/dictionary.d.ts +1 -0
- package/build/dictionary.js +25 -0
- package/build/dictionary.js.map +1 -0
- package/build/globals.d.ts +19 -0
- package/build/i18n/de.json +480 -0
- package/build/i18n/en.json +480 -0
- package/build/i18n/es.json +480 -0
- package/build/i18n/fr.json +480 -0
- package/build/i18n/it.json +475 -0
- package/build/i18n/nl.json +475 -0
- package/build/i18n/pl.json +475 -0
- package/build/i18n/pt.json +475 -0
- package/build/i18n/ru.json +475 -0
- package/build/i18n/uk.json +475 -0
- package/build/i18n/zh-cn.json +475 -0
- package/build/i18n.d.ts +84 -0
- package/build/i18n.js +224 -0
- package/build/i18n.js.map +1 -0
- package/build/icons/IconAdapter.d.ts +3 -0
- package/build/icons/IconAdapter.js +7 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +7 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconButtonImage.d.ts +3 -0
- package/build/icons/IconButtonImage.js +9 -0
- package/build/icons/IconButtonImage.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +10 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +8 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +7 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +6 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +16 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +7 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +8 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +7 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +6 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +7 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +7 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +6 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +7 -0
- package/build/icons/IconOpen.js.map +1 -0
- package/build/icons/IconState.d.ts +3 -0
- package/build/icons/IconState.js +7 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/icons/IconVacuum.d.ts +3 -0
- package/build/icons/IconVacuum.js +12 -0
- package/build/icons/IconVacuum.js.map +1 -0
- package/build/index.css +56 -0
- package/build/index.d.ts +87 -0
- package/build/index.js +85 -0
- package/build/index.js.map +1 -0
- package/build/modulefederation.admin.config.d.ts +13 -0
- package/build/modulefederation.admin.config.js +45 -0
- package/build/modulefederation.admin.config.js.map +1 -0
- package/build/types.d.ts +236 -0
- package/i18n/de.json +480 -0
- package/i18n/en.json +480 -0
- package/i18n/es.json +480 -0
- package/i18n/fr.json +480 -0
- package/i18n/it.json +475 -0
- package/i18n/nl.json +475 -0
- package/i18n/pl.json +475 -0
- package/i18n/pt.json +475 -0
- package/i18n/ru.json +475 -0
- package/i18n/uk.json +475 -0
- package/i18n/zh-cn.json +475 -0
- package/index.css +56 -0
- package/modulefederation.admin.config.d.ts +20 -0
- package/modulefederation.admin.config.js +54 -0
- package/package.json +86 -0
- package/tasksExample.js +91 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2018-2025 Denis Haev (bluefox) <dogafox@gmail.com>
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import React, { Component } from 'react';
|
|
8
|
+
import { Button, DialogTitle, DialogContent, DialogActions, Dialog } from '@mui/material';
|
|
9
|
+
import { Cancel as IconCancel, Check as IconOk } from '@mui/icons-material';
|
|
10
|
+
import { I18n } from '../i18n';
|
|
11
|
+
import { ObjectBrowser, } from '../Components/ObjectBrowser';
|
|
12
|
+
export class DialogSelectID extends Component {
|
|
13
|
+
dialogName;
|
|
14
|
+
filters;
|
|
15
|
+
filterFunc;
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.dialogName = this.props.dialogName || 'default';
|
|
19
|
+
this.dialogName = `SelectID.${this.dialogName}`;
|
|
20
|
+
const filters = (window._localStorage || window.localStorage).getItem(this.dialogName) || '{}';
|
|
21
|
+
try {
|
|
22
|
+
this.filters = JSON.parse(filters);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
this.filters = {};
|
|
26
|
+
}
|
|
27
|
+
if (props.filters) {
|
|
28
|
+
this.filters = { ...this.filters, ...(props.filters || {}) };
|
|
29
|
+
}
|
|
30
|
+
let selected = this.props.selected || [];
|
|
31
|
+
if (!Array.isArray(selected)) {
|
|
32
|
+
selected = [selected];
|
|
33
|
+
}
|
|
34
|
+
selected = selected.filter(id => id);
|
|
35
|
+
if (props.filterFunc) {
|
|
36
|
+
if (typeof props.filterFunc === 'string') {
|
|
37
|
+
try {
|
|
38
|
+
this.filterFunc = new Function('obj', props.filterFunc);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
console.error(`Cannot parse filter function: "obj => ${props.filterFunc}"`);
|
|
42
|
+
this.filterFunc = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.filterFunc = props.filterFunc;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this.state = {
|
|
50
|
+
selected,
|
|
51
|
+
name: '',
|
|
52
|
+
selectionBlocked: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
handleCancel() {
|
|
56
|
+
this.props.onClose();
|
|
57
|
+
}
|
|
58
|
+
handleOk() {
|
|
59
|
+
this.props.onOk(this.props.multiSelect ? this.state.selected : this.state.selected[0] || '', this.state.name);
|
|
60
|
+
this.props.onClose();
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
let title;
|
|
64
|
+
if (this.state.name || this.state.selected.length) {
|
|
65
|
+
if (this.state.selected.length === 1) {
|
|
66
|
+
title = [
|
|
67
|
+
React.createElement("span", { key: "selected" },
|
|
68
|
+
I18n.t('ra_Selected'),
|
|
69
|
+
"\u00A0"),
|
|
70
|
+
React.createElement("span", { key: "id", style: { fontWeight: 'bold', fontStyle: 'italic' } }, (this.state.name || this.state.selected[0]) +
|
|
71
|
+
(this.state.name ? ` [${this.state.selected[0]}]` : '')),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
title = [
|
|
76
|
+
React.createElement("span", { key: "selected" },
|
|
77
|
+
I18n.t('ra_Selected'),
|
|
78
|
+
"\u00A0"),
|
|
79
|
+
React.createElement("span", { key: "id", style: { fontWeight: 'bold', fontStyle: 'italic' } }, I18n.t('%s items', this.state.selected.length.toString())),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
title = this.props.title || I18n.t('ra_Please select object ID...');
|
|
85
|
+
}
|
|
86
|
+
return (React.createElement(Dialog, { onClose: () => { }, maxWidth: false, style: { zIndex: this.props.zIndex || undefined }, sx: {
|
|
87
|
+
'& .MuiDialog-paper': {
|
|
88
|
+
height: '95%',
|
|
89
|
+
p: '4px',
|
|
90
|
+
width: '100%',
|
|
91
|
+
maxWidth: '100%',
|
|
92
|
+
maxHeight: 'calc(100% - 16px)',
|
|
93
|
+
},
|
|
94
|
+
}, fullWidth: true, open: !0, "aria-labelledby": "ar_dialog_selectid_title" },
|
|
95
|
+
React.createElement(DialogTitle, { id: "ar_dialog_selectid_title", style: {
|
|
96
|
+
whiteSpace: 'nowrap',
|
|
97
|
+
width: 'calc(100% - 72px)',
|
|
98
|
+
overflow: 'hidden',
|
|
99
|
+
display: 'inline-block',
|
|
100
|
+
textOverflow: 'ellipsis',
|
|
101
|
+
} }, title),
|
|
102
|
+
React.createElement(DialogContent, { style: {
|
|
103
|
+
height: '100%',
|
|
104
|
+
overflow: 'hidden',
|
|
105
|
+
padding: '8px 4px',
|
|
106
|
+
} },
|
|
107
|
+
React.createElement(ObjectBrowser, { foldersFirst: this.props.foldersFirst, imagePrefix: this.props.imagePrefix || this.props.prefix, dateFormat: this.props.dateFormat, defaultFilters: this.filters, dialogName: this.dialogName, isFloatComma: this.props.isFloatComma, showExpertButton: this.props.showExpertButton !== undefined ? this.props.showExpertButton : true, expertMode: this.props.expertMode,
|
|
108
|
+
// style={{ width: '100%', height: '100%' }}
|
|
109
|
+
columns: this.props.columns || ['name', 'type', 'role', 'room', 'func', 'val'], types: this.props.types
|
|
110
|
+
? Array.isArray(this.props.types)
|
|
111
|
+
? this.props.types
|
|
112
|
+
: [this.props.types]
|
|
113
|
+
: ['state'], root: this.props.root, t: I18n.t, lang: this.props.lang || I18n.getLanguage(), socket: this.props.socket, selected: this.state.selected, multiSelect: this.props.multiSelect, notEditable: this.props.notEditable === undefined ? true : this.props.notEditable,
|
|
114
|
+
// name={this.state.name}
|
|
115
|
+
themeName: this.props.themeName, themeType: this.props.themeType, theme: this.props.theme, customFilter: this.props.customFilter, allowNonObjects: this.props.allowNonObjects, onFilterChanged: (filterConfig) => {
|
|
116
|
+
this.filters = filterConfig;
|
|
117
|
+
(window._localStorage || window.localStorage).setItem(this.dialogName, JSON.stringify(filterConfig));
|
|
118
|
+
}, onSelect: async (_selected, name, isDouble) => {
|
|
119
|
+
let selected;
|
|
120
|
+
if (!Array.isArray(_selected)) {
|
|
121
|
+
selected = [_selected];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
selected = _selected;
|
|
125
|
+
}
|
|
126
|
+
if (JSON.stringify(selected) !== JSON.stringify(this.state.selected)) {
|
|
127
|
+
let selectionAllowed = true;
|
|
128
|
+
if (this.props.onSelectConfirm) {
|
|
129
|
+
const objects = {};
|
|
130
|
+
for (const id of selected) {
|
|
131
|
+
try {
|
|
132
|
+
objects[id] = await this.props.socket.getObject(id);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// ignore
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
selectionAllowed = await this.props.onSelectConfirm(selected, objects);
|
|
139
|
+
}
|
|
140
|
+
this.setState({ selected, name, selectionBlocked: !selectionAllowed }, () => isDouble && this.handleOk());
|
|
141
|
+
}
|
|
142
|
+
else if (isDouble) {
|
|
143
|
+
this.handleOk();
|
|
144
|
+
}
|
|
145
|
+
}, filterFunc: this.filterFunc, title: "", onAllLoaded: () => this.setState({ allLoaded: true }) })),
|
|
146
|
+
React.createElement(DialogActions, null,
|
|
147
|
+
React.createElement(Button, { id: `ar_dialog_selectid_ok_${this.props.dialogName || ''}`, variant: "contained", onClick: () => this.handleOk(), startIcon: React.createElement(IconOk, null), disabled: !this.state.allLoaded || !this.state.selected.length || this.state.selectionBlocked, color: "primary" }, this.props.ok || I18n.t('ra_Ok')),
|
|
148
|
+
React.createElement(Button, { id: `ar_dialog_selectid_cancel_${this.props.dialogName || ''}`, color: "grey", variant: "contained", onClick: () => this.handleCancel(), startIcon: React.createElement(IconCancel, null) }, this.props.cancel || I18n.t('ra_Cancel')))));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=SelectID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectID.js","sourceRoot":"./src/","sources":["Dialogs/SelectID.tsx"],"names":[],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,CAAC;4BAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACpB,CAAC;oBACL,CAAC,EACD,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAC,EAAE,EACR,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,GACvD,CACU;YAChB,oBAAC,aAAa;gBACV,oBAAC,MAAM,IACH,EAAE,EAAE,yBAAyB,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,EAC1D,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC9B,SAAS,EAAE,oBAAC,MAAM,OAAG,EACrB,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAC7F,KAAK,EAAC,SAAS,IAEd,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAC5B;gBACT,oBAAC,MAAM,IACH,EAAE,EAAE,6BAA6B,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,EAC9D,KAAK,EAAC,MAAM,EACZ,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAClC,SAAS,EAAE,oBAAC,UAAU,OAAG,IAExB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CACpC,CACG,CACX,CACZ,CAAC;IACN,CAAC;CACJ","sourcesContent":["/**\n * Copyright 2018-2025 Denis Haev (bluefox) <dogafox@gmail.com>\n *\n * MIT License\n *\n */\nimport React, { Component, type JSX } from 'react';\n\nimport { Button, DialogTitle, DialogContent, DialogActions, Dialog } from '@mui/material';\n\nimport { Cancel as IconCancel, Check as IconOk } from '@mui/icons-material';\n\nimport type { Connection } from '../Connection';\n\nimport { I18n } from '../i18n';\nimport {\n ObjectBrowser,\n type ObjectBrowserFilter,\n type ObjectBrowserColumn,\n type ObjectBrowserCustomFilter,\n} from '../Components/ObjectBrowser';\nimport type { IobTheme } from '../types';\n\nexport interface SelectIDFilters {\n id?: string;\n name?: string;\n room?: string[];\n func?: string[];\n role?: string[];\n type?: string[];\n custom?: string[];\n}\n\ninterface DialogSelectIDProps {\n /** The internal name of the dialog; default: \"default\". Used to store settings in local storage */\n dialogName?: string;\n /** The dialog title; default: Please select object ID... (translated) */\n title?: string;\n /** Set to true to allow the selection of multiple IDs. */\n multiSelect?: boolean;\n /** Show folders before any leaves. */\n foldersFirst?: boolean;\n /** Path prefix for images (default: '.') */\n imagePrefix?: string;\n /** @deprecated same as imagePrefix */\n prefix?: string;\n /** Show the expert button */\n showExpertButton?: boolean;\n /** Force expert mode */\n expertMode?: boolean;\n /** optional ['name', 'type', 'role', 'room', 'func', 'val', 'buttons'] */\n columns?: ObjectBrowserColumn[];\n /** Object types to show; default: 'state' only */\n types?: ioBroker.ObjectType | ioBroker.ObjectType[];\n /** The language. */\n lang?: ioBroker.Languages;\n /** The socket connection. */\n socket: Connection;\n /** Can't objects be edited? (default: true) */\n notEditable?: boolean;\n /** Theme name. */\n themeName?: string;\n /** Theme type: dark or light */\n themeType?: string;\n /** The theme object */\n theme: IobTheme;\n /** The date format for the date columns */\n dateFormat?: string;\n /** Is use comma or point for displaying of float numbers */\n isFloatComma?: boolean;\n /** Custom filter. */\n customFilter?: ObjectBrowserCustomFilter;\n /** The selected IDs. */\n selected?: string | string[];\n /** The ok button text; default: OK (translated) */\n ok?: string;\n /** The cancel button text; default: Cancel (translated) */\n cancel?: string;\n /** Close handler that is always called when the dialog is closed. */\n onClose: () => void;\n /** Handler that is called when the user presses OK. */\n onOk: (selected: string | string[] | undefined, name: string | null) => void;\n /**\n * Function to filter out all unnecessary objects. Can be string or function.\n * It cannot be used together with \"types\".\n * Example for function: `obj => obj.common?.type === 'boolean'` to show only boolean states\n * In case of string, it must look like `obj.common && obj.common.type === 'boolean'`\n */\n filterFunc?: string | ((obj: ioBroker.Object) => boolean);\n /** predefined filter fields, like {\"id\":\"\",\"name\":\"\",\"room\":\"\",\"func\":\"\",\"role\":\"level\",\"type\":\"\",\"custom\":\"\"} */\n filters?: SelectIDFilters;\n /** Show elements only of this root ID */\n root?: string;\n /** Allow selection of non-objects (virtual branches) */\n allowNonObjects?: boolean;\n /** Will be called by selection, so the decision could be done if the OK button is available or not */\n onSelectConfirm?: (\n selected: string | string[],\n objects: Record<string, ioBroker.Object | null | undefined>,\n ) => Promise<boolean>;\n /** The z-index of the dialog; default: 1300 */\n zIndex?: number;\n}\n\ninterface DialogSelectIDState {\n selected: string[];\n name: string | null;\n selectionBlocked: boolean;\n allLoaded?: boolean; // used to detect if all objects are loaded\n}\n\nexport class DialogSelectID extends Component<DialogSelectIDProps, DialogSelectIDState> {\n private readonly dialogName: string;\n\n private filters: ObjectBrowserFilter;\n\n private readonly filterFunc?: (obj: ioBroker.Object) => boolean;\n\n constructor(props: DialogSelectIDProps) {\n super(props);\n this.dialogName = this.props.dialogName || 'default';\n this.dialogName = `SelectID.${this.dialogName}`;\n\n const filters: string = ((window as any)._localStorage || window.localStorage).getItem(this.dialogName) || '{}';\n\n try {\n this.filters = JSON.parse(filters);\n } catch {\n this.filters = {};\n }\n\n if (props.filters) {\n this.filters = { ...this.filters, ...(props.filters || {}) };\n }\n\n let selected = this.props.selected || [];\n if (!Array.isArray(selected)) {\n selected = [selected];\n }\n selected = selected.filter(id => id);\n\n if (props.filterFunc) {\n if (typeof props.filterFunc === 'string') {\n try {\n this.filterFunc = new Function('obj', props.filterFunc) as (obj: ioBroker.Object) => boolean;\n } catch {\n console.error(`Cannot parse filter function: \"obj => ${props.filterFunc}\"`);\n this.filterFunc = undefined;\n }\n } else {\n this.filterFunc = props.filterFunc;\n }\n }\n\n this.state = {\n selected,\n name: '',\n selectionBlocked: false,\n };\n }\n\n handleCancel(): void {\n this.props.onClose();\n }\n\n handleOk(): void {\n this.props.onOk(this.props.multiSelect ? this.state.selected : this.state.selected[0] || '', this.state.name);\n this.props.onClose();\n }\n\n render(): JSX.Element {\n let title;\n if (this.state.name || this.state.selected.length) {\n if (this.state.selected.length === 1) {\n title = [\n <span key=\"selected\">\n {I18n.t('ra_Selected')}\n \n </span>,\n <span\n key=\"id\"\n style={{ fontWeight: 'bold', fontStyle: 'italic' }}\n >\n {(this.state.name || this.state.selected[0]) +\n (this.state.name ? ` [${this.state.selected[0]}]` : '')}\n </span>,\n ];\n } else {\n title = [\n <span key=\"selected\">\n {I18n.t('ra_Selected')}\n \n </span>,\n <span\n key=\"id\"\n style={{ fontWeight: 'bold', fontStyle: 'italic' }}\n >\n {I18n.t('%s items', this.state.selected.length.toString())}\n </span>,\n ];\n }\n } else {\n title = this.props.title || I18n.t('ra_Please select object ID...');\n }\n\n return (\n <Dialog\n onClose={() => {}}\n maxWidth={false}\n style={{ zIndex: this.props.zIndex || undefined }}\n sx={{\n '& .MuiDialog-paper': {\n height: '95%',\n p: '4px',\n width: '100%',\n maxWidth: '100%',\n maxHeight: 'calc(100% - 16px)',\n },\n }}\n fullWidth\n open={!0}\n aria-labelledby=\"ar_dialog_selectid_title\"\n >\n <DialogTitle\n id=\"ar_dialog_selectid_title\"\n style={{\n whiteSpace: 'nowrap',\n width: 'calc(100% - 72px)',\n overflow: 'hidden',\n display: 'inline-block',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </DialogTitle>\n <DialogContent\n style={{\n height: '100%',\n overflow: 'hidden',\n padding: '8px 4px',\n }}\n >\n <ObjectBrowser\n foldersFirst={this.props.foldersFirst}\n imagePrefix={this.props.imagePrefix || this.props.prefix} // prefix is for back compatibility\n dateFormat={this.props.dateFormat}\n defaultFilters={this.filters}\n dialogName={this.dialogName}\n isFloatComma={this.props.isFloatComma}\n showExpertButton={\n this.props.showExpertButton !== undefined ? this.props.showExpertButton : true\n }\n expertMode={this.props.expertMode}\n // style={{ width: '100%', height: '100%' }}\n columns={this.props.columns || ['name', 'type', 'role', 'room', 'func', 'val']}\n types={\n this.props.types\n ? Array.isArray(this.props.types)\n ? this.props.types\n : [this.props.types]\n : ['state']\n }\n root={this.props.root}\n t={I18n.t}\n lang={this.props.lang || I18n.getLanguage()}\n socket={this.props.socket}\n selected={this.state.selected}\n multiSelect={this.props.multiSelect}\n notEditable={this.props.notEditable === undefined ? true : this.props.notEditable}\n // name={this.state.name}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n theme={this.props.theme}\n customFilter={this.props.customFilter}\n allowNonObjects={this.props.allowNonObjects}\n onFilterChanged={(filterConfig: ObjectBrowserFilter) => {\n this.filters = filterConfig;\n ((window as any)._localStorage || window.localStorage).setItem(\n this.dialogName,\n JSON.stringify(filterConfig),\n );\n }}\n onSelect={async (\n _selected: string | string[],\n name: string | null,\n isDouble?: boolean,\n ): Promise<void> => {\n let selected: string[];\n if (!Array.isArray(_selected)) {\n selected = [_selected];\n } else {\n selected = _selected;\n }\n\n if (JSON.stringify(selected) !== JSON.stringify(this.state.selected)) {\n let selectionAllowed = true;\n if (this.props.onSelectConfirm) {\n const objects: Record<string, ioBroker.Object | null | undefined> = {};\n for (const id of selected) {\n try {\n objects[id] = await this.props.socket.getObject(id);\n } catch {\n // ignore\n }\n }\n\n selectionAllowed = await this.props.onSelectConfirm(selected, objects);\n }\n\n this.setState(\n { selected, name, selectionBlocked: !selectionAllowed },\n () => isDouble && this.handleOk(),\n );\n } else if (isDouble) {\n this.handleOk();\n }\n }}\n filterFunc={this.filterFunc}\n title=\"\"\n onAllLoaded={() => this.setState({ allLoaded: true })}\n />\n </DialogContent>\n <DialogActions>\n <Button\n id={`ar_dialog_selectid_ok_${this.props.dialogName || ''}`}\n variant=\"contained\"\n onClick={() => this.handleOk()}\n startIcon={<IconOk />}\n disabled={!this.state.allLoaded || !this.state.selected.length || this.state.selectionBlocked}\n color=\"primary\"\n >\n {this.props.ok || I18n.t('ra_Ok')}\n </Button>\n <Button\n id={`ar_dialog_selectid_cancel_${this.props.dialogName || ''}`}\n color=\"grey\"\n variant=\"contained\"\n onClick={() => this.handleCancel()}\n startIcon={<IconCancel />}\n >\n {this.props.cancel || I18n.t('ra_Cancel')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { type JSX } from 'react';
|
|
2
|
+
interface DialogCronProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onOk: (cron: string) => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
cron?: string;
|
|
7
|
+
cancel?: string;
|
|
8
|
+
ok?: string;
|
|
9
|
+
}
|
|
10
|
+
interface DialogCronState {
|
|
11
|
+
cron: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class DialogSimpleCron extends React.Component<DialogCronProps, DialogCronState> {
|
|
14
|
+
constructor(props: DialogCronProps);
|
|
15
|
+
handleCancel(): void;
|
|
16
|
+
handleOk(): void;
|
|
17
|
+
render(): JSX.Element;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DialogTitle, DialogContent, DialogActions, Dialog } from '@mui/material';
|
|
3
|
+
import { Check as IconOk, Cancel as IconCancel } from '@mui/icons-material';
|
|
4
|
+
import { SimpleCron } from '../Components/SimpleCron';
|
|
5
|
+
import { I18n } from '../i18n';
|
|
6
|
+
// Generates cron expression
|
|
7
|
+
const styles = {
|
|
8
|
+
dialogPaper: {
|
|
9
|
+
height: 'calc(100% - 96px)',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export class DialogSimpleCron extends React.Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
let cron;
|
|
16
|
+
if (this.props.cron && typeof this.props.cron === 'string' && this.props.cron.replace(/^["']/, '')[0] !== '{') {
|
|
17
|
+
cron = this.props.cron.replace(/['"]/g, '').trim();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
cron = this.props.cron || '{}';
|
|
21
|
+
if (typeof cron === 'string') {
|
|
22
|
+
cron = cron.replace(/^["']/, '').replace(/["']\n?$/, '');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
this.state = {
|
|
26
|
+
cron,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
handleCancel() {
|
|
30
|
+
this.props.onClose();
|
|
31
|
+
}
|
|
32
|
+
handleOk() {
|
|
33
|
+
this.props.onOk(this.state.cron);
|
|
34
|
+
this.props.onClose();
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return (React.createElement(Dialog, { onClose: () => { }, maxWidth: "md", fullWidth: true, sx: { '& .MuiDialog-paper': styles.dialogPaper }, open: !0, "aria-labelledby": "cron-dialog-title" },
|
|
38
|
+
React.createElement(DialogTitle, { id: "cron-dialog-title" }, this.props.title || I18n.t('ra_Define CRON...')),
|
|
39
|
+
React.createElement(DialogContent, { style: { height: '100%', overflow: 'hidden' } },
|
|
40
|
+
React.createElement(SimpleCron, { cronExpression: this.state.cron, onChange: (cron) => this.setState({ cron }), language: I18n.getLanguage() })),
|
|
41
|
+
React.createElement(DialogActions, null,
|
|
42
|
+
React.createElement(Button, { variant: "contained", disabled: !this.state.cron || this.state.cron.includes('_'), onClick: () => this.handleOk(), color: "primary", startIcon: React.createElement(IconOk, null) }, this.props.ok || I18n.t('ra_Ok')),
|
|
43
|
+
React.createElement(Button, { variant: "contained", onClick: () => this.handleCancel(), color: "grey", startIcon: React.createElement(IconCancel, null) }, this.props.cancel || I18n.t('ra_Cancel')))));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=SimpleCron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleCron.js","sourceRoot":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EAAE,oBAAC,MAAM,OAAG,IAEpB,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAC5B;gBACT,oBAAC,MAAM,IACH,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAClC,KAAK,EAAC,MAAM,EACZ,SAAS,EAAE,oBAAC,UAAU,OAAG,IAExB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CACpC,CACG,CACX,CACZ,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\r\nimport { Button, DialogTitle, DialogContent, DialogActions, Dialog } from '@mui/material';\r\n\r\nimport { Check as IconOk, Cancel as IconCancel } from '@mui/icons-material';\r\n\r\nimport { SimpleCron } from '../Components/SimpleCron';\r\n\r\nimport { I18n } from '../i18n';\r\n\r\n// Generates cron expression\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n dialogPaper: {\r\n height: 'calc(100% - 96px)',\r\n },\r\n};\r\n\r\ninterface DialogCronProps {\r\n onClose: () => void;\r\n onOk: (cron: string) => void;\r\n title?: string;\r\n cron?: string;\r\n cancel?: string;\r\n ok?: string;\r\n}\r\n\r\ninterface DialogCronState {\r\n cron: string;\r\n}\r\n\r\nexport class DialogSimpleCron extends React.Component<DialogCronProps, DialogCronState> {\r\n constructor(props: DialogCronProps) {\r\n super(props);\r\n\r\n let cron;\r\n if (this.props.cron && typeof this.props.cron === 'string' && this.props.cron.replace(/^[\"']/, '')[0] !== '{') {\r\n cron = this.props.cron.replace(/['\"]/g, '').trim();\r\n } else {\r\n cron = this.props.cron || '{}';\r\n if (typeof cron === 'string') {\r\n cron = cron.replace(/^[\"']/, '').replace(/[\"']\\n?$/, '');\r\n }\r\n }\r\n\r\n this.state = {\r\n cron,\r\n };\r\n }\r\n\r\n handleCancel(): void {\r\n this.props.onClose();\r\n }\r\n\r\n handleOk(): void {\r\n this.props.onOk(this.state.cron);\r\n this.props.onClose();\r\n }\r\n\r\n render(): JSX.Element {\r\n return (\r\n <Dialog\r\n onClose={() => {}}\r\n maxWidth=\"md\"\r\n fullWidth\r\n sx={{ '& .MuiDialog-paper': styles.dialogPaper }}\r\n open={!0}\r\n aria-labelledby=\"cron-dialog-title\"\r\n >\r\n <DialogTitle id=\"cron-dialog-title\">{this.props.title || I18n.t('ra_Define CRON...')}</DialogTitle>\r\n <DialogContent style={{ height: '100%', overflow: 'hidden' }}>\r\n <SimpleCron\r\n cronExpression={this.state.cron}\r\n onChange={(cron: string) => this.setState({ cron })}\r\n language={I18n.getLanguage()}\r\n />\r\n </DialogContent>\r\n <DialogActions>\r\n <Button\r\n variant=\"contained\"\r\n disabled={!this.state.cron || this.state.cron.includes('_')}\r\n onClick={() => this.handleOk()}\r\n color=\"primary\"\r\n startIcon={<IconOk />}\r\n >\r\n {this.props.ok || I18n.t('ra_Ok')}\r\n </Button>\r\n <Button\r\n variant=\"contained\"\r\n onClick={() => this.handleCancel()}\r\n color=\"grey\"\r\n startIcon={<IconCancel />}\r\n >\r\n {this.props.cancel || I18n.t('ra_Cancel')}\r\n </Button>\r\n </DialogActions>\r\n </Dialog>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, TextField, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
|
|
3
|
+
import { Close as IconClose, Check as IconCheck } from '@mui/icons-material';
|
|
4
|
+
import { I18n } from '../i18n';
|
|
5
|
+
import { withWidth } from '../Components/withWidth';
|
|
6
|
+
function TextInputFunc(props) {
|
|
7
|
+
const [text, setText] = React.useState(props.input || props.value || '');
|
|
8
|
+
const [error, setError] = React.useState('');
|
|
9
|
+
return (React.createElement(Dialog, { open: !0, onClose: () => props.onClose(null), "aria-labelledby": "form-dialog-title", fullWidth: props.fullWidth !== undefined ? props.fullWidth : false },
|
|
10
|
+
React.createElement(DialogTitle, { id: "form-dialog-title" }, props.titleText),
|
|
11
|
+
React.createElement(DialogContent, null,
|
|
12
|
+
React.createElement(DialogContentText, null, props.promptText),
|
|
13
|
+
React.createElement(TextField, { variant: "standard", autoFocus: true, margin: "dense", error: !!error, helperText: error === true || !error ? '' : error, value: text, label: props.labelText || '', type: props.type || 'text', onKeyUp: e => e.code === 'Enter' && text && props.onClose(text), onChange: e => {
|
|
14
|
+
let _error = '';
|
|
15
|
+
if (props.verify) {
|
|
16
|
+
_error = !props.verify(e.target.value);
|
|
17
|
+
}
|
|
18
|
+
if (props.rule) {
|
|
19
|
+
setText(props.rule(e.target.value));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
setText(e.target.value);
|
|
23
|
+
}
|
|
24
|
+
setError(_error);
|
|
25
|
+
}, fullWidth: true })),
|
|
26
|
+
React.createElement(DialogActions, null,
|
|
27
|
+
React.createElement(Button, { variant: "contained", disabled: !text || !!error, onClick: () => props.onClose(text), color: "primary", startIcon: React.createElement(IconCheck, null) }, props.applyText || I18n.t('ra_Ok')),
|
|
28
|
+
React.createElement(Button, { color: "grey", variant: "contained", onClick: () => props.onClose(null), startIcon: React.createElement(IconClose, null) }, props.cancelText || I18n.t('ra_Cancel')))));
|
|
29
|
+
}
|
|
30
|
+
export const DialogTextInput = withWidth()(TextInputFunc);
|
|
31
|
+
//# sourceMappingURL=TextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"./src/","sources":["Dialogs/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAExH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,SAAS,EAAE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":["import React, { type JSX } from 'react';\r\n\r\nimport { Button, TextField, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';\r\n\r\nimport { Close as IconClose, Check as IconCheck } from '@mui/icons-material';\r\n\r\nimport { I18n } from '../i18n';\r\nimport { withWidth } from '../Components/withWidth';\r\n\r\ninterface TextInputProps {\r\n /** The dialog close callback */\r\n onClose: (text: string | null) => void;\r\n /** The title text */\r\n titleText: string;\r\n /** Prompt text (default: empty) */\r\n promptText?: string;\r\n /** Label text (default: empty) */\r\n labelText?: string;\r\n /** The text of the cancel button */\r\n cancelText: string;\r\n /** The text of the \"apply\" button */\r\n applyText: string;\r\n /** The verification callback. Return a non-empty string if there was an error */\r\n verify?: (text: string) => string;\r\n /** The text replacement callback */\r\n rule?: (text: string) => string;\r\n /** The type of the textbox (default: text) */\r\n type?: 'text' | 'number' | 'password' | 'email';\r\n /** The initial input value when opening the dialog */\r\n value?: string;\r\n /** @deprecated Use value. The input when opening the dialog */\r\n input?: string;\r\n /** If true, the dialog will be full width */\r\n fullWidth?: boolean;\r\n}\r\n\r\nfunction TextInputFunc(props: TextInputProps): JSX.Element {\r\n const [text, setText] = React.useState<string>(props.input || props.value || '');\r\n const [error, setError] = React.useState<string | boolean>('');\r\n return (\r\n <Dialog\r\n open={!0}\r\n onClose={() => props.onClose(null)}\r\n aria-labelledby=\"form-dialog-title\"\r\n fullWidth={props.fullWidth !== undefined ? props.fullWidth : false}\r\n >\r\n <DialogTitle id=\"form-dialog-title\">{props.titleText}</DialogTitle>\r\n <DialogContent>\r\n <DialogContentText>{props.promptText}</DialogContentText>\r\n <TextField\r\n variant=\"standard\"\r\n autoFocus\r\n margin=\"dense\"\r\n error={!!error}\r\n helperText={error === true || !error ? '' : error}\r\n value={text}\r\n label={props.labelText || ''}\r\n type={props.type || 'text'}\r\n onKeyUp={e => e.code === 'Enter' && text && props.onClose(text)}\r\n onChange={e => {\r\n let _error: string | boolean = '';\r\n if (props.verify) {\r\n _error = !props.verify(e.target.value);\r\n }\r\n\r\n if (props.rule) {\r\n setText(props.rule(e.target.value));\r\n } else {\r\n setText(e.target.value);\r\n }\r\n setError(_error);\r\n }}\r\n fullWidth\r\n />\r\n </DialogContent>\r\n <DialogActions>\r\n <Button\r\n variant=\"contained\"\r\n disabled={!text || !!error}\r\n onClick={() => props.onClose(text)}\r\n color=\"primary\"\r\n startIcon={<IconCheck />}\r\n >\r\n {props.applyText || I18n.t('ra_Ok')}\r\n </Button>\r\n <Button\r\n color=\"grey\"\r\n variant=\"contained\"\r\n onClick={() => props.onClose(null)}\r\n startIcon={<IconClose />}\r\n >\r\n {props.cancelText || I18n.t('ra_Cancel')}\r\n </Button>\r\n </DialogActions>\r\n </Dialog>\r\n );\r\n}\r\n\r\nexport const DialogTextInput = withWidth()(TextInputFunc);\r\n"]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com>
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import React, { type JSX } from 'react';
|
|
8
|
+
import { type AdminConnection } from '@iobroker/socket-client';
|
|
9
|
+
import { Router } from './Components/Router';
|
|
10
|
+
import type { GenericAppProps, GenericAppState, GenericAppSettings, ThemeName, ThemeType, IobTheme, Width } from './types';
|
|
11
|
+
declare global {
|
|
12
|
+
/** If config has been changed */
|
|
13
|
+
var changed: boolean;
|
|
14
|
+
interface Window {
|
|
15
|
+
io: any;
|
|
16
|
+
SocketClient: any;
|
|
17
|
+
adapterName: undefined | string;
|
|
18
|
+
socketUrl: undefined | string;
|
|
19
|
+
iobOldAlert: any;
|
|
20
|
+
changed: boolean;
|
|
21
|
+
$iframeDialog: {
|
|
22
|
+
close?: () => void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare class GenericApp<TProps extends GenericAppProps = GenericAppProps, TState extends GenericAppState = GenericAppState> extends Router<TProps, TState> {
|
|
27
|
+
protected socket: AdminConnection;
|
|
28
|
+
protected isIFrame: boolean;
|
|
29
|
+
protected readonly instance: number;
|
|
30
|
+
protected readonly adapterName: string;
|
|
31
|
+
protected readonly instanceId: string;
|
|
32
|
+
protected readonly newReact: boolean;
|
|
33
|
+
protected encryptedFields: string[];
|
|
34
|
+
protected readonly sentryDSN: string | undefined;
|
|
35
|
+
private alertDialogRendered;
|
|
36
|
+
private _secret;
|
|
37
|
+
protected _systemConfig: ioBroker.SystemConfigCommon | undefined;
|
|
38
|
+
private savedNative;
|
|
39
|
+
protected common: ioBroker.InstanceCommon | null;
|
|
40
|
+
private sentryStarted;
|
|
41
|
+
private sentryInited;
|
|
42
|
+
private resizeTimer;
|
|
43
|
+
constructor(props: TProps, settings?: GenericAppSettings);
|
|
44
|
+
/**
|
|
45
|
+
* Checks if this connection is running in a web adapter and not in an admin.
|
|
46
|
+
*
|
|
47
|
+
* @returns True if running in a web adapter or in a socketio adapter.
|
|
48
|
+
*/
|
|
49
|
+
static isWeb(): boolean;
|
|
50
|
+
showAlert(message: string, type?: 'info' | 'warning' | 'error' | 'success'): void;
|
|
51
|
+
renderAlertSnackbar(): JSX.Element;
|
|
52
|
+
onSystemConfigChanged: (id: string, obj: ioBroker.AnyObject | null | undefined) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Called immediately after a component is mounted. Setting state here will trigger re-rendering.
|
|
55
|
+
*/
|
|
56
|
+
componentDidMount(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Called immediately before a component is destroyed.
|
|
59
|
+
*/
|
|
60
|
+
componentWillUnmount(): void;
|
|
61
|
+
onReceiveMessage: (message: {
|
|
62
|
+
data: string;
|
|
63
|
+
} | null) => void;
|
|
64
|
+
private onResize;
|
|
65
|
+
/**
|
|
66
|
+
* Gets the width depending on the window inner width.
|
|
67
|
+
*/
|
|
68
|
+
static getWidth(): Width;
|
|
69
|
+
/**
|
|
70
|
+
* Get a theme
|
|
71
|
+
*
|
|
72
|
+
* @param name Theme name
|
|
73
|
+
*/
|
|
74
|
+
createTheme(name?: ThemeName | null): IobTheme;
|
|
75
|
+
/**
|
|
76
|
+
* Get the theme name
|
|
77
|
+
*/
|
|
78
|
+
getThemeName(currentTheme: IobTheme): ThemeName;
|
|
79
|
+
/**
|
|
80
|
+
* Get the theme type
|
|
81
|
+
*/
|
|
82
|
+
getThemeType(currentTheme: IobTheme): ThemeType;
|
|
83
|
+
onThemeChanged(_newThemeName: string): void;
|
|
84
|
+
onToggleExpertMode(_expertMode: boolean): void;
|
|
85
|
+
/**
|
|
86
|
+
* Changes the current theme
|
|
87
|
+
*/
|
|
88
|
+
toggleTheme(newThemeName?: ThemeName): void;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the system configuration.
|
|
91
|
+
*/
|
|
92
|
+
getSystemConfig(): Promise<ioBroker.SystemConfigObject>;
|
|
93
|
+
/**
|
|
94
|
+
* Get current expert mode
|
|
95
|
+
*/
|
|
96
|
+
getExpertMode(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Gets called when the socket.io connection is ready.
|
|
99
|
+
* You can overload this function to execute own commands.
|
|
100
|
+
*/
|
|
101
|
+
onConnectionReady(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Encrypts a string.
|
|
104
|
+
*/
|
|
105
|
+
encrypt(value: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Decrypts a string.
|
|
108
|
+
*/
|
|
109
|
+
decrypt(value: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Gets called when the navigation hash changes.
|
|
112
|
+
* You may override this if needed.
|
|
113
|
+
*/
|
|
114
|
+
onHashChanged(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Selects the given tab.
|
|
117
|
+
*/
|
|
118
|
+
selectTab(tab: string, index?: number): void;
|
|
119
|
+
/**
|
|
120
|
+
* Gets called before the settings are saved.
|
|
121
|
+
* You may override this if needed.
|
|
122
|
+
*/
|
|
123
|
+
onPrepareSave(settings: Record<string, any>): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Gets called after the settings are loaded.
|
|
126
|
+
* You may override this if needed.
|
|
127
|
+
*
|
|
128
|
+
* @param settings instance settings from native part
|
|
129
|
+
* @param encryptedNative optional list of fields to be decrypted
|
|
130
|
+
*/
|
|
131
|
+
onPrepareLoad(settings: Record<string, any>, encryptedNative?: string[]): void;
|
|
132
|
+
/**
|
|
133
|
+
* Gets the extendable instances.
|
|
134
|
+
*/
|
|
135
|
+
getExtendableInstances(): Promise<ioBroker.InstanceObject[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Gets the IP addresses of the given host.
|
|
138
|
+
*/
|
|
139
|
+
getIpAddresses(host: string): Promise<{
|
|
140
|
+
name: string;
|
|
141
|
+
address: string;
|
|
142
|
+
family: 'ipv4' | 'ipv6';
|
|
143
|
+
}[]>;
|
|
144
|
+
/**
|
|
145
|
+
* Saves the settings to the server.
|
|
146
|
+
*
|
|
147
|
+
* @param isClose True if the user is closing the dialog.
|
|
148
|
+
*/
|
|
149
|
+
onSave(isClose?: boolean): void;
|
|
150
|
+
/**
|
|
151
|
+
* Renders the toast.
|
|
152
|
+
*/
|
|
153
|
+
renderToast(): JSX.Element | null;
|
|
154
|
+
/**
|
|
155
|
+
* Closes the dialog.
|
|
156
|
+
*/
|
|
157
|
+
static onClose(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Renders the error dialog.
|
|
160
|
+
*/
|
|
161
|
+
renderError(): React.JSX.Element | null;
|
|
162
|
+
/**
|
|
163
|
+
* Checks if the configuration has changed.
|
|
164
|
+
*
|
|
165
|
+
* @param native the new state
|
|
166
|
+
*/
|
|
167
|
+
getIsChanged(native: Record<string, any>): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Gets called when loading the configuration.
|
|
170
|
+
*
|
|
171
|
+
* @param newNative The new configuration object.
|
|
172
|
+
*/
|
|
173
|
+
onLoadConfig(newNative: Record<string, any>): void;
|
|
174
|
+
/**
|
|
175
|
+
* Sets the configuration error.
|
|
176
|
+
*/
|
|
177
|
+
setConfigurationError(errorText: string): void;
|
|
178
|
+
/**
|
|
179
|
+
* Renders the save and close buttons.
|
|
180
|
+
*/
|
|
181
|
+
renderSaveCloseButtons(): React.JSX.Element | null;
|
|
182
|
+
private _updateNativeValue;
|
|
183
|
+
/**
|
|
184
|
+
* Update the native value
|
|
185
|
+
*
|
|
186
|
+
* @param attr The attribute name with dots as delimiter.
|
|
187
|
+
* @param value The new value.
|
|
188
|
+
* @param cb Callback which will be called upon completion.
|
|
189
|
+
*/
|
|
190
|
+
updateNativeValue(attr: string, value: any, cb?: () => void): void;
|
|
191
|
+
/**
|
|
192
|
+
* Set the error text to be shown.
|
|
193
|
+
*/
|
|
194
|
+
showError(text: string | React.JSX.Element): void;
|
|
195
|
+
/**
|
|
196
|
+
* Sets the toast to be shown.
|
|
197
|
+
*
|
|
198
|
+
* @param toast Text to be shown.
|
|
199
|
+
*/
|
|
200
|
+
showToast(toast: string | React.JSX.Element): void;
|
|
201
|
+
/**
|
|
202
|
+
* Renders helper dialogs
|
|
203
|
+
*/
|
|
204
|
+
renderHelperDialogs(): React.JSX.Element;
|
|
205
|
+
/**
|
|
206
|
+
* Renders this component.
|
|
207
|
+
*/
|
|
208
|
+
render(): React.JSX.Element;
|
|
209
|
+
}
|