@iobroker/adapter-react-v5 7.4.22 → 7.5.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.
Files changed (116) hide show
  1. package/LICENSE +22 -22
  2. package/build/AdminConnection.js.map +1 -1
  3. package/build/Components/404.js +13 -13
  4. package/build/Components/404.js.map +1 -1
  5. package/build/Components/ColorPicker.js.map +1 -1
  6. package/build/Components/ComplexCron.js.map +1 -1
  7. package/build/Components/CopyToClipboard.js.map +1 -1
  8. package/build/Components/CustomModal.js.map +1 -1
  9. package/build/Components/FileBrowser.js +1 -1
  10. package/build/Components/FileBrowser.js.map +1 -1
  11. package/build/Components/FileViewer.js.map +1 -1
  12. package/build/Components/Icon.js.map +1 -1
  13. package/build/Components/IconPicker.js.map +1 -1
  14. package/build/Components/IconSelector.js.map +1 -1
  15. package/build/Components/IobUri.js.map +1 -1
  16. package/build/Components/Loader.js +223 -223
  17. package/build/Components/Loader.js.map +1 -1
  18. package/build/Components/Loaders/MV.js.map +1 -1
  19. package/build/Components/Loaders/PT.js +103 -103
  20. package/build/Components/Loaders/PT.js.map +1 -1
  21. package/build/Components/Loaders/Vendor.js +7 -7
  22. package/build/Components/Loaders/Vendor.js.map +1 -1
  23. package/build/Components/MDUtils.js.map +1 -1
  24. package/build/Components/ObjectBrowser.d.ts +11 -0
  25. package/build/Components/ObjectBrowser.js +169 -9
  26. package/build/Components/ObjectBrowser.js.map +1 -1
  27. package/build/Components/Router.js.map +1 -1
  28. package/build/Components/SaveCloseButtons.js.map +1 -1
  29. package/build/Components/Schedule.js.map +1 -1
  30. package/build/Components/SelectWithIcon.js.map +1 -1
  31. package/build/Components/SimpleCron/cronText.js.map +1 -1
  32. package/build/Components/SimpleCron/index.js.map +1 -1
  33. package/build/Components/TabContainer.js.map +1 -1
  34. package/build/Components/TabContent.js.map +1 -1
  35. package/build/Components/TabHeader.js.map +1 -1
  36. package/build/Components/TableResize.js.map +1 -1
  37. package/build/Components/TextWithIcon.js.map +1 -1
  38. package/build/Components/ToggleThemeMenu.js.map +1 -1
  39. package/build/Components/TreeTable.js.map +1 -1
  40. package/build/Components/UploadImage.js +305 -305
  41. package/build/Components/UploadImage.js.map +1 -1
  42. package/build/Components/withWidth.js.map +1 -1
  43. package/build/Connection.js.map +1 -1
  44. package/build/Dialogs/ComplexCron.js.map +1 -1
  45. package/build/Dialogs/Confirm.js.map +1 -1
  46. package/build/Dialogs/Cron.js.map +1 -1
  47. package/build/Dialogs/Error.js.map +1 -1
  48. package/build/Dialogs/Message.js.map +1 -1
  49. package/build/Dialogs/SelectFile.js.map +1 -1
  50. package/build/Dialogs/SimpleCron.js.map +1 -1
  51. package/build/Dialogs/TextInput.d.ts +1 -1
  52. package/build/Dialogs/TextInput.js.map +1 -1
  53. package/build/GenericApp.js.map +1 -1
  54. package/build/LegacyConnection.d.ts +4 -46
  55. package/build/LegacyConnection.js.map +1 -1
  56. package/build/Prompt.js +7 -7
  57. package/build/Prompt.js.map +1 -1
  58. package/build/assets/devices/parseNames.js.map +1 -1
  59. package/build/assets/devices.json +1 -1
  60. package/build/assets/lamp_ceiling.svg +8 -8
  61. package/build/assets/lamp_table.svg +7 -7
  62. package/build/assets/no_icon.svg +9 -9
  63. package/build/assets/rooms/parseNames.js.map +1 -1
  64. package/build/assets/rooms.json +1 -1
  65. package/build/dictionary.js.map +1 -1
  66. package/build/i18n/de.json +9 -0
  67. package/build/i18n/en.json +9 -0
  68. package/build/i18n/es.json +9 -0
  69. package/build/i18n/fr.json +9 -0
  70. package/build/i18n/it.json +9 -0
  71. package/build/i18n/nl.json +9 -0
  72. package/build/i18n/pl.json +9 -0
  73. package/build/i18n/pt.json +9 -0
  74. package/build/i18n/ru.json +9 -0
  75. package/build/i18n/uk.json +9 -0
  76. package/build/i18n/zh-cn.json +9 -0
  77. package/build/i18n.js.map +1 -1
  78. package/build/icons/IconAdapter.js.map +1 -1
  79. package/build/icons/IconAlias.js.map +1 -1
  80. package/build/icons/IconButtonImage.js.map +1 -1
  81. package/build/icons/IconChannel.js.map +1 -1
  82. package/build/icons/IconClearFilter.js.map +1 -1
  83. package/build/icons/IconClosed.js.map +1 -1
  84. package/build/icons/IconCopy.js.map +1 -1
  85. package/build/icons/IconDevice.js.map +1 -1
  86. package/build/icons/IconDocument.js.map +1 -1
  87. package/build/icons/IconDocumentReadOnly.js.map +1 -1
  88. package/build/icons/IconExpert.js.map +1 -1
  89. package/build/icons/IconFx.js +1 -1
  90. package/build/icons/IconFx.js.map +1 -1
  91. package/build/icons/IconInstance.js.map +1 -1
  92. package/build/icons/IconLogout.js +1 -1
  93. package/build/icons/IconLogout.js.map +1 -1
  94. package/build/icons/IconNoIcon.js.map +1 -1
  95. package/build/icons/IconOpen.js.map +1 -1
  96. package/build/icons/IconProps.js.map +1 -1
  97. package/build/icons/IconState.js.map +1 -1
  98. package/build/icons/IconVacuum.js.map +1 -1
  99. package/build/index.css +56 -56
  100. package/build/index.js.map +1 -1
  101. package/craco-module-federation.js +62 -62
  102. package/i18n/de.json +9 -0
  103. package/i18n/en.json +9 -0
  104. package/i18n/es.json +9 -0
  105. package/i18n/fr.json +9 -0
  106. package/i18n/it.json +9 -0
  107. package/i18n/nl.json +9 -0
  108. package/i18n/pl.json +9 -0
  109. package/i18n/pt.json +9 -0
  110. package/i18n/ru.json +9 -0
  111. package/i18n/uk.json +9 -0
  112. package/i18n/zh-cn.json +9 -0
  113. package/index.css +56 -56
  114. package/modulefederation.admin.config.js +33 -33
  115. package/package.json +4 -5
  116. package/tasksExample.js +91 -91
@@ -8,7 +8,7 @@ import React, { Component, createRef } from 'react';
8
8
  import SVG from 'react-inlinesvg';
9
9
  import { Badge, Box, Button, Checkbox, CircularProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Fab, FormControl, FormControlLabel, Grid2, IconButton, Input, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Menu, MenuItem, Paper, Select, Snackbar, Switch, TextField, Tooltip, } from '@mui/material';
10
10
  // Icons
11
- import { Add as AddIcon, ArrowRight as ArrowRightIcon, BedroomParent, BorderColor, Build as BuildIcon, CalendarToday as IconSchedule, Check as IconCheck, Close as IconClose, Code as IconScript, Construction, CreateNewFolder as IconFolder, Delete as IconDelete, Description as IconMeta, Edit as IconEdit, Error as IconError, FindInPage, FormatItalic as IconValueEdit, Info as IconInfo, Link as IconLink, ListAlt as IconEnum, LooksOne as LooksOneIcon, PersonOutlined as IconUser, Publish as PublishIcon, Refresh as RefreshIcon, Router as IconHost, Settings as IconConfig, SettingsApplications as IconSystem, DataObject as IconData, ShowChart as IconChart, SupervisedUserCircle as IconGroup, TextFields as TextFieldsIcon, ViewColumn as IconColumns, Wifi as IconConnection, WifiOff as IconDisconnected, } from '@mui/icons-material';
11
+ import { Add as AddIcon, ArrowRight as ArrowRightIcon, BedroomParent, BorderColor, Build as BuildIcon, CalendarToday as IconSchedule, Check as IconCheck, Close as IconClose, Code as IconScript, Construction, CreateNewFolder as IconFolder, Delete as IconDelete, Description as IconMeta, Edit as IconEdit, Error as IconError, FindInPage, FormatItalic as IconValueEdit, Info as IconInfo, Link as IconLink, ListAlt as IconEnum, LooksOne as LooksOneIcon, PersonOutlined as IconUser, Publish as PublishIcon, Refresh as RefreshIcon, Router as IconHost, Settings as IconConfig, SettingsApplications as IconSystem, DataObject as IconData, ShowChart as IconChart, SupervisedUserCircle as IconGroup, TextFields as TextFieldsIcon, ViewColumn as IconColumns, Wifi as IconConnection, WifiOff as IconDisconnected, DriveFileRenameOutline, } from '@mui/icons-material';
12
12
  import { IconExpert } from '../icons/IconExpert';
13
13
  import { IconAdapter } from '../icons/IconAdapter';
14
14
  import { IconChannel } from '../icons/IconChannel';
@@ -574,9 +574,6 @@ const styles = {
574
574
  height: 'calc(100% - 50px)',
575
575
  overflow: 'auto',
576
576
  },
577
- enumButton: {
578
- float: 'right',
579
- },
580
577
  enumCheckbox: {
581
578
  minWidth: 0,
582
579
  },
@@ -2033,6 +2030,7 @@ export class ObjectBrowserClass extends Component {
2033
2030
  excludeTranslations: false,
2034
2031
  tooltipInfo: null,
2035
2032
  aliasMenu: '',
2033
+ showRenameDialog: null,
2036
2034
  };
2037
2035
  this.texts = {
2038
2036
  name: props.t('ra_Name'),
@@ -3369,6 +3367,139 @@ export class ObjectBrowserClass extends Component {
3369
3367
  ")"),
3370
3368
  React.createElement(Button, { color: "grey", variant: "contained", onClick: () => this.setState({ showExportDialog: false, showAllExportOptions: false }), startIcon: React.createElement(IconClose, null) }, this.props.t('ra_Cancel')))));
3371
3369
  }
3370
+ static calculateNewId(oldId, newId, id) {
3371
+ // find common name
3372
+ const oldParts = oldId.split('.');
3373
+ const newParts = newId.split('.');
3374
+ let i = 0;
3375
+ while (oldParts[i] === newParts[i]) {
3376
+ i++;
3377
+ }
3378
+ const parts = id.split('.');
3379
+ parts.splice(0, i + 1);
3380
+ return `${newId}.${parts.join('.')}`;
3381
+ }
3382
+ async renameObject(oldId, newId, withChildren) {
3383
+ if (oldId === newId) {
3384
+ return;
3385
+ }
3386
+ let obj;
3387
+ try {
3388
+ obj = await this.props.socket.getObject(oldId);
3389
+ }
3390
+ catch {
3391
+ // ignore
3392
+ }
3393
+ let state;
3394
+ if (obj?.type === 'state') {
3395
+ state = await this.props.socket.getState(oldId);
3396
+ }
3397
+ if (withChildren) {
3398
+ const children = Object.keys(this.objects).filter(id => id.startsWith(`${oldId}.`));
3399
+ for (const id of children) {
3400
+ const nid = ObjectBrowserClass.calculateNewId(oldId, newId, id);
3401
+ // calculate new id
3402
+ await this.renameObject(id, nid, false);
3403
+ }
3404
+ }
3405
+ if (obj) {
3406
+ await this.props.socket.setObject(newId, obj);
3407
+ if (state) {
3408
+ await this.props.socket.setState(newId, state);
3409
+ }
3410
+ await this.props.socket.delObject(oldId);
3411
+ }
3412
+ }
3413
+ renderRenameDialog() {
3414
+ if (!this.state.showRenameDialog) {
3415
+ return null;
3416
+ }
3417
+ let newID;
3418
+ let notExtendedPossible = true;
3419
+ const parts = this.state.showRenameDialog.id.split('.');
3420
+ if (this.state.showRenameDialog.extended) {
3421
+ newID = `${parts[0]}.${parts[1]}.${this.state.showRenameDialog.value}`;
3422
+ parts.pop();
3423
+ const parentId = parts.join('.');
3424
+ const newParts = newID.split('.');
3425
+ newParts.splice(parentId.length);
3426
+ if (newParts.join('.') !== parentId) {
3427
+ notExtendedPossible = false;
3428
+ }
3429
+ }
3430
+ else {
3431
+ parts.pop();
3432
+ newID = `${parts.join('.')}.${this.state.showRenameDialog.value}`;
3433
+ }
3434
+ return (React.createElement(Dialog, { open: !0, maxWidth: "md", fullWidth: true, onClose: () => this.setState({ showRenameDialog: null }) },
3435
+ React.createElement(DialogTitle, null, this.props.t('ra_Rename object')),
3436
+ React.createElement(DialogContent, null,
3437
+ React.createElement(TextField, { value: this.state.showRenameDialog.value, onChange: e => {
3438
+ const value = e.target.value
3439
+ .replace(Utils.FORBIDDEN_CHARS, '_')
3440
+ .replace(/\s/g, '_')
3441
+ .replace(/,/g, '_')
3442
+ .replace(/__/g, '_')
3443
+ .replace(/__/g, '_');
3444
+ if (!this.state.showRenameDialog.extended && value.includes('.')) {
3445
+ this.setState({
3446
+ showRenameDialog: {
3447
+ ...this.state.showRenameDialog,
3448
+ value: e.target.value.replace(/\./g, '_'),
3449
+ },
3450
+ });
3451
+ }
3452
+ else {
3453
+ this.setState({
3454
+ showRenameDialog: { ...this.state.showRenameDialog, value },
3455
+ });
3456
+ }
3457
+ }, variant: "standard", fullWidth: true, label: this.props.t('ra_New object ID'), helperText: `${this.props.t('ra_New object ID')}: ${newID}` }),
3458
+ this.props.expertMode ? (React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { disabled: !notExtendedPossible, checked: this.state.showRenameDialog.extended, onChange: () => {
3459
+ if (this.state.showRenameDialog.extended) {
3460
+ const parts = this.state.showRenameDialog.value.split('.');
3461
+ this.setState({
3462
+ showRenameDialog: {
3463
+ ...this.state.showRenameDialog,
3464
+ value: parts.pop(),
3465
+ extended: false,
3466
+ },
3467
+ });
3468
+ }
3469
+ else {
3470
+ const parts = this.state.showRenameDialog.id.split('.');
3471
+ parts.shift(); // remove "javascript"
3472
+ parts.shift(); // remove "0"
3473
+ parts.pop(); // remove the last part
3474
+ this.setState({
3475
+ showRenameDialog: {
3476
+ ...this.state.showRenameDialog,
3477
+ value: `${parts.join('.')}.${this.state.showRenameDialog.value}`,
3478
+ extended: true,
3479
+ },
3480
+ });
3481
+ }
3482
+ } }), label: this.props.t('ra_Edit full path') })) : null,
3483
+ this.state.showRenameDialog.hasChildren ? (React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: this.state.showRenameDialog.renameAllChildren, onChange: () => {
3484
+ this.setState({
3485
+ showRenameDialog: {
3486
+ ...this.state.showRenameDialog,
3487
+ renameAllChildren: !this.state.showRenameDialog.renameAllChildren,
3488
+ },
3489
+ });
3490
+ } }), label: this.props.t('ra_Rename all children') })) : null),
3491
+ React.createElement(DialogActions, null,
3492
+ React.createElement(Button, { disabled: !this.state.showRenameDialog.value ||
3493
+ this.state.showRenameDialog.value.endsWith('.') ||
3494
+ newID === this.state.showRenameDialog.id, color: "primary", variant: "contained", onClick: async () => {
3495
+ await this.renameObject(this.state.showRenameDialog.id, newID, this.state.showRenameDialog.hasChildren &&
3496
+ this.state.showRenameDialog.renameAllChildren);
3497
+ this.setState({ showRenameDialog: null });
3498
+ } }, newID !== this.state.showRenameDialog.id && this.objects[newID]
3499
+ ? this.props.t('ra_Replace')
3500
+ : this.props.t('ra_Rename')),
3501
+ React.createElement(Button, { variant: "contained", color: "grey", onClick: () => this.setState({ showRenameDialog: null }), startIcon: React.createElement(IconClose, null) }, this.props.t('ra_Cancel')))));
3502
+ }
3372
3503
  handleJsonUpload(evt) {
3373
3504
  const target = evt.target;
3374
3505
  const f = target.files?.length && target.files[0];
@@ -4077,9 +4208,16 @@ export class ObjectBrowserClass extends Component {
4077
4208
  });
4078
4209
  // const hasIcons = !!enums.find(item => item.icon);
4079
4210
  return (React.createElement(Dialog, { sx: { '& .MuiPaper-root': styles.enumDialog }, onClose: () => this.setState({ enumDialog: null }), "aria-labelledby": "enum-dialog-title", open: !0 },
4080
- React.createElement(DialogTitle, { id: "enum-dialog-title" },
4211
+ React.createElement(DialogTitle, { id: "enum-dialog-title", style: {
4212
+ display: 'flex',
4213
+ justifyContent: 'space-between',
4214
+ width: '100%',
4215
+ flexWrap: 'nowrap',
4216
+ gap: 8,
4217
+ paddingRight: 12,
4218
+ } },
4081
4219
  type === 'func' ? this.props.t('ra_Define functions') : this.props.t('ra_Define rooms'),
4082
- React.createElement(Fab, { sx: styles.enumButton, color: "primary", disabled: enumsOriginal === JSON.stringify(itemEnums), size: "small", onClick: () => this.syncEnum(item.data.id, type, itemEnums).then(() => this.setState({ enumDialog: null, enumDialogEnums: null })) },
4220
+ React.createElement(Fab, { color: "primary", disabled: enumsOriginal === JSON.stringify(itemEnums), size: "small", onClick: () => this.syncEnum(item.data.id, type, itemEnums).then(() => this.setState({ enumDialog: null, enumDialogEnums: null })) },
4083
4221
  React.createElement(IconCheck, null))),
4084
4222
  React.createElement(List, { sx: { '&.MuiList-root': styles.enumList } }, enums.map(_item => {
4085
4223
  let id;
@@ -5257,9 +5395,7 @@ export class ObjectBrowserClass extends Component {
5257
5395
  window.removeEventListener('mouseup', this.resizerMouseUp);
5258
5396
  };
5259
5397
  resizerMouseDown = (e) => {
5260
- this.storedWidths =
5261
- this.storedWidths ||
5262
- JSON.parse(JSON.stringify(SCREEN_WIDTHS[this.props.width || 'lg']));
5398
+ this.storedWidths ||= JSON.parse(JSON.stringify(SCREEN_WIDTHS[this.props.width || 'lg']));
5263
5399
  this.resizerCurrentWidths = this.resizerCurrentWidths || {};
5264
5400
  this.resizerActiveDiv = e.target.parentNode;
5265
5401
  this.resizerActiveName = this.resizerActiveDiv.dataset.name || null;
@@ -5839,6 +5975,29 @@ export class ObjectBrowserClass extends Component {
5839
5975
  },
5840
5976
  ],
5841
5977
  },
5978
+ RENAME: {
5979
+ key: '8',
5980
+ visibility: !!(!this.props.notEditable &&
5981
+ !item.data.id.startsWith('system.') &&
5982
+ item.data.id.split('.').length > 2 &&
5983
+ (this.props.expertMode ||
5984
+ item.data.id.startsWith('javascript.0.') ||
5985
+ item.data.id.startsWith('0_userdata.0.'))),
5986
+ icon: React.createElement(DriveFileRenameOutline, null),
5987
+ label: this.props.t('ra_Rename'),
5988
+ onClick: () => {
5989
+ this.setState({
5990
+ showContextMenu: null,
5991
+ showRenameDialog: {
5992
+ id: item.data.id,
5993
+ value: item.data.id.split('.').pop(),
5994
+ extended: false,
5995
+ hasChildren: !!item.children?.length,
5996
+ renameAllChildren: true,
5997
+ },
5998
+ });
5999
+ },
6000
+ },
5842
6001
  DELETE: {
5843
6002
  key: 'Delete',
5844
6003
  visibility: !!(this.props.onObjectDelete &&
@@ -6045,6 +6204,7 @@ export class ObjectBrowserClass extends Component {
6045
6204
  this.renderEnumDialog(),
6046
6205
  this.renderErrorDialog(),
6047
6206
  this.renderExportDialog(),
6207
+ this.renderRenameDialog(),
6048
6208
  this.state.modalNewObj && this.props.modalNewObject && this.props.modalNewObject(this),
6049
6209
  this.state.modalEditOfAccess &&
6050
6210
  this.state.modalEditOfAccessObjData &&