@iobroker/adapter-react-v5 4.7.14 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/Components/JsonConfigComponent/ConfigAccordion.d.ts +1 -1
  2. package/Components/JsonConfigComponent/ConfigAccordion.js +4 -6
  3. package/Components/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  4. package/Components/JsonConfigComponent/ConfigAlive.d.ts +2 -2
  5. package/Components/JsonConfigComponent/ConfigAutocomplete.d.ts +36 -13
  6. package/Components/JsonConfigComponent/ConfigAutocomplete.js +66 -164
  7. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +16 -13
  8. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +119 -251
  9. package/Components/JsonConfigComponent/ConfigCRON.d.ts +2 -2
  10. package/Components/JsonConfigComponent/ConfigCertCollection.d.ts +2 -2
  11. package/Components/JsonConfigComponent/ConfigCertificateSelect.d.ts +2 -2
  12. package/Components/JsonConfigComponent/ConfigCertificates.d.ts +2 -2
  13. package/Components/JsonConfigComponent/ConfigCheckbox.d.ts +14 -13
  14. package/Components/JsonConfigComponent/ConfigCheckbox.js +37 -79
  15. package/Components/JsonConfigComponent/ConfigChip.d.ts +2 -2
  16. package/Components/JsonConfigComponent/ConfigColor.d.ts +2 -2
  17. package/Components/JsonConfigComponent/ConfigCoordinates.d.ts +2 -2
  18. package/Components/JsonConfigComponent/ConfigDatePicker.d.ts +2 -2
  19. package/Components/JsonConfigComponent/ConfigDeviceManager.d.ts +6 -0
  20. package/Components/JsonConfigComponent/ConfigDeviceManager.js +18 -0
  21. package/Components/JsonConfigComponent/ConfigFile.d.ts +2 -2
  22. package/Components/JsonConfigComponent/ConfigFile.js +2 -2
  23. package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
  24. package/Components/JsonConfigComponent/ConfigFileSelector.js +8 -5
  25. package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  26. package/Components/JsonConfigComponent/ConfigFunc.d.ts +2 -2
  27. package/Components/JsonConfigComponent/ConfigGeneric.d.ts +12 -4
  28. package/Components/JsonConfigComponent/ConfigGeneric.js +11 -2
  29. package/Components/JsonConfigComponent/ConfigIP.d.ts +2 -2
  30. package/Components/JsonConfigComponent/ConfigImageSendTo.d.ts +2 -2
  31. package/Components/JsonConfigComponent/ConfigImageUpload.js +38 -44
  32. package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
  33. package/Components/JsonConfigComponent/ConfigInstanceSelect.d.ts +2 -2
  34. package/Components/JsonConfigComponent/ConfigInterface.d.ts +2 -2
  35. package/Components/JsonConfigComponent/ConfigInterface.js +1 -1
  36. package/Components/JsonConfigComponent/ConfigInterface.js.map +1 -1
  37. package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +2 -2
  38. package/Components/JsonConfigComponent/ConfigJsonEditor.js +0 -1
  39. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  40. package/Components/JsonConfigComponent/ConfigLanguage.d.ts +6 -13
  41. package/Components/JsonConfigComponent/ConfigLanguage.js +105 -154
  42. package/Components/JsonConfigComponent/ConfigLicense.d.ts +1 -1
  43. package/Components/JsonConfigComponent/ConfigNumber.d.ts +1 -1
  44. package/Components/JsonConfigComponent/ConfigObjectId.d.ts +2 -2
  45. package/Components/JsonConfigComponent/ConfigPanel.js +8 -1
  46. package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
  47. package/Components/JsonConfigComponent/ConfigPassword.d.ts +2 -2
  48. package/Components/JsonConfigComponent/ConfigPattern.d.ts +2 -2
  49. package/Components/JsonConfigComponent/ConfigRoom.d.ts +2 -2
  50. package/Components/JsonConfigComponent/ConfigSelect.d.ts +2 -2
  51. package/Components/JsonConfigComponent/ConfigSelectSendTo.d.ts +2 -2
  52. package/Components/JsonConfigComponent/ConfigSendto.d.ts +23 -17
  53. package/Components/JsonConfigComponent/ConfigSendto.js +259 -399
  54. package/Components/JsonConfigComponent/ConfigSetState.d.ts +2 -2
  55. package/Components/JsonConfigComponent/ConfigSlider.d.ts +2 -2
  56. package/Components/JsonConfigComponent/ConfigStaticDivider.d.ts +2 -2
  57. package/Components/JsonConfigComponent/ConfigStaticHeader.d.ts +2 -2
  58. package/Components/JsonConfigComponent/ConfigStaticImage.d.ts +2 -2
  59. package/Components/JsonConfigComponent/ConfigStaticText.d.ts +2 -2
  60. package/Components/JsonConfigComponent/ConfigText.d.ts +2 -2
  61. package/Components/JsonConfigComponent/ConfigText.js +18 -0
  62. package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
  63. package/Components/JsonConfigComponent/ConfigTextSendTo.d.ts +2 -2
  64. package/Components/JsonConfigComponent/ConfigTimePicker.d.ts +2 -2
  65. package/Components/JsonConfigComponent/ConfigTopic.d.ts +2 -2
  66. package/Components/JsonConfigComponent/ConfigUUID.d.ts +2 -2
  67. package/Components/JsonConfigComponent/ConfigUser.d.ts +2 -2
  68. package/Components/JsonConfigComponent/DeviceManager/Communication.d.ts +63 -0
  69. package/Components/JsonConfigComponent/DeviceManager/Communication.js +268 -0
  70. package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.d.ts +11 -0
  71. package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.js +15 -0
  72. package/Components/JsonConfigComponent/DeviceManager/DeviceCard.d.ts +53 -0
  73. package/Components/JsonConfigComponent/DeviceManager/DeviceCard.js +340 -0
  74. package/Components/JsonConfigComponent/DeviceManager/DeviceControl.d.ts +45 -0
  75. package/Components/JsonConfigComponent/DeviceManager/DeviceControl.js +146 -0
  76. package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.d.ts +12 -0
  77. package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.js +69 -0
  78. package/Components/JsonConfigComponent/DeviceManager/DeviceList.d.ts +51 -0
  79. package/Components/JsonConfigComponent/DeviceManager/DeviceList.js +216 -0
  80. package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.d.ts +13 -0
  81. package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.js +111 -0
  82. package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.d.ts +7 -0
  83. package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.js +16 -0
  84. package/Components/JsonConfigComponent/DeviceManager/JsonConfig.d.ts +11 -0
  85. package/Components/JsonConfigComponent/DeviceManager/JsonConfig.js +94 -0
  86. package/Components/JsonConfigComponent/DeviceManager/TooltipButton.d.ts +10 -0
  87. package/Components/JsonConfigComponent/DeviceManager/TooltipButton.js +22 -0
  88. package/Components/JsonConfigComponent/DeviceManager/Utils.d.ts +12 -0
  89. package/Components/JsonConfigComponent/DeviceManager/Utils.js +158 -0
  90. package/Components/JsonConfigComponent/DeviceManager/i18n/de.json +21 -0
  91. package/Components/JsonConfigComponent/DeviceManager/i18n/en.json +21 -0
  92. package/Components/JsonConfigComponent/DeviceManager/i18n/es.json +21 -0
  93. package/Components/JsonConfigComponent/DeviceManager/i18n/fr.json +21 -0
  94. package/Components/JsonConfigComponent/DeviceManager/i18n/i18n.d.ts +26 -0
  95. package/Components/JsonConfigComponent/DeviceManager/i18n/it.json +21 -0
  96. package/Components/JsonConfigComponent/DeviceManager/i18n/nl.json +21 -0
  97. package/Components/JsonConfigComponent/DeviceManager/i18n/pl.json +21 -0
  98. package/Components/JsonConfigComponent/DeviceManager/i18n/pt.json +21 -0
  99. package/Components/JsonConfigComponent/DeviceManager/i18n/ru.json +21 -0
  100. package/Components/JsonConfigComponent/DeviceManager/i18n/uk.json +21 -0
  101. package/Components/JsonConfigComponent/DeviceManager/i18n/zh-cn.json +21 -0
  102. package/Components/JsonConfigComponent/DeviceManager/index.d.ts +2 -0
  103. package/Components/JsonConfigComponent/DeviceManager/index.js +10 -0
  104. package/Components/JsonConfigComponent/DeviceManager/index.js.map +1 -0
  105. package/Components/JsonConfigComponent/index.js +2 -7
  106. package/Components/JsonConfigComponent/index.js.map +1 -1
  107. package/Components/TextWithIcon.d.ts +1 -1
  108. package/Components/Utils.js +1 -1
  109. package/Components/Utils.js.map +1 -1
  110. package/Dialogs/ComplexCron.js +15 -17
  111. package/Dialogs/ComplexCron.js.map +1 -1
  112. package/Dialogs/Confirm.d.ts +20 -44
  113. package/Dialogs/Confirm.js +102 -158
  114. package/Dialogs/Error.d.ts +20 -39
  115. package/Dialogs/Error.js +50 -76
  116. package/Dialogs/Message.d.ts +22 -32
  117. package/Dialogs/Message.js +51 -83
  118. package/LegacyConnection.d.ts +3 -3
  119. package/README.md +9 -6
  120. package/i18n.d.ts +6 -6
  121. package/package.json +6 -5
  122. package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +0 -1
  123. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +0 -1
  124. package/Components/JsonConfigComponent/ConfigCheckbox.js.map +0 -1
  125. package/Components/JsonConfigComponent/ConfigLanguage.js.map +0 -1
  126. package/Components/JsonConfigComponent/ConfigSendto.js.map +0 -1
  127. package/Dialogs/Confirm.js.map +0 -1
  128. package/Dialogs/Error.js.map +0 -1
  129. package/Dialogs/Message.js.map +0 -1
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const material_1 = require("@mui/material");
8
+ const icons_material_1 = require("@mui/icons-material");
9
+ const i18n_1 = __importDefault(require("../../../i18n"));
10
+ const DeviceCard_1 = __importDefault(require("./DeviceCard"));
11
+ const Utils_1 = require("./Utils");
12
+ const Communication_1 = __importDefault(require("./Communication"));
13
+ const InstanceActionButton_1 = __importDefault(require("./InstanceActionButton"));
14
+ const de_json_1 = __importDefault(require("./i18n/de.json"));
15
+ const en_json_1 = __importDefault(require("./i18n/en.json"));
16
+ const ru_json_1 = __importDefault(require("./i18n/ru.json"));
17
+ const pt_json_1 = __importDefault(require("./i18n/pt.json"));
18
+ const nl_json_1 = __importDefault(require("./i18n/nl.json"));
19
+ const fr_json_1 = __importDefault(require("./i18n/fr.json"));
20
+ const it_json_1 = __importDefault(require("./i18n/it.json"));
21
+ const es_json_1 = __importDefault(require("./i18n/es.json"));
22
+ const pl_json_1 = __importDefault(require("./i18n/pl.json"));
23
+ const uk_json_1 = __importDefault(require("./i18n/uk.json"));
24
+ const zh_cn_json_1 = __importDefault(require("./i18n/zh-cn.json"));
25
+ /**
26
+ * Device List Component
27
+ * @param {object} params - Component parameters
28
+ * @param {object} params.socket - socket object
29
+ * @param {string} params.selectedInstance - Selected instance
30
+ * @param {string} params.uploadImagesToInstance - Instance to upload images to
31
+ * @param {string} params.filter - Filter
32
+ * @param {string} params.empbedded - true if this list used with multiple instances and false if only with one
33
+ * @param {string} params.title - Title in appbar (only in non-embedded mode)
34
+ * @param {string} params.style - Style of devices list
35
+ * @returns {*[]} - Array of device cards
36
+ */
37
+ class DeviceList extends Communication_1.default {
38
+ constructor(props) {
39
+ super(props);
40
+ this.aliveHandler = (id, state) => {
41
+ if (id === `system.adapter.${this.props.selectedInstance}.alive`) {
42
+ const alive = !!(state === null || state === void 0 ? void 0 : state.val);
43
+ if (alive !== this.state.alive) {
44
+ this.setState({ alive }, () => {
45
+ if (alive) {
46
+ this.componentDidMount().catch(console.error);
47
+ }
48
+ });
49
+ }
50
+ }
51
+ };
52
+ if (!DeviceList.i18nInitialized) {
53
+ DeviceList.i18nInitialized = true;
54
+ // @ts-expect-error
55
+ i18n_1.default.extendTranslations({
56
+ en: en_json_1.default,
57
+ de: de_json_1.default,
58
+ ru: ru_json_1.default,
59
+ pt: pt_json_1.default,
60
+ nl: nl_json_1.default,
61
+ fr: fr_json_1.default,
62
+ it: it_json_1.default,
63
+ es: es_json_1.default,
64
+ pl: pl_json_1.default,
65
+ uk: uk_json_1.default,
66
+ 'zh-cn': zh_cn_json_1.default,
67
+ });
68
+ }
69
+ Object.assign(this.state, {
70
+ devices: [],
71
+ filteredDevices: [],
72
+ filter: '',
73
+ instanceInfo: null,
74
+ loading: null,
75
+ alive: null,
76
+ });
77
+ this.lastPropsFilter = this.props.filter;
78
+ this.lastInstance = this.props.selectedInstance;
79
+ this.filterTimeout = null;
80
+ this.language = i18n_1.default.getLanguage();
81
+ }
82
+ async componentDidMount() {
83
+ let alive = false;
84
+ if (this.state.alive === null) {
85
+ try {
86
+ // check if instance is alive
87
+ const stateAlive = await this.props.socket.getState(`system.adapter.${this.props.selectedInstance}.alive`);
88
+ if (stateAlive === null || stateAlive === void 0 ? void 0 : stateAlive.val) {
89
+ alive = true;
90
+ }
91
+ }
92
+ catch (error) {
93
+ console.error(error);
94
+ }
95
+ this.setState({ alive }, () => this.props.socket.subscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler));
96
+ if (!alive) {
97
+ return;
98
+ }
99
+ }
100
+ else {
101
+ alive = this.state.alive;
102
+ }
103
+ if (!this.props.embedded && alive) {
104
+ try {
105
+ const instanceInfo = await this.loadInstanceInfos();
106
+ this.setState({ instanceInfo });
107
+ }
108
+ catch (error) {
109
+ console.error(error);
110
+ }
111
+ }
112
+ if (alive) {
113
+ try {
114
+ await this.loadData();
115
+ }
116
+ catch (error) {
117
+ console.error(error);
118
+ }
119
+ }
120
+ }
121
+ componentWillUnmount() {
122
+ this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler);
123
+ }
124
+ /**
125
+ * Load devices
126
+ */
127
+ async loadData() {
128
+ this.setState({ loading: true });
129
+ console.log(`Loading devices for ${this.props.selectedInstance}...`);
130
+ const devices = await this.loadDevices();
131
+ if (!devices || !Array.isArray(devices)) {
132
+ throw new Error(`Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(devices)}`);
133
+ }
134
+ this.setState({ devices, loading: false }, () => this.applyFilter());
135
+ }
136
+ getText(text) {
137
+ if (typeof text === 'object') {
138
+ return text[this.language] || text.en;
139
+ }
140
+ return text;
141
+ }
142
+ applyFilter() {
143
+ const filter = this.props.embedded ? this.props.filter : this.state.filter;
144
+ // filter devices name
145
+ if (filter) {
146
+ const filteredDevices = this.state.devices.filter(device => this.getText(device.name).toLowerCase().includes(filter.toLowerCase()));
147
+ this.setState({ filteredDevices });
148
+ }
149
+ else {
150
+ this.setState({ filteredDevices: this.state.devices });
151
+ }
152
+ }
153
+ handleFilterChange(filter) {
154
+ this.setState({ filter }, () => {
155
+ this.filterTimeout && clearTimeout(this.filterTimeout);
156
+ this.filterTimeout = setTimeout(() => {
157
+ this.filterTimeout = null;
158
+ this.applyFilter();
159
+ }, 250);
160
+ });
161
+ }
162
+ renderContent() {
163
+ var _a, _b;
164
+ /** @type {object} */
165
+ const emptyStyle = {
166
+ padding: 25,
167
+ };
168
+ if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {
169
+ this.lastPropsFilter = this.props.filter;
170
+ setTimeout(() => this.applyFilter(), 50);
171
+ }
172
+ if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {
173
+ this.lastInstance = this.props.selectedInstance;
174
+ setTimeout(() => this.loadData().catch(console.error), 50);
175
+ }
176
+ let list;
177
+ if (!this.props.embedded && !this.state.alive) {
178
+ list = react_1.default.createElement("div", { style: emptyStyle },
179
+ react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('instanceNotAlive')));
180
+ }
181
+ else if (!this.state.devices.length && this.props.selectedInstance) {
182
+ list = react_1.default.createElement("div", { style: emptyStyle },
183
+ react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('noDevicesFoundText')));
184
+ }
185
+ else if (this.state.devices.length && !this.state.filteredDevices.length) {
186
+ list = react_1.default.createElement("div", { style: emptyStyle },
187
+ react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('allDevicesFilteredOut')));
188
+ }
189
+ else {
190
+ list = this.state.filteredDevices.map(device => react_1.default.createElement(DeviceCard_1.default, { alive: !!this.state.alive, key: device.id, id: device.id, title: this.getText(device.name), device: device, instanceId: this.props.selectedInstance, uploadImagesToInstance: this.props.uploadImagesToInstance, deviceHandler: this.deviceHandler, controlHandler: this.controlHandler, controlStateHandler: this.controlStateHandler, socket: this.props.socket }));
191
+ }
192
+ if (this.props.embedded) {
193
+ return list;
194
+ }
195
+ return react_1.default.createElement("div", { style: { width: '100%', height: '100%', overflow: 'hidden' } },
196
+ react_1.default.createElement(material_1.Toolbar, { variant: "dense", style: { backgroundColor: '#777', display: 'flex' } },
197
+ this.props.title,
198
+ this.state.alive && ((_b = (_a = this.state.instanceInfo) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length) ? react_1.default.createElement("div", { style: {
199
+ marginLeft: 20,
200
+ } }, this.state.instanceInfo.actions.map(action => react_1.default.createElement(InstanceActionButton_1.default, { key: action.id, action: action, instanceHandler: this.instanceHandler }))) : null,
201
+ react_1.default.createElement("div", { style: { flexGrow: 1 } }),
202
+ this.state.alive ? react_1.default.createElement(material_1.TextField, { variant: "standard", style: { width: 200 }, size: "small", label: (0, Utils_1.getTranslation)('filterLabelText'), onChange: e => this.handleFilterChange(e.target.value), value: this.state.filter, autoComplete: "off", inputProps: {
203
+ autoComplete: 'new-password',
204
+ form: { autoComplete: 'off' },
205
+ },
206
+ // eslint-disable-next-line react/jsx-no-duplicate-props
207
+ InputProps: {
208
+ endAdornment: this.state.filter ? react_1.default.createElement(material_1.InputAdornment, { position: "end" },
209
+ react_1.default.createElement(material_1.IconButton, { onClick: () => this.handleFilterChange(''), edge: "end" },
210
+ react_1.default.createElement(icons_material_1.Clear, null))) : null,
211
+ } }) : null),
212
+ react_1.default.createElement("div", { style: Object.assign({ width: '100%', height: 'calc(100% - 56px)', marginTop: 8, overflow: 'auto' }, this.props.style) }, list));
213
+ }
214
+ }
215
+ DeviceList.i18nInitialized = false;
216
+ exports.default = DeviceList;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface DeviceStatusProps {
3
+ status: any;
4
+ }
5
+ /**
6
+ * Device Status component
7
+ * @param {object} params - Parameters
8
+ * @param {object} params.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }
9
+ * @returns {React.JSX.Element|null}
10
+ * @constructor
11
+ */
12
+ export default function DeviceStatus(params: DeviceStatusProps): React.JSX.Element | null;
13
+ export {};
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const material_1 = require("@mui/material");
8
+ const icons_material_1 = require("@mui/icons-material");
9
+ const Utils_1 = require("./Utils");
10
+ /**
11
+ * Device Status component
12
+ * @param {object} params - Parameters
13
+ * @param {object} params.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }
14
+ * @returns {React.JSX.Element|null}
15
+ * @constructor
16
+ */
17
+ function DeviceStatus(params) {
18
+ if (!params.status) {
19
+ return null;
20
+ }
21
+ let status;
22
+ if (typeof params.status === 'string') {
23
+ status = {
24
+ connection: params.status,
25
+ };
26
+ }
27
+ else {
28
+ status = params.status;
29
+ }
30
+ /** @type {object} */
31
+ const iconStyleOK = {
32
+ fill: '#00ac00',
33
+ };
34
+ /** @type {object} */
35
+ const iconStyleNotOK = {
36
+ fill: '#ff0000',
37
+ };
38
+ /** @type {object} */
39
+ const iconStyleWarning = {
40
+ fill: '#ff9900',
41
+ };
42
+ /** @type {object} */
43
+ let batteryIconTooltip;
44
+ if (typeof status.battery === 'number') {
45
+ if (status.battery >= 96 && status.battery <= 100) {
46
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.BatteryFull, { style: iconStyleOK });
47
+ }
48
+ else if (status.battery >= 90 && status.battery <= 95) {
49
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery90, { style: iconStyleOK });
50
+ }
51
+ else if (status.battery >= 80 && status.battery <= 89) {
52
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery80, { style: iconStyleOK });
53
+ }
54
+ else if (status.battery >= 60 && status.battery <= 79) {
55
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery60, { style: iconStyleOK });
56
+ }
57
+ else if (status.battery >= 50 && status.battery <= 59) {
58
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery50, { style: iconStyleOK });
59
+ }
60
+ else if (status.battery >= 30 && status.battery <= 49) {
61
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery30, { style: iconStyleOK });
62
+ }
63
+ else if (status.battery >= 20 && status.battery <= 29) {
64
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery20, { style: iconStyleNotOK });
65
+ }
66
+ else {
67
+ batteryIconTooltip = react_1.default.createElement(icons_material_1.BatteryAlert, { style: iconStyleNotOK });
68
+ }
69
+ }
70
+ return react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
71
+ status.connection === 'connected' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
72
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('connectedIconTooltip') },
73
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
74
+ react_1.default.createElement(icons_material_1.Link, { style: iconStyleOK })))),
75
+ status.connection === 'disconnected' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
76
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('disconnectedIconTooltip') },
77
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
78
+ react_1.default.createElement(icons_material_1.LinkOff, { style: iconStyleNotOK })))),
79
+ status.rssi && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
80
+ react_1.default.createElement(material_1.Tooltip, { title: "RSSI" },
81
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
82
+ react_1.default.createElement(icons_material_1.NetworkCheck, null),
83
+ react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } }, status.rssi)))),
84
+ typeof status.battery === 'number' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
85
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
86
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
87
+ batteryIconTooltip,
88
+ react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } },
89
+ status.battery,
90
+ "%")))),
91
+ typeof status.battery === 'string' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
92
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
93
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
94
+ status.battery === 'charging' ? react_1.default.createElement(icons_material_1.BatteryCharging50, null) : react_1.default.createElement(icons_material_1.BatteryFull, null),
95
+ status.battery !== 'charging' ? (status.battery.includes('V') || status.battery.includes('mV') ?
96
+ react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } }, status.battery) :
97
+ react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } },
98
+ react_1.default.createElement("span", { style: { marginRight: 4 } }, status.battery),
99
+ "mV")) : null))),
100
+ typeof status.battery === 'boolean' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
101
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
102
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } }, status.battery ? react_1.default.createElement(icons_material_1.BatteryFull, { style: iconStyleOK }) :
103
+ react_1.default.createElement(icons_material_1.BatteryAlert, { style: iconStyleNotOK })))),
104
+ status.warning && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } }, typeof status.warning === 'string' || typeof status.warning === 'object' ?
105
+ react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)(status.warning) },
106
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
107
+ react_1.default.createElement(icons_material_1.Warning, { style: iconStyleWarning }))) :
108
+ react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
109
+ react_1.default.createElement(icons_material_1.Warning, { style: iconStyleWarning }))));
110
+ }
111
+ exports.default = DeviceStatus;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface InstanceActionButtonProps {
3
+ action: any;
4
+ instanceHandler: (action: any) => () => void;
5
+ }
6
+ export default function InstanceActionButton(params: InstanceActionButtonProps): React.JSX.Element | null;
7
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const TooltipButton_1 = __importDefault(require("./TooltipButton"));
8
+ const Utils_1 = require("./Utils");
9
+ function InstanceActionButton(params) {
10
+ const { action, instanceHandler } = params;
11
+ const tooltip = (0, Utils_1.getTranslation)((action === null || action === void 0 ? void 0 : action.description) ? action.description : '');
12
+ const title = (0, Utils_1.getTranslation)((action === null || action === void 0 ? void 0 : action.title) ? action.title : '');
13
+ const icon = (0, Utils_1.renderIcon)(action);
14
+ return react_1.default.createElement(TooltipButton_1.default, { tooltip: tooltip, label: title, disabled: action.disabled, Icon: icon, onClick: instanceHandler(action) });
15
+ }
16
+ exports.default = InstanceActionButton;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Connection } from '@iobroker/socket-client';
3
+ interface JsonConfigProps {
4
+ instanceId: string;
5
+ socket: Connection;
6
+ schema: Record<string, any>;
7
+ data: Record<string, any>;
8
+ onChange: (data: Record<string, any>) => void;
9
+ }
10
+ export default function JsonConfig(props: JsonConfigProps): React.JSX.Element | null;
11
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const JsonConfigComponent_1 = __importDefault(require("../../JsonConfigComponent"));
31
+ function JsonConfig(props) {
32
+ const { instanceId, socket, schema, data, onChange, } = props;
33
+ console.log('JsonConfig', props);
34
+ const [error, setError] = (0, react_1.useState)();
35
+ if (schema === undefined) {
36
+ return null;
37
+ }
38
+ const [adapterName, instance] = instanceId.split('.', 2);
39
+ return react_1.default.createElement(react_1.default.Fragment, null,
40
+ error && react_1.default.createElement("div", null, error),
41
+ react_1.default.createElement(JsonConfigComponent_1.default, { socket: socket, adapterName: adapterName, instance: parseInt(instance), schema: schema, data: data, onError: setError, onChange: _data => onChange(_data), embedded: true }));
42
+ /*
43
+ JSON adapter config:
44
+ className={classes.scroll}
45
+ socket={socket}
46
+ theme={this.props.theme}
47
+ themeName={this.props.themeName}
48
+ themeType={this.props.themeType}
49
+ adapterName={this.props.adapterName}
50
+ instance={this.props.instance}
51
+ isFloatComma={this.props.isFloatComma}
52
+ dateFormat={this.props.dateFormat}
53
+ schema={this.state.schema}
54
+ common={this.state.common}
55
+ data={this.state.data}
56
+ updateData={this.state.updateData}
57
+ onError={(error) => this.setState({ error })}
58
+ onChange={(data, changed) => this.setState({ data, changed })}
59
+ customs={{ configCustomEasyAccess: ConfigCustomEasyAccess }}
60
+ Object custom:
61
+ instanceObj={instanceObj}
62
+ customObj={customObj}
63
+ custom={true}
64
+ className={ '' }
65
+ adapterName={adapter}
66
+ instance={parseInt(instance.split('.').pop(), 10) || 0}
67
+ socket={this.props.socket}
68
+ theme={this.props.theme}
69
+ themeName={this.props.themeName}
70
+ themeType={this.props.themeType}
71
+ multiEdit={this.props.objectIDs.length > 1}
72
+
73
+ schema={this.jsonConfigs[adapter].json}
74
+ data={data}
75
+ onError={error =>
76
+ this.setState({error}, () => this.props.onError && this.props.onError(error))}
77
+ onValueChange={(attr, value) => {
78
+ console.log(attr + ' => ' + value);
79
+ const newValues = JSON.parse(JSON.stringify(this.state.newValues));
80
+ newValues[instance] = newValues[instance] || {};
81
+ if (this.commonConfig[instance][attr] === value) {
82
+ delete newValues[instance][attr];
83
+ if (!Object.keys(newValues[instance]).length) {
84
+ delete newValues[instance];
85
+ }
86
+ } else {
87
+ newValues[instance][attr] = value;
88
+ }
89
+ this.setState({newValues, hasChanges: this.isChanged(newValues)}, () =>
90
+ this.props.onChange && this.props.onChange(this.state.hasChanges));
91
+ }}
92
+ */
93
+ }
94
+ exports.default = JsonConfig;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface TooltipButtonProps {
3
+ tooltip?: string;
4
+ label?: string;
5
+ disabled?: boolean;
6
+ Icon: React.JSX.Element | null;
7
+ onClick?: () => void;
8
+ }
9
+ export default function TooltipButton(props: TooltipButtonProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const material_1 = require("@mui/material");
8
+ function TooltipButton(props) {
9
+ const { tooltip, label, disabled, Icon, onClick } = props;
10
+ const text = !!label && react_1.default.createElement(material_1.Typography, { variant: "button", style: { marginLeft: 4 } }, label);
11
+ if (tooltip) {
12
+ return react_1.default.createElement(material_1.Tooltip, { title: tooltip },
13
+ react_1.default.createElement("span", null,
14
+ react_1.default.createElement(material_1.IconButton, { onClick: onClick, disabled: disabled, size: "small" },
15
+ Icon,
16
+ text)));
17
+ }
18
+ return react_1.default.createElement(material_1.IconButton, { onClick: onClick, disabled: disabled, size: "small" },
19
+ Icon,
20
+ text);
21
+ }
22
+ exports.default = TooltipButton;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { ControlBase } from '@iobroker/dm-utils/build/types/base';
3
+ export declare function renderIcon(action: ControlBase, colors?: {
4
+ primary: string;
5
+ secondary: string;
6
+ }, value?: string | number | boolean | null): React.JSX.Element | null;
7
+ /**
8
+ * Get Translation
9
+ * @param {string | object} text - Text to translate
10
+ * @returns {string}
11
+ */
12
+ export declare function getTranslation(text: ioBroker.StringOrTranslated): string;