@iobroker/dm-gui-components 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/DeviceList.d.ts +1 -0
- package/build/DeviceList.js +26 -8
- package/build/DeviceList.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/build/DeviceList.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export default class DeviceList extends Communication<DeviceListProps, DeviceLis
|
|
|
45
45
|
private filterTimeout;
|
|
46
46
|
private readonly language;
|
|
47
47
|
constructor(props: DeviceListProps);
|
|
48
|
+
setStateAsync(state: Partial<DeviceListState>): Promise<void>;
|
|
48
49
|
private loadAdapters;
|
|
49
50
|
componentDidMount(): Promise<void>;
|
|
50
51
|
componentWillUnmount(): void;
|
package/build/DeviceList.js
CHANGED
|
@@ -59,6 +59,9 @@ export default class DeviceList extends Communication {
|
|
|
59
59
|
this.lastInstance = this.state.selectedInstance;
|
|
60
60
|
this.lastTriggerLoad = this.props.triggerLoad || 0;
|
|
61
61
|
}
|
|
62
|
+
setStateAsync(state) {
|
|
63
|
+
return new Promise(resolve => this.setState(state, resolve));
|
|
64
|
+
}
|
|
62
65
|
async loadAdapters() {
|
|
63
66
|
await this.props.socket.waitForFirstConnection();
|
|
64
67
|
console.log('Loading adapters...');
|
|
@@ -85,7 +88,12 @@ export default class DeviceList extends Communication {
|
|
|
85
88
|
console.error(error);
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
|
|
91
|
+
if (Object.keys(dmInstances).length === 1) {
|
|
92
|
+
await this.setStateAsync({ dmInstances, selectedInstance: Object.keys(dmInstances)[0] });
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await this.setStateAsync({ dmInstances });
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
async componentDidMount() {
|
|
91
99
|
let alive = false;
|
|
@@ -111,18 +119,15 @@ export default class DeviceList extends Communication {
|
|
|
111
119
|
else if (this.state.alive !== null) {
|
|
112
120
|
alive = this.state.alive;
|
|
113
121
|
}
|
|
114
|
-
if (
|
|
122
|
+
if (alive) {
|
|
115
123
|
try {
|
|
116
124
|
const instanceInfo = await this.loadInstanceInfos();
|
|
117
|
-
this.setState({ instanceInfo, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) });
|
|
125
|
+
this.setState({ instanceInfo, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) }, () => this.loadData());
|
|
118
126
|
}
|
|
119
127
|
catch (error) {
|
|
120
128
|
console.error(error);
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
if (alive) {
|
|
124
|
-
this.loadData();
|
|
125
|
-
}
|
|
126
131
|
}
|
|
127
132
|
componentWillUnmount() {
|
|
128
133
|
if (this.state.selectedInstance) {
|
|
@@ -232,7 +237,20 @@ export default class DeviceList extends Communication {
|
|
|
232
237
|
// if instance changed
|
|
233
238
|
if (this.lastInstance !== this.state.selectedInstance) {
|
|
234
239
|
this.lastInstance = this.state.selectedInstance;
|
|
235
|
-
setTimeout(() =>
|
|
240
|
+
setTimeout(async () => {
|
|
241
|
+
if (this.state.selectedInstance) {
|
|
242
|
+
try {
|
|
243
|
+
const instanceInfo = await this.loadInstanceInfos();
|
|
244
|
+
this.setState({ instanceInfo, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) }, () => this.loadData());
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(error);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
this.loadData();
|
|
252
|
+
}
|
|
253
|
+
}, 50);
|
|
236
254
|
}
|
|
237
255
|
if (this.props.selectedInstance && this.props.selectedInstance !== this.state.selectedInstance) {
|
|
238
256
|
setTimeout(() => this.setState({ selectedInstance: this.props.selectedInstance }), 50);
|
|
@@ -325,7 +343,7 @@ export default class DeviceList extends Communication {
|
|
|
325
343
|
if (this.props.embedded) {
|
|
326
344
|
return (React.createElement(React.Fragment, null,
|
|
327
345
|
this.state.loading ? React.createElement(LinearProgress, { style: { width: '100%' } }) : null,
|
|
328
|
-
list));
|
|
346
|
+
this.state.apiVersionError ? React.createElement("div", null, I18n.t('apiVersionError')) : list));
|
|
329
347
|
}
|
|
330
348
|
return (React.createElement("div", { style: { width: '100%', height: '100%', overflow: 'hidden' } },
|
|
331
349
|
React.createElement(Toolbar, { variant: "dense", style: { backgroundColor: '#777', display: 'flex' } },
|
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,EACH,UAAU,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,GAAG,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,UAAU,EAAE,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,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,EA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,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,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,iCAAM,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAO,CAAC,CAAC,CAAC,IAAI,CACzE,CACJ,CACT,CAAC;IACN,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport {\n IconButton,\n InputAdornment,\n TextField,\n Toolbar,\n Tooltip,\n LinearProgress,\n Select,\n MenuItem,\n FormControl,\n InputLabel,\n Box,\n} from '@mui/material';\n\nimport { Clear, QuestionMark, Refresh, FilterAltOff } from '@mui/icons-material';\n\nimport { I18n, DeviceTypeIcon } from '@iobroker/adapter-react-v5';\nimport type { DeviceInfo, InstanceDetails } from './protocol/api';\n\nimport DeviceCard, { DeviceCardSkeleton } 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 totalDevices?: number;\n filter: string;\n instanceInfo: InstanceDetails | null;\n loading: boolean | null;\n alive: boolean | null;\n triggerLoad: number;\n groupKey: string;\n dmInstances: { [instanceName: string]: { title: string; instance: number } } | null;\n apiVersionError: boolean;\n}\n\n/**\n * Device List Component\n */\nexport default class DeviceList extends Communication<DeviceListProps, DeviceListState> {\n static i18nInitialized = false;\n\n private lastInstance: string;\n\n private lastAliveSubscribe = '';\n\n private lastTriggerLoad = 0;\n\n private filterTimeout: ReturnType<typeof setTimeout> | null = null;\n\n private readonly language: ioBroker.Languages = I18n.getLanguage();\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 this.state = {\n ...this.state,\n devices: [],\n filter: '',\n instanceInfo: null,\n loading: null,\n alive: null,\n groupKey: '',\n dmInstances: null,\n apiVersionError: false,\n };\n\n this.lastInstance = this.state.selectedInstance;\n this.lastTriggerLoad = this.props.triggerLoad || 0;\n }\n\n private async loadAdapters(): Promise<void> {\n await this.props.socket.waitForFirstConnection();\n\n console.log('Loading adapters...');\n const res = await this.props.socket.getObjectViewSystem('instance', 'system.adapter.', 'system.adapter.\\u9999');\n const dmInstances: { [instanceName: string]: { title: string; instance: number } } = {};\n for (const id in res) {\n if (!res[id].common.supportedMessages?.deviceManager) {\n continue;\n }\n\n const instanceName = id.substring('system.adapter.'.length);\n try {\n // Check if the instance is alive by getting the state alive\n const alive = await this.props.socket.getState(`system.adapter.${instanceName}.alive`);\n if (!alive?.val) {\n continue;\n }\n\n const instance = parseInt(instanceName.split('.').pop() || '0') || 0;\n dmInstances[instanceName] = {\n title: '',\n instance,\n };\n } catch (error) {\n console.error(error);\n }\n }\n\n this.setState({ dmInstances });\n }\n\n async componentDidMount(): Promise<void> {\n let alive = false;\n // If an instance selector must be shown\n if (this.props.selectedInstance === undefined) {\n // show instance selector\n await this.loadAdapters();\n }\n\n if (this.state.alive === null && this.state.selectedInstance) {\n try {\n // check if the instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n this.lastAliveSubscribe = this.state.selectedInstance;\n this.setState({ alive }, () =>\n this.props.socket.subscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n ),\n );\n } else if (this.state.alive !== null) {\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, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) });\n } catch (error) {\n console.error(error);\n }\n }\n if (alive) {\n this.loadData();\n }\n }\n\n componentWillUnmount(): void {\n if (this.state.selectedInstance) {\n this.props.socket.unsubscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n );\n }\n }\n\n aliveHandler: ioBroker.StateChangeHandler = (id: string, state: ioBroker.State | null | undefined): void => {\n if (this.state.selectedInstance && id === `system.adapter.${this.state.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.state.selectedInstance}...`);\n let alive = this.state.alive;\n\n if (this.state.selectedInstance !== this.lastAliveSubscribe) {\n if (this.lastAliveSubscribe) {\n // unsubscribe from the old instance\n this.props.socket.unsubscribeState(\n `system.adapter.${this.lastAliveSubscribe}.alive`,\n this.aliveHandler,\n );\n }\n\n this.lastAliveSubscribe = this.state.selectedInstance;\n\n if (this.state.selectedInstance) {\n try {\n // check if the instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n await this.props.socket.subscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n );\n } else {\n alive = false;\n }\n }\n\n let devices: DeviceInfo[] = [];\n try {\n this.setState({ devices, loading: !!alive, alive });\n if (alive) {\n await this.loadDevices((batch, total) => {\n devices = devices.concat(batch);\n this.setState({ devices, loading: true, totalDevices: total });\n console.log(`Loaded ${devices.length} of ${total} devices...`);\n });\n }\n } catch (error) {\n console.error(error);\n devices = [];\n }\n\n this.setState({ devices, loading: false, totalDevices: devices.length });\n console.log(`Loaded ${devices.length} devices for ${this.state.selectedInstance}`);\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 handleFilterChange(filter: string): void {\n if (this.filterTimeout) {\n clearTimeout(this.filterTimeout);\n }\n this.filterTimeout = setTimeout(() => {\n this.filterTimeout = null;\n this.setState({ filter });\n }, 250);\n }\n\n renderGroups(\n groups: { name: string; value: string; count: number; icon?: React.JSX.Element | string | null }[] | undefined,\n ): React.JSX.Element | null {\n if (!groups?.length) {\n return null;\n }\n\n return (\n <Select\n style={{ minWidth: 120, marginRight: 8, marginTop: 12.5 }}\n variant=\"standard\"\n value={this.state.groupKey || '_'}\n renderValue={value => {\n if (value === '_') {\n value = '';\n }\n const g = groups.find(g => g.value === value);\n return (\n <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n {g?.icon || <div style={{ width: 24 }} />}\n {g?.name || value}\n </div>\n );\n }}\n onChange={e => this.setState({ groupKey: e.target.value === '_' ? '' : e.target.value })}\n >\n {groups.map(g => (\n <MenuItem\n value={g.value || '_'}\n key={g.value || '_'}\n style={{ display: 'flex', alignItems: 'center', gap: 8 }}\n >\n {g.icon || <div style={{ width: 24 }} />}\n {g.name}\n </MenuItem>\n ))}\n </Select>\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 instance changed\n if (this.lastInstance !== this.state.selectedInstance) {\n this.lastInstance = this.state.selectedInstance;\n setTimeout(() => this.loadData(), 50);\n }\n if (this.props.selectedInstance && this.props.selectedInstance !== this.state.selectedInstance) {\n setTimeout(() => this.setState({ selectedInstance: this.props.selectedInstance! }), 50);\n }\n const deviceGroups: { name: string; value: string; count: number; icon?: React.JSX.Element | string | null }[] =\n [];\n let list: React.JSX.Element[] | undefined;\n if (!this.props.embedded && !this.state.alive) {\n list = [\n <div\n style={emptyStyle}\n key=\"notAlive\"\n >\n <span>{getTranslation('instanceNotAlive')}</span>\n </div>,\n ];\n } else if (!this.state.devices.length && this.state.selectedInstance && !this.state.loading) {\n list = [\n <div\n style={emptyStyle}\n key=\"notFound\"\n >\n <span>{getTranslation('noDevicesFoundText')}</span>\n </div>,\n ];\n } else {\n // build a device types list\n let filteredDevices = this.state.devices;\n if (!this.state.loading && !this.props.embedded && filteredDevices.find(device => device.group)) {\n deviceGroups.push({\n name: I18n.t('All'),\n value: '',\n count: filteredDevices.length,\n icon: <FilterAltOff />,\n });\n filteredDevices.forEach(device => {\n if (device.group) {\n const type = deviceGroups.find(t => t.value === device.group?.key);\n if (type) {\n type.count++;\n } else {\n const icon = device.group.icon ? <DeviceTypeIcon src={device.group.icon} /> : null;\n\n deviceGroups.push({\n name: this.getText(device.group.name || device.group.key),\n value: device.group.key,\n count: 1,\n icon,\n });\n }\n }\n });\n const unknown = filteredDevices.filter(device => !device.group);\n if (unknown.length) {\n deviceGroups.push({\n name: I18n.t('Unknown'),\n value: '?',\n count: unknown.length,\n icon: <QuestionMark />,\n });\n }\n\n if (this.state.groupKey) {\n // filter out all devices belonging to this group\n if (this.state.groupKey === '?') {\n filteredDevices = filteredDevices.filter(device => !device.group?.key);\n } else {\n filteredDevices = filteredDevices.filter(device => device.group?.key === this.state.groupKey);\n }\n }\n }\n\n if (this.state.selectedInstance) {\n list = filteredDevices.map(device => (\n <DeviceCard\n key={JSON.stringify(device.id)}\n smallCards={this.props.smallCards}\n filter={this.props.embedded ? this.props.filter : this.state.filter}\n alive={!!this.state.alive}\n id={device.id}\n identifierLabel={this.state.instanceInfo?.identifierLabel ?? 'ID'}\n device={device}\n instanceId={this.state.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 if (this.state.loading) {\n const skeletons = (this.state.totalDevices ?? list.length + 1) - list.length;\n for (let i = 0; i < skeletons; i++) {\n list.push(\n <DeviceCardSkeleton\n key={`skeleton-${i}`}\n smallCards={this.props.smallCards}\n theme={this.props.theme}\n />,\n );\n }\n } else if (this.state.devices.length > 0) {\n list.push(\n <Box\n key=\"filtered\"\n sx={{\n padding: '25px',\n '&:not(:first-child)': {\n display: 'none',\n },\n }}\n >\n <span>{getTranslation('allDevicesFilteredOut')}</span>\n </Box>,\n );\n }\n } else {\n list = [\n <div\n style={emptyStyle}\n key=\"selectInstance\"\n >\n <span>{getTranslation('selectInstanceText')}</span>\n </div>,\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 === undefined && this.state.dmInstances ? (\n <FormControl>\n <InputLabel\n id=\"instance-select-label\"\n style={{ transform: 'translate(0, -9px) scale(0.75)' }}\n >\n {getTranslation('instanceLabelText')}\n </InputLabel>\n <Select\n style={{ marginTop: 0, minWidth: 120 }}\n labelId=\"instance-select-label\"\n id=\"instance-select\"\n value={this.state.selectedInstance}\n onChange={event => {\n window.localStorage.setItem('dmSelectedInstance', event.target.value);\n this.setState({ selectedInstance: event.target.value });\n }}\n displayEmpty\n variant=\"standard\"\n >\n {Object.keys(this.state.dmInstances).map(id => (\n <MenuItem\n key={id}\n value={id}\n >\n {id}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n ) : null}\n {this.state.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 || this.state.apiVersionError}\n size=\"small\"\n >\n <Refresh />\n </IconButton>\n </span>\n </Tooltip>\n ) : null}\n {!this.state.apiVersionError && 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.apiVersionError && this.renderGroups(deviceGroups)}\n {!this.state.apiVersionError && 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 tabIndex={-1}\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 {this.state.apiVersionError ? <div>{I18n.t('apiVersionError')}</div> : 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,EACH,UAAU,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,GAAG,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,UAAU,EAAE,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,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,OA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AAG,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,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,iCAAM,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAO,CAAC,CAAC,CAAC,IAAI,CACzE,CACJ,CACT,CAAC;IACN,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport {\n IconButton,\n InputAdornment,\n TextField,\n Toolbar,\n Tooltip,\n LinearProgress,\n Select,\n MenuItem,\n FormControl,\n InputLabel,\n Box,\n} from '@mui/material';\n\nimport { Clear, QuestionMark, Refresh, FilterAltOff } from '@mui/icons-material';\n\nimport { I18n, DeviceTypeIcon } from '@iobroker/adapter-react-v5';\nimport type { DeviceInfo, InstanceDetails } from './protocol/api';\n\nimport DeviceCard, { DeviceCardSkeleton } 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 totalDevices?: number;\n filter: string;\n instanceInfo: InstanceDetails | null;\n loading: boolean | null;\n alive: boolean | null;\n triggerLoad: number;\n groupKey: string;\n dmInstances: { [instanceName: string]: { title: string; instance: number } } | null;\n apiVersionError: boolean;\n}\n\n/**\n * Device List Component\n */\nexport default class DeviceList extends Communication<DeviceListProps, DeviceListState> {\n static i18nInitialized = false;\n\n private lastInstance: string;\n\n private lastAliveSubscribe = '';\n\n private lastTriggerLoad = 0;\n\n private filterTimeout: ReturnType<typeof setTimeout> | null = null;\n\n private readonly language: ioBroker.Languages = I18n.getLanguage();\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 this.state = {\n ...this.state,\n devices: [],\n filter: '',\n instanceInfo: null,\n loading: null,\n alive: null,\n groupKey: '',\n dmInstances: null,\n apiVersionError: false,\n };\n\n this.lastInstance = this.state.selectedInstance;\n this.lastTriggerLoad = this.props.triggerLoad || 0;\n }\n\n setStateAsync(state: Partial<DeviceListState>): Promise<void> {\n return new Promise<void>(resolve => this.setState(state as DeviceListState, resolve));\n }\n\n private async loadAdapters(): Promise<void> {\n await this.props.socket.waitForFirstConnection();\n\n console.log('Loading adapters...');\n const res = await this.props.socket.getObjectViewSystem('instance', 'system.adapter.', 'system.adapter.\\u9999');\n const dmInstances: { [instanceName: string]: { title: string; instance: number } } = {};\n for (const id in res) {\n if (!res[id].common.supportedMessages?.deviceManager) {\n continue;\n }\n\n const instanceName = id.substring('system.adapter.'.length);\n try {\n // Check if the instance is alive by getting the state alive\n const alive = await this.props.socket.getState(`system.adapter.${instanceName}.alive`);\n if (!alive?.val) {\n continue;\n }\n\n const instance = parseInt(instanceName.split('.').pop() || '0') || 0;\n dmInstances[instanceName] = {\n title: '',\n instance,\n };\n } catch (error) {\n console.error(error);\n }\n }\n\n if (Object.keys(dmInstances).length === 1) {\n await this.setStateAsync({ dmInstances, selectedInstance: Object.keys(dmInstances)[0] });\n } else {\n await this.setStateAsync({ dmInstances });\n }\n }\n\n async componentDidMount(): Promise<void> {\n let alive = false;\n // If an instance selector must be shown\n if (this.props.selectedInstance === undefined) {\n // show instance selector\n await this.loadAdapters();\n }\n\n if (this.state.alive === null && this.state.selectedInstance) {\n try {\n // check if the instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n this.lastAliveSubscribe = this.state.selectedInstance;\n this.setState({ alive }, () =>\n this.props.socket.subscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n ),\n );\n } else if (this.state.alive !== null) {\n alive = this.state.alive;\n }\n\n if (alive) {\n try {\n const instanceInfo = await this.loadInstanceInfos();\n this.setState(\n { instanceInfo, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) },\n () => this.loadData(),\n );\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n componentWillUnmount(): void {\n if (this.state.selectedInstance) {\n this.props.socket.unsubscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n );\n }\n }\n\n aliveHandler: ioBroker.StateChangeHandler = (id: string, state: ioBroker.State | null | undefined): void => {\n if (this.state.selectedInstance && id === `system.adapter.${this.state.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.state.selectedInstance}...`);\n let alive = this.state.alive;\n\n if (this.state.selectedInstance !== this.lastAliveSubscribe) {\n if (this.lastAliveSubscribe) {\n // unsubscribe from the old instance\n this.props.socket.unsubscribeState(\n `system.adapter.${this.lastAliveSubscribe}.alive`,\n this.aliveHandler,\n );\n }\n\n this.lastAliveSubscribe = this.state.selectedInstance;\n\n if (this.state.selectedInstance) {\n try {\n // check if the instance is alive\n const stateAlive = await this.props.socket.getState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n );\n if (stateAlive?.val) {\n alive = true;\n }\n } catch (error) {\n console.error(error);\n }\n await this.props.socket.subscribeState(\n `system.adapter.${this.state.selectedInstance}.alive`,\n this.aliveHandler,\n );\n } else {\n alive = false;\n }\n }\n\n let devices: DeviceInfo[] = [];\n try {\n this.setState({ devices, loading: !!alive, alive });\n if (alive) {\n await this.loadDevices((batch, total) => {\n devices = devices.concat(batch);\n this.setState({ devices, loading: true, totalDevices: total });\n console.log(`Loaded ${devices.length} of ${total} devices...`);\n });\n }\n } catch (error) {\n console.error(error);\n devices = [];\n }\n\n this.setState({ devices, loading: false, totalDevices: devices.length });\n console.log(`Loaded ${devices.length} devices for ${this.state.selectedInstance}`);\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 handleFilterChange(filter: string): void {\n if (this.filterTimeout) {\n clearTimeout(this.filterTimeout);\n }\n this.filterTimeout = setTimeout(() => {\n this.filterTimeout = null;\n this.setState({ filter });\n }, 250);\n }\n\n renderGroups(\n groups: { name: string; value: string; count: number; icon?: React.JSX.Element | string | null }[] | undefined,\n ): React.JSX.Element | null {\n if (!groups?.length) {\n return null;\n }\n\n return (\n <Select\n style={{ minWidth: 120, marginRight: 8, marginTop: 12.5 }}\n variant=\"standard\"\n value={this.state.groupKey || '_'}\n renderValue={value => {\n if (value === '_') {\n value = '';\n }\n const g = groups.find(g => g.value === value);\n return (\n <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n {g?.icon || <div style={{ width: 24 }} />}\n {g?.name || value}\n </div>\n );\n }}\n onChange={e => this.setState({ groupKey: e.target.value === '_' ? '' : e.target.value })}\n >\n {groups.map(g => (\n <MenuItem\n value={g.value || '_'}\n key={g.value || '_'}\n style={{ display: 'flex', alignItems: 'center', gap: 8 }}\n >\n {g.icon || <div style={{ width: 24 }} />}\n {g.name}\n </MenuItem>\n ))}\n </Select>\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 instance changed\n if (this.lastInstance !== this.state.selectedInstance) {\n this.lastInstance = this.state.selectedInstance;\n setTimeout(async (): Promise<void> => {\n if (this.state.selectedInstance) {\n try {\n const instanceInfo = await this.loadInstanceInfos();\n this.setState(\n { instanceInfo, apiVersionError: !['v1', 'v2', 'v3'].includes(instanceInfo.apiVersion) },\n () => this.loadData(),\n );\n } catch (error) {\n console.error(error);\n }\n } else {\n this.loadData();\n }\n }, 50);\n }\n if (this.props.selectedInstance && this.props.selectedInstance !== this.state.selectedInstance) {\n setTimeout(() => this.setState({ selectedInstance: this.props.selectedInstance! }), 50);\n }\n const deviceGroups: { name: string; value: string; count: number; icon?: React.JSX.Element | string | null }[] =\n [];\n let list: React.JSX.Element[] | undefined;\n if (!this.props.embedded && !this.state.alive) {\n list = [\n <div\n style={emptyStyle}\n key=\"notAlive\"\n >\n <span>{getTranslation('instanceNotAlive')}</span>\n </div>,\n ];\n } else if (!this.state.devices.length && this.state.selectedInstance && !this.state.loading) {\n list = [\n <div\n style={emptyStyle}\n key=\"notFound\"\n >\n <span>{getTranslation('noDevicesFoundText')}</span>\n </div>,\n ];\n } else {\n // build a device types list\n let filteredDevices = this.state.devices;\n if (!this.state.loading && !this.props.embedded && filteredDevices.find(device => device.group)) {\n deviceGroups.push({\n name: I18n.t('All'),\n value: '',\n count: filteredDevices.length,\n icon: <FilterAltOff />,\n });\n filteredDevices.forEach(device => {\n if (device.group) {\n const type = deviceGroups.find(t => t.value === device.group?.key);\n if (type) {\n type.count++;\n } else {\n const icon = device.group.icon ? <DeviceTypeIcon src={device.group.icon} /> : null;\n\n deviceGroups.push({\n name: this.getText(device.group.name || device.group.key),\n value: device.group.key,\n count: 1,\n icon,\n });\n }\n }\n });\n const unknown = filteredDevices.filter(device => !device.group);\n if (unknown.length) {\n deviceGroups.push({\n name: I18n.t('Unknown'),\n value: '?',\n count: unknown.length,\n icon: <QuestionMark />,\n });\n }\n\n if (this.state.groupKey) {\n // filter out all devices belonging to this group\n if (this.state.groupKey === '?') {\n filteredDevices = filteredDevices.filter(device => !device.group?.key);\n } else {\n filteredDevices = filteredDevices.filter(device => device.group?.key === this.state.groupKey);\n }\n }\n }\n\n if (this.state.selectedInstance) {\n list = filteredDevices.map(device => (\n <DeviceCard\n key={JSON.stringify(device.id)}\n smallCards={this.props.smallCards}\n filter={this.props.embedded ? this.props.filter : this.state.filter}\n alive={!!this.state.alive}\n id={device.id}\n identifierLabel={this.state.instanceInfo?.identifierLabel ?? 'ID'}\n device={device}\n instanceId={this.state.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 if (this.state.loading) {\n const skeletons = (this.state.totalDevices ?? list.length + 1) - list.length;\n for (let i = 0; i < skeletons; i++) {\n list.push(\n <DeviceCardSkeleton\n key={`skeleton-${i}`}\n smallCards={this.props.smallCards}\n theme={this.props.theme}\n />,\n );\n }\n } else if (this.state.devices.length > 0) {\n list.push(\n <Box\n key=\"filtered\"\n sx={{\n padding: '25px',\n '&:not(:first-child)': {\n display: 'none',\n },\n }}\n >\n <span>{getTranslation('allDevicesFilteredOut')}</span>\n </Box>,\n );\n }\n } else {\n list = [\n <div\n style={emptyStyle}\n key=\"selectInstance\"\n >\n <span>{getTranslation('selectInstanceText')}</span>\n </div>,\n ];\n }\n }\n\n if (this.props.embedded) {\n return (\n <>\n {this.state.loading ? <LinearProgress style={{ width: '100%' }} /> : null}\n {this.state.apiVersionError ? <div>{I18n.t('apiVersionError')}</div> : 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 === undefined && this.state.dmInstances ? (\n <FormControl>\n <InputLabel\n id=\"instance-select-label\"\n style={{ transform: 'translate(0, -9px) scale(0.75)' }}\n >\n {getTranslation('instanceLabelText')}\n </InputLabel>\n <Select\n style={{ marginTop: 0, minWidth: 120 }}\n labelId=\"instance-select-label\"\n id=\"instance-select\"\n value={this.state.selectedInstance}\n onChange={event => {\n window.localStorage.setItem('dmSelectedInstance', event.target.value);\n this.setState({ selectedInstance: event.target.value });\n }}\n displayEmpty\n variant=\"standard\"\n >\n {Object.keys(this.state.dmInstances).map(id => (\n <MenuItem\n key={id}\n value={id}\n >\n {id}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n ) : null}\n {this.state.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 || this.state.apiVersionError}\n size=\"small\"\n >\n <Refresh />\n </IconButton>\n </span>\n </Tooltip>\n ) : null}\n {!this.state.apiVersionError && 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.apiVersionError && this.renderGroups(deviceGroups)}\n {!this.state.apiVersionError && 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 tabIndex={-1}\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 {this.state.apiVersionError ? <div>{I18n.t('apiVersionError')}</div> : list}\n </div>\n </div>\n );\n }\n}\n"]}
|