@iobroker/dm-gui-components 7.3.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/DeviceCard.js +13 -12
- package/build/DeviceCard.js.map +1 -1
- package/build/DeviceList.d.ts +4 -0
- package/build/DeviceList.js +6 -0
- package/build/DeviceList.js.map +1 -1
- package/build/Utils.js +38 -24
- package/build/Utils.js.map +1 -1
- package/package.json +4 -4
package/build/DeviceCard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Button, Typography, Dialog, DialogActions, DialogContent, IconButton, Fab, DialogTitle, Card, CardActions, CardHeader, CardContent, Paper, Box, } from '@mui/material';
|
|
3
3
|
import { MoreVert as MoreVertIcon, VideogameAsset as ControlIcon, Close as CloseIcon } from '@mui/icons-material';
|
|
4
|
-
import { Utils,
|
|
4
|
+
import { Utils, I18n, IconDeviceType, } from '@iobroker/adapter-react-v5';
|
|
5
5
|
import DeviceActionButton from './DeviceActionButton';
|
|
6
6
|
import DeviceControlComponent from './DeviceControl';
|
|
7
7
|
import DeviceStatusComponent from './DeviceStatus';
|
|
@@ -153,6 +153,7 @@ class DeviceCard extends Component {
|
|
|
153
153
|
: Array.isArray(this.props.device.status)
|
|
154
154
|
? this.props.device.status
|
|
155
155
|
: [this.props.device.status];
|
|
156
|
+
const icon = this.state.icon ? React.createElement(IconDeviceType, { src: this.state.icon }) : React.createElement(NoImageIcon, null);
|
|
156
157
|
return (React.createElement(Card, { sx: {
|
|
157
158
|
maxWidth: 345,
|
|
158
159
|
minWidth: 200,
|
|
@@ -169,7 +170,7 @@ class DeviceCard extends Component {
|
|
|
169
170
|
this.setState({ icon: imageData });
|
|
170
171
|
}
|
|
171
172
|
}, socket: this.props.socket })) : null,
|
|
172
|
-
|
|
173
|
+
icon), action: hasDetails ? (React.createElement(IconButton, { "aria-label": "settings", onClick: () => {
|
|
173
174
|
if (!this.state.open) {
|
|
174
175
|
this.loadDetails().catch(console.error);
|
|
175
176
|
this.setState({ open: true });
|
|
@@ -222,31 +223,29 @@ class DeviceCard extends Component {
|
|
|
222
223
|
};
|
|
223
224
|
const headerStyle = {
|
|
224
225
|
display: 'flex',
|
|
226
|
+
alignItems: 'center',
|
|
227
|
+
gap: 8,
|
|
228
|
+
paddingLeft: 8,
|
|
225
229
|
position: 'relative',
|
|
226
|
-
justifyContent: 'space-between',
|
|
227
230
|
minHeight: 60,
|
|
228
231
|
color: '#000',
|
|
229
|
-
padding: '0 10px 0 10px',
|
|
230
|
-
borderRadius: '4px 4px 0 0',
|
|
231
232
|
};
|
|
232
233
|
const imgAreaStyle = {
|
|
233
234
|
height: 45,
|
|
234
235
|
width: 45,
|
|
235
|
-
margin: 'auto',
|
|
236
236
|
justifyContent: 'center',
|
|
237
|
-
display: '
|
|
237
|
+
display: 'flex',
|
|
238
|
+
alignItems: 'center',
|
|
238
239
|
};
|
|
239
240
|
const imgStyle = {
|
|
240
241
|
zIndex: 2,
|
|
241
242
|
maxWidth: '100%',
|
|
242
243
|
maxHeight: '100%',
|
|
244
|
+
color: '#FFF',
|
|
243
245
|
};
|
|
244
246
|
const titleStyle = {
|
|
245
|
-
width: '100%',
|
|
246
247
|
fontSize: 16,
|
|
247
248
|
fontWeight: 'bold',
|
|
248
|
-
paddingTop: 16,
|
|
249
|
-
paddingLeft: 8,
|
|
250
249
|
whiteSpace: 'nowrap',
|
|
251
250
|
overflow: 'hidden',
|
|
252
251
|
textOverflow: 'ellipsis',
|
|
@@ -272,6 +271,8 @@ class DeviceCard extends Component {
|
|
|
272
271
|
: Array.isArray(this.props.device.status)
|
|
273
272
|
? this.props.device.status
|
|
274
273
|
: [this.props.device.status];
|
|
274
|
+
const icon = this.state.icon ? (React.createElement(IconDeviceType, { src: this.state.icon, style: imgStyle })) : (React.createElement(NoImageIcon, { style: imgStyle }));
|
|
275
|
+
const title = this.state.details?.data?.name || this.props.title || '';
|
|
275
276
|
return (React.createElement(Paper, { style: cardStyle, key: this.props.id },
|
|
276
277
|
React.createElement(Box, { sx: theme => ({ backgroundColor: theme.palette.secondary.main }), style: headerStyle },
|
|
277
278
|
React.createElement("div", { style: imgAreaStyle },
|
|
@@ -280,8 +281,8 @@ class DeviceCard extends Component {
|
|
|
280
281
|
this.setState({ icon: imageData });
|
|
281
282
|
}
|
|
282
283
|
}, socket: this.props.socket })) : null,
|
|
283
|
-
|
|
284
|
-
React.createElement(Box, { style: titleStyle, sx: theme => ({ color: theme.palette.secondary.contrastText }) }, this.state.details?.data?.name || this.props.title),
|
|
284
|
+
icon),
|
|
285
|
+
React.createElement(Box, { style: titleStyle, title: title.length > 20 ? title : undefined, sx: theme => ({ color: theme.palette.secondary.contrastText }) }, this.state.details?.data?.name || this.props.title),
|
|
285
286
|
this.props.device.hasDetails ? (React.createElement(Fab, { disabled: !this.props.alive, size: "small", style: detailsButtonStyle, onClick: () => {
|
|
286
287
|
if (!this.state.open) {
|
|
287
288
|
this.loadDetails().catch(console.error);
|
package/build/DeviceCard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCard.js","sourceRoot":"./src/","sources":["DeviceCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,OAAO,EACH,MAAM,EACN,UAAU,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,GAAG,EACH,WAAW,EACX,IAAI,EACJ,WAAW,EACX,UAAU,EACV,WAAW,EACX,KAAK,EACL,GAAG,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,cAAc,IAAI,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAElH,OAAO,EACH,KAAK,EACL,IAAI,EAEJ,IAAI,GAIP,MAAM,4BAA4B,CAAC;AAGpC,OAAO,kBAAkB,MAAM,sBAAs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EAAE,CACvB,CACX,CAAC;IACN,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACvB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { Component, type JSX } from 'react';\n\nimport {\n Button,\n Typography,\n Dialog,\n DialogActions,\n DialogContent,\n IconButton,\n Fab,\n DialogTitle,\n Card,\n CardActions,\n CardHeader,\n CardContent,\n Paper,\n Box,\n} from '@mui/material';\n\nimport { MoreVert as MoreVertIcon, VideogameAsset as ControlIcon, Close as CloseIcon } from '@mui/icons-material';\n\nimport {\n Utils,\n Icon,\n type Connection,\n I18n,\n type ThemeName,\n type ThemeType,\n type IobTheme,\n} from '@iobroker/adapter-react-v5';\nimport type { DeviceDetails, DeviceInfo, ActionBase, ControlBase, ControlState } from '@iobroker/dm-utils';\n\nimport DeviceActionButton from './DeviceActionButton';\nimport DeviceControlComponent from './DeviceControl';\nimport DeviceStatusComponent from './DeviceStatus';\nimport JsonConfig from './JsonConfig';\nimport DeviceImageUpload from './DeviceImageUpload';\nimport { getTranslation } from './Utils';\n\nfunction NoImageIcon(props: { style?: React.CSSProperties; className?: string }): JSX.Element {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"24\"\n height=\"24\"\n style={props.style}\n className={props.className}\n >\n <path\n fill=\"currentColor\"\n d=\"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z\"\n />\n </svg>\n );\n}\n\ninterface DeviceCardProps {\n title?: string;\n /* Device ID */\n id: string;\n device: DeviceInfo;\n instanceId: string;\n socket: Connection;\n /* Instance, where the images should be uploaded to */\n uploadImagesToInstance?: string;\n deviceHandler: (deviceId: string, action: ActionBase, refresh: () => void) => () => void;\n controlHandler: (\n deviceId: string,\n control: ControlBase,\n state: ControlState,\n ) => () => Promise<ioBroker.State | null>;\n controlStateHandler: (deviceId: string, control: ControlBase) => () => Promise<ioBroker.State | null>;\n smallCards?: boolean;\n alive: boolean;\n themeName: ThemeName;\n themeType: ThemeType;\n theme: IobTheme;\n isFloatComma: boolean;\n dateFormat: string;\n}\n\nfunction getText(text: ioBroker.StringOrTranslated | undefined): string | undefined {\n if (typeof text === 'object') {\n return text[I18n.getLanguage()] || text.en;\n }\n\n return text;\n}\n\ninterface DeviceCardState {\n open: boolean;\n details: DeviceDetails | null;\n data: Record<string, any>;\n icon: string | undefined;\n showControlDialog: boolean;\n}\n\n/**\n * Device Card Component\n */\nclass DeviceCard extends Component<DeviceCardProps, DeviceCardState> {\n constructor(props: DeviceCardProps) {\n super(props);\n\n this.state = {\n open: false,\n details: null,\n data: {},\n icon: props.device.icon,\n showControlDialog: false,\n };\n }\n\n async fetchIcon(): Promise<void> {\n if (!this.props.device.icon) {\n const lang = I18n.getLanguage();\n const manufacturer =\n this.props.device.manufacturer && typeof this.props.device.manufacturer === 'object'\n ? this.props.device.manufacturer[lang] || this.props.device.manufacturer.en\n : this.props.device.manufacturer;\n const model =\n this.props.device.model && typeof this.props.device.model === 'object'\n ? this.props.device.model[lang] || this.props.device.model.en\n : this.props.device.model;\n\n // try to load the icon from file storage\n const fileName = `${manufacturer ? `${manufacturer}_` : ''}${model || this.props.device.id}`;\n\n try {\n const file = await this.props.socket.readFile(\n this.props.instanceId.replace('system.adapter.', ''),\n `${fileName}.webp`,\n true,\n );\n if (file) {\n this.setState({ icon: `data:image/${file.mimeType},${file.file}` });\n } else {\n this.setState({ icon: '' });\n }\n // const response = await fetch(url);\n // if (response.ok) {\n // const blob = await response.blob();\n // const reader = new FileReader();\n // reader.onloadend = () => {\n // setIcon(reader.result);\n // };\n // reader.readAsDataURL(blob);\n // } else {\n // throw new Error('Response not ok');\n // }\n } catch {\n if (this.state.icon) {\n this.setState({ icon: '' });\n }\n }\n }\n }\n\n componentDidMount(): void {\n this.fetchIcon().catch(e => console.error(e));\n }\n\n /**\n * Load the device details\n */\n async loadDetails(): Promise<void> {\n console.log(`Loading device details for ${this.props.device.id}... from ${this.props.instanceId}`);\n const details: DeviceDetails | null = await this.props.socket.sendTo(\n this.props.instanceId,\n 'dm:deviceDetails',\n this.props.device.id,\n );\n console.log(`Got device details for ${this.props.device.id}:`, details);\n this.setState({ details, data: details?.data || {} });\n }\n\n /**\n * Refresh the device details\n */\n refresh = (): void => {\n this.setState({ details: null });\n this.loadDetails().catch(console.error);\n };\n\n /**\n * Copy the device ID to the clipboard\n */\n copyToClipboard = (): void => {\n const textToCopy = this.props.device.id;\n Utils.copyToClipboard(textToCopy);\n alert(`${getTranslation('copied')} ${textToCopy} ${getTranslation('toClipboard')}!`);\n };\n\n renderDialog(): JSX.Element | null {\n if (!this.state.open || !this.state.details) {\n return null;\n }\n\n return (\n <Dialog\n open={!0}\n maxWidth=\"md\"\n onClose={() => this.setState({ open: false })}\n >\n <DialogContent>\n <JsonConfig\n instanceId={this.props.instanceId}\n socket={this.props.socket}\n schema={this.state.details.schema}\n data={this.state.data}\n onChange={(data: Record<string, any>) => this.setState({ data })}\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 </DialogContent>\n <DialogActions>\n <Button\n disabled={!this.props.alive}\n variant=\"contained\"\n color=\"primary\"\n onClick={() => this.setState({ open: false })}\n autoFocus\n >\n {getTranslation('closeButtonText')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n }\n\n renderControlDialog(): JSX.Element | null {\n if (!this.state.showControlDialog || !this.props.alive) {\n return null;\n }\n const colors = { primary: '#111', secondary: '#888' };\n return (\n <Dialog\n open={!0}\n onClose={() => this.setState({ showControlDialog: false })}\n >\n <DialogTitle>\n {this.props.title}\n <IconButton\n style={{\n position: 'absolute',\n top: 5,\n right: 5,\n zIndex: 10,\n }}\n onClick={() => this.setState({ showControlDialog: false })}\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n <DialogContent style={{ display: 'flex', flexDirection: 'column' }}>\n {this.props.device.controls?.map(control => (\n <DeviceControlComponent\n disabled={false}\n key={control.id}\n control={control}\n socket={this.props.socket}\n colors={colors}\n deviceId={this.props.device.id}\n controlHandler={this.props.controlHandler}\n controlStateHandler={this.props.controlStateHandler}\n />\n ))}\n </DialogContent>\n </Dialog>\n );\n }\n\n renderControls(): JSX.Element | null {\n const colors = { primary: '#111', secondary: '#888' };\n const firstControl = this.props.device.controls?.[0];\n if (\n this.props.device.controls?.length === 1 &&\n firstControl &&\n (firstControl.type === 'icon' || firstControl.type === 'switch') &&\n !firstControl.label\n ) {\n // control can be placed in button icon\n return (\n <DeviceControlComponent\n disabled={!this.props.alive}\n control={firstControl}\n colors={colors}\n socket={this.props.socket}\n deviceId={this.props.device.id}\n controlHandler={this.props.controlHandler}\n controlStateHandler={this.props.controlStateHandler}\n />\n );\n }\n\n if (this.props.device.controls?.length) {\n // place button and show controls dialog\n return (\n <Fab\n size=\"small\"\n disabled={!this.props.alive}\n onClick={() => this.setState({ showControlDialog: true })}\n >\n <ControlIcon />\n </Fab>\n );\n }\n return null;\n }\n\n renderActions(): JSX.Element[] | null {\n return this.props.device.actions?.length\n ? this.props.device.actions.map(a => (\n <DeviceActionButton\n disabled={!this.props.alive}\n key={a.id}\n deviceId={this.props.device.id}\n action={a}\n deviceHandler={this.props.deviceHandler}\n refresh={this.refresh}\n />\n ))\n : null;\n }\n\n renderSmall(): JSX.Element {\n const hasDetails = this.props.device.hasDetails;\n const status = !this.props.device.status\n ? []\n : Array.isArray(this.props.device.status)\n ? this.props.device.status\n : [this.props.device.status];\n\n return (\n <Card\n sx={{\n maxWidth: 345,\n minWidth: 200,\n }}\n >\n <CardHeader\n sx={theme => ({\n backgroundColor: this.props.device.color || theme.palette.secondary.main,\n color: this.props.device.color\n ? Utils.invertColor(this.props.device.color, true)\n : theme.palette.secondary.contrastText,\n maxWidth: 345,\n })}\n avatar={\n <div>\n {this.props.uploadImagesToInstance ? (\n <DeviceImageUpload\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceId={this.props.device.id}\n manufacturer={getText(this.props.device.manufacturer)}\n model={getText(this.props.device.model)}\n onImageSelect={(imageData: string): void => {\n if (imageData) {\n this.setState({ icon: imageData });\n }\n }}\n socket={this.props.socket}\n />\n ) : null}\n {this.state.icon ? <Icon src={this.state.icon} /> : <NoImageIcon />}\n </div>\n }\n action={\n hasDetails ? (\n <IconButton\n aria-label=\"settings\"\n onClick={() => {\n if (!this.state.open) {\n this.loadDetails().catch(console.error);\n this.setState({ open: true });\n }\n }}\n >\n <MoreVertIcon />\n </IconButton>\n ) : null\n }\n title={this.props.title}\n subheader={\n this.props.device.manufacturer ? (\n <span>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </span>\n ) : null\n }\n />\n <CardContent style={{ position: 'relative' }}>\n {status?.length ? (\n <div\n style={{\n display: 'flex',\n position: 'absolute',\n top: -11,\n background: '#88888880',\n padding: '0 8px',\n borderRadius: 5,\n width: 'calc(100% - 46px)',\n }}\n >\n {status.map((s, i) => (\n <DeviceStatusComponent\n key={i}\n status={s}\n />\n ))}\n </div>\n ) : null}\n <div>\n <Typography variant=\"body1\">\n <div\n onClick={this.copyToClipboard}\n style={{ textOverflow: 'ellipsis', overflow: 'hidden' }}\n >\n <b>ID:</b>\n <span style={{ marginLeft: 4 }}>{this.props.device.id.replace(/.*\\.\\d\\./, '')}</span>\n </div>\n {this.props.device.manufacturer ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </div>\n ) : null}\n {this.props.device.model ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('model')}:</b>\n {getText(this.props.device.model)}\n </div>\n ) : null}\n </Typography>\n </div>\n </CardContent>\n <CardActions disableSpacing>\n {this.renderActions()}\n <div style={{ flexGrow: 1 }} />\n {this.renderControls()}\n </CardActions>\n {this.renderDialog()}\n {this.renderControlDialog()}\n </Card>\n );\n }\n\n renderBig(): JSX.Element {\n const cardStyle: React.CSSProperties = {\n width: 300,\n minHeight: 280,\n margin: 10,\n overflow: 'hidden',\n display: 'inline-block',\n };\n const headerStyle: React.CSSProperties = {\n display: 'flex',\n position: 'relative',\n justifyContent: 'space-between',\n minHeight: 60,\n color: '#000',\n padding: '0 10px 0 10px',\n borderRadius: '4px 4px 0 0',\n };\n const imgAreaStyle: React.CSSProperties = {\n height: 45,\n width: 45,\n margin: 'auto',\n justifyContent: 'center',\n display: 'grid',\n };\n const imgStyle: React.CSSProperties = {\n zIndex: 2,\n maxWidth: '100%',\n maxHeight: '100%',\n };\n const titleStyle: React.CSSProperties = {\n width: '100%',\n fontSize: 16,\n fontWeight: 'bold',\n paddingTop: 16,\n paddingLeft: 8,\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n };\n const detailsButtonStyle: React.CSSProperties = {\n right: 20,\n bottom: -20,\n position: 'absolute',\n };\n const bodyStyle: React.CSSProperties = {\n height: 'calc(100% - 116px)',\n };\n const deviceInfoStyle: React.CSSProperties = {\n padding: '20px 16px 0 16px',\n height: 133,\n };\n const statusStyle: React.CSSProperties = {\n padding: '15px 15px 0 15px',\n height: 41,\n };\n const status = !this.props.device.status\n ? []\n : Array.isArray(this.props.device.status)\n ? this.props.device.status\n : [this.props.device.status];\n\n return (\n <Paper\n style={cardStyle}\n key={this.props.id}\n >\n <Box\n sx={theme => ({ backgroundColor: theme.palette.secondary.main })}\n style={headerStyle}\n >\n <div style={imgAreaStyle}>\n {this.props.uploadImagesToInstance ? (\n <DeviceImageUpload\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceId={this.props.device.id}\n manufacturer={getText(this.props.device.manufacturer)}\n model={getText(this.props.device.model)}\n onImageSelect={(imageData: string): void => {\n if (imageData) {\n this.setState({ icon: imageData });\n }\n }}\n socket={this.props.socket}\n />\n ) : null}\n <Icon\n src={this.state.icon}\n style={imgStyle}\n />\n </div>\n <Box\n style={titleStyle}\n sx={theme => ({ color: theme.palette.secondary.contrastText })}\n >\n {this.state.details?.data?.name || this.props.title}\n </Box>\n {this.props.device.hasDetails ? (\n <Fab\n disabled={!this.props.alive}\n size=\"small\"\n style={detailsButtonStyle}\n onClick={() => {\n if (!this.state.open) {\n this.loadDetails().catch(console.error);\n this.setState({ open: true });\n }\n }}\n color=\"primary\"\n >\n <MoreVertIcon />\n </Fab>\n ) : null}\n </Box>\n <div style={statusStyle}>\n {status.map((s, i) => (\n <DeviceStatusComponent\n key={i}\n status={s}\n />\n ))}\n </div>\n <div style={bodyStyle}>\n <Typography\n variant=\"body1\"\n style={deviceInfoStyle}\n >\n <div onClick={this.copyToClipboard}>\n <b style={{ marginRight: 4 }}>ID:</b>\n {this.props.device.id.replace(/.*\\.\\d\\./, '')}\n </div>\n {this.props.device.manufacturer ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </div>\n ) : null}\n {this.props.device.model ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('model')}:</b>\n {getText(this.props.device.model)}\n </div>\n ) : null}\n </Typography>\n {!!this.props.device.actions?.length && (\n <div\n style={{\n flex: 1,\n position: 'relative',\n display: 'flex',\n gap: 8,\n paddingBottom: 5,\n height: 34,\n paddingLeft: 10,\n paddingRight: 10,\n }}\n >\n {this.renderActions()}\n <div style={{ flexGrow: 1 }} />\n {this.renderControls()}\n </div>\n )}\n </div>\n {this.renderDialog()}\n {this.renderControlDialog()}\n </Paper>\n );\n }\n\n render(): JSX.Element {\n if (this.props.smallCards) {\n return this.renderSmall();\n }\n\n return this.renderBig();\n }\n}\n\n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n Typography,\n Dialog,\n DialogActions,\n DialogContent,\n IconButton,\n Fab,\n DialogTitle,\n Card,\n CardActions,\n CardHeader,\n CardContent,\n Paper,\n Box,\n} from '@mui/material';\n\nimport { MoreVert as MoreVertIcon, VideogameAsset as ControlIcon, Close as CloseIcon } from '@mui/icons-material';\n\nimport {\n Utils,\n type Connection,\n I18n,\n type ThemeName,\n type ThemeType,\n type IobTheme,\n IconDeviceType,\n} from '@iobroker/adapter-react-v5';\nimport type { DeviceDetails, DeviceInfo, ActionBase, ControlBase, ControlState } from '@iobroker/dm-utils';\n\nimport DeviceActionButton from './DeviceActionButton';\nimport DeviceControlComponent from './DeviceControl';\nimport DeviceStatusComponent from './DeviceStatus';\nimport JsonConfig from './JsonConfig';\nimport DeviceImageUpload from './DeviceImageUpload';\nimport { getTranslation } from './Utils';\n\nfunction NoImageIcon(props: { style?: React.CSSProperties; className?: string }): JSX.Element {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"24\"\n height=\"24\"\n style={props.style}\n className={props.className}\n >\n <path\n fill=\"currentColor\"\n d=\"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z\"\n />\n </svg>\n );\n}\n\ninterface DeviceCardProps {\n title?: string;\n /* Device ID */\n id: string;\n device: DeviceInfo;\n instanceId: string;\n socket: Connection;\n /* Instance, where the images should be uploaded to */\n uploadImagesToInstance?: string;\n deviceHandler: (deviceId: string, action: ActionBase, refresh: () => void) => () => void;\n controlHandler: (\n deviceId: string,\n control: ControlBase,\n state: ControlState,\n ) => () => Promise<ioBroker.State | null>;\n controlStateHandler: (deviceId: string, control: ControlBase) => () => Promise<ioBroker.State | null>;\n smallCards?: boolean;\n alive: boolean;\n themeName: ThemeName;\n themeType: ThemeType;\n theme: IobTheme;\n isFloatComma: boolean;\n dateFormat: string;\n}\n\nfunction getText(text: ioBroker.StringOrTranslated | undefined): string | undefined {\n if (typeof text === 'object') {\n return text[I18n.getLanguage()] || text.en;\n }\n\n return text;\n}\n\ninterface DeviceCardState {\n open: boolean;\n details: DeviceDetails | null;\n data: Record<string, any>;\n icon: string | undefined;\n showControlDialog: boolean;\n}\n\n/**\n * Device Card Component\n */\nclass DeviceCard extends Component<DeviceCardProps, DeviceCardState> {\n constructor(props: DeviceCardProps) {\n super(props);\n\n this.state = {\n open: false,\n details: null,\n data: {},\n icon: props.device.icon,\n showControlDialog: false,\n };\n }\n\n async fetchIcon(): Promise<void> {\n if (!this.props.device.icon) {\n const lang = I18n.getLanguage();\n const manufacturer =\n this.props.device.manufacturer && typeof this.props.device.manufacturer === 'object'\n ? this.props.device.manufacturer[lang] || this.props.device.manufacturer.en\n : this.props.device.manufacturer;\n const model =\n this.props.device.model && typeof this.props.device.model === 'object'\n ? this.props.device.model[lang] || this.props.device.model.en\n : this.props.device.model;\n\n // try to load the icon from file storage\n const fileName = `${manufacturer ? `${manufacturer}_` : ''}${model || this.props.device.id}`;\n\n try {\n const file = await this.props.socket.readFile(\n this.props.instanceId.replace('system.adapter.', ''),\n `${fileName}.webp`,\n true,\n );\n if (file) {\n this.setState({ icon: `data:image/${file.mimeType},${file.file}` });\n } else {\n this.setState({ icon: '' });\n }\n // const response = await fetch(url);\n // if (response.ok) {\n // const blob = await response.blob();\n // const reader = new FileReader();\n // reader.onloadend = () => {\n // setIcon(reader.result);\n // };\n // reader.readAsDataURL(blob);\n // } else {\n // throw new Error('Response not ok');\n // }\n } catch {\n if (this.state.icon) {\n this.setState({ icon: '' });\n }\n }\n }\n }\n\n componentDidMount(): void {\n this.fetchIcon().catch(e => console.error(e));\n }\n\n /**\n * Load the device details\n */\n async loadDetails(): Promise<void> {\n console.log(`Loading device details for ${this.props.device.id}... from ${this.props.instanceId}`);\n const details: DeviceDetails | null = await this.props.socket.sendTo(\n this.props.instanceId,\n 'dm:deviceDetails',\n this.props.device.id,\n );\n console.log(`Got device details for ${this.props.device.id}:`, details);\n this.setState({ details, data: details?.data || {} });\n }\n\n /**\n * Refresh the device details\n */\n refresh = (): void => {\n this.setState({ details: null });\n this.loadDetails().catch(console.error);\n };\n\n /**\n * Copy the device ID to the clipboard\n */\n copyToClipboard = (): void => {\n const textToCopy = this.props.device.id;\n Utils.copyToClipboard(textToCopy);\n alert(`${getTranslation('copied')} ${textToCopy} ${getTranslation('toClipboard')}!`);\n };\n\n renderDialog(): JSX.Element | null {\n if (!this.state.open || !this.state.details) {\n return null;\n }\n\n return (\n <Dialog\n open={!0}\n maxWidth=\"md\"\n onClose={() => this.setState({ open: false })}\n >\n <DialogContent>\n <JsonConfig\n instanceId={this.props.instanceId}\n socket={this.props.socket}\n schema={this.state.details.schema}\n data={this.state.data}\n onChange={(data: Record<string, any>) => this.setState({ data })}\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 </DialogContent>\n <DialogActions>\n <Button\n disabled={!this.props.alive}\n variant=\"contained\"\n color=\"primary\"\n onClick={() => this.setState({ open: false })}\n autoFocus\n >\n {getTranslation('closeButtonText')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n }\n\n renderControlDialog(): JSX.Element | null {\n if (!this.state.showControlDialog || !this.props.alive) {\n return null;\n }\n const colors = { primary: '#111', secondary: '#888' };\n return (\n <Dialog\n open={!0}\n onClose={() => this.setState({ showControlDialog: false })}\n >\n <DialogTitle>\n {this.props.title}\n <IconButton\n style={{\n position: 'absolute',\n top: 5,\n right: 5,\n zIndex: 10,\n }}\n onClick={() => this.setState({ showControlDialog: false })}\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n <DialogContent style={{ display: 'flex', flexDirection: 'column' }}>\n {this.props.device.controls?.map(control => (\n <DeviceControlComponent\n disabled={false}\n key={control.id}\n control={control}\n socket={this.props.socket}\n colors={colors}\n deviceId={this.props.device.id}\n controlHandler={this.props.controlHandler}\n controlStateHandler={this.props.controlStateHandler}\n />\n ))}\n </DialogContent>\n </Dialog>\n );\n }\n\n renderControls(): JSX.Element | null {\n const colors = { primary: '#111', secondary: '#888' };\n const firstControl = this.props.device.controls?.[0];\n if (\n this.props.device.controls?.length === 1 &&\n firstControl &&\n (firstControl.type === 'icon' || firstControl.type === 'switch') &&\n !firstControl.label\n ) {\n // control can be placed in button icon\n return (\n <DeviceControlComponent\n disabled={!this.props.alive}\n control={firstControl}\n colors={colors}\n socket={this.props.socket}\n deviceId={this.props.device.id}\n controlHandler={this.props.controlHandler}\n controlStateHandler={this.props.controlStateHandler}\n />\n );\n }\n\n if (this.props.device.controls?.length) {\n // place button and show controls dialog\n return (\n <Fab\n size=\"small\"\n disabled={!this.props.alive}\n onClick={() => this.setState({ showControlDialog: true })}\n >\n <ControlIcon />\n </Fab>\n );\n }\n return null;\n }\n\n renderActions(): JSX.Element[] | null {\n return this.props.device.actions?.length\n ? this.props.device.actions.map(a => (\n <DeviceActionButton\n disabled={!this.props.alive}\n key={a.id}\n deviceId={this.props.device.id}\n action={a}\n deviceHandler={this.props.deviceHandler}\n refresh={this.refresh}\n />\n ))\n : null;\n }\n\n renderSmall(): JSX.Element {\n const hasDetails = this.props.device.hasDetails;\n const status = !this.props.device.status\n ? []\n : Array.isArray(this.props.device.status)\n ? this.props.device.status\n : [this.props.device.status];\n\n const icon = this.state.icon ? <IconDeviceType src={this.state.icon} /> : <NoImageIcon />;\n\n return (\n <Card\n sx={{\n maxWidth: 345,\n minWidth: 200,\n }}\n >\n <CardHeader\n sx={theme => ({\n backgroundColor: this.props.device.color || theme.palette.secondary.main,\n color: this.props.device.color\n ? Utils.invertColor(this.props.device.color, true)\n : theme.palette.secondary.contrastText,\n maxWidth: 345,\n })}\n avatar={\n <div>\n {this.props.uploadImagesToInstance ? (\n <DeviceImageUpload\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceId={this.props.device.id}\n manufacturer={getText(this.props.device.manufacturer)}\n model={getText(this.props.device.model)}\n onImageSelect={(imageData: string): void => {\n if (imageData) {\n this.setState({ icon: imageData });\n }\n }}\n socket={this.props.socket}\n />\n ) : null}\n {icon}\n </div>\n }\n action={\n hasDetails ? (\n <IconButton\n aria-label=\"settings\"\n onClick={() => {\n if (!this.state.open) {\n this.loadDetails().catch(console.error);\n this.setState({ open: true });\n }\n }}\n >\n <MoreVertIcon />\n </IconButton>\n ) : null\n }\n title={this.props.title}\n subheader={\n this.props.device.manufacturer ? (\n <span>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </span>\n ) : null\n }\n />\n <CardContent style={{ position: 'relative' }}>\n {status?.length ? (\n <div\n style={{\n display: 'flex',\n position: 'absolute',\n top: -11,\n background: '#88888880',\n padding: '0 8px',\n borderRadius: 5,\n width: 'calc(100% - 46px)',\n }}\n >\n {status.map((s, i) => (\n <DeviceStatusComponent\n key={i}\n status={s}\n />\n ))}\n </div>\n ) : null}\n <div>\n <Typography variant=\"body1\">\n <div\n onClick={this.copyToClipboard}\n style={{ textOverflow: 'ellipsis', overflow: 'hidden' }}\n >\n <b>ID:</b>\n <span style={{ marginLeft: 4 }}>{this.props.device.id.replace(/.*\\.\\d\\./, '')}</span>\n </div>\n {this.props.device.manufacturer ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </div>\n ) : null}\n {this.props.device.model ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('model')}:</b>\n {getText(this.props.device.model)}\n </div>\n ) : null}\n </Typography>\n </div>\n </CardContent>\n <CardActions disableSpacing>\n {this.renderActions()}\n <div style={{ flexGrow: 1 }} />\n {this.renderControls()}\n </CardActions>\n {this.renderDialog()}\n {this.renderControlDialog()}\n </Card>\n );\n }\n\n renderBig(): JSX.Element {\n const cardStyle: React.CSSProperties = {\n width: 300,\n minHeight: 280,\n margin: 10,\n overflow: 'hidden',\n display: 'inline-block',\n };\n const headerStyle: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n paddingLeft: 8,\n position: 'relative',\n minHeight: 60,\n color: '#000',\n };\n const imgAreaStyle: React.CSSProperties = {\n height: 45,\n width: 45,\n justifyContent: 'center',\n display: 'flex',\n alignItems: 'center',\n };\n const imgStyle: React.CSSProperties = {\n zIndex: 2,\n maxWidth: '100%',\n maxHeight: '100%',\n color: '#FFF',\n };\n const titleStyle: React.CSSProperties = {\n fontSize: 16,\n fontWeight: 'bold',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n };\n const detailsButtonStyle: React.CSSProperties = {\n right: 20,\n bottom: -20,\n position: 'absolute',\n };\n const bodyStyle: React.CSSProperties = {\n height: 'calc(100% - 116px)',\n };\n const deviceInfoStyle: React.CSSProperties = {\n padding: '20px 16px 0 16px',\n height: 133,\n };\n const statusStyle: React.CSSProperties = {\n padding: '15px 15px 0 15px',\n height: 41,\n };\n const status = !this.props.device.status\n ? []\n : Array.isArray(this.props.device.status)\n ? this.props.device.status\n : [this.props.device.status];\n\n const icon = this.state.icon ? (\n <IconDeviceType\n src={this.state.icon}\n style={imgStyle}\n />\n ) : (\n <NoImageIcon style={imgStyle} />\n );\n\n const title: string = this.state.details?.data?.name || this.props.title || '';\n\n return (\n <Paper\n style={cardStyle}\n key={this.props.id}\n >\n <Box\n sx={theme => ({ backgroundColor: theme.palette.secondary.main })}\n style={headerStyle}\n >\n <div style={imgAreaStyle}>\n {this.props.uploadImagesToInstance ? (\n <DeviceImageUpload\n uploadImagesToInstance={this.props.uploadImagesToInstance}\n deviceId={this.props.device.id}\n manufacturer={getText(this.props.device.manufacturer)}\n model={getText(this.props.device.model)}\n onImageSelect={(imageData: string): void => {\n if (imageData) {\n this.setState({ icon: imageData });\n }\n }}\n socket={this.props.socket}\n />\n ) : null}\n {icon}\n </div>\n <Box\n style={titleStyle}\n title={title.length > 20 ? title : undefined}\n sx={theme => ({ color: theme.palette.secondary.contrastText })}\n >\n {this.state.details?.data?.name || this.props.title}\n </Box>\n {this.props.device.hasDetails ? (\n <Fab\n disabled={!this.props.alive}\n size=\"small\"\n style={detailsButtonStyle}\n onClick={() => {\n if (!this.state.open) {\n this.loadDetails().catch(console.error);\n this.setState({ open: true });\n }\n }}\n color=\"primary\"\n >\n <MoreVertIcon />\n </Fab>\n ) : null}\n </Box>\n <div style={statusStyle}>\n {status.map((s, i) => (\n <DeviceStatusComponent\n key={i}\n status={s}\n />\n ))}\n </div>\n <div style={bodyStyle}>\n <Typography\n variant=\"body1\"\n style={deviceInfoStyle}\n >\n <div onClick={this.copyToClipboard}>\n <b style={{ marginRight: 4 }}>ID:</b>\n {this.props.device.id.replace(/.*\\.\\d\\./, '')}\n </div>\n {this.props.device.manufacturer ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('manufacturer')}:</b>\n {getText(this.props.device.manufacturer)}\n </div>\n ) : null}\n {this.props.device.model ? (\n <div>\n <b style={{ marginRight: 4 }}>{getTranslation('model')}:</b>\n {getText(this.props.device.model)}\n </div>\n ) : null}\n </Typography>\n {!!this.props.device.actions?.length && (\n <div\n style={{\n flex: 1,\n position: 'relative',\n display: 'flex',\n gap: 8,\n paddingBottom: 5,\n height: 34,\n paddingLeft: 10,\n paddingRight: 10,\n }}\n >\n {this.renderActions()}\n <div style={{ flexGrow: 1 }} />\n {this.renderControls()}\n </div>\n )}\n </div>\n {this.renderDialog()}\n {this.renderControlDialog()}\n </Paper>\n );\n }\n\n render(): JSX.Element {\n if (this.props.smallCards) {\n return this.renderSmall();\n }\n\n return this.renderBig();\n }\n}\n\nexport default DeviceCard;\n"]}
|
package/build/DeviceList.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ interface DeviceListProps extends CommunicationProps {
|
|
|
14
14
|
style?: React.CSSProperties;
|
|
15
15
|
/** Use small cards for devices */
|
|
16
16
|
smallCards?: boolean;
|
|
17
|
+
/** To trigger the reload of devices, just change this variable */
|
|
18
|
+
triggerLoad?: number;
|
|
17
19
|
}
|
|
18
20
|
interface DeviceListState extends CommunicationState {
|
|
19
21
|
devices: DeviceInfo[];
|
|
@@ -22,6 +24,7 @@ interface DeviceListState extends CommunicationState {
|
|
|
22
24
|
instanceInfo: InstanceDetails;
|
|
23
25
|
loading: boolean;
|
|
24
26
|
alive: boolean | null;
|
|
27
|
+
triggerLoad: number;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Device List Component
|
|
@@ -30,6 +33,7 @@ export default class DeviceList extends Communication<DeviceListProps, DeviceLis
|
|
|
30
33
|
static i18nInitialized: boolean;
|
|
31
34
|
private lastPropsFilter;
|
|
32
35
|
private lastInstance;
|
|
36
|
+
private lastTriggerLoad;
|
|
33
37
|
private filterTimeout;
|
|
34
38
|
private readonly language;
|
|
35
39
|
constructor(props: DeviceListProps);
|
package/build/DeviceList.js
CHANGED
|
@@ -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,6 +161,10 @@ 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);
|
package/build/DeviceList.js.map
CHANGED
|
@@ -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;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;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,IAAI,MAAM,mBAAmB,CAAC;AA0BrC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,aAA+C;IACn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C,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACxB,YAAY,EAAC,KAAK,EAClB,SAAS,EAAE;wBACP,KAAK,EAAE;4BACH,YAAY,EAAE,cAAc;4BAC5B,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAC9B,oBAAC,cAAc,IAAC,QAAQ,EAAC,KAAK;gCAC1B,oBAAC,UAAU,IACP,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAC1C,IAAI,EAAC,KAAK;oCAEV,oBAAC,KAAK,OAAG,CACA,CACA,CACpB,CAAC,CAAC,CAAC,IAAI;yBACX;wBACD,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}\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":"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AAC,iBAAiB,CAAC,EACxC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACxB,YAAY,EAAC,KAAK,EAClB,SAAS,EAAE;wBACP,KAAK,EAAE;4BACH,YAAY,EAAE,cAAc;4BAC5B,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAC9B,oBAAC,cAAc,IAAC,QAAQ,EAAC,KAAK;gCAC1B,oBAAC,UAAU,IACP,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAC1C,IAAI,EAAC,KAAK;oCAEV,oBAAC,KAAK,OAAG,CACA,CACA,CACpB,CAAC,CAAC,CAAC,IAAI;yBACX;wBACD,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 (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"]}
|
package/build/Utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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, 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
4
|
function getFaIcon(icon, color) {
|
|
5
5
|
const iconStyle = icon
|
|
@@ -71,67 +71,81 @@ function getFaIcon(icon, color) {
|
|
|
71
71
|
}
|
|
72
72
|
return React.createElement(QuestionMark, { style: { color } });
|
|
73
73
|
}
|
|
74
|
-
function getIconByName(name, color) {
|
|
75
|
-
if (name === 'edit' || name === 'rename') {
|
|
74
|
+
function getIconByName(name, altName, color) {
|
|
75
|
+
if (name === 'edit' || name === 'rename' || altName === 'edit' || altName === 'rename') {
|
|
76
76
|
return React.createElement(Edit, { style: { color } });
|
|
77
77
|
}
|
|
78
|
-
if (name === 'delete') {
|
|
78
|
+
if (name === 'delete' || altName === 'delete') {
|
|
79
79
|
return React.createElement(Delete, { style: { color } });
|
|
80
80
|
}
|
|
81
|
-
if (name === 'refresh') {
|
|
81
|
+
if (name === 'refresh' || altName === 'refresh') {
|
|
82
82
|
return React.createElement(Refresh, { style: { color } });
|
|
83
83
|
}
|
|
84
|
-
if (name === 'newDevice' ||
|
|
84
|
+
if (name === 'newDevice' ||
|
|
85
|
+
name === 'new' ||
|
|
86
|
+
name === 'add' ||
|
|
87
|
+
altName === 'newDevice' ||
|
|
88
|
+
altName === 'new' ||
|
|
89
|
+
altName === 'add') {
|
|
85
90
|
return React.createElement(Add, { style: { color } });
|
|
86
91
|
}
|
|
87
|
-
if (name === 'discover' || name === 'search') {
|
|
92
|
+
if (name === 'discover' || name === 'search' || altName === 'discover' || altName === 'search') {
|
|
88
93
|
return React.createElement(Search, { style: { color } });
|
|
89
94
|
}
|
|
90
|
-
if (name === 'unpairDevice' || name === 'unpair') {
|
|
95
|
+
if (name === 'unpairDevice' || name === 'unpair' || altName === 'unpairDevice' || altName === 'unpair') {
|
|
91
96
|
return React.createElement(LinkOff, { style: { color } });
|
|
92
97
|
}
|
|
93
|
-
if (name === 'pairDevice' || name === 'pair') {
|
|
98
|
+
if (name === 'pairDevice' || name === 'pair' || altName === 'pairDevice' || altName === 'pair') {
|
|
94
99
|
return React.createElement(LinkIcon, { style: { color } });
|
|
95
100
|
}
|
|
96
|
-
if (name === 'identify') {
|
|
101
|
+
if (name === 'identify' || altName === 'identify') {
|
|
97
102
|
return React.createElement(NotListedLocation, { style: { color } });
|
|
98
103
|
}
|
|
99
|
-
if (name === 'play') {
|
|
104
|
+
if (name === 'play' || altName === 'play') {
|
|
100
105
|
return React.createElement(PlayArrow, { style: { color } });
|
|
101
106
|
}
|
|
102
|
-
if (name === 'stop') {
|
|
107
|
+
if (name === 'stop' || altName === 'stop') {
|
|
103
108
|
return React.createElement(Stop, { style: { color } });
|
|
104
109
|
}
|
|
105
|
-
if (name === 'pause') {
|
|
110
|
+
if (name === 'pause' || altName === 'pause') {
|
|
106
111
|
return React.createElement(Pause, { style: { color } });
|
|
107
112
|
}
|
|
108
|
-
if (name === 'forward' || name === 'next') {
|
|
113
|
+
if (name === 'forward' || name === 'next' || altName === 'forward' || altName === 'next') {
|
|
109
114
|
return React.createElement(FastForward, { style: { color } });
|
|
110
115
|
}
|
|
111
|
-
if (name === 'rewind' || name === 'previous') {
|
|
116
|
+
if (name === 'rewind' || name === 'previous' || altName === 'rewind' || altName === 'previous') {
|
|
112
117
|
return React.createElement(FastRewind, { style: { color } });
|
|
113
118
|
}
|
|
114
|
-
if (name === 'lamp' || name === 'light') {
|
|
119
|
+
if (name === 'lamp' || name === 'light' || altName === 'lamp' || altName === 'light') {
|
|
115
120
|
return React.createElement(Lightbulb, { style: { color } });
|
|
116
121
|
}
|
|
117
|
-
if (name === 'backlight') {
|
|
122
|
+
if (name === 'backlight' || altName === 'backlight') {
|
|
118
123
|
return React.createElement(Fluorescent, { style: { color } });
|
|
119
124
|
}
|
|
120
|
-
if (name === 'dimmer') {
|
|
125
|
+
if (name === 'dimmer' || altName === 'dimmer') {
|
|
121
126
|
return React.createElement(WbIncandescent, { style: { color } });
|
|
122
127
|
}
|
|
123
|
-
if (name === 'socket') {
|
|
128
|
+
if (name === 'socket' || altName === 'socket') {
|
|
124
129
|
return React.createElement(Power, { style: { color } });
|
|
125
130
|
}
|
|
126
|
-
if (name === 'settings') {
|
|
131
|
+
if (name === 'settings' || altName === 'settings') {
|
|
127
132
|
return React.createElement(Settings, { style: { color } });
|
|
128
133
|
}
|
|
129
|
-
if (name === 'users' || name === 'group') {
|
|
134
|
+
if (name === 'users' || name === 'group' || altName === 'users' || altName === 'group') {
|
|
130
135
|
return React.createElement(Group, { style: { color } });
|
|
131
136
|
}
|
|
132
|
-
if (name === 'user') {
|
|
137
|
+
if (name === 'user' || altName === 'user') {
|
|
133
138
|
return React.createElement(Person, { style: { color } });
|
|
134
139
|
}
|
|
140
|
+
if (name === 'qrcode' || altName === 'qrcode') {
|
|
141
|
+
return React.createElement(QrCode, { style: { color } });
|
|
142
|
+
}
|
|
143
|
+
if (name === 'identify' || altName === 'identify') {
|
|
144
|
+
return React.createElement(WifiFind, { style: { color } });
|
|
145
|
+
}
|
|
146
|
+
if (name === 'info' || altName === 'info') {
|
|
147
|
+
return React.createElement(Info, { style: { color } });
|
|
148
|
+
}
|
|
135
149
|
return React.createElement(QuestionMark, { style: { color } });
|
|
136
150
|
}
|
|
137
151
|
export function renderControlIcon(action, colors, value) {
|
|
@@ -156,7 +170,7 @@ export function renderControlIcon(action, colors, value) {
|
|
|
156
170
|
if (action.icon?.startsWith('data:image')) {
|
|
157
171
|
return (React.createElement(Icon, { src: action.icon, style: { color } }));
|
|
158
172
|
}
|
|
159
|
-
return getIconByName(action.id, color);
|
|
173
|
+
return getIconByName(action.id, action.icon, color);
|
|
160
174
|
}
|
|
161
175
|
export function renderActionIcon(action) {
|
|
162
176
|
if (!action) {
|
|
@@ -168,7 +182,7 @@ export function renderActionIcon(action) {
|
|
|
168
182
|
if (action.icon?.startsWith('data:image')) {
|
|
169
183
|
return (React.createElement(Icon, { src: action.icon, style: { color: action.color } }));
|
|
170
184
|
}
|
|
171
|
-
return getIconByName(action.id, action.color);
|
|
185
|
+
return getIconByName(action.id, action.icon, action.color);
|
|
172
186
|
}
|
|
173
187
|
let language;
|
|
174
188
|
/**
|
package/build/Utils.js.map
CHANGED
|
@@ -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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AAE,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,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,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,SAAS,SAAS,CAAC,IAAY,EAAE,KAAc;IAC3C,MAAM,SAAS,GAAG,IAAI;SACjB,KAAK,CAAC,GAAG,CA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AAC,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;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 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\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, 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 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): 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/dm-gui-components",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
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.
|
|
52
|
-
"@iobroker/json-config": "7.
|
|
51
|
+
"@iobroker/adapter-react-v5": "7.4.0",
|
|
52
|
+
"@iobroker/json-config": "7.4.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@craco/craco": "^7.1.0",
|
|
56
56
|
"@iobroker/dm-utils": "^0.5.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "90a2d92cbe2e62a7afdabf73ae2141dfffc8b9e0"
|
|
59
59
|
}
|