@iobroker/dm-gui-components 7.3.2 → 7.4.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.
@@ -24,6 +24,7 @@ export default class DeviceList extends Communication {
24
24
  static i18nInitialized = false;
25
25
  lastPropsFilter;
26
26
  lastInstance;
27
+ lastTriggerLoad = 0;
27
28
  filterTimeout;
28
29
  language;
29
30
  constructor(props) {
@@ -54,6 +55,7 @@ export default class DeviceList extends Communication {
54
55
  });
55
56
  this.lastPropsFilter = this.props.filter;
56
57
  this.lastInstance = this.props.selectedInstance;
58
+ this.lastTriggerLoad = this.props.triggerLoad || 0;
57
59
  this.filterTimeout = null;
58
60
  this.language = I18n.getLanguage();
59
61
  }
@@ -159,10 +161,15 @@ export default class DeviceList extends Communication {
159
161
  const emptyStyle = {
160
162
  padding: 25,
161
163
  };
164
+ if ((this.props.triggerLoad || 0) !== this.lastTriggerLoad) {
165
+ this.lastTriggerLoad = this.props.triggerLoad || 0;
166
+ setTimeout(() => this.loadData(), 50);
167
+ }
162
168
  if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {
163
169
  this.lastPropsFilter = this.props.filter;
164
170
  setTimeout(() => this.applyFilter(), 50);
165
171
  }
172
+ // if instance changed
166
173
  if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {
167
174
  this.lastInstance = this.props.selectedInstance;
168
175
  setTimeout(() => this.loadData(), 50);
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceList.js","sourceRoot":"./src/","sources":["DeviceList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAExG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;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AC,CAAC,CAAC,IAAI,CACF;YACV,6BACI,KAAK,EAAE;oBACH,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,mBAAmB;oBAC3B,SAAS,EAAE,CAAC;oBACZ,QAAQ,EAAE,MAAM;oBAChB,4BAA4B;oBAC5B,yBAAyB;oBACzB,mBAAmB;oBACnB,gBAAgB;oBAChB,aAAa;oBACb,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;iBACtB;gBAEA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI;gBACxE,IAAI,CACH,CACJ,CACT,CAAC;IACN,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport { IconButton, InputAdornment, TextField, Toolbar, Tooltip, LinearProgress } from '@mui/material';\n\nimport { Clear, Refresh } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { DeviceInfo, InstanceDetails } from '@iobroker/dm-utils';\n\nimport DeviceCard from './DeviceCard';\nimport { getTranslation } from './Utils';\nimport Communication, { type CommunicationProps, type CommunicationState } from './Communication';\nimport InstanceActionButton from './InstanceActionButton';\n\nimport de from './i18n/de.json';\nimport en from './i18n/en.json';\nimport ru from './i18n/ru.json';\nimport pt from './i18n/pt.json';\nimport nl from './i18n/nl.json';\nimport fr from './i18n/fr.json';\nimport it from './i18n/it.json';\nimport es from './i18n/es.json';\nimport pl from './i18n/pl.json';\nimport uk from './i18n/uk.json';\nimport zhCn from './i18n/zh-cn.json';\n\ninterface DeviceListProps extends CommunicationProps {\n /** Instance to upload images to, like `adapterName.X` */\n uploadImagesToInstance?: string;\n /** Filter devices with this string */\n filter?: string;\n /** If this component is used in GUI with own toolbar. `false` if this list is used with multiple instances and true if only with one (in this case, it will monitor alive itself */\n embedded?: boolean;\n /** If embedded, this text is shown in the toolbar */\n title?: string;\n /** Style of a component that displays all devices */\n style?: React.CSSProperties;\n /** Use small cards for devices */\n smallCards?: boolean;\n}\n\ninterface DeviceListState extends CommunicationState {\n devices: DeviceInfo[];\n filteredDevices: DeviceInfo[];\n filter: string;\n instanceInfo: InstanceDetails;\n loading: boolean;\n alive: boolean | null;\n}\n\n/**\n * Device List Component\n */\nexport default class DeviceList extends Communication<DeviceListProps, DeviceListState> {\n static i18nInitialized = false;\n\n private lastPropsFilter: string | undefined;\n\n private lastInstance: string;\n\n private filterTimeout: ReturnType<typeof setTimeout> | null;\n\n private readonly language: ioBroker.Languages;\n\n constructor(props: DeviceListProps) {\n super(props);\n\n if (!DeviceList.i18nInitialized) {\n DeviceList.i18nInitialized = true;\n I18n.extendTranslations({\n en,\n de,\n ru,\n pt,\n nl,\n fr,\n it,\n es,\n pl,\n uk,\n 'zh-cn': zhCn,\n });\n }\n\n Object.assign(this.state, {\n devices: [],\n filteredDevices: [],\n filter: '',\n instanceInfo: null,\n loading: null,\n alive: null,\n });\n\n this.lastPropsFilter = this.props.filter;\n this.lastInstance = this.props.selectedInstance;\n this.filterTimeout = null;\n this.language = I18n.getLanguage();\n }\n\n async componentDidMount(): Promise<void> {\n let alive = false;\n if (this.state.alive === null) {\n try {\n // check if instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.props.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n this.setState({ alive }, () =>\n this.props.socket.subscribeState(\n `system.adapter.${this.props.selectedInstance}.alive`,\n this.aliveHandler,\n ),\n );\n if (!alive) {\n return;\n }\n } else {\n alive = this.state.alive;\n }\n\n if (!this.props.embedded && alive) {\n try {\n const instanceInfo = await this.loadInstanceInfos();\n this.setState({ instanceInfo });\n } catch (error) {\n console.error(error);\n }\n }\n if (alive) {\n this.loadData();\n }\n }\n\n componentWillUnmount(): void {\n this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler);\n }\n\n aliveHandler: ioBroker.StateChangeHandler = (id: string, state: ioBroker.State | null | undefined): void => {\n if (id === `system.adapter.${this.props.selectedInstance}.alive`) {\n const alive = !!state?.val;\n if (alive !== this.state.alive) {\n this.setState({ alive }, () => {\n if (alive) {\n this.componentDidMount().catch(console.error);\n }\n });\n }\n }\n };\n\n /**\n * Load devices\n */\n override loadData(): void {\n this.setState({ loading: true }, async () => {\n console.log(`Loading devices for ${this.props.selectedInstance}...`);\n let devices: DeviceInfo[] = [];\n try {\n devices = await this.loadDevices();\n\n if (!devices || !Array.isArray(devices)) {\n console.error(\n `Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(\n devices,\n )}`,\n );\n devices = [];\n }\n } catch (error) {\n console.error(error);\n devices = [];\n }\n\n this.setState({ devices, loading: false }, () => this.applyFilter());\n });\n }\n\n getText(text: ioBroker.StringOrTranslated): string {\n if (typeof text === 'object') {\n return text[this.language] || text.en;\n }\n\n return text;\n }\n\n applyFilter(): void {\n const filter = this.props.embedded ? this.props.filter : this.state.filter;\n\n // filter devices name\n if (filter) {\n const filteredDevices = this.state.devices.filter(device =>\n this.getText(device.name).toLowerCase().includes(filter.toLowerCase()),\n );\n this.setState({ filteredDevices });\n } else {\n this.setState({ filteredDevices: this.state.devices });\n }\n }\n\n handleFilterChange(filter: string): void {\n this.setState({ filter }, () => {\n if (this.filterTimeout) {\n clearTimeout(this.filterTimeout);\n }\n this.filterTimeout = setTimeout(() => {\n this.filterTimeout = null;\n this.applyFilter();\n }, 250);\n });\n }\n\n renderContent(): JSX.Element | JSX.Element[] | null {\n const emptyStyle: React.CSSProperties = {\n padding: 25,\n };\n\n if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {\n this.lastPropsFilter = this.props.filter;\n setTimeout(() => this.applyFilter(), 50);\n }\n if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {\n this.lastInstance = this.props.selectedInstance;\n setTimeout(() => this.loadData(), 50);\n }\n\n let list;\n if (!this.props.embedded && !this.state.alive) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('instanceNotAlive')}</span>\n </div>\n );\n } else if (!this.state.devices.length && this.props.selectedInstance) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('noDevicesFoundText')}</span>\n </div>\n );\n } else if (this.state.devices.length && !this.state.filteredDevices.length) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('allDevicesFilteredOut')}</span>\n </div>\n );\n } else {\n list = this.state.filteredDevices.map(device => (\n <DeviceCard\n alive={!!this.state.alive}\n key={device.id}\n id={device.id}\n title={this.getText(device.name)}\n device={device}\n instanceId={this.props.selectedInstance}\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceHandler={this.deviceHandler}\n controlHandler={this.controlHandler}\n controlStateHandler={this.controlStateHandler}\n socket={this.props.socket}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n theme={this.props.theme}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n />\n ));\n }\n\n if (this.props.embedded) {\n return (\n <>\n {this.state.loading ? <LinearProgress style={{ width: '100%' }} /> : null}\n {list}\n </>\n );\n }\n\n return (\n <div style={{ width: '100%', height: '100%', overflow: 'hidden' }}>\n <Toolbar\n variant=\"dense\"\n style={{ backgroundColor: '#777', display: 'flex' }}\n >\n {this.props.title}\n {this.props.selectedInstance ? (\n <Tooltip\n title={getTranslation('refreshTooltip')}\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\n >\n <span>\n <IconButton\n onClick={() => this.loadData()}\n disabled={!this.state.alive}\n size=\"small\"\n >\n <Refresh />\n </IconButton>\n </span>\n </Tooltip>\n ) : null}\n {this.state.alive && this.state.instanceInfo?.actions?.length ? (\n <div style={{ marginLeft: 20 }}>\n {this.state.instanceInfo.actions.map(action => (\n <InstanceActionButton\n key={action.id}\n action={action}\n instanceHandler={this.instanceHandler}\n />\n ))}\n </div>\n ) : null}\n\n <div style={{ flexGrow: 1 }} />\n\n {this.state.alive ? (\n <TextField\n variant=\"standard\"\n style={{ width: 200 }}\n size=\"small\"\n label={getTranslation('filterLabelText')}\n onChange={e => this.handleFilterChange(e.target.value)}\n value={this.state.filter}\n autoComplete=\"off\"\n slotProps={{\n input: {\n autoComplete: 'new-password',\n endAdornment: this.state.filter ? (\n <InputAdornment position=\"end\">\n <IconButton\n onClick={() => this.handleFilterChange('')}\n edge=\"end\"\n >\n <Clear />\n </IconButton>\n </InputAdornment>\n ) : null,\n },\n htmlInput: {\n autoComplete: 'off',\n },\n }}\n />\n ) : null}\n </Toolbar>\n <div\n style={{\n width: '100%',\n height: 'calc(100% - 56px)',\n marginTop: 8,\n overflow: 'auto',\n // justifyContent: 'center',\n // alignItems: 'stretch',\n // display: 'grid',\n // columnGap: 8,\n // rowGap: 8,\n ...this.props.style,\n }}\n >\n {this.state.loading ? <LinearProgress style={{ width: '100%' }} /> : null}\n {list}\n </div>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"DeviceList.js","sourceRoot":"./src/","sources":["DeviceList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAExG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;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BACD,SAAS,EAAE;4BACP,YAAY,EAAE,KAAK;yBACtB;qBACJ,GACH,CACL,CAAC,CAAC,CAAC,IAAI,CACF;YACV,6BACI,KAAK,EAAE;oBACH,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,mBAAmB;oBAC3B,SAAS,EAAE,CAAC;oBACZ,QAAQ,EAAE,MAAM;oBAChB,4BAA4B;oBAC5B,yBAAyB;oBACzB,mBAAmB;oBACnB,gBAAgB;oBAChB,aAAa;oBACb,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;iBACtB;gBAEA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI;gBACxE,IAAI,CACH,CACJ,CACT,CAAC;IACN,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport { IconButton, InputAdornment, TextField, Toolbar, Tooltip, LinearProgress } from '@mui/material';\n\nimport { Clear, Refresh } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { DeviceInfo, InstanceDetails } from '@iobroker/dm-utils';\n\nimport DeviceCard from './DeviceCard';\nimport { getTranslation } from './Utils';\nimport Communication, { type CommunicationProps, type CommunicationState } from './Communication';\nimport InstanceActionButton from './InstanceActionButton';\n\nimport de from './i18n/de.json';\nimport en from './i18n/en.json';\nimport ru from './i18n/ru.json';\nimport pt from './i18n/pt.json';\nimport nl from './i18n/nl.json';\nimport fr from './i18n/fr.json';\nimport it from './i18n/it.json';\nimport es from './i18n/es.json';\nimport pl from './i18n/pl.json';\nimport uk from './i18n/uk.json';\nimport zhCn from './i18n/zh-cn.json';\n\ninterface DeviceListProps extends CommunicationProps {\n /** Instance to upload images to, like `adapterName.X` */\n uploadImagesToInstance?: string;\n /** Filter devices with this string */\n filter?: string;\n /** If this component is used in GUI with own toolbar. `false` if this list is used with multiple instances and true if only with one (in this case, it will monitor alive itself */\n embedded?: boolean;\n /** If embedded, this text is shown in the toolbar */\n title?: string;\n /** Style of a component that displays all devices */\n style?: React.CSSProperties;\n /** Use small cards for devices */\n smallCards?: boolean;\n /** To trigger the reload of devices, just change this variable */\n triggerLoad?: number;\n}\n\ninterface DeviceListState extends CommunicationState {\n devices: DeviceInfo[];\n filteredDevices: DeviceInfo[];\n filter: string;\n instanceInfo: InstanceDetails;\n loading: boolean;\n alive: boolean | null;\n triggerLoad: number;\n}\n\n/**\n * Device List Component\n */\nexport default class DeviceList extends Communication<DeviceListProps, DeviceListState> {\n static i18nInitialized = false;\n\n private lastPropsFilter: string | undefined;\n\n private lastInstance: string;\n\n private lastTriggerLoad = 0;\n\n private filterTimeout: ReturnType<typeof setTimeout> | null;\n\n private readonly language: ioBroker.Languages;\n\n constructor(props: DeviceListProps) {\n super(props);\n\n if (!DeviceList.i18nInitialized) {\n DeviceList.i18nInitialized = true;\n I18n.extendTranslations({\n en,\n de,\n ru,\n pt,\n nl,\n fr,\n it,\n es,\n pl,\n uk,\n 'zh-cn': zhCn,\n });\n }\n\n Object.assign(this.state, {\n devices: [],\n filteredDevices: [],\n filter: '',\n instanceInfo: null,\n loading: null,\n alive: null,\n });\n\n this.lastPropsFilter = this.props.filter;\n this.lastInstance = this.props.selectedInstance;\n this.lastTriggerLoad = this.props.triggerLoad || 0;\n this.filterTimeout = null;\n this.language = I18n.getLanguage();\n }\n\n async componentDidMount(): Promise<void> {\n let alive = false;\n if (this.state.alive === null) {\n try {\n // check if instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.props.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n this.setState({ alive }, () =>\n this.props.socket.subscribeState(\n `system.adapter.${this.props.selectedInstance}.alive`,\n this.aliveHandler,\n ),\n );\n if (!alive) {\n return;\n }\n } else {\n alive = this.state.alive;\n }\n\n if (!this.props.embedded && alive) {\n try {\n const instanceInfo = await this.loadInstanceInfos();\n this.setState({ instanceInfo });\n } catch (error) {\n console.error(error);\n }\n }\n if (alive) {\n this.loadData();\n }\n }\n\n componentWillUnmount(): void {\n this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler);\n }\n\n aliveHandler: ioBroker.StateChangeHandler = (id: string, state: ioBroker.State | null | undefined): void => {\n if (id === `system.adapter.${this.props.selectedInstance}.alive`) {\n const alive = !!state?.val;\n if (alive !== this.state.alive) {\n this.setState({ alive }, () => {\n if (alive) {\n this.componentDidMount().catch(console.error);\n }\n });\n }\n }\n };\n\n /**\n * Load devices\n */\n override loadData(): void {\n this.setState({ loading: true }, async () => {\n console.log(`Loading devices for ${this.props.selectedInstance}...`);\n let devices: DeviceInfo[] = [];\n try {\n devices = await this.loadDevices();\n\n if (!devices || !Array.isArray(devices)) {\n console.error(\n `Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(\n devices,\n )}`,\n );\n devices = [];\n }\n } catch (error) {\n console.error(error);\n devices = [];\n }\n\n this.setState({ devices, loading: false }, () => this.applyFilter());\n });\n }\n\n getText(text: ioBroker.StringOrTranslated): string {\n if (typeof text === 'object') {\n return text[this.language] || text.en;\n }\n\n return text;\n }\n\n applyFilter(): void {\n const filter = this.props.embedded ? this.props.filter : this.state.filter;\n\n // filter devices name\n if (filter) {\n const filteredDevices = this.state.devices.filter(device =>\n this.getText(device.name).toLowerCase().includes(filter.toLowerCase()),\n );\n this.setState({ filteredDevices });\n } else {\n this.setState({ filteredDevices: this.state.devices });\n }\n }\n\n handleFilterChange(filter: string): void {\n this.setState({ filter }, () => {\n if (this.filterTimeout) {\n clearTimeout(this.filterTimeout);\n }\n this.filterTimeout = setTimeout(() => {\n this.filterTimeout = null;\n this.applyFilter();\n }, 250);\n });\n }\n\n renderContent(): JSX.Element | JSX.Element[] | null {\n const emptyStyle: React.CSSProperties = {\n padding: 25,\n };\n\n if ((this.props.triggerLoad || 0) !== this.lastTriggerLoad) {\n this.lastTriggerLoad = this.props.triggerLoad || 0;\n setTimeout(() => this.loadData(), 50);\n }\n\n if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {\n this.lastPropsFilter = this.props.filter;\n setTimeout(() => this.applyFilter(), 50);\n }\n // if instance changed\n if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {\n this.lastInstance = this.props.selectedInstance;\n setTimeout(() => this.loadData(), 50);\n }\n\n let list;\n if (!this.props.embedded && !this.state.alive) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('instanceNotAlive')}</span>\n </div>\n );\n } else if (!this.state.devices.length && this.props.selectedInstance) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('noDevicesFoundText')}</span>\n </div>\n );\n } else if (this.state.devices.length && !this.state.filteredDevices.length) {\n list = (\n <div style={emptyStyle}>\n <span>{getTranslation('allDevicesFilteredOut')}</span>\n </div>\n );\n } else {\n list = this.state.filteredDevices.map(device => (\n <DeviceCard\n alive={!!this.state.alive}\n key={device.id}\n id={device.id}\n title={this.getText(device.name)}\n device={device}\n instanceId={this.props.selectedInstance}\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceHandler={this.deviceHandler}\n controlHandler={this.controlHandler}\n controlStateHandler={this.controlStateHandler}\n socket={this.props.socket}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n theme={this.props.theme}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n />\n ));\n }\n\n if (this.props.embedded) {\n return (\n <>\n {this.state.loading ? <LinearProgress style={{ width: '100%' }} /> : null}\n {list}\n </>\n );\n }\n\n return (\n <div style={{ width: '100%', height: '100%', overflow: 'hidden' }}>\n <Toolbar\n variant=\"dense\"\n style={{ backgroundColor: '#777', display: 'flex' }}\n >\n {this.props.title}\n {this.props.selectedInstance ? (\n <Tooltip\n title={getTranslation('refreshTooltip')}\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\n >\n <span>\n <IconButton\n onClick={() => this.loadData()}\n disabled={!this.state.alive}\n size=\"small\"\n >\n <Refresh />\n </IconButton>\n </span>\n </Tooltip>\n ) : null}\n {this.state.alive && this.state.instanceInfo?.actions?.length ? (\n <div style={{ marginLeft: 20 }}>\n {this.state.instanceInfo.actions.map(action => (\n <InstanceActionButton\n key={action.id}\n action={action}\n instanceHandler={this.instanceHandler}\n />\n ))}\n </div>\n ) : null}\n\n <div style={{ flexGrow: 1 }} />\n\n {this.state.alive ? (\n <TextField\n variant=\"standard\"\n style={{ width: 200 }}\n size=\"small\"\n label={getTranslation('filterLabelText')}\n onChange={e => this.handleFilterChange(e.target.value)}\n value={this.state.filter}\n autoComplete=\"off\"\n slotProps={{\n input: {\n autoComplete: 'new-password',\n endAdornment: this.state.filter ? (\n <InputAdornment position=\"end\">\n <IconButton\n onClick={() => this.handleFilterChange('')}\n edge=\"end\"\n >\n <Clear />\n </IconButton>\n </InputAdornment>\n ) : null,\n },\n htmlInput: {\n autoComplete: 'off',\n },\n }}\n />\n ) : null}\n </Toolbar>\n <div\n style={{\n width: '100%',\n height: 'calc(100% - 56px)',\n marginTop: 8,\n overflow: 'auto',\n // justifyContent: 'center',\n // alignItems: 'stretch',\n // display: 'grid',\n // columnGap: 8,\n // rowGap: 8,\n ...this.props.style,\n }}\n >\n {this.state.loading ? <LinearProgress style={{ width: '100%' }} /> : null}\n {list}\n </div>\n </div>\n );\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { Connection, ThemeName, ThemeType, IobTheme } from '@iobroker/adapter-react-v5';
3
- import { type ConfigItemPanel } from '@iobroker/json-config';
3
+ import { type ConfigItemPanel, type ConfigItemTabs } from '@iobroker/json-config';
4
4
  interface JsonConfigDmProps {
5
5
  instanceId: string;
6
6
  socket: Connection;
7
- schema: ConfigItemPanel;
7
+ schema: ConfigItemPanel | ConfigItemTabs;
8
8
  data: Record<string, any>;
9
9
  onChange: (data: Record<string, any>) => void;
10
10
  themeName: ThemeName;
@@ -1 +1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,KAAK,CAAC,UAAU,KAAK,SAAS;gBAC1B,CAAC,CAAE,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,UAAqB;gBAC1D,CAAC,CAAC,KAAK,CAAC,UAAU,GAE5B,CACH,CACN,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkDE;AACN,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport type { Connection, AdminConnection, ThemeName, ThemeType, IobTheme } from '@iobroker/adapter-react-v5';\nimport { JsonConfigComponent, type ConfigItemPanel } from '@iobroker/json-config';\n\ninterface JsonConfigDmProps {\n instanceId: string;\n socket: Connection;\n schema: ConfigItemPanel;\n data: Record<string, any>;\n onChange: (data: Record<string, any>) => void;\n themeName: ThemeName;\n themeType: ThemeType;\n theme: IobTheme;\n isFloatComma?: boolean;\n dateFormat?: string;\n}\n\nexport default function JsonConfig(props: JsonConfigDmProps): React.JSX.Element | null {\n const { instanceId, socket, schema, data, onChange } = props;\n const [error, setError] = useState(false);\n\n if (schema === undefined) {\n return null;\n }\n\n const [adapterName, instance] = instanceId.split('.', 2);\n\n return (\n <>\n {error && <div>{error}</div>}\n <JsonConfigComponent\n socket={socket as any as AdminConnection}\n adapterName={adapterName}\n instance={parseInt(instance, 10)}\n schema={schema}\n data={data}\n onError={setError}\n onChange={(_data: Record<string, any>) => onChange(_data)}\n embedded\n themeName={props.themeName}\n themeType={props.themeType}\n theme={props.theme}\n isFloatComma={\n props.isFloatComma === undefined\n ? !!props.socket.systemConfig?.common.isFloatComma\n : props.isFloatComma\n }\n dateFormat={\n props.dateFormat === undefined\n ? (props.socket.systemConfig?.common.dateFormat as string)\n : props.dateFormat\n }\n />\n </>\n );\n\n /*\n JSON adapter config:\n className={classes.scroll}\n socket={socket}\n theme={this.props.theme}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n schema={this.state.schema}\n common={this.state.common}\n data={this.state.data}\n updateData={this.state.updateData}\n onError={(error) => this.setState({ error })}\n onChange={(data, changed) => this.setState({ data, changed })}\n customs={{ configCustomEasyAccess: ConfigCustomEasyAccess }}\n Object custom:\n instanceObj={instanceObj}\n customObj={customObj}\n custom={true}\n className={ '' }\n adapterName={adapter}\n instance={parseInt(instance.split('.').pop(), 10) || 0}\n socket={this.props.socket}\n theme={this.props.theme}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n multiEdit={this.props.objectIDs.length > 1}\n\n schema={this.jsonConfigs[adapter].json}\n data={data}\n onError={error =>\n this.setState({error}, () => this.props.onError && this.props.onError(error))}\n onValueChange={(attr, value) => {\n console.log(attr + ' => ' + value);\n const newValues = JSON.parse(JSON.stringify(this.state.newValues));\n newValues[instance] = newValues[instance] || {};\n if (this.commonConfig[instance][attr] === value) {\n delete newValues[instance][attr];\n if (!Object.keys(newValues[instance]).length) {\n delete newValues[instance];\n }\n } else {\n newValues[instance][attr] = value;\n }\n this.setState({newValues, hasChanges: this.isChanged(newValues)}, () =>\n this.props.onChange && this.props.onChange(this.state.hasChanges));\n }}\n */\n}\n"]}
1
+ {"version":3,"file":"JsonConfig.js","sourceRoot":"./src/","sources":["JsonConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAA6C,MAAM,uBAAuB,CAAC;AAevG,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAwB;IACvD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC7D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,MAAM,KAAK,SAAS,EAAE;QACtB,OAAO,IAAI,CAAC;KACf;IAED,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAEzD,OAAO,CACH;QACK,KAAK,IAAI,iCAAM,KAAK,CAAO;QAC5B,oBAAC,mBAAmB,IAChB,MAAM,EAAE,MAAgC,EACxC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,CAAC,KAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACzD,QAAQ,QACR,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,YAAY,EACR,KAAK,CAAC,YAAY,KAAK,SAAS;gBAC5B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY;gBAClD,CAAC,CAAC,KAAK,CAAC,YAAY,EAE5B,UAAU,EACN,KAAK,CAAC,UAAU,KAAK,SAAS;gBAC1B,CAAC,CAAE,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,UAAqB;gBAC1D,CAAC,CAAC,KAAK,CAAC,UAAU,GAE5B,CACH,CACN,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkDE;AACN,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport type { Connection, AdminConnection, ThemeName, ThemeType, IobTheme } from '@iobroker/adapter-react-v5';\nimport { JsonConfigComponent, type ConfigItemPanel, type ConfigItemTabs } from '@iobroker/json-config';\n\ninterface JsonConfigDmProps {\n instanceId: string;\n socket: Connection;\n schema: ConfigItemPanel | ConfigItemTabs;\n data: Record<string, any>;\n onChange: (data: Record<string, any>) => void;\n themeName: ThemeName;\n themeType: ThemeType;\n theme: IobTheme;\n isFloatComma?: boolean;\n dateFormat?: string;\n}\n\nexport default function JsonConfig(props: JsonConfigDmProps): React.JSX.Element | null {\n const { instanceId, socket, schema, data, onChange } = props;\n const [error, setError] = useState(false);\n\n if (schema === undefined) {\n return null;\n }\n\n const [adapterName, instance] = instanceId.split('.', 2);\n\n return (\n <>\n {error && <div>{error}</div>}\n <JsonConfigComponent\n socket={socket as any as AdminConnection}\n adapterName={adapterName}\n instance={parseInt(instance, 10)}\n schema={schema}\n data={data}\n onError={setError}\n onChange={(_data: Record<string, any>) => onChange(_data)}\n embedded\n themeName={props.themeName}\n themeType={props.themeType}\n theme={props.theme}\n isFloatComma={\n props.isFloatComma === undefined\n ? !!props.socket.systemConfig?.common.isFloatComma\n : props.isFloatComma\n }\n dateFormat={\n props.dateFormat === undefined\n ? (props.socket.systemConfig?.common.dateFormat as string)\n : props.dateFormat\n }\n />\n </>\n );\n\n /*\n JSON adapter config:\n className={classes.scroll}\n socket={socket}\n theme={this.props.theme}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n schema={this.state.schema}\n common={this.state.common}\n data={this.state.data}\n updateData={this.state.updateData}\n onError={(error) => this.setState({ error })}\n onChange={(data, changed) => this.setState({ data, changed })}\n customs={{ configCustomEasyAccess: ConfigCustomEasyAccess }}\n Object custom:\n instanceObj={instanceObj}\n customObj={customObj}\n custom={true}\n className={ '' }\n adapterName={adapter}\n instance={parseInt(instance.split('.').pop(), 10) || 0}\n socket={this.props.socket}\n theme={this.props.theme}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n multiEdit={this.props.objectIDs.length > 1}\n\n schema={this.jsonConfigs[adapter].json}\n data={data}\n onError={error =>\n this.setState({error}, () => this.props.onError && this.props.onError(error))}\n onValueChange={(attr, value) => {\n console.log(attr + ' => ' + value);\n const newValues = JSON.parse(JSON.stringify(this.state.newValues));\n newValues[instance] = newValues[instance] || {};\n if (this.commonConfig[instance][attr] === value) {\n delete newValues[instance][attr];\n if (!Object.keys(newValues[instance]).length) {\n delete newValues[instance];\n }\n } else {\n newValues[instance][attr] = value;\n }\n this.setState({newValues, hasChanges: this.isChanged(newValues)}, () =>\n this.props.onChange && this.props.onChange(this.state.hasChanges));\n }}\n */\n}\n"]}
package/build/Utils.d.ts CHANGED
@@ -11,4 +11,4 @@ export declare function renderActionIcon(action: ActionBase): React.JSX.Element
11
11
  */
12
12
  export declare function getTranslation(
13
13
  /** Text to translate */
14
- text: ioBroker.StringOrTranslated): string;
14
+ text: ioBroker.StringOrTranslated, noTranslation?: boolean): string;
package/build/Utils.js CHANGED
@@ -1,6 +1,30 @@
1
1
  import React from 'react';
2
- import { Add, Bluetooth, BluetoothDisabled, Delete, Edit, FastForward, FastRewind, Fluorescent, Group, Lightbulb, Link as LinkIcon, LinkOff, NotListedLocation, Pause, Person, PlayArrow, Power, QrCode, QuestionMark, Refresh, Search, Settings, Stop, Visibility, WbIncandescent, Wifi, WifiOff, } from '@mui/icons-material';
2
+ import { Add, Article, Bluetooth, BluetoothDisabled, Delete, Edit, FastForward, FastRewind, Fluorescent, Group, Info, Lightbulb, Link as LinkIcon, LinkOff, NotListedLocation, Pause, Person, PlayArrow, Power, QrCode, QuestionMark, Refresh, Search, Settings, Stop, Visibility, WbIncandescent, Wifi, WifiFind, WifiOff, } from '@mui/icons-material';
3
3
  import { I18n, Icon } from '@iobroker/adapter-react-v5';
4
+ /**
5
+ * Get Icon by font-awesome name. Do not use these name, use names from getIconByName
6
+ *
7
+ * @param icon font-awesome icon name
8
+ * Only following font-awesome icons are supported:
9
+ * - fa-trash-can, fa-trash
10
+ * - fa-pen
11
+ * - fa-redo-alt
12
+ * - fa-plus
13
+ * - fa-qrcode, qrcode
14
+ * - fa-wifi
15
+ * - fa-wifi-slash
16
+ * - fa-bluetooth
17
+ * - fa-bluetooth-slash
18
+ * - fa-eye
19
+ * - fa-search
20
+ * - fa-unlink
21
+ * - fa-link
22
+ * - fa-search-location
23
+ * - fa-play
24
+ * - fa-stop
25
+ * - fa-pause
26
+ * @param color color of the icon
27
+ */
4
28
  function getFaIcon(icon, color) {
5
29
  const iconStyle = icon
6
30
  .split(' ')
@@ -57,81 +81,118 @@ function getFaIcon(icon, color) {
57
81
  if (iconStyle.includes('fa-pause')) {
58
82
  return React.createElement(Pause, { style: { color } });
59
83
  }
60
- if (iconStyle.includes('forward')) {
61
- return React.createElement(FastForward, { style: { color } });
62
- }
63
- if (iconStyle.includes('rewind')) {
64
- return React.createElement(FastRewind, { style: { color } });
65
- }
66
- if (iconStyle.includes('users') || iconStyle.includes('group')) {
67
- return React.createElement(Group, { style: { color } });
68
- }
69
- if (iconStyle.includes('user')) {
70
- return React.createElement(Person, { style: { color } });
71
- }
72
84
  return React.createElement(QuestionMark, { style: { color } });
73
85
  }
74
- function getIconByName(name, color) {
75
- if (name === 'edit' || name === 'rename') {
86
+ /**
87
+ * Get Icon by name or by action
88
+ *
89
+ * @param name action name
90
+ * possible action or icon names are
91
+ * - edit, rename
92
+ * - delete
93
+ * - refresh
94
+ * - newDevice, new, add
95
+ * - discover, search
96
+ * - unpairDevice, unpair
97
+ * - pairDevice, pair
98
+ * - identify
99
+ * - play
100
+ * - stop
101
+ * - pause
102
+ * - forward, next
103
+ * - rewind, previous
104
+ * - lamp, light
105
+ * - backlight
106
+ * - dimmer
107
+ * - socket
108
+ * - settings
109
+ * - users, group
110
+ * - user
111
+ * - qrcode
112
+ * - identify
113
+ * - info
114
+ * - lines
115
+ * @param altName icon name
116
+ * @param color color of the icon
117
+ */
118
+ function getIconByName(name, altName, color) {
119
+ if (name === 'edit' || name === 'rename' || altName === 'edit' || altName === 'rename') {
76
120
  return React.createElement(Edit, { style: { color } });
77
121
  }
78
- if (name === 'delete') {
122
+ if (name === 'delete' || altName === 'delete') {
79
123
  return React.createElement(Delete, { style: { color } });
80
124
  }
81
- if (name === 'refresh') {
125
+ if (name === 'refresh' || altName === 'refresh') {
82
126
  return React.createElement(Refresh, { style: { color } });
83
127
  }
84
- if (name === 'newDevice' || name === 'new' || name === 'add') {
128
+ if (name === 'newDevice' ||
129
+ name === 'new' ||
130
+ name === 'add' ||
131
+ altName === 'newDevice' ||
132
+ altName === 'new' ||
133
+ altName === 'add') {
85
134
  return React.createElement(Add, { style: { color } });
86
135
  }
87
- if (name === 'discover' || name === 'search') {
136
+ if (name === 'discover' || name === 'search' || altName === 'discover' || altName === 'search') {
88
137
  return React.createElement(Search, { style: { color } });
89
138
  }
90
- if (name === 'unpairDevice' || name === 'unpair') {
139
+ if (name === 'unpairDevice' || name === 'unpair' || altName === 'unpairDevice' || altName === 'unpair') {
91
140
  return React.createElement(LinkOff, { style: { color } });
92
141
  }
93
- if (name === 'pairDevice' || name === 'pair') {
142
+ if (name === 'pairDevice' || name === 'pair' || altName === 'pairDevice' || altName === 'pair') {
94
143
  return React.createElement(LinkIcon, { style: { color } });
95
144
  }
96
- if (name === 'identify') {
145
+ if (name === 'identify' || altName === 'identify') {
97
146
  return React.createElement(NotListedLocation, { style: { color } });
98
147
  }
99
- if (name === 'play') {
148
+ if (name === 'play' || altName === 'play') {
100
149
  return React.createElement(PlayArrow, { style: { color } });
101
150
  }
102
- if (name === 'stop') {
151
+ if (name === 'stop' || altName === 'stop') {
103
152
  return React.createElement(Stop, { style: { color } });
104
153
  }
105
- if (name === 'pause') {
154
+ if (name === 'pause' || altName === 'pause') {
106
155
  return React.createElement(Pause, { style: { color } });
107
156
  }
108
- if (name === 'forward' || name === 'next') {
157
+ if (name === 'forward' || name === 'next' || altName === 'forward' || altName === 'next') {
109
158
  return React.createElement(FastForward, { style: { color } });
110
159
  }
111
- if (name === 'rewind' || name === 'previous') {
160
+ if (name === 'rewind' || name === 'previous' || altName === 'rewind' || altName === 'previous') {
112
161
  return React.createElement(FastRewind, { style: { color } });
113
162
  }
114
- if (name === 'lamp' || name === 'light') {
163
+ if (name === 'lamp' || name === 'light' || altName === 'lamp' || altName === 'light') {
115
164
  return React.createElement(Lightbulb, { style: { color } });
116
165
  }
117
- if (name === 'backlight') {
166
+ if (name === 'backlight' || altName === 'backlight') {
118
167
  return React.createElement(Fluorescent, { style: { color } });
119
168
  }
120
- if (name === 'dimmer') {
169
+ if (name === 'dimmer' || altName === 'dimmer') {
121
170
  return React.createElement(WbIncandescent, { style: { color } });
122
171
  }
123
- if (name === 'socket') {
172
+ if (name === 'socket' || altName === 'socket') {
124
173
  return React.createElement(Power, { style: { color } });
125
174
  }
126
- if (name === 'settings') {
175
+ if (name === 'settings' || altName === 'settings') {
127
176
  return React.createElement(Settings, { style: { color } });
128
177
  }
129
- if (name === 'users' || name === 'group') {
178
+ if (name === 'users' || name === 'group' || altName === 'users' || altName === 'group') {
130
179
  return React.createElement(Group, { style: { color } });
131
180
  }
132
- if (name === 'user') {
181
+ if (name === 'user' || altName === 'user') {
133
182
  return React.createElement(Person, { style: { color } });
134
183
  }
184
+ if (name === 'qrcode' || altName === 'qrcode') {
185
+ return React.createElement(QrCode, { style: { color } });
186
+ }
187
+ if (name === 'identify' || altName === 'identify') {
188
+ return React.createElement(WifiFind, { style: { color } });
189
+ }
190
+ if (name === 'info' || altName === 'info') {
191
+ return React.createElement(Info, { style: { color } });
192
+ }
193
+ if (name === 'lines' || altName === 'lines') {
194
+ return React.createElement(Article, { style: { color } });
195
+ }
135
196
  return React.createElement(QuestionMark, { style: { color } });
136
197
  }
137
198
  export function renderControlIcon(action, colors, value) {
@@ -156,7 +217,7 @@ export function renderControlIcon(action, colors, value) {
156
217
  if (action.icon?.startsWith('data:image')) {
157
218
  return (React.createElement(Icon, { src: action.icon, style: { color } }));
158
219
  }
159
- return getIconByName(action.id, color);
220
+ return getIconByName(action.id, action.icon, color);
160
221
  }
161
222
  export function renderActionIcon(action) {
162
223
  if (!action) {
@@ -168,7 +229,7 @@ export function renderActionIcon(action) {
168
229
  if (action.icon?.startsWith('data:image')) {
169
230
  return (React.createElement(Icon, { src: action.icon, style: { color: action.color } }));
170
231
  }
171
- return getIconByName(action.id, action.color);
232
+ return getIconByName(action.id, action.icon, action.color);
172
233
  }
173
234
  let language;
174
235
  /**
@@ -176,11 +237,11 @@ let language;
176
237
  */
177
238
  export function getTranslation(
178
239
  /** Text to translate */
179
- text) {
240
+ text, noTranslation) {
180
241
  language = language || I18n.getLanguage();
181
242
  if (typeof text === 'object') {
182
243
  return text[language] || text.en;
183
244
  }
184
- return I18n.t(text);
245
+ return noTranslation ? text : I18n.t(text);
185
246
  }
186
247
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"./src/","sources":["Utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACH,GAAG,EACH,SAAS,EACT,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,EACT,IAAI,IAAI,QAAQ,EAChB,OAAO,EACP,iBAAiB,EACjB,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,cAAc,EACd,IAAI,EACJ,OAAO,GACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD,SAAS,SAAS,CAAC,IAAY,EAAE,KAAc;IAC3C,MAAM,SAAS,GAAG,IAAI;SACjB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,S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AC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,IAAI,QAA4B,CAAC;AAEjC;;GAEG;AACH,MAAM,UAAU,cAAc;AAC1B,wBAAwB;AACxB,IAAiC;IAEjC,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;IAE1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;KACpC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ControlBase } from '@iobroker/dm-utils/build/types/base';\nimport type { ActionBase } from '@iobroker/dm-utils/build/types/api';\nimport {\n Add,\n Bluetooth,\n BluetoothDisabled,\n Delete,\n Edit,\n FastForward,\n FastRewind,\n Fluorescent,\n Group,\n Lightbulb,\n Link as LinkIcon,\n LinkOff,\n NotListedLocation,\n Pause,\n Person,\n PlayArrow,\n Power,\n QrCode,\n QuestionMark,\n Refresh,\n Search,\n Settings,\n Stop,\n Visibility,\n WbIncandescent,\n Wifi,\n WifiOff,\n} from '@mui/icons-material';\n\nimport { I18n, Icon } from '@iobroker/adapter-react-v5';\n\nfunction getFaIcon(icon: string, color?: string): React.JSX.Element | null {\n const iconStyle = icon\n .split(' ')\n .map(s => s.trim())\n .filter(s => s !== 'fa-solid');\n\n if (iconStyle.includes('fa-trash-can') || iconStyle.includes('fa-trash')) {\n return <Delete style={{ color }} />;\n }\n if (iconStyle.includes('fa-pen')) {\n return <Edit style={{ color }} />;\n }\n if (iconStyle.includes('fa-redo-alt')) {\n return <Refresh style={{ color }} />;\n }\n if (iconStyle.includes('fa-plus')) {\n return <Add style={{ color }} />;\n }\n if (iconStyle.includes('fa-qrcode') || iconStyle.includes('qrcode')) {\n return <QrCode style={{ color }} />;\n }\n if (iconStyle.includes('fa-wifi')) {\n return <Wifi style={{ color }} />;\n }\n if (iconStyle.includes('fa-wifi-slash')) {\n return <WifiOff style={{ color }} />;\n }\n if (iconStyle.includes('fa-bluetooth')) {\n return <Bluetooth style={{ color }} />;\n }\n if (iconStyle.includes('fa-bluetooth-slash')) {\n return <BluetoothDisabled style={{ color }} />;\n }\n if (iconStyle.includes('fa-eye')) {\n return <Visibility style={{ color }} />;\n }\n if (iconStyle.includes('fa-search')) {\n return <Search style={{ color }} />;\n }\n if (iconStyle.includes('fa-unlink')) {\n return <LinkOff style={{ color }} />;\n }\n if (iconStyle.includes('fa-link')) {\n return <LinkIcon style={{ color }} />;\n }\n if (iconStyle.includes('fa-search-location')) {\n return <NotListedLocation style={{ color }} />;\n }\n if (iconStyle.includes('fa-play')) {\n return <PlayArrow style={{ color }} />;\n }\n if (iconStyle.includes('fa-stop')) {\n return <Stop style={{ color }} />;\n }\n if (iconStyle.includes('fa-pause')) {\n return <Pause style={{ color }} />;\n }\n if (iconStyle.includes('forward')) {\n return <FastForward style={{ color }} />;\n }\n if (iconStyle.includes('rewind')) {\n return <FastRewind style={{ color }} />;\n }\n if (iconStyle.includes('users') || iconStyle.includes('group')) {\n return <Group style={{ color }} />;\n }\n if (iconStyle.includes('user')) {\n return <Person style={{ color }} />;\n }\n return <QuestionMark style={{ color }} />;\n}\n\nfunction getIconByName(name: string, color?: string): React.JSX.Element | null {\n if (name === 'edit' || name === 'rename') {\n return <Edit style={{ color }} />;\n }\n if (name === 'delete') {\n return <Delete style={{ color }} />;\n }\n if (name === 'refresh') {\n return <Refresh style={{ color }} />;\n }\n if (name === 'newDevice' || name === 'new' || name === 'add') {\n return <Add style={{ color }} />;\n }\n if (name === 'discover' || name === 'search') {\n return <Search style={{ color }} />;\n }\n if (name === 'unpairDevice' || name === 'unpair') {\n return <LinkOff style={{ color }} />;\n }\n if (name === 'pairDevice' || name === 'pair') {\n return <LinkIcon style={{ color }} />;\n }\n if (name === 'identify') {\n return <NotListedLocation style={{ color }} />;\n }\n if (name === 'play') {\n return <PlayArrow style={{ color }} />;\n }\n if (name === 'stop') {\n return <Stop style={{ color }} />;\n }\n if (name === 'pause') {\n return <Pause style={{ color }} />;\n }\n if (name === 'forward' || name === 'next') {\n return <FastForward style={{ color }} />;\n }\n if (name === 'rewind' || name === 'previous') {\n return <FastRewind style={{ color }} />;\n }\n if (name === 'lamp' || name === 'light') {\n return <Lightbulb style={{ color }} />;\n }\n if (name === 'backlight') {\n return <Fluorescent style={{ color }} />;\n }\n if (name === 'dimmer') {\n return <WbIncandescent style={{ color }} />;\n }\n if (name === 'socket') {\n return <Power style={{ color }} />;\n }\n if (name === 'settings') {\n return <Settings style={{ color }} />;\n }\n if (name === 'users' || name === 'group') {\n return <Group style={{ color }} />;\n }\n if (name === 'user') {\n return <Person style={{ color }} />;\n }\n return <QuestionMark style={{ color }} />;\n}\n\nexport function renderControlIcon(\n action: ControlBase,\n colors?: { primary: string; secondary: string },\n value?: string | number | boolean | null,\n): React.JSX.Element | null {\n if (!action) {\n return null;\n }\n\n let color = (value && action.colorOn) || action.color || (action.state ? 'primary' : 'inherit');\n\n if (colors) {\n if (color === 'primary') {\n color = colors.primary;\n } else if (color === 'secondary') {\n color = colors.secondary;\n }\n }\n\n if (action.icon?.startsWith('fa-') || action.icon?.startsWith('fas')) {\n return getFaIcon(action.icon, color);\n }\n if (value && action.iconOn?.startsWith('data:image')) {\n return (\n <Icon\n src={action.iconOn}\n style={{ color }}\n />\n );\n }\n if (action.icon?.startsWith('data:image')) {\n return (\n <Icon\n src={action.icon}\n style={{ color }}\n />\n );\n }\n return getIconByName(action.id, color);\n}\n\nexport function renderActionIcon(action: ActionBase): React.JSX.Element | null {\n if (!action) {\n return null;\n }\n\n if (action.icon?.startsWith('fa-') || action.icon?.startsWith('fas')) {\n return getFaIcon(action.icon, action.color);\n }\n if (action.icon?.startsWith('data:image')) {\n return (\n <Icon\n src={action.icon}\n style={{ color: action.color }}\n />\n );\n }\n return getIconByName(action.id, action.color);\n}\n\nlet language: ioBroker.Languages;\n\n/**\n * Get Translation\n */\nexport function getTranslation(\n /** Text to translate */\n text: ioBroker.StringOrTranslated,\n): string {\n language = language || I18n.getLanguage();\n\n if (typeof text === 'object') {\n return text[language] || text.en;\n }\n\n return I18n.t(text);\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"./src/","sources":["Utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACH,GAAG,EACH,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,WAAW,EACX,KAAK,EACL,IAAI,EACJ,SAAS,EACT,IAAI,IAAI,QAAQ,EAChB,OAAO,EACP,iBAAiB,EACjB,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,OAAO,GACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,KAAc;IAC3C,MAAM,SAAS,GAAG,IAAI;SACjB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACtE,OAAO,oBAAC,MAAM,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAI,CAAC;KACvC;IACD,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,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AAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IAC/C,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IAED,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE;QAClE,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;KAC/C;IACD,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,CACH,oBAAC,IAAI,IACD,GAAG,EAAE,MAAM,CAAC,IAAI,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,GAChC,CACL,CAAC;KACL;IACD,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,IAAI,QAA4B,CAAC;AAEjC;;GAEG;AACH,MAAM,UAAU,cAAc;AAC1B,wBAAwB;AACxB,IAAiC,EACjC,aAAuB;IAEvB,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;IAE1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;KACpC;IAED,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ControlBase } from '@iobroker/dm-utils/build/types/base';\nimport type { ActionBase } from '@iobroker/dm-utils/build/types/api';\nimport {\n Add,\n Article,\n Bluetooth,\n BluetoothDisabled,\n Delete,\n Edit,\n FastForward,\n FastRewind,\n Fluorescent,\n Group,\n Info,\n Lightbulb,\n Link as LinkIcon,\n LinkOff,\n NotListedLocation,\n Pause,\n Person,\n PlayArrow,\n Power,\n QrCode,\n QuestionMark,\n Refresh,\n Search,\n Settings,\n Stop,\n Visibility,\n WbIncandescent,\n Wifi,\n WifiFind,\n WifiOff,\n} from '@mui/icons-material';\n\nimport { I18n, Icon } from '@iobroker/adapter-react-v5';\n\n/**\n * Get Icon by font-awesome name. Do not use these name, use names from getIconByName\n *\n * @param icon font-awesome icon name\n * Only following font-awesome icons are supported:\n * - fa-trash-can, fa-trash\n * - fa-pen\n * - fa-redo-alt\n * - fa-plus\n * - fa-qrcode, qrcode\n * - fa-wifi\n * - fa-wifi-slash\n * - fa-bluetooth\n * - fa-bluetooth-slash\n * - fa-eye\n * - fa-search\n * - fa-unlink\n * - fa-link\n * - fa-search-location\n * - fa-play\n * - fa-stop\n * - fa-pause\n * @param color color of the icon\n */\nfunction getFaIcon(icon: string, color?: string): React.JSX.Element | null {\n const iconStyle = icon\n .split(' ')\n .map(s => s.trim())\n .filter(s => s !== 'fa-solid');\n\n if (iconStyle.includes('fa-trash-can') || iconStyle.includes('fa-trash')) {\n return <Delete style={{ color }} />;\n }\n if (iconStyle.includes('fa-pen')) {\n return <Edit style={{ color }} />;\n }\n if (iconStyle.includes('fa-redo-alt')) {\n return <Refresh style={{ color }} />;\n }\n if (iconStyle.includes('fa-plus')) {\n return <Add style={{ color }} />;\n }\n if (iconStyle.includes('fa-qrcode') || iconStyle.includes('qrcode')) {\n return <QrCode style={{ color }} />;\n }\n if (iconStyle.includes('fa-wifi')) {\n return <Wifi style={{ color }} />;\n }\n if (iconStyle.includes('fa-wifi-slash')) {\n return <WifiOff style={{ color }} />;\n }\n if (iconStyle.includes('fa-bluetooth')) {\n return <Bluetooth style={{ color }} />;\n }\n if (iconStyle.includes('fa-bluetooth-slash')) {\n return <BluetoothDisabled style={{ color }} />;\n }\n if (iconStyle.includes('fa-eye')) {\n return <Visibility style={{ color }} />;\n }\n if (iconStyle.includes('fa-search')) {\n return <Search style={{ color }} />;\n }\n if (iconStyle.includes('fa-unlink')) {\n return <LinkOff style={{ color }} />;\n }\n if (iconStyle.includes('fa-link')) {\n return <LinkIcon style={{ color }} />;\n }\n if (iconStyle.includes('fa-search-location')) {\n return <NotListedLocation style={{ color }} />;\n }\n if (iconStyle.includes('fa-play')) {\n return <PlayArrow style={{ color }} />;\n }\n if (iconStyle.includes('fa-stop')) {\n return <Stop style={{ color }} />;\n }\n if (iconStyle.includes('fa-pause')) {\n return <Pause style={{ color }} />;\n }\n return <QuestionMark style={{ color }} />;\n}\n\n/**\n * Get Icon by name or by action\n *\n * @param name action name\n * possible action or icon names are\n * - edit, rename\n * - delete\n * - refresh\n * - newDevice, new, add\n * - discover, search\n * - unpairDevice, unpair\n * - pairDevice, pair\n * - identify\n * - play\n * - stop\n * - pause\n * - forward, next\n * - rewind, previous\n * - lamp, light\n * - backlight\n * - dimmer\n * - socket\n * - settings\n * - users, group\n * - user\n * - qrcode\n * - identify\n * - info\n * - lines\n * @param altName icon name\n * @param color color of the icon\n */\nfunction getIconByName(name: string, altName?: string, color?: string): React.JSX.Element | null {\n if (name === 'edit' || name === 'rename' || altName === 'edit' || altName === 'rename') {\n return <Edit style={{ color }} />;\n }\n if (name === 'delete' || altName === 'delete') {\n return <Delete style={{ color }} />;\n }\n if (name === 'refresh' || altName === 'refresh') {\n return <Refresh style={{ color }} />;\n }\n if (\n name === 'newDevice' ||\n name === 'new' ||\n name === 'add' ||\n altName === 'newDevice' ||\n altName === 'new' ||\n altName === 'add'\n ) {\n return <Add style={{ color }} />;\n }\n if (name === 'discover' || name === 'search' || altName === 'discover' || altName === 'search') {\n return <Search style={{ color }} />;\n }\n if (name === 'unpairDevice' || name === 'unpair' || altName === 'unpairDevice' || altName === 'unpair') {\n return <LinkOff style={{ color }} />;\n }\n if (name === 'pairDevice' || name === 'pair' || altName === 'pairDevice' || altName === 'pair') {\n return <LinkIcon style={{ color }} />;\n }\n if (name === 'identify' || altName === 'identify') {\n return <NotListedLocation style={{ color }} />;\n }\n if (name === 'play' || altName === 'play') {\n return <PlayArrow style={{ color }} />;\n }\n if (name === 'stop' || altName === 'stop') {\n return <Stop style={{ color }} />;\n }\n if (name === 'pause' || altName === 'pause') {\n return <Pause style={{ color }} />;\n }\n if (name === 'forward' || name === 'next' || altName === 'forward' || altName === 'next') {\n return <FastForward style={{ color }} />;\n }\n if (name === 'rewind' || name === 'previous' || altName === 'rewind' || altName === 'previous') {\n return <FastRewind style={{ color }} />;\n }\n if (name === 'lamp' || name === 'light' || altName === 'lamp' || altName === 'light') {\n return <Lightbulb style={{ color }} />;\n }\n if (name === 'backlight' || altName === 'backlight') {\n return <Fluorescent style={{ color }} />;\n }\n if (name === 'dimmer' || altName === 'dimmer') {\n return <WbIncandescent style={{ color }} />;\n }\n if (name === 'socket' || altName === 'socket') {\n return <Power style={{ color }} />;\n }\n if (name === 'settings' || altName === 'settings') {\n return <Settings style={{ color }} />;\n }\n if (name === 'users' || name === 'group' || altName === 'users' || altName === 'group') {\n return <Group style={{ color }} />;\n }\n if (name === 'user' || altName === 'user') {\n return <Person style={{ color }} />;\n }\n if (name === 'qrcode' || altName === 'qrcode') {\n return <QrCode style={{ color }} />;\n }\n if (name === 'identify' || altName === 'identify') {\n return <WifiFind style={{ color }} />;\n }\n if (name === 'info' || altName === 'info') {\n return <Info style={{ color }} />;\n }\n if (name === 'lines' || altName === 'lines') {\n return <Article style={{ color }} />;\n }\n return <QuestionMark style={{ color }} />;\n}\n\nexport function renderControlIcon(\n action: ControlBase,\n colors?: { primary: string; secondary: string },\n value?: string | number | boolean | null,\n): React.JSX.Element | null {\n if (!action) {\n return null;\n }\n\n let color = (value && action.colorOn) || action.color || (action.state ? 'primary' : 'inherit');\n\n if (colors) {\n if (color === 'primary') {\n color = colors.primary;\n } else if (color === 'secondary') {\n color = colors.secondary;\n }\n }\n\n if (action.icon?.startsWith('fa-') || action.icon?.startsWith('fas')) {\n return getFaIcon(action.icon, color);\n }\n if (value && action.iconOn?.startsWith('data:image')) {\n return (\n <Icon\n src={action.iconOn}\n style={{ color }}\n />\n );\n }\n if (action.icon?.startsWith('data:image')) {\n return (\n <Icon\n src={action.icon}\n style={{ color }}\n />\n );\n }\n return getIconByName(action.id, action.icon, color);\n}\n\nexport function renderActionIcon(action: ActionBase): React.JSX.Element | null {\n if (!action) {\n return null;\n }\n\n if (action.icon?.startsWith('fa-') || action.icon?.startsWith('fas')) {\n return getFaIcon(action.icon, action.color);\n }\n if (action.icon?.startsWith('data:image')) {\n return (\n <Icon\n src={action.icon}\n style={{ color: action.color }}\n />\n );\n }\n return getIconByName(action.id, action.icon, action.color);\n}\n\nlet language: ioBroker.Languages;\n\n/**\n * Get Translation\n */\nexport function getTranslation(\n /** Text to translate */\n text: ioBroker.StringOrTranslated,\n noTranslation?: boolean,\n): string {\n language = language || I18n.getLanguage();\n\n if (typeof text === 'object') {\n return text[language] || text.en;\n }\n\n return noTranslation ? text : I18n.t(text);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/dm-gui-components",
3
- "version": "7.3.2",
3
+ "version": "7.4.1",
4
4
  "description": "ReactJS components to develop admin interface for ioBroker device manager.",
5
5
  "author": {
6
6
  "name": "Jey Cee",
@@ -48,12 +48,12 @@
48
48
  },
49
49
  "homepage": "https://github.com/ioBroker/dm-gui-components#readme",
50
50
  "dependencies": {
51
- "@iobroker/adapter-react-v5": "7.3.2",
52
- "@iobroker/json-config": "7.3.2"
51
+ "@iobroker/adapter-react-v5": "7.4.1",
52
+ "@iobroker/json-config": "7.4.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@craco/craco": "^7.1.0",
56
- "@iobroker/dm-utils": "^0.5.0"
56
+ "@iobroker/dm-utils": "^0.6.6"
57
57
  },
58
- "gitHead": "345dc9e5cd8b3a79521e6e61ad26714b7fb7cd57"
58
+ "gitHead": "aa4b7b2369c0d377fa176c014d295ea191af864c"
59
59
  }