@iobroker/adapter-react-v5 4.7.15 → 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.
- package/Components/JsonConfigComponent/ConfigAccordion.d.ts +1 -1
- package/Components/JsonConfigComponent/ConfigAccordion.js +4 -6
- package/Components/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigAlive.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigAutocomplete.d.ts +36 -13
- package/Components/JsonConfigComponent/ConfigAutocomplete.js +66 -164
- package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +16 -13
- package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +119 -251
- package/Components/JsonConfigComponent/ConfigCRON.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigCertCollection.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigCertificateSelect.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigCertificates.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigCheckbox.d.ts +14 -13
- package/Components/JsonConfigComponent/ConfigCheckbox.js +37 -79
- package/Components/JsonConfigComponent/ConfigChip.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigColor.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigCoordinates.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigDatePicker.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigDeviceManager.d.ts +6 -0
- package/Components/JsonConfigComponent/ConfigDeviceManager.js +18 -0
- package/Components/JsonConfigComponent/ConfigFile.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigFile.js +2 -2
- package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFileSelector.js +8 -5
- package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFunc.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigGeneric.d.ts +12 -4
- package/Components/JsonConfigComponent/ConfigGeneric.js +11 -2
- package/Components/JsonConfigComponent/ConfigIP.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigImageSendTo.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigImageUpload.js +38 -44
- package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigInstanceSelect.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigInterface.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigInterface.js +1 -1
- package/Components/JsonConfigComponent/ConfigInterface.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigJsonEditor.js +0 -1
- package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigLanguage.d.ts +6 -13
- package/Components/JsonConfigComponent/ConfigLanguage.js +105 -154
- package/Components/JsonConfigComponent/ConfigLicense.d.ts +1 -1
- package/Components/JsonConfigComponent/ConfigNumber.d.ts +1 -1
- package/Components/JsonConfigComponent/ConfigObjectId.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigPanel.js +8 -1
- package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigPassword.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigPattern.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigRoom.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigSelect.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigSelectSendTo.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigSendto.d.ts +23 -17
- package/Components/JsonConfigComponent/ConfigSendto.js +259 -399
- package/Components/JsonConfigComponent/ConfigSetState.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigSlider.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigStaticDivider.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigStaticHeader.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigStaticImage.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigStaticText.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigText.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigText.js +18 -0
- package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTextSendTo.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigTimePicker.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigTopic.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigUUID.d.ts +2 -2
- package/Components/JsonConfigComponent/ConfigUser.d.ts +2 -2
- package/Components/JsonConfigComponent/DeviceManager/Communication.d.ts +63 -0
- package/Components/JsonConfigComponent/DeviceManager/Communication.js +268 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.d.ts +11 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.js +15 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceCard.d.ts +53 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceCard.js +340 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceControl.d.ts +45 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceControl.js +146 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.d.ts +12 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.js +69 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceList.d.ts +51 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceList.js +216 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.d.ts +13 -0
- package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.js +111 -0
- package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.d.ts +7 -0
- package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.js +16 -0
- package/Components/JsonConfigComponent/DeviceManager/JsonConfig.d.ts +11 -0
- package/Components/JsonConfigComponent/DeviceManager/JsonConfig.js +94 -0
- package/Components/JsonConfigComponent/DeviceManager/TooltipButton.d.ts +10 -0
- package/Components/JsonConfigComponent/DeviceManager/TooltipButton.js +22 -0
- package/Components/JsonConfigComponent/DeviceManager/Utils.d.ts +12 -0
- package/Components/JsonConfigComponent/DeviceManager/Utils.js +158 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/de.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/en.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/es.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/fr.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/i18n.d.ts +26 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/it.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/nl.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/pl.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/pt.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/ru.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/uk.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/i18n/zh-cn.json +21 -0
- package/Components/JsonConfigComponent/DeviceManager/index.d.ts +2 -0
- package/Components/JsonConfigComponent/DeviceManager/index.js +10 -0
- package/Components/JsonConfigComponent/DeviceManager/index.js.map +1 -0
- package/Components/JsonConfigComponent/index.js +2 -7
- package/Components/JsonConfigComponent/index.js.map +1 -1
- package/Components/TextWithIcon.d.ts +1 -1
- package/Dialogs/ComplexCron.js +15 -17
- package/Dialogs/ComplexCron.js.map +1 -1
- package/Dialogs/Confirm.d.ts +20 -44
- package/Dialogs/Confirm.js +102 -158
- package/Dialogs/Error.d.ts +20 -39
- package/Dialogs/Error.js +50 -76
- package/Dialogs/Message.d.ts +22 -32
- package/Dialogs/Message.js +51 -83
- package/LegacyConnection.d.ts +3 -3
- package/README.md +7 -4
- package/i18n.d.ts +6 -6
- package/package.json +6 -5
- package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigCheckbox.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigLanguage.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigSendto.js.map +0 -1
- package/Dialogs/Confirm.js.map +0 -1
- package/Dialogs/Error.js.map +0 -1
- package/Dialogs/Message.js.map +0 -1
|
@@ -1,434 +1,294 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
|
-
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
|
-
var _styles = require("@mui/styles");
|
|
21
|
-
var _material = require("@mui/material");
|
|
22
|
-
var _iconsMaterial = require("@mui/icons-material");
|
|
23
|
-
var _i18n = _interopRequireDefault(require("./wrapper/i18n"));
|
|
24
|
-
var _Error = _interopRequireDefault(require("./wrapper/Dialogs/Error"));
|
|
25
|
-
var _Message = _interopRequireDefault(require("./wrapper/Dialogs/Message"));
|
|
26
|
-
var _Confirm = _interopRequireDefault(require("./wrapper/Dialogs/Confirm"));
|
|
27
|
-
var _ConfigGeneric2 = _interopRequireDefault(require("./ConfigGeneric"));
|
|
28
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
31
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
32
|
-
var styles = function styles() {
|
|
33
|
-
return {
|
|
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 styles_1 = require("@mui/styles");
|
|
8
|
+
const material_1 = require("@mui/material");
|
|
9
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
10
|
+
const i18n_1 = __importDefault(require("./wrapper/i18n"));
|
|
11
|
+
const Error_1 = __importDefault(require("./wrapper/Dialogs/Error"));
|
|
12
|
+
const Message_1 = __importDefault(require("./wrapper/Dialogs/Message"));
|
|
13
|
+
const Confirm_1 = __importDefault(require("./wrapper/Dialogs/Confirm"));
|
|
14
|
+
const ConfigGeneric_1 = __importDefault(require("./ConfigGeneric"));
|
|
15
|
+
const styles = () => ({
|
|
34
16
|
fullWidth: {
|
|
35
|
-
|
|
17
|
+
width: '100%',
|
|
36
18
|
},
|
|
37
19
|
icon: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
};
|
|
20
|
+
width: 24,
|
|
21
|
+
height: 24,
|
|
22
|
+
marginRight: 4,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
44
25
|
function ip2int(ip) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return (ipInt << 8) + parseInt(octet, 10);
|
|
48
|
-
}, 0) >>> 0;
|
|
26
|
+
// eslint-disable-next-line no-bitwise
|
|
27
|
+
return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;
|
|
49
28
|
}
|
|
50
|
-
|
|
51
29
|
// copied from iobroker.admin/src-rx/src/Utils.js
|
|
52
30
|
function findNetworkAddressOfHost(obj, localIp) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
62
|
-
return networkInterfaces[inter].forEach(function (ip) {
|
|
63
|
-
if (ip.internal) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// if ip4 and not docker or wsl
|
|
73
|
-
if (ip.family === 'IPv4' && !ip.address.startsWith('172') && (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/))) {
|
|
74
|
-
// if DNS name
|
|
75
|
-
hostIp = ip.address;
|
|
76
|
-
} else if (!hostIp) {
|
|
77
|
-
if (ip.family === 'IPv4' && localIp.includes('.') &&
|
|
78
|
-
// eslint-disable-next-line no-bitwise
|
|
79
|
-
(ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
|
|
80
|
-
hostIp = ip.address;
|
|
81
|
-
} else {
|
|
82
|
-
hostIp = ip.address;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// check ipv6 addresses
|
|
89
|
-
if (!hostIp) {
|
|
90
|
-
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
91
|
-
return networkInterfaces[inter].forEach(function (ip) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const networkInterfaces = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.native) === null || _a === void 0 ? void 0 : _a.hardware) === null || _b === void 0 ? void 0 : _b.networkInterfaces;
|
|
33
|
+
if (!networkInterfaces) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
let hostIp;
|
|
37
|
+
// check ipv4 addresses
|
|
38
|
+
Object.keys(networkInterfaces).forEach(inter => networkInterfaces[inter].forEach((ip) => {
|
|
92
39
|
if (ip.internal) {
|
|
93
|
-
|
|
40
|
+
return;
|
|
94
41
|
}
|
|
95
42
|
if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
96
|
-
|
|
43
|
+
return;
|
|
97
44
|
}
|
|
98
45
|
if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
99
|
-
|
|
46
|
+
return;
|
|
100
47
|
}
|
|
101
|
-
if
|
|
102
|
-
|
|
103
|
-
hostIp = ip.address;
|
|
104
|
-
} else if (!hostIp) {
|
|
105
|
-
if (ip.family === 'IPv4' && localIp.includes('.') &&
|
|
106
|
-
// eslint-disable-next-line no-bitwise
|
|
107
|
-
(ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
|
|
48
|
+
// if ip4 and not docker or wsl
|
|
49
|
+
if (ip.family === 'IPv4' && !ip.address.startsWith('172') && (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/))) { // if DNS name
|
|
108
50
|
hostIp = ip.address;
|
|
109
|
-
} else {
|
|
110
|
-
hostIp = ip.address;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
if (!hostIp) {
|
|
117
|
-
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
118
|
-
networkInterfaces[inter].forEach(function (ip) {
|
|
119
|
-
if (ip.internal) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
123
|
-
return;
|
|
124
51
|
}
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (!hostIp) {
|
|
138
|
-
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
139
|
-
networkInterfaces[inter].forEach(function (ip) {
|
|
140
|
-
if (ip.internal) {
|
|
141
|
-
return;
|
|
52
|
+
else if (!hostIp) {
|
|
53
|
+
if (ip.family === 'IPv4' && localIp.includes('.') &&
|
|
54
|
+
// eslint-disable-next-line no-bitwise
|
|
55
|
+
(ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
|
|
56
|
+
hostIp = ip.address;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
hostIp = ip.address;
|
|
60
|
+
}
|
|
142
61
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
break;
|
|
190
|
-
case 17:
|
|
191
|
-
console.warn("Cannot find suitable IP in host ".concat(instanceObj.common.host, " for ").concat(instanceObj._id));
|
|
192
|
-
return _context.abrupt("return");
|
|
193
|
-
case 19:
|
|
194
|
-
this.setState({
|
|
195
|
-
_error: '',
|
|
196
|
-
_message: '',
|
|
197
|
-
hostname: hostname
|
|
198
|
-
});
|
|
199
|
-
case 20:
|
|
200
|
-
case "end":
|
|
201
|
-
return _context.stop();
|
|
202
|
-
}
|
|
203
|
-
}, _callee, this);
|
|
204
|
-
}));
|
|
205
|
-
function componentDidMount() {
|
|
206
|
-
return _componentDidMount.apply(this, arguments);
|
|
207
|
-
}
|
|
208
|
-
return componentDidMount;
|
|
209
|
-
}()
|
|
210
|
-
}, {
|
|
211
|
-
key: "renderErrorDialog",
|
|
212
|
-
value: function renderErrorDialog() {
|
|
213
|
-
var _this = this;
|
|
214
|
-
if (this.state._error) {
|
|
215
|
-
return /*#__PURE__*/_react["default"].createElement(_Error["default"], {
|
|
216
|
-
text: this.state._error,
|
|
217
|
-
classes: undefined,
|
|
218
|
-
onClose: function onClose() {
|
|
219
|
-
return _this.setState({
|
|
220
|
-
_error: ''
|
|
62
|
+
}));
|
|
63
|
+
// check ipv6 addresses
|
|
64
|
+
if (!hostIp) {
|
|
65
|
+
Object.keys(networkInterfaces).forEach(inter => networkInterfaces[inter].forEach((ip) => {
|
|
66
|
+
if (ip.internal) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (ip.family === 'IPv6' && (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/))) { // if DNS name
|
|
76
|
+
hostIp = ip.address;
|
|
77
|
+
}
|
|
78
|
+
else if (!hostIp) {
|
|
79
|
+
if (ip.family === 'IPv4' && localIp.includes('.') &&
|
|
80
|
+
// eslint-disable-next-line no-bitwise
|
|
81
|
+
(ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
|
|
82
|
+
hostIp = ip.address;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
hostIp = ip.address;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
if (!hostIp) {
|
|
91
|
+
Object.keys(networkInterfaces).forEach(inter => {
|
|
92
|
+
networkInterfaces[inter].forEach((ip) => {
|
|
93
|
+
if (ip.internal) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/)) { // if DNS name
|
|
103
|
+
hostIp = ip.address;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
hostIp = ip.address;
|
|
107
|
+
}
|
|
221
108
|
});
|
|
222
|
-
}
|
|
223
109
|
});
|
|
224
|
-
}
|
|
225
|
-
return null;
|
|
226
110
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
classes: undefined,
|
|
235
|
-
onClose: function onClose() {
|
|
236
|
-
return _this2.setState({
|
|
237
|
-
_message: ''
|
|
111
|
+
if (!hostIp) {
|
|
112
|
+
Object.keys(networkInterfaces).forEach(inter => {
|
|
113
|
+
networkInterfaces[inter].forEach((ip) => {
|
|
114
|
+
if (ip.internal) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
hostIp = ip.address;
|
|
238
118
|
});
|
|
239
|
-
}
|
|
240
119
|
});
|
|
241
|
-
}
|
|
242
|
-
return null;
|
|
243
120
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
121
|
+
return hostIp;
|
|
122
|
+
}
|
|
123
|
+
class ConfigSendto extends ConfigGeneric_1.default {
|
|
124
|
+
async componentDidMount() {
|
|
125
|
+
var _a;
|
|
126
|
+
super.componentDidMount();
|
|
127
|
+
let hostname = window.location.hostname;
|
|
128
|
+
if (this.props.schema.openUrl) {
|
|
129
|
+
// read admin host
|
|
130
|
+
const adminInstance = await this.props.socket.getCurrentInstance();
|
|
131
|
+
// @ts-expect-error
|
|
132
|
+
const instanceObj = await this.props.socket.getObject(`system.adapter.${adminInstance}`);
|
|
133
|
+
if (instanceObj) {
|
|
134
|
+
const hostObj = await this.props.socket.getObject(`system.host.${(_a = instanceObj === null || instanceObj === void 0 ? void 0 : instanceObj.common) === null || _a === void 0 ? void 0 : _a.host}`);
|
|
135
|
+
if (hostObj) {
|
|
136
|
+
const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);
|
|
137
|
+
if (ip) {
|
|
138
|
+
hostname = `${ip}:${window.location.port}`;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.warn(`Cannot find suitable IP in host ${instanceObj.common.host} for ${instanceObj._id}`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
264
146
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
_this3.setState({
|
|
280
|
-
_error: _i18n["default"].t('ra_Request timed out'),
|
|
281
|
-
running: false
|
|
282
|
-
});
|
|
283
|
-
}, parseInt(this.props.schema.timeout, 10) || 10000);
|
|
284
|
-
}
|
|
285
|
-
this.props.socket.sendTo("".concat(this.props.adapterName, ".").concat(this.props.instance), this.props.schema.command || 'send', data).then(function (response) {
|
|
286
|
-
if (timeout) {
|
|
287
|
-
clearTimeout(timeout);
|
|
288
|
-
timeout = null;
|
|
147
|
+
await new Promise(resolve => { this.setState({ _error: '', _message: '', hostname }, resolve); });
|
|
148
|
+
if (this.props.schema.onLoaded) {
|
|
149
|
+
this._onClick();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
renderErrorDialog() {
|
|
153
|
+
if (this.state._error) {
|
|
154
|
+
return react_1.default.createElement(Error_1.default, { text: this.state._error, onClose: () => this.setState({ _error: '' }) });
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
renderMessageDialog() {
|
|
159
|
+
if (this.state._message) {
|
|
160
|
+
return react_1.default.createElement(Message_1.default, { text: this.state._message, onClose: () => this.setState({ _message: '' }) });
|
|
289
161
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
_onClick() {
|
|
165
|
+
this.props.onCommandRunning(true);
|
|
166
|
+
this.setState({ running: true });
|
|
167
|
+
const _origin = `${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\/index\.html$/, '')}`;
|
|
168
|
+
const _originIp = `${window.location.protocol}//${this.state.hostname.split(':').length > 3 ? `[${this.state.hostname}]` : this.state.hostname}${window.location.pathname.replace(/\/index\.html$/, '')}`;
|
|
169
|
+
let data = this.props.schema.data;
|
|
170
|
+
if (data === undefined && this.props.schema.jsonData) {
|
|
171
|
+
data = this.getPattern(this.props.schema.jsonData, Object.assign({ _origin,
|
|
172
|
+
_originIp }, this.props.data));
|
|
173
|
+
console.log(this.props.schema.jsonData);
|
|
174
|
+
try {
|
|
175
|
+
data = JSON.parse(data);
|
|
297
176
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
});
|
|
301
|
-
} else {
|
|
302
|
-
_this3.setState({
|
|
303
|
-
_error: response.error ? _i18n["default"].t(response.error) : _i18n["default"].t('ra_Error')
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
} else {
|
|
307
|
-
if (response !== null && response !== void 0 && response.reloadBrowser && _this3.props.schema.reloadBrowser) {
|
|
308
|
-
window.location.reload();
|
|
309
|
-
} else if (response !== null && response !== void 0 && response.openUrl && _this3.props.schema.openUrl) {
|
|
310
|
-
window.open(response.openUrl, response.window || _this3.props.schema.window || '_blank');
|
|
311
|
-
} else if (response !== null && response !== void 0 && response.result && _this3.props.schema.result && _this3.props.schema.result[response.result]) {
|
|
312
|
-
var text = _this3.getText(_this3.props.schema.result[response.result]);
|
|
313
|
-
if (response.args) {
|
|
314
|
-
response.args.forEach(function (arg) {
|
|
315
|
-
return text = text.replace('%s', arg);
|
|
316
|
-
});
|
|
177
|
+
catch (e) {
|
|
178
|
+
console.error(`Cannot parse json data: ${data}`);
|
|
317
179
|
}
|
|
318
|
-
window.alert(text);
|
|
319
|
-
}
|
|
320
|
-
if (response !== null && response !== void 0 && response["native"] && _this3.props.schema.useNative) {
|
|
321
|
-
var attrs = Object.keys(response["native"]);
|
|
322
|
-
attrs.forEach(function (attr) {
|
|
323
|
-
return _this3.onChange(attr, response["native"][attr]);
|
|
324
|
-
});
|
|
325
|
-
setTimeout(function () {
|
|
326
|
-
return _this3.props.forceUpdate(attrs, _this3.props.data);
|
|
327
|
-
}, 300);
|
|
328
|
-
} else if (response !== null && response !== void 0 && response.result) {
|
|
329
|
-
window.alert((0, _typeof2["default"])(response.result) === 'object' ? JSON.stringify(response.result) : response.result);
|
|
330
|
-
} else {
|
|
331
|
-
window.alert(_i18n["default"].t('ra_Ok'));
|
|
332
|
-
}
|
|
333
|
-
if (response !== null && response !== void 0 && response.saveConfig) {
|
|
334
|
-
_this3.props.onChange(null, null, null, true);
|
|
335
|
-
}
|
|
336
180
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
});
|
|
181
|
+
if (data === undefined) {
|
|
182
|
+
data = null;
|
|
183
|
+
}
|
|
184
|
+
if (this.props.schema.openUrl && !data) {
|
|
185
|
+
data = {
|
|
186
|
+
_origin,
|
|
187
|
+
_originIp,
|
|
188
|
+
};
|
|
346
189
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
190
|
+
let timeout;
|
|
191
|
+
if (this.props.schema.timeout) {
|
|
192
|
+
timeout = setTimeout(() => {
|
|
193
|
+
this.props.onCommandRunning(false);
|
|
194
|
+
this.setState({ _error: i18n_1.default.t('ra_Request timed out'), running: false });
|
|
195
|
+
}, parseInt(this.props.schema.timeout, 10) || 10000);
|
|
196
|
+
}
|
|
197
|
+
this.props.socket.sendTo(`${this.props.adapterName}.${this.props.instance}`, this.props.schema.command || 'send', data)
|
|
198
|
+
.then(async (response) => {
|
|
199
|
+
if (timeout) {
|
|
200
|
+
clearTimeout(timeout);
|
|
201
|
+
timeout = undefined;
|
|
202
|
+
}
|
|
203
|
+
if (response === null || response === void 0 ? void 0 : response.error) {
|
|
204
|
+
if (this.props.schema.error && this.props.schema.error[response.error]) {
|
|
205
|
+
let error = this.getText(this.props.schema.error[response.error]);
|
|
206
|
+
if (response.args) {
|
|
207
|
+
response.args.forEach((arg) => error = error.replace('%s', arg));
|
|
208
|
+
}
|
|
209
|
+
this.setState({ _error: error });
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.setState({ _error: response.error ? i18n_1.default.t(response.error) : i18n_1.default.t('ra_Error') });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
if ((response === null || response === void 0 ? void 0 : response.reloadBrowser) && this.props.schema.reloadBrowser) {
|
|
217
|
+
window.location.reload();
|
|
218
|
+
}
|
|
219
|
+
else if ((response === null || response === void 0 ? void 0 : response.openUrl) && this.props.schema.openUrl) {
|
|
220
|
+
window.open(response.openUrl, response.window || this.props.schema.window || '_blank');
|
|
221
|
+
}
|
|
222
|
+
else if ((response === null || response === void 0 ? void 0 : response.result) && this.props.schema.result && this.props.schema.result[response.result]) {
|
|
223
|
+
let text = this.getText(this.props.schema.result[response.result]);
|
|
224
|
+
if (response.args) {
|
|
225
|
+
response.args.forEach((arg) => text = text.replace('%s', arg));
|
|
226
|
+
}
|
|
227
|
+
window.alert(text);
|
|
228
|
+
}
|
|
229
|
+
if ((response === null || response === void 0 ? void 0 : response.native) && this.props.schema.useNative) {
|
|
230
|
+
for (const [attr, val] of Object.entries(response.native)) {
|
|
231
|
+
await this.onChangeAsync(attr, val);
|
|
232
|
+
}
|
|
233
|
+
setTimeout(() => this.props.forceUpdate(Object.keys(response.native), this.props.data), 300);
|
|
234
|
+
}
|
|
235
|
+
else if (response === null || response === void 0 ? void 0 : response.result) {
|
|
236
|
+
window.alert(typeof response.result === 'object' ? JSON.stringify(response.result) : response.result);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
window.alert(i18n_1.default.t('ra_Ok'));
|
|
240
|
+
}
|
|
241
|
+
if (response === null || response === void 0 ? void 0 : response.saveConfig) {
|
|
242
|
+
// @ts-expect-error 4 values intended?
|
|
243
|
+
this.props.onChange(null, null, null, true);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
.catch((e) => {
|
|
248
|
+
if (this.props.schema.error && this.props.schema.error[e.toString()]) {
|
|
249
|
+
this.setState({ _error: this.getText(this.props.schema.error[e.toString()]) });
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.setState({ _error: i18n_1.default.t(e.toString()) || i18n_1.default.t('ra_Error') });
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
.then(() => {
|
|
256
|
+
this.props.onCommandRunning(false);
|
|
257
|
+
this.setState({ running: false });
|
|
351
258
|
});
|
|
352
|
-
});
|
|
353
259
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
var _this4 = this;
|
|
358
|
-
if (!this.state.confirmDialog) {
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
var confirm = this.state.confirmData || this.props.schema.confirm;
|
|
362
|
-
var icon = null;
|
|
363
|
-
if (confirm.type === 'warning') {
|
|
364
|
-
icon = /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Warning, null);
|
|
365
|
-
} else if (confirm.type === 'error') {
|
|
366
|
-
icon = /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Error, null);
|
|
367
|
-
} else if (confirm.type === 'info') {
|
|
368
|
-
icon = /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Info, null);
|
|
369
|
-
}
|
|
370
|
-
return /*#__PURE__*/_react["default"].createElement(_Confirm["default"], {
|
|
371
|
-
title: this.getText(confirm.title) || _i18n["default"].t('ra_Please confirm'),
|
|
372
|
-
text: this.getText(confirm.text),
|
|
373
|
-
ok: this.getText(confirm.ok) || _i18n["default"].t('ra_Ok'),
|
|
374
|
-
cancel: this.getText(confirm.cancel) || _i18n["default"].t('ra_Cancel'),
|
|
375
|
-
icon: icon,
|
|
376
|
-
onClose: function onClose(isOk) {
|
|
377
|
-
return _this4.setState({
|
|
378
|
-
confirmDialog: false
|
|
379
|
-
}, function () {
|
|
380
|
-
return isOk && _this4._onClick();
|
|
381
|
-
});
|
|
260
|
+
renderConfirmDialog() {
|
|
261
|
+
if (!this.state.confirmDialog) {
|
|
262
|
+
return null;
|
|
382
263
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
391
|
-
className: this.props.classes.fullWidth
|
|
392
|
-
}, /*#__PURE__*/_react["default"].createElement(_material.Button, {
|
|
393
|
-
variant: this.props.schema.variant || undefined,
|
|
394
|
-
color: this.props.schema.color || 'grey',
|
|
395
|
-
className: this.props.classes.fullWidth,
|
|
396
|
-
disabled: disabled || !this.props.alive,
|
|
397
|
-
startIcon: icon,
|
|
398
|
-
title: this.props.alive ? this.getText(this.props.schema.title) || '' : _i18n["default"].t('ra_Instance is not alive'),
|
|
399
|
-
onClick: function onClick() {
|
|
400
|
-
if (_this5.props.schema.confirm) {
|
|
401
|
-
_this5.setState({
|
|
402
|
-
confirmDialog: true
|
|
403
|
-
});
|
|
404
|
-
} else {
|
|
405
|
-
_this5._onClick();
|
|
406
|
-
}
|
|
264
|
+
const confirm = this.state.confirmData || this.props.schema.confirm;
|
|
265
|
+
let icon = null;
|
|
266
|
+
if (confirm.type === 'warning') {
|
|
267
|
+
icon = react_1.default.createElement(icons_material_1.Warning, null);
|
|
268
|
+
}
|
|
269
|
+
else if (confirm.type === 'error') {
|
|
270
|
+
icon = react_1.default.createElement(icons_material_1.Error, null);
|
|
407
271
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
style: {
|
|
411
|
-
marginRight: 8
|
|
272
|
+
else if (confirm.type === 'info') {
|
|
273
|
+
icon = react_1.default.createElement(icons_material_1.Info, null);
|
|
412
274
|
}
|
|
413
|
-
|
|
275
|
+
return react_1.default.createElement(Confirm_1.default, { title: this.getText(confirm.title) || i18n_1.default.t('ra_Please confirm'), text: this.getText(confirm.text), ok: this.getText(confirm.ok) || i18n_1.default.t('ra_Ok'), cancel: this.getText(confirm.cancel) || i18n_1.default.t('ra_Cancel'), icon: icon, onClose: isOk => this.setState({ confirmDialog: false }, () => isOk && this._onClick()) });
|
|
414
276
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var _default = exports["default"] = (0, _styles.withStyles)(styles)(ConfigSendto);
|
|
434
|
-
//# sourceMappingURL=ConfigSendto.js.map
|
|
277
|
+
renderItem(error, disabled) {
|
|
278
|
+
const icon = this.getIcon();
|
|
279
|
+
return react_1.default.createElement("div", { className: this.props.classes.fullWidth },
|
|
280
|
+
react_1.default.createElement(material_1.Button, { variant: this.props.schema.variant || undefined, color: this.props.schema.color || 'grey', className: this.props.classes.fullWidth, disabled: disabled || !this.props.alive, startIcon: icon, title: this.props.alive ? this.getText(this.props.schema.title) || '' : i18n_1.default.t('ra_Instance is not alive'), onClick: () => {
|
|
281
|
+
if (this.props.schema.confirm) {
|
|
282
|
+
this.setState({ confirmDialog: true });
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
this._onClick();
|
|
286
|
+
}
|
|
287
|
+
} },
|
|
288
|
+
this.props.schema.showProcess && this.state.running ? react_1.default.createElement(material_1.CircularProgress, { size: 20, style: { marginRight: 8 } }) : null,
|
|
289
|
+
this.getText(this.props.schema.label, this.props.schema.noTranslation)),
|
|
290
|
+
this.renderErrorDialog(),
|
|
291
|
+
this.renderMessageDialog());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.default = (0, styles_1.withStyles)(styles)(ConfigSendto);
|