@iobroker/dm-gui-components 0.1.0 → 6.13.7
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/Communication.js +247 -0
- package/build/Communication.js.map +1 -0
- package/build/DeviceActionButton.js +10 -0
- package/build/DeviceActionButton.js.map +1 -0
- package/build/DeviceCard.js +307 -0
- package/build/DeviceCard.js.map +1 -0
- package/build/DeviceControl.js +119 -0
- package/build/DeviceControl.js.map +1 -0
- package/{DeviceImageUpload.js → build/DeviceImageUpload.js} +5 -9
- package/build/DeviceImageUpload.js.map +1 -0
- package/build/DeviceList.js +235 -0
- package/build/DeviceList.js.map +1 -0
- package/build/DeviceStatus.js +106 -0
- package/build/DeviceStatus.js.map +1 -0
- package/build/InstanceActionButton.js +11 -0
- package/build/InstanceActionButton.js.map +1 -0
- package/{JsonConfig.js → build/JsonConfig.js} +10 -33
- package/build/JsonConfig.js.map +1 -0
- package/build/TooltipButton.js +17 -0
- package/build/TooltipButton.js.map +1 -0
- package/build/Utils.js +149 -0
- package/build/Utils.js.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/package.json +14 -16
- package/Communication.js +0 -268
- package/DeviceActionButton.js +0 -15
- package/DeviceCard.js +0 -338
- package/DeviceControl.js +0 -146
- package/DeviceList.js +0 -226
- package/DeviceStatus.js +0 -111
- package/InstanceActionButton.js +0 -16
- package/TooltipButton.js +0 -22
- package/Utils.js +0 -157
- package/index.js +0 -7
- package/{Communication.d.ts → build/Communication.d.ts} +0 -0
- package/{DeviceActionButton.d.ts → build/DeviceActionButton.d.ts} +0 -0
- package/{DeviceCard.d.ts → build/DeviceCard.d.ts} +0 -0
- package/{DeviceControl.d.ts → build/DeviceControl.d.ts} +0 -0
- package/{DeviceImageUpload.d.ts → build/DeviceImageUpload.d.ts} +0 -0
- package/{DeviceList.d.ts → build/DeviceList.d.ts} +0 -0
- package/{DeviceStatus.d.ts → build/DeviceStatus.d.ts} +0 -0
- package/{InstanceActionButton.d.ts → build/InstanceActionButton.d.ts} +0 -0
- package/{JsonConfig.d.ts → build/JsonConfig.d.ts} +0 -0
- package/{TooltipButton.d.ts → build/TooltipButton.d.ts} +0 -0
- package/{Utils.d.ts → build/Utils.d.ts} +0 -0
- package/{i18n → build/i18n}/de.json +0 -0
- package/{i18n → build/i18n}/en.json +0 -0
- package/{i18n → build/i18n}/es.json +0 -0
- package/{i18n → build/i18n}/fr.json +0 -0
- package/{i18n → build/i18n}/it.json +0 -0
- package/{i18n → build/i18n}/nl.json +0 -0
- package/{i18n → build/i18n}/pl.json +0 -0
- package/{i18n → build/i18n}/pt.json +0 -0
- package/{i18n → build/i18n}/ru.json +0 -0
- package/{i18n → build/i18n}/uk.json +0 -0
- package/{i18n → build/i18n}/zh-cn.json +0 -0
- package/{index.d.ts → build/index.d.ts} +1 -1
package/build/Utils.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Add, Delete, Edit, Refresh, Search, Wifi, WifiOff, Bluetooth, BluetoothDisabled, Visibility, LinkOff, Link as LinkIcon, NotListedLocation, PlayArrow, Stop, FastForward, FastRewind, Pause, Lightbulb, Power, Fluorescent, WbIncandescent, } from '@mui/icons-material';
|
|
3
|
+
import { I18n, Icon, } from '@iobroker/adapter-react-v5';
|
|
4
|
+
export function renderIcon(action, colors, value) {
|
|
5
|
+
if (!action) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
let color = (value && action.colorOn) || action.color || (action.state ? 'primary' : 'inherit');
|
|
9
|
+
if (colors) {
|
|
10
|
+
if (color === 'primary') {
|
|
11
|
+
color = colors.primary;
|
|
12
|
+
}
|
|
13
|
+
else if (color === 'secondary') {
|
|
14
|
+
color = colors.secondary;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (action.icon?.startsWith('fa-') || action.icon?.startsWith('fas')) {
|
|
18
|
+
const iconStyle = action.icon.split(' ').map(s => s.trim()).filter(s => s !== 'fa-solid');
|
|
19
|
+
if (iconStyle.includes('fa-trash-can') || iconStyle.includes('fa-trash')) {
|
|
20
|
+
return React.createElement(Delete, { style: { color } });
|
|
21
|
+
}
|
|
22
|
+
if (iconStyle.includes('fa-pen')) {
|
|
23
|
+
return React.createElement(Edit, { style: { color } });
|
|
24
|
+
}
|
|
25
|
+
if (iconStyle.includes('fa-redo-alt')) {
|
|
26
|
+
return React.createElement(Refresh, { style: { color } });
|
|
27
|
+
}
|
|
28
|
+
if (iconStyle.includes('fa-plus')) {
|
|
29
|
+
return React.createElement(Add, { style: { color } });
|
|
30
|
+
}
|
|
31
|
+
if (iconStyle.includes('fa-wifi')) {
|
|
32
|
+
return React.createElement(Wifi, { style: { color } });
|
|
33
|
+
}
|
|
34
|
+
if (iconStyle.includes('fa-wifi-slash')) {
|
|
35
|
+
return React.createElement(WifiOff, { style: { color } });
|
|
36
|
+
}
|
|
37
|
+
if (iconStyle.includes('fa-bluetooth')) {
|
|
38
|
+
return React.createElement(Bluetooth, { style: { color } });
|
|
39
|
+
}
|
|
40
|
+
if (iconStyle.includes('fa-bluetooth-slash')) {
|
|
41
|
+
return React.createElement(BluetoothDisabled, { style: { color } });
|
|
42
|
+
}
|
|
43
|
+
if (iconStyle.includes('fa-eye')) {
|
|
44
|
+
return React.createElement(Visibility, { style: { color } });
|
|
45
|
+
}
|
|
46
|
+
if (iconStyle.includes('fa-search')) {
|
|
47
|
+
return React.createElement(Search, { style: { color } });
|
|
48
|
+
}
|
|
49
|
+
if (iconStyle.includes('fa-unlink')) {
|
|
50
|
+
return React.createElement(LinkOff, { style: { color } });
|
|
51
|
+
}
|
|
52
|
+
if (iconStyle.includes('fa-link')) {
|
|
53
|
+
return React.createElement(LinkIcon, { style: { color } });
|
|
54
|
+
}
|
|
55
|
+
if (iconStyle.includes('fa-search-location')) {
|
|
56
|
+
return React.createElement(NotListedLocation, { style: { color } });
|
|
57
|
+
}
|
|
58
|
+
if (iconStyle.includes('fa-play')) {
|
|
59
|
+
return React.createElement(PlayArrow, { style: { color } });
|
|
60
|
+
}
|
|
61
|
+
if (iconStyle.includes('fa-stop')) {
|
|
62
|
+
return React.createElement(Stop, { style: { color } });
|
|
63
|
+
}
|
|
64
|
+
if (iconStyle.includes('fa-pause')) {
|
|
65
|
+
return React.createElement(Pause, { style: { color } });
|
|
66
|
+
}
|
|
67
|
+
if (iconStyle.includes('forward') || iconStyle.includes('fa-forward')) {
|
|
68
|
+
return React.createElement(FastForward, { style: { color } });
|
|
69
|
+
}
|
|
70
|
+
if (iconStyle.includes('rewind') || iconStyle.includes('fa-rewind')) {
|
|
71
|
+
return React.createElement(FastRewind, { style: { color } });
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
if (value && action.iconOn?.startsWith('data:image')) {
|
|
76
|
+
return React.createElement(Icon, { src: action.iconOn, style: { color } });
|
|
77
|
+
}
|
|
78
|
+
if (action.icon?.startsWith('data:image')) {
|
|
79
|
+
return React.createElement(Icon, { src: action.icon, style: { color } });
|
|
80
|
+
}
|
|
81
|
+
if (action.id === 'edit' || action.id === 'rename') {
|
|
82
|
+
return React.createElement(Edit, { style: { color } });
|
|
83
|
+
}
|
|
84
|
+
if (action.id === 'delete') {
|
|
85
|
+
return React.createElement(Delete, { style: { color } });
|
|
86
|
+
}
|
|
87
|
+
if (action.id === 'refresh') {
|
|
88
|
+
return React.createElement(Refresh, { style: { color } });
|
|
89
|
+
}
|
|
90
|
+
if (action.id === 'newDevice' || action.id === 'new' || action.id === 'add') {
|
|
91
|
+
return React.createElement(Add, { style: { color } });
|
|
92
|
+
}
|
|
93
|
+
if (action.id === 'discover' || action.id === 'search') {
|
|
94
|
+
return React.createElement(Search, { style: { color } });
|
|
95
|
+
}
|
|
96
|
+
if (action.id === 'unpairDevice') {
|
|
97
|
+
return React.createElement(LinkOff, { style: { color } });
|
|
98
|
+
}
|
|
99
|
+
if (action.id === 'pairDevice') {
|
|
100
|
+
return React.createElement(LinkIcon, { style: { color } });
|
|
101
|
+
}
|
|
102
|
+
if (action.id === 'identify') {
|
|
103
|
+
return React.createElement(NotListedLocation, { style: { color } });
|
|
104
|
+
}
|
|
105
|
+
if (action.id === 'play') {
|
|
106
|
+
return React.createElement(PlayArrow, { style: { color } });
|
|
107
|
+
}
|
|
108
|
+
if (action.id === 'stop') {
|
|
109
|
+
return React.createElement(Stop, { style: { color } });
|
|
110
|
+
}
|
|
111
|
+
if (action.id === 'pause') {
|
|
112
|
+
return React.createElement(Pause, { style: { color } });
|
|
113
|
+
}
|
|
114
|
+
if (action.id === 'forward' || action.id === 'next') {
|
|
115
|
+
return React.createElement(FastForward, { style: { color } });
|
|
116
|
+
}
|
|
117
|
+
if (action.id === 'rewind' || action.id === 'previous') {
|
|
118
|
+
return React.createElement(FastRewind, { style: { color } });
|
|
119
|
+
}
|
|
120
|
+
if (action.id === 'lamp' || action.id === 'light') {
|
|
121
|
+
return React.createElement(Lightbulb, { style: { color } });
|
|
122
|
+
}
|
|
123
|
+
if (action.id === 'backlight') {
|
|
124
|
+
return React.createElement(Fluorescent, { style: { color } });
|
|
125
|
+
}
|
|
126
|
+
if (action.id === 'dimmer') {
|
|
127
|
+
return React.createElement(WbIncandescent, { style: { color } });
|
|
128
|
+
}
|
|
129
|
+
if (action.id === 'socket') {
|
|
130
|
+
return React.createElement(Power, { style: { color } });
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
let language;
|
|
135
|
+
/**
|
|
136
|
+
* Get Translation
|
|
137
|
+
* @param {string | object} text - Text to translate
|
|
138
|
+
* @returns {string}
|
|
139
|
+
*/
|
|
140
|
+
export function getTranslation(text) {
|
|
141
|
+
language = language || I18n.getLanguage();
|
|
142
|
+
if (typeof text === 'object') {
|
|
143
|
+
const words = text;
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
return words[language] || text.en;
|
|
146
|
+
}
|
|
147
|
+
return I18n.t(text);
|
|
148
|
+
}
|
|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D,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;IAE1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAmC,CAAC;QAClD,aAAa;QACb,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;IACtC,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/dm-gui-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.13.7",
|
|
4
4
|
"description": "ReactJS components to develop admin interface for ioBroker device manager.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jey Cee",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"email": "dogafox@gmail.com"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"clean": "rimraf build",
|
|
21
|
+
"build": "tsc && tsc-alias"
|
|
22
|
+
},
|
|
18
23
|
"repository": {
|
|
19
24
|
"type": "git",
|
|
20
25
|
"url": "git+https://github.com/ioBroker/dm-gui-components.git"
|
|
@@ -22,7 +27,12 @@
|
|
|
22
27
|
"publishConfig": {
|
|
23
28
|
"access": "public"
|
|
24
29
|
},
|
|
25
|
-
"
|
|
30
|
+
"files": [
|
|
31
|
+
"build",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"module": "./build/index.js",
|
|
35
|
+
"types": "./build/index.d.ts",
|
|
26
36
|
"keywords": [
|
|
27
37
|
"iobroker",
|
|
28
38
|
"adapter",
|
|
@@ -34,18 +44,6 @@
|
|
|
34
44
|
},
|
|
35
45
|
"homepage": "https://github.com/ioBroker/dm-gui-components#readme",
|
|
36
46
|
"dependencies": {
|
|
37
|
-
"react": "^
|
|
38
|
-
"react-dom": "^18.2.0",
|
|
39
|
-
"@iobroker/adapter-react-v5": "^4.9.1",
|
|
40
|
-
"@mui/icons-material": "^5.15.1",
|
|
41
|
-
"@mui/material": "5.14.14",
|
|
42
|
-
"@types/react": "^18.2.45",
|
|
43
|
-
"@types/react-dom": "^18.2.18",
|
|
44
|
-
"eslint": "^8.56.0",
|
|
45
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
46
|
-
"eslint-plugin-eqeqeq-fix": "^1.0.3",
|
|
47
|
-
"eslint-plugin-react": "^7.33.2",
|
|
48
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
49
|
-
"eslint-plugin-react-refresh": "^0.4.5"
|
|
47
|
+
"@iobroker/adapter-react-v5": "^4.9.1"
|
|
50
48
|
}
|
|
51
|
-
}
|
|
49
|
+
}
|
package/Communication.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
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 material_1 = require("@mui/material");
|
|
31
|
-
const Utils_1 = require("./Utils");
|
|
32
|
-
const JsonConfig_1 = __importDefault(require("./JsonConfig"));
|
|
33
|
-
/**
|
|
34
|
-
* Device List Component
|
|
35
|
-
* @param {object} params - Component parameters
|
|
36
|
-
* @param {object} params.socket - socket object
|
|
37
|
-
* @param {string} params.selectedInstance - Selected instance
|
|
38
|
-
* @returns {*[]} - Array of device cards
|
|
39
|
-
*/
|
|
40
|
-
class Communication extends react_1.Component {
|
|
41
|
-
constructor(props) {
|
|
42
|
-
super(props);
|
|
43
|
-
this.sendActionToInstance = (command, messageToSend, refresh) => {
|
|
44
|
-
const send = async () => {
|
|
45
|
-
this.setState({ showSpinner: true });
|
|
46
|
-
/** @type {object} */
|
|
47
|
-
const response = await this.props.socket.sendTo(this.props.selectedInstance, command, messageToSend);
|
|
48
|
-
/** @type {string} */
|
|
49
|
-
const type = response.type;
|
|
50
|
-
console.log(`Response: ${response.type}`);
|
|
51
|
-
switch (type) {
|
|
52
|
-
case 'message':
|
|
53
|
-
console.log(`Message received: ${response.message}`);
|
|
54
|
-
if (response.message) {
|
|
55
|
-
this.setState({
|
|
56
|
-
message: {
|
|
57
|
-
message: response.message,
|
|
58
|
-
handleClose: () => this.setState({ message: null }, () => this.sendActionToInstance('dm:actionProgress', { origin: response.origin })),
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
break;
|
|
63
|
-
case 'confirm':
|
|
64
|
-
console.log(`Confirm received: ${response.confirm}`);
|
|
65
|
-
if (response.confirm) {
|
|
66
|
-
this.setState({
|
|
67
|
-
confirm: {
|
|
68
|
-
message: response.confirm,
|
|
69
|
-
handleClose: (confirm) => this.setState({ confirm: null }, () => this.sendActionToInstance('dm:actionProgress', {
|
|
70
|
-
origin: response.origin,
|
|
71
|
-
confirm,
|
|
72
|
-
})),
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case 'form':
|
|
78
|
-
console.log('Form received');
|
|
79
|
-
if (response.form) {
|
|
80
|
-
this.setState({
|
|
81
|
-
form: Object.assign(Object.assign({}, response.form), { handleClose: (data) => this.setState({ form: null }, () => {
|
|
82
|
-
console.log(`Form ${JSON.stringify(data)}`);
|
|
83
|
-
this.sendActionToInstance('dm:actionProgress', {
|
|
84
|
-
origin: response.origin,
|
|
85
|
-
data,
|
|
86
|
-
});
|
|
87
|
-
}) }),
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
case 'progress':
|
|
92
|
-
if (response.progress) {
|
|
93
|
-
if (this.state.progress) {
|
|
94
|
-
const progress = Object.assign(Object.assign({}, this.state.progress), response.progress);
|
|
95
|
-
this.setState({ progress });
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.setState({ progress: response.progress });
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
this.sendActionToInstance('dm:actionProgress', { origin: response.origin });
|
|
102
|
-
break;
|
|
103
|
-
case 'result':
|
|
104
|
-
console.log('Response content', response.result);
|
|
105
|
-
if (response.result.refresh) {
|
|
106
|
-
if (response.result.refresh === true) {
|
|
107
|
-
this.loadData();
|
|
108
|
-
console.log('Refreshing all');
|
|
109
|
-
}
|
|
110
|
-
else if (response.result.refresh === 'instance') {
|
|
111
|
-
console.log(`Refreshing instance infos: ${this.props.selectedInstance}`);
|
|
112
|
-
}
|
|
113
|
-
else if (response.result.refresh === 'device') {
|
|
114
|
-
if (refresh) {
|
|
115
|
-
console.log(`Refreshing device infos: ${this.props.selectedInstance}`);
|
|
116
|
-
refresh();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
console.log('Not refreshing anything');
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (response.result.error) {
|
|
124
|
-
console.error(`Error: ${response.result.error}`);
|
|
125
|
-
this.setState({ showToast: response.result.error.message });
|
|
126
|
-
}
|
|
127
|
-
this.setState({ showSpinner: false });
|
|
128
|
-
break;
|
|
129
|
-
default:
|
|
130
|
-
console.log(`Unknown response type: ${type}`);
|
|
131
|
-
this.setState({ showSpinner: false });
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
send().catch(console.error);
|
|
136
|
-
};
|
|
137
|
-
this.sendControlToInstance = async (command, messageToSend) => {
|
|
138
|
-
const response = await this.props.socket.sendTo(this.props.selectedInstance, command, messageToSend);
|
|
139
|
-
const type = response.type;
|
|
140
|
-
console.log(`Response: ${response.type}`);
|
|
141
|
-
if (response.type === 'result') {
|
|
142
|
-
console.log('Response content', response.result);
|
|
143
|
-
if (response.result.error) {
|
|
144
|
-
console.error(`Error: ${response.result.error}`);
|
|
145
|
-
this.setState({ showToast: response.result.error.message });
|
|
146
|
-
}
|
|
147
|
-
else if (response.result.state !== undefined) {
|
|
148
|
-
return response.result.state;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
console.warn('Unexpected response type', type);
|
|
153
|
-
}
|
|
154
|
-
return null;
|
|
155
|
-
};
|
|
156
|
-
// @ts-expect-error
|
|
157
|
-
this.state = {
|
|
158
|
-
showSpinner: false,
|
|
159
|
-
showToast: null,
|
|
160
|
-
message: null,
|
|
161
|
-
confirm: null,
|
|
162
|
-
form: null,
|
|
163
|
-
progress: null,
|
|
164
|
-
};
|
|
165
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
166
|
-
this.instanceHandler = action => () => this.sendActionToInstance('dm:instanceAction', { actionId: action.id });
|
|
167
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
168
|
-
this.deviceHandler = (deviceId, action, refresh) => () => this.sendActionToInstance('dm:deviceAction', { deviceId, actionId: action.id }, refresh);
|
|
169
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
170
|
-
this.controlHandler = (deviceId, control, state) => () => this.sendControlToInstance('dm:deviceControl', { deviceId, controlId: control.id, state });
|
|
171
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
172
|
-
this.controlStateHandler = (deviceId, control) => () => this.sendControlToInstance('dm:deviceControlState', { deviceId, controlId: control.id });
|
|
173
|
-
this.props.registerHandler && this.props.registerHandler(() => this.loadData());
|
|
174
|
-
}
|
|
175
|
-
// eslint-disable-next-line class-methods-use-this
|
|
176
|
-
loadData() {
|
|
177
|
-
console.error('loadData not implemented');
|
|
178
|
-
}
|
|
179
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
180
|
-
loadDevices() {
|
|
181
|
-
return this.props.socket.sendTo(this.props.selectedInstance, 'dm:listDevices');
|
|
182
|
-
}
|
|
183
|
-
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
184
|
-
loadInstanceInfos() {
|
|
185
|
-
return this.props.socket.sendTo(this.props.selectedInstance, 'dm:instanceInfo');
|
|
186
|
-
}
|
|
187
|
-
renderMessageDialog() {
|
|
188
|
-
var _a;
|
|
189
|
-
if (!this.state.message) {
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
return react_1.default.createElement(material_1.Dialog, { open: !0, onClose: () => { var _a; return (_a = this.state.message) === null || _a === void 0 ? void 0 : _a.handleClose(); }, hideBackdrop: true, "aria-describedby": "message-dialog-description" },
|
|
193
|
-
react_1.default.createElement(material_1.DialogContent, null,
|
|
194
|
-
react_1.default.createElement(material_1.DialogContentText, { id: "message-dialog-description" }, (_a = this.state.message) === null || _a === void 0 ? void 0 : _a.message)),
|
|
195
|
-
react_1.default.createElement(material_1.DialogActions, null,
|
|
196
|
-
react_1.default.createElement(material_1.Button, { onClick: () => { var _a; return (_a = this.state.message) === null || _a === void 0 ? void 0 : _a.handleClose(); }, autoFocus: true }, (0, Utils_1.getTranslation)('okButtonText'))));
|
|
197
|
-
}
|
|
198
|
-
renderConfirmDialog() {
|
|
199
|
-
var _a;
|
|
200
|
-
if (!this.state.confirm) {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
return react_1.default.createElement(material_1.Dialog, { open: !0, onClose: () => { var _a; return (_a = this.state.confirm) === null || _a === void 0 ? void 0 : _a.handleClose(); }, hideBackdrop: true, "aria-describedby": "confirm-dialog-description" },
|
|
204
|
-
react_1.default.createElement(material_1.DialogContent, null,
|
|
205
|
-
react_1.default.createElement(material_1.DialogContentText, { id: "confirm-dialog-description" }, (0, Utils_1.getTranslation)((_a = this.state.confirm) === null || _a === void 0 ? void 0 : _a.message))),
|
|
206
|
-
react_1.default.createElement(material_1.DialogActions, null,
|
|
207
|
-
react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", onClick: () => { var _a; return (_a = this.state.confirm) === null || _a === void 0 ? void 0 : _a.handleClose(true); }, autoFocus: true }, (0, Utils_1.getTranslation)('yesButtonText')),
|
|
208
|
-
react_1.default.createElement(material_1.Button, { variant: "contained",
|
|
209
|
-
// @ts-expect-error
|
|
210
|
-
color: "grey", onClick: () => { var _a; return (_a = this.state.confirm) === null || _a === void 0 ? void 0 : _a.handleClose(false); }, autoFocus: true, hideBackdrop: true }, (0, Utils_1.getTranslation)('noButtonText'))));
|
|
211
|
-
}
|
|
212
|
-
renderSnackbar() {
|
|
213
|
-
return react_1.default.createElement(material_1.Snackbar, { open: !!this.state.showToast, autoHideDuration: 6000, onClose: () => this.setState({ showToast: null }), message: this.state.showToast });
|
|
214
|
-
}
|
|
215
|
-
renderFormDialog() {
|
|
216
|
-
var _a, _b;
|
|
217
|
-
if (!this.state.form || !this.state.form.schema || !this.state.form.data) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
return react_1.default.createElement(material_1.Dialog, { open: !0, onClose: () => { var _a; return ((_a = this.state.form) === null || _a === void 0 ? void 0 : _a.handleClose) && this.state.form.handleClose(); }, hideBackdrop: true },
|
|
221
|
-
((_a = this.state.form) === null || _a === void 0 ? void 0 : _a.title) ? react_1.default.createElement(material_1.DialogTitle, null, (0, Utils_1.getTranslation)((_b = this.state.form) === null || _b === void 0 ? void 0 : _b.title)) : null,
|
|
222
|
-
react_1.default.createElement(material_1.DialogContent, null,
|
|
223
|
-
react_1.default.createElement(JsonConfig_1.default, { instanceId: this.props.selectedInstance, schema: this.state.form.schema, data: this.state.form.data, socket: this.props.socket, onChange: (data) => {
|
|
224
|
-
console.log('handleFormChange', { data });
|
|
225
|
-
const form = Object.assign({}, this.state.form);
|
|
226
|
-
if (form) {
|
|
227
|
-
form.data = data;
|
|
228
|
-
this.setState({ form });
|
|
229
|
-
}
|
|
230
|
-
} })),
|
|
231
|
-
react_1.default.createElement(material_1.DialogActions, null,
|
|
232
|
-
react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", onClick: () => { var _a, _b; return ((_a = this.state.form) === null || _a === void 0 ? void 0 : _a.handleClose) && this.state.form.handleClose((_b = this.state.form) === null || _b === void 0 ? void 0 : _b.data); }, autoFocus: true }, (0, Utils_1.getTranslation)('okButtonText')),
|
|
233
|
-
react_1.default.createElement(material_1.Button, { variant: "contained",
|
|
234
|
-
// @ts-expect-error
|
|
235
|
-
color: "grey", onClick: () => { var _a; return ((_a = this.state.form) === null || _a === void 0 ? void 0 : _a.handleClose) && this.state.form.handleClose(); }, hideBackdrop: true }, (0, Utils_1.getTranslation)('cancelButtonText'))));
|
|
236
|
-
}
|
|
237
|
-
renderProgressDialog() {
|
|
238
|
-
var _a, _b;
|
|
239
|
-
if (!((_a = this.state.progress) === null || _a === void 0 ? void 0 : _a.open)) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
return react_1.default.createElement(material_1.Dialog, { open: !0, onClose: () => { }, hideBackdrop: true },
|
|
243
|
-
react_1.default.createElement(material_1.LinearProgress, { variant: "determinate", value: ((_b = this.state.progress) === null || _b === void 0 ? void 0 : _b.progress) || 0 }));
|
|
244
|
-
}
|
|
245
|
-
// eslint-disable-next-line class-methods-use-this
|
|
246
|
-
renderContent() {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
renderSpinner() {
|
|
250
|
-
var _a;
|
|
251
|
-
if (!this.state.showSpinner && !((_a = this.state.progress) === null || _a === void 0 ? void 0 : _a.open) && !this.state.message && !this.state.confirm && !this.state.form) {
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
return react_1.default.createElement(material_1.Backdrop, { style: { zIndex: 1000 }, open: !0 },
|
|
255
|
-
react_1.default.createElement(material_1.CircularProgress, null));
|
|
256
|
-
}
|
|
257
|
-
render() {
|
|
258
|
-
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
259
|
-
this.renderSnackbar(),
|
|
260
|
-
this.renderContent(),
|
|
261
|
-
this.renderSpinner(),
|
|
262
|
-
this.renderConfirmDialog(),
|
|
263
|
-
this.renderMessageDialog(),
|
|
264
|
-
this.renderFormDialog(),
|
|
265
|
-
this.renderProgressDialog());
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
exports.default = Communication;
|
package/DeviceActionButton.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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_js_1 = __importDefault(require("./TooltipButton.js"));
|
|
8
|
-
const Utils_js_1 = require("./Utils.js");
|
|
9
|
-
function DeviceActionButton(props) {
|
|
10
|
-
const { deviceId, action, refresh, deviceHandler, disabled, } = props;
|
|
11
|
-
const tooltip = (0, Utils_js_1.getTranslation)(action.description);
|
|
12
|
-
const icon = (0, Utils_js_1.renderIcon)(action);
|
|
13
|
-
return react_1.default.createElement(TooltipButton_js_1.default, { label: action.label || (icon ? null : action.id), tooltip: tooltip, disabled: disabled || action.disabled, Icon: icon, onClick: deviceHandler(deviceId, action, refresh) });
|
|
14
|
-
}
|
|
15
|
-
exports.default = DeviceActionButton;
|