@iobroker/dm-gui-components 10.0.23 → 10.1.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/README.md +10 -0
- package/build/AnimatedIcons.d.ts +37 -0
- package/build/AnimatedIcons.js +108 -0
- package/build/AnimatedIcons.js.map +1 -0
- package/build/Communication.d.ts +7 -0
- package/build/Communication.js +43 -11
- package/build/Communication.js.map +1 -1
- package/build/DeviceCard.d.ts +25 -13
- package/build/DeviceCard.js +177 -282
- package/build/DeviceCard.js.map +1 -1
- package/build/DeviceControl.js +38 -26
- package/build/DeviceControl.js.map +1 -1
- package/build/DeviceImageUpload.d.ts +5 -1
- package/build/DeviceImageUpload.js +79 -62
- package/build/DeviceImageUpload.js.map +1 -1
- package/build/DeviceList.d.ts +8 -0
- package/build/DeviceList.js +74 -59
- package/build/DeviceList.js.map +1 -1
- package/build/DeviceStatus.d.ts +20 -4
- package/build/DeviceStatus.js +146 -191
- package/build/DeviceStatus.js.map +1 -1
- package/build/StatusIndicator.js +9 -37
- package/build/StatusIndicator.js.map +1 -1
- package/build/StatusPill.d.ts +18 -0
- package/build/StatusPill.js +30 -0
- package/build/StatusPill.js.map +1 -0
- package/build/Switch.d.ts +3 -0
- package/build/Switch.js +36 -26
- package/build/Switch.js.map +1 -1
- package/build/Utils.js +92 -60
- package/build/Utils.js.map +1 -1
- package/build/i18n/de.json +3 -0
- package/build/i18n/en.json +3 -0
- package/build/i18n/es.json +3 -0
- package/build/i18n/fr.json +3 -0
- package/build/i18n/it.json +3 -0
- package/build/i18n/nl.json +3 -0
- package/build/i18n/pl.json +3 -0
- package/build/i18n/pt.json +3 -0
- package/build/i18n/ru.json +3 -0
- package/build/i18n/uk.json +3 -0
- package/build/i18n/zh-cn.json +3 -0
- package/build/styles.d.ts +17 -0
- package/build/styles.js +226 -0
- package/build/styles.js.map +1 -0
- package/package.json +10 -10
package/build/DeviceStatus.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { I18n } from '@iobroker/gui-components';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { I18n, IconConnectionState, IconStatusLed } from '@iobroker/gui-components';
|
|
2
|
+
import { Bluetooth as IconConnectionBluetooth, Cable as IconConnectionLan, BluetoothDisabled as IconConnectionNoBluetooth, Link as LinkIcon, LinkOff as LinkOffIcon, Warning as WarningIcon, } from '@mui/icons-material';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { IconBattery, IconSignal, IconUpdate, useValueTick } from './AnimatedIcons';
|
|
5
5
|
import { useStateOrObject } from './hooks';
|
|
6
|
-
import
|
|
6
|
+
import StatusPill from './StatusPill';
|
|
7
7
|
import { getTranslation } from './Utils';
|
|
8
8
|
export const ACTIONS = {
|
|
9
9
|
STATUS: 'status',
|
|
10
10
|
DISABLE: 'disable',
|
|
11
11
|
ENABLE: 'enable',
|
|
12
12
|
};
|
|
13
|
-
const styles = {
|
|
14
|
-
tooltip: {
|
|
15
|
-
pointerEvents: 'none',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
13
|
function ThreadIcon(props) {
|
|
19
14
|
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", onClick: e => props.onClick && props.onClick(e), viewBox: "0 0 165 165", width: props.width || (props.fontSize === 'small' ? 16 : 20), height: props.height || props.width || (props.fontSize === 'small' ? 16 : 20), className: props.className, style: props.style },
|
|
20
15
|
React.createElement("path", { fill: "currentColor", d: "M82.498,0C37.008,0,0,37.008,0,82.496c0,45.181,36.51,81.977,81.573,82.476V82.569l-27.002-0.002 c-8.023,0-14.554,6.53-14.554,14.561c0,8.023,6.531,14.551,14.554,14.551v17.98c-17.939,0-32.534-14.595-32.534-32.531 c0-17.944,14.595-32.543,32.534-32.543l27.002,0.004v-9.096c0-14.932,12.146-27.08,27.075-27.08 c14.932,0,27.082,12.148,27.082,27.08c0,14.931-12.15,27.08-27.082,27.08l-9.097-0.001v80.641 C136.889,155.333,165,122.14,165,82.496C165,37.008,127.99,0,82.498,0z" }),
|
|
@@ -29,85 +24,51 @@ function ZigBeeIcon(props) {
|
|
|
29
24
|
React.createElement("path", { fill: "currentColor", d: "M32.042,9.792c4.595,1.238,4.88,3.165,5.524,5.048C34.841,17.664,17.35,35.7,17.35,35.7 s10.901,1.177,23.487-1.003c-0.001,0.029-0.002,0.048-0.003,0.076C42.829,31.661,44,27.97,44,24c0-11.046-8.954-20-20-20 c-5.634,0-10.715,2.338-14.35,6.087C15.489,9.124,26.89,8.403,32.042,9.792z" }),
|
|
30
25
|
React.createElement("path", { fill: "currentColor", d: "M14.724,37.285c-1.982-0.347-4.212-2.131-4.707-5.302c1.437-1.239,19.994-20.507,19.994-20.507 c-7.008-0.424-14.569-0.465-22.237,0.864C5.408,15.625,4,19.644,4,24c0,11.046,8.954,20,20,20c6.173,0,11.689-2.8,15.358-7.195 C35.486,37.33,23.257,38.769,14.724,37.285z" })));
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (signal < -60) {
|
|
37
|
-
return themeType === 'dark' ? '#fa8547' : '#ae5c00';
|
|
27
|
+
/** The status as an object, also if the device gives only the connection as a string */
|
|
28
|
+
function normalizeStatus(status) {
|
|
29
|
+
if (!status) {
|
|
30
|
+
return {};
|
|
38
31
|
}
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
32
|
+
if (typeof status === 'string') {
|
|
33
|
+
return { connection: status };
|
|
41
34
|
}
|
|
42
|
-
return
|
|
35
|
+
return status;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
color: '#2196f3',
|
|
67
|
-
};
|
|
68
|
-
function getBatteryIcon(battery) {
|
|
69
|
-
if (battery > 95) {
|
|
70
|
-
return React.createElement(BatteryFullIcon, { style: iconStyleOK });
|
|
71
|
-
}
|
|
72
|
-
if (battery > 85 && battery <= 95) {
|
|
73
|
-
return React.createElement(Battery90Icon, { style: iconStyleOK });
|
|
74
|
-
}
|
|
75
|
-
if (battery > 70 && battery <= 85) {
|
|
76
|
-
return React.createElement(Battery80Icon, { style: iconStyleOK });
|
|
77
|
-
}
|
|
78
|
-
if (battery > 55 && battery <= 70) {
|
|
79
|
-
return React.createElement(Battery60Icon, { style: iconStyleOK });
|
|
80
|
-
}
|
|
81
|
-
if (battery > 40 && battery <= 55) {
|
|
82
|
-
return React.createElement(Battery50Icon, { style: iconStylePreWarning });
|
|
83
|
-
}
|
|
84
|
-
if (battery > 25 && battery <= 40) {
|
|
85
|
-
return React.createElement(Battery30Icon, { style: iconStylePreWarning });
|
|
86
|
-
}
|
|
87
|
-
if (battery > 10 && battery <= 25) {
|
|
88
|
-
return React.createElement(Battery20Icon, { style: iconStyleWarning });
|
|
37
|
+
/** The symbol of the connection type; `null` if there is nothing to show */
|
|
38
|
+
function getConnectionSymbol(connectionType, connection) {
|
|
39
|
+
const disconnected = connection === 'disconnected';
|
|
40
|
+
switch (connectionType) {
|
|
41
|
+
case 'wifi':
|
|
42
|
+
// The waves are crossed out when the connection is lost
|
|
43
|
+
return React.createElement(IconConnectionState, { state: disconnected ? 'disconnected' : 'connected' });
|
|
44
|
+
case 'bluetooth':
|
|
45
|
+
return disconnected ? React.createElement(IconConnectionNoBluetooth, null) : React.createElement(IconConnectionBluetooth, null);
|
|
46
|
+
case 'lan':
|
|
47
|
+
return React.createElement(IconConnectionLan, null);
|
|
48
|
+
case 'thread':
|
|
49
|
+
return React.createElement(ThreadIcon, null);
|
|
50
|
+
case 'z-wave':
|
|
51
|
+
return React.createElement(ZWaveIcon, null);
|
|
52
|
+
case 'zigbee':
|
|
53
|
+
return React.createElement(ZigBeeIcon, null);
|
|
54
|
+
default:
|
|
55
|
+
if (connection === 'connected') {
|
|
56
|
+
return React.createElement(LinkIcon, null);
|
|
57
|
+
}
|
|
58
|
+
return disconnected ? React.createElement(LinkOffIcon, null) : null;
|
|
89
59
|
}
|
|
90
|
-
return React.createElement(BatteryAlertIcon, { style: iconStyleNotOK });
|
|
91
60
|
}
|
|
92
61
|
/**
|
|
93
|
-
* Device Status component
|
|
62
|
+
* Device Status component: connection, signal, battery, warning and update as pills of the status line.
|
|
63
|
+
*
|
|
64
|
+
* A pill is neutral while the value is fine and tinted with its color when it needs attention, so that
|
|
65
|
+
* the problems stand out in a list of many devices.
|
|
94
66
|
*
|
|
95
67
|
* @param props - Parameters
|
|
96
68
|
* @param props.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }
|
|
97
69
|
*/
|
|
98
|
-
export default function
|
|
99
|
-
|
|
100
|
-
if (!props.status) {
|
|
101
|
-
status = {};
|
|
102
|
-
}
|
|
103
|
-
else if (typeof props.status === 'string') {
|
|
104
|
-
status = {
|
|
105
|
-
connection: props.status,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
status = props.status;
|
|
110
|
-
}
|
|
70
|
+
export default function DeviceStatusComponent(props) {
|
|
71
|
+
const status = normalizeStatus(props.status);
|
|
111
72
|
const connection = useStateOrObject(status.connection, props.stateOrObjectHandler);
|
|
112
73
|
const rssi = useStateOrObject(status.rssi, props.stateOrObjectHandler);
|
|
113
74
|
const battery = useStateOrObject(status.battery, props.stateOrObjectHandler);
|
|
@@ -115,123 +76,117 @@ export default function DeviceStatus(props) {
|
|
|
115
76
|
const updateAvailable = useStateOrObject(props.update?.available, props.stateOrObjectHandler);
|
|
116
77
|
const updateVersion = useStateOrObject(props.update?.version, props.stateOrObjectHandler);
|
|
117
78
|
const updateNewVersion = useStateOrObject(props.update?.newVersion, props.stateOrObjectHandler);
|
|
118
|
-
|
|
79
|
+
// The new value slides in when it changes
|
|
80
|
+
const rssiRef = useValueTick(rssi);
|
|
81
|
+
const batteryRef = useValueTick(battery);
|
|
82
|
+
const pills = [];
|
|
83
|
+
// Connection
|
|
84
|
+
const connectionSymbol = getConnectionSymbol(props.connectionType, connection);
|
|
85
|
+
if (connectionSymbol) {
|
|
86
|
+
const known = connection === 'connected' || connection === 'disconnected';
|
|
87
|
+
const tooltip = known
|
|
88
|
+
? (connection === 'connected'
|
|
89
|
+
? getTranslation('connectedIconTooltip')
|
|
90
|
+
: getTranslation('disconnectedIconTooltip')) +
|
|
91
|
+
(props.statusAction ? `. ${getTranslation(props.statusAction.description || 'moreInformation')}` : '')
|
|
92
|
+
: undefined;
|
|
93
|
+
pills.push(React.createElement(StatusPill, { key: "connection", tone: connection === 'disconnected' ? 'err' : undefined, tooltip: tooltip, onClick: known && props.statusAction
|
|
94
|
+
? () => props.deviceHandler(props.deviceId, props.statusAction)()
|
|
95
|
+
: undefined }, known ? connectionSymbol : React.createElement("span", { style: { display: 'flex', opacity: 0.55 } }, connectionSymbol)));
|
|
96
|
+
}
|
|
97
|
+
// Signal strength
|
|
98
|
+
const rssiNumber = rssi === undefined || rssi === null || rssi === '' ? NaN : Number(rssi);
|
|
99
|
+
if (!isNaN(rssiNumber) && rssiNumber !== 0) {
|
|
100
|
+
pills.push(React.createElement(StatusPill, { key: "rssi", tone: rssiNumber < -80 ? 'warn' : undefined, tooltip: `RSSI: ${rssiNumber} dBm` },
|
|
101
|
+
React.createElement(IconSignal, { rssi: rssiNumber }),
|
|
102
|
+
React.createElement("span", { ref: rssiRef }, rssiNumber)));
|
|
103
|
+
}
|
|
104
|
+
// Battery. A button if the backend offers the reserved "battery" action (e.g. for the battery history)
|
|
105
|
+
if (battery !== undefined && battery !== null && battery !== '') {
|
|
106
|
+
let icon;
|
|
107
|
+
let text = null;
|
|
108
|
+
let tone;
|
|
119
109
|
if (typeof battery === 'number') {
|
|
120
|
-
|
|
110
|
+
icon = React.createElement(IconBattery, { level: battery });
|
|
111
|
+
text = `${battery}%`;
|
|
112
|
+
tone = battery <= 10 ? 'err' : battery <= 25 ? 'warn' : undefined;
|
|
121
113
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
React.createElement(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
114
|
+
else if (typeof battery === 'boolean') {
|
|
115
|
+
icon = React.createElement(IconBattery, { level: battery ? 100 : 0 });
|
|
116
|
+
tone = battery ? undefined : 'err';
|
|
117
|
+
}
|
|
118
|
+
else if (battery === 'charging') {
|
|
119
|
+
icon = React.createElement(IconBattery, { charging: true });
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
icon = React.createElement(IconBattery, null);
|
|
123
|
+
text = battery.includes('V') ? battery : `${battery} mV`;
|
|
124
|
+
}
|
|
125
|
+
pills.push(React.createElement(StatusPill, { key: "battery", tone: tone, tooltip: getTranslation('batteryTooltip') +
|
|
126
|
+
(props.batteryAction
|
|
127
|
+
? `. ${getTranslation(props.batteryAction.description || 'moreInformation')}`
|
|
128
|
+
: ''), onClick: props.batteryAction ? () => props.deviceHandler(props.deviceId, props.batteryAction)() : undefined },
|
|
129
|
+
icon,
|
|
130
|
+
text ? React.createElement("span", { ref: batteryRef }, text) : null));
|
|
131
|
+
}
|
|
132
|
+
// Warning: it pulses when it appears or changes
|
|
133
|
+
if (warning) {
|
|
134
|
+
const text = typeof warning === 'string' || typeof warning === 'object' ? getTranslation(warning) : '';
|
|
135
|
+
pills.push(React.createElement(StatusPill, { key: "warning", tone: "warn", tooltip: text || undefined },
|
|
136
|
+
React.createElement(IconStatusLed, { color: "var(--dm-warn)", beat: typeof warning === 'object' ? JSON.stringify(warning) : warning },
|
|
137
|
+
React.createElement(WarningIcon, { fontSize: "inherit" }))));
|
|
138
|
+
}
|
|
139
|
+
// Update
|
|
140
|
+
if (updateAvailable) {
|
|
141
|
+
const versions = updateNewVersion ? `${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}` : '';
|
|
142
|
+
pills.push(React.createElement(StatusPill, { key: "update", tone: "info", tooltip: getTranslation('updateAvailable') + (versions ? `: ${versions}` : ''), onClick: props.updateAction
|
|
143
|
+
? () => {
|
|
144
|
+
// An update is a significant operation, so always ask for confirmation
|
|
145
|
+
// before triggering it. Reuse the action's own confirmation message if the
|
|
146
|
+
// backend provided one; otherwise build a default one including the versions.
|
|
147
|
+
// The confirmation is then handled by the standard device action flow
|
|
148
|
+
// (deviceHandler -> showConfirmation -> renderConfirmationDialog).
|
|
149
|
+
let confirmation = props.updateAction.confirmation;
|
|
150
|
+
if (!confirmation) {
|
|
151
|
+
let message = getTranslation('updateConfirmation');
|
|
152
|
+
if (versions) {
|
|
153
|
+
message += `: ${versions}`;
|
|
154
|
+
}
|
|
155
|
+
confirmation = { [I18n.getLanguage()]: message, en: message };
|
|
156
|
+
}
|
|
157
|
+
props.deviceHandler(props.deviceId, { ...props.updateAction, confirmation })();
|
|
158
|
+
}
|
|
159
|
+
: undefined },
|
|
160
|
+
React.createElement(IconUpdate, null)));
|
|
146
161
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
return pills.length ? React.createElement(React.Fragment, null, pills) : null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The LED on the device symbol: green while the device is connected, red without connection.
|
|
166
|
+
*
|
|
167
|
+
* It sends a pulse each time the device reports a new signal strength, like the LED of a real device
|
|
168
|
+
* that blinks on traffic. Nothing is shown while the connection is unknown.
|
|
169
|
+
*/
|
|
170
|
+
export function DeviceLed(props) {
|
|
171
|
+
const status = normalizeStatus(props.status);
|
|
172
|
+
const connection = useStateOrObject(status.connection, props.stateOrObjectHandler);
|
|
173
|
+
const rssi = useStateOrObject(status.rssi, props.stateOrObjectHandler);
|
|
174
|
+
// Only a change of a known value is a beat, not the first value after the (re)mount of the card
|
|
175
|
+
const [beat, setBeat] = useState({ rssi: undefined, count: 0 });
|
|
176
|
+
if (rssi !== undefined && rssi !== null && rssi !== beat.rssi) {
|
|
177
|
+
// Adjusting the state while rendering, as React recommends for values derived from a change
|
|
178
|
+
setBeat({ rssi, count: beat.rssi === undefined ? 0 : beat.count + 1 });
|
|
150
179
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
connection === 'connected' ? (React.createElement(ZigBeeIcon, { style: iconStyleOK })) : connection === 'disconnected' ? (React.createElement(ZigBeeIcon, { style: iconStyleNotOK })) : (React.createElement(ZigBeeIcon, { style: iconStyleUnknown }));
|
|
180
|
+
if (connection !== 'connected' && connection !== 'disconnected') {
|
|
181
|
+
return null;
|
|
154
182
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
183
|
+
let color = connection === 'connected' ? 'green' : 'red';
|
|
184
|
+
if (!props.alive || props.enabled === false) {
|
|
185
|
+
color = 'grey';
|
|
158
186
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
? `. ${getTranslation(props.statusAction.description || 'moreInformation')}`
|
|
164
|
-
: ''), slotProps: { popper: { sx: styles.tooltip } } }, props.statusAction ? (React.createElement(IconButton, { onClick: e => {
|
|
165
|
-
if (props.statusAction) {
|
|
166
|
-
e.stopPropagation();
|
|
167
|
-
props.deviceHandler(props.deviceId, props.statusAction)();
|
|
168
|
-
}
|
|
169
|
-
} },
|
|
170
|
-
connectionSymbol,
|
|
171
|
-
React.createElement("div", { style: { position: 'absolute', top: 0, left: 0, color: 'grey' } }, "*"))) : (React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } }, connectionSymbol)))) : (connectionSymbol);
|
|
172
|
-
// The battery indicator is wrapped into a button if the reserved "battery" action is provided by the backend,
|
|
173
|
-
// so the adapter can open its own dialog (e.g. battery history or battery type) on click.
|
|
174
|
-
const renderBattery = (content) => (React.createElement(Tooltip, { title: getTranslation('batteryTooltip') +
|
|
175
|
-
(props.batteryAction ? `. ${getTranslation(props.batteryAction.description || 'moreInformation')}` : ''), slotProps: { popper: { sx: styles.tooltip } } }, props.batteryAction ? (React.createElement(IconButton, { size: "small", style: { padding: 2, borderRadius: 4 }, onClick: e => {
|
|
176
|
-
if (props.batteryAction) {
|
|
177
|
-
e.stopPropagation();
|
|
178
|
-
props.deviceHandler(props.deviceId, props.batteryAction)();
|
|
179
|
-
}
|
|
180
|
-
} },
|
|
181
|
-
React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } }, content))) : (React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } }, content))));
|
|
182
|
-
return (React.createElement("div", { style: {
|
|
183
|
-
display: 'flex',
|
|
184
|
-
alignItems: 'baseline',
|
|
185
|
-
cursor: props.statusAction ? 'pointer' : undefined,
|
|
186
|
-
width: props.disableEnableAction ? '100%' : undefined,
|
|
187
|
-
gap: 8,
|
|
188
|
-
} },
|
|
189
|
-
connectionIcon,
|
|
190
|
-
rssi && (React.createElement(Tooltip, { title: "RSSI", slotProps: { popper: { sx: styles.tooltip } } },
|
|
191
|
-
React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
|
|
192
|
-
React.createElement(NetworkCheckIcon, { style: { color: rssiColor(rssi, props.theme.palette.mode) } }),
|
|
193
|
-
React.createElement("p", { style: { fontSize: 'small', margin: 0 } }, rssi)))),
|
|
194
|
-
typeof battery === 'number' &&
|
|
195
|
-
renderBattery(React.createElement(React.Fragment, null,
|
|
196
|
-
batteryIconTooltip,
|
|
197
|
-
React.createElement("p", { style: { fontSize: 'small', margin: 0 } },
|
|
198
|
-
battery,
|
|
199
|
-
"%"))),
|
|
200
|
-
typeof battery === 'string' &&
|
|
201
|
-
renderBattery(React.createElement(React.Fragment, null,
|
|
202
|
-
battery === 'charging' ? React.createElement(BatteryCharging50Icon, null) : React.createElement(BatteryFullIcon, null),
|
|
203
|
-
battery !== 'charging' ? (battery.includes('V') || battery.includes('mV') ? (React.createElement("p", { style: { fontSize: 'small', margin: 0 } }, battery)) : (React.createElement("p", { style: { fontSize: 'small', margin: 0 } },
|
|
204
|
-
React.createElement("span", { style: { marginRight: 4 } }, battery),
|
|
205
|
-
"mV"))) : null)),
|
|
206
|
-
typeof battery === 'boolean' &&
|
|
207
|
-
renderBattery(battery ? React.createElement(BatteryFullIcon, { style: iconStyleOK }) : React.createElement(BatteryAlertIcon, { style: iconStyleNotOK })),
|
|
208
|
-
warning ? (typeof warning === 'string' || typeof warning === 'object' ? (React.createElement(Tooltip, { title: getTranslation(warning), slotProps: { popper: { sx: styles.tooltip } } },
|
|
209
|
-
React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
|
|
210
|
-
React.createElement(WarningIcon, { style: iconStyleWarning })))) : (React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
|
|
211
|
-
React.createElement(WarningIcon, { style: iconStyleWarning })))) : null,
|
|
212
|
-
updateAvailable ? (React.createElement(Tooltip, { title: getTranslation('updateAvailable') +
|
|
213
|
-
(updateNewVersion ? `: ${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}` : ''), slotProps: { popper: { sx: styles.tooltip } } }, props.updateAction ? (React.createElement(IconButton, { size: "small", onClick: e => {
|
|
214
|
-
if (!props.updateAction) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
e.stopPropagation();
|
|
218
|
-
// An update is a significant operation, so always ask for confirmation
|
|
219
|
-
// before triggering it. Reuse the action's own confirmation message if the
|
|
220
|
-
// backend provided one; otherwise build a default one including the versions.
|
|
221
|
-
// The confirmation is then handled by the standard device action flow
|
|
222
|
-
// (deviceHandler -> showConfirmation -> renderConfirmationDialog).
|
|
223
|
-
let confirmation = props.updateAction.confirmation;
|
|
224
|
-
if (!confirmation) {
|
|
225
|
-
let message = getTranslation('updateConfirmation');
|
|
226
|
-
if (updateNewVersion) {
|
|
227
|
-
message += `: ${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}`;
|
|
228
|
-
}
|
|
229
|
-
confirmation = { [I18n.getLanguage()]: message, en: message };
|
|
230
|
-
}
|
|
231
|
-
props.deviceHandler(props.deviceId, { ...props.updateAction, confirmation })();
|
|
232
|
-
} },
|
|
233
|
-
React.createElement(SystemUpdateAltIcon, { style: iconStyleUpdate }))) : (React.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
|
|
234
|
-
React.createElement(SystemUpdateAltIcon, { style: iconStyleUpdate }))))) : null,
|
|
235
|
-
disability));
|
|
187
|
+
return (React.createElement("span", { className: "dm-avatar-led" },
|
|
188
|
+
React.createElement(IconStatusLed, { color: color, beat: beat.count, ariaLabel: connection === 'connected'
|
|
189
|
+
? getTranslation('connectedIconTooltip')
|
|
190
|
+
: getTranslation('disconnectedIconTooltip') })));
|
|
236
191
|
}
|
|
237
192
|
//# sourceMappingURL=DeviceStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceStatus.js","sourceRoot":"./src/","sources":["DeviceStatus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,OAAO,EACH,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,YAAY,IAAI,gBAAgB,EAChC,iBAAiB,IAAI,qBAAqB,EAC1C,WAAW,IAAI,eAAe,EAC9B,SAAS,IAAI,uBAAuB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,iBAAiB,IAAI,yBAAyB,EAC9C,O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gBACX,CAAC;gBACD,CAAC,CAAC,eAAe,EAAE,CAAC;gBACpB,uEAAuE;gBACvE,2EAA2E;gBAC3E,8EAA8E;gBAC9E,sEAAsE;gBACtE,mEAAmE;gBACnE,IAAI,YAAY,GACZ,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC;gBACpC,IAAI,CAAC,YAAY,EAAE,CAAC;oBAChB,IAAI,OAAO,GAAG,cAAc,CAAC,oBAAoB,CAAC,CAAC;oBACnD,IAAI,gBAAgB,EAAE,CAAC;wBACnB,OAAO,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,gBAAgB,EAAE,CAAC;oBACpF,CAAC;oBACD,YAAY,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;gBAClE,CAAC;gBACD,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,YAAY,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;YACnF,CAAC;YAED,oBAAC,mBAAmB,IAAC,KAAK,EAAE,eAAe,GAAI,CACtC,CAChB,CAAC,CAAC,CAAC,CACA,6BAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE;YAC1E,oBAAC,mBAAmB,IAAC,KAAK,EAAE,eAAe,GAAI,CAC7C,CACT,CACK,CACb,CAAC,CAAC,CAAC,IAAI;QAEP,UAAU,CACT,CACT,CAAC;AACN,CAAC","sourcesContent":["import { I18n } from '@iobroker/gui-components';\nimport type { Connection, IobTheme, ThemeType } from '@iobroker/gui-components';\nimport {\n Battery20 as Battery20Icon,\n Battery30 as Battery30Icon,\n Battery50 as Battery50Icon,\n Battery60 as Battery60Icon,\n Battery80 as Battery80Icon,\n Battery90 as Battery90Icon,\n BatteryAlert as BatteryAlertIcon,\n BatteryCharging50 as BatteryCharging50Icon,\n BatteryFull as BatteryFullIcon,\n Bluetooth as IconConnectionBluetooth,\n Cable as IconConnectionLan,\n BluetoothDisabled as IconConnectionNoBluetooth,\n WifiOff as IconConnectionNoWifi,\n Wifi as IconConnectionWifi,\n Link as LinkIcon,\n LinkOff as LinkOffIcon,\n NetworkCheck as NetworkCheckIcon,\n SystemUpdateAlt as SystemUpdateAltIcon,\n Warning as WarningIcon,\n} from '@mui/icons-material';\nimport { IconButton, Tooltip } from '@mui/material';\nimport React, { useMemo, type CSSProperties, type MouseEvent } from 'react';\nimport { useStateOrObject } from './hooks';\nimport type {\n ActionBase,\n ConfigConnectionType,\n DeviceAction,\n DeviceId,\n DeviceInfo,\n DeviceStatus,\n} from './protocol/api';\nimport Switch from './Switch';\nimport { getTranslation } from './Utils';\nimport type { StateOrObjectHandler } from './StateOrObjectHandler';\n\nexport const ACTIONS = {\n STATUS: 'status',\n DISABLE: 'disable',\n ENABLE: 'enable',\n};\n\nconst styles: Record<string, React.CSSProperties> = {\n tooltip: {\n pointerEvents: 'none',\n },\n};\n\nexport interface IconProps {\n /** The width in pixels or percentage of the icon. */\n width?: number | string;\n /** The height in pixels or percentage of the icon. */\n height?: number | string;\n /** Click handler. */\n onClick?: (e: MouseEvent) => void;\n /** The class name for the SVG element. */\n className?: string;\n /** Styles for the SVG element. */\n style?: CSSProperties;\n /** The font size of the icon. */\n fontSize?: 'small';\n}\n\nfunction ThreadIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 165 165\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M82.498,0C37.008,0,0,37.008,0,82.496c0,45.181,36.51,81.977,81.573,82.476V82.569l-27.002-0.002 c-8.023,0-14.554,6.53-14.554,14.561c0,8.023,6.531,14.551,14.554,14.551v17.98c-17.939,0-32.534-14.595-32.534-32.531 c0-17.944,14.595-32.543,32.534-32.543l27.002,0.004v-9.096c0-14.932,12.146-27.08,27.075-27.08 c14.932,0,27.082,12.148,27.082,27.08c0,14.931-12.15,27.08-27.082,27.08l-9.097-0.001v80.641 C136.889,155.333,165,122.14,165,82.496C165,37.008,127.99,0,82.498,0z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M117.748,55.493c0-5.016-4.082-9.098-9.1-9.098c-5.015,0-9.097,4.082-9.097,9.098v9.097l9.097,0.001 C113.666,64.591,117.748,60.51,117.748,55.493z\"\n />\n </svg>\n );\n}\n\nfunction ZWaveIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 1073 1068\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M716 1.1C632.9 5.3 549.8 23.7 472 55c-66.4 26.7-132.6 65.5-188.5 110.4-43.8 35.1-85.2 76.7-120.1 120.6C72.4 400.4 16.7 539.8 3.5 686 1.8 705.1-.1 754.7.7 758c.5 2 1 2 49.7 1.8l49.1-.3.7-20c2.4-64.6 13.4-126 33.2-186 80.8-243.9 297-419.9 552.1-449.4 20.2-2.4 44.2-4.1 56.6-4.1h8.9V50 0l-9.7.1c-5.4.1-16.8.6-25.3 1zm-.8 208c-78.5 4.7-158 27.4-226.5 64.5-68.7 37.3-126.4 86.3-175.2 148.9-11 14-33.2 47.3-42.3 63.5-44 77.8-68.6 164.9-70.9 251.2l-.6 22.8h49.5 49.4l1.2-19c6.3-98.7 40-185.8 102.2-263.3 12.7-15.9 41.2-45.2 57-58.7 66.1-56.3 142.1-91.8 226-105.5 18.9-3 44.1-5.5 56.7-5.5h9.3v-50-50l-11.2.1c-6.2.1-17.3.6-24.6 1zm17.8 251c-104.5 9.2-195.2 69.7-243.6 162.4-43.9 84-45.5 184.2-4.5 270 60.3 125.9 198.1 194.2 334.9 166 46.6-9.7 89.5-29.7 127.2-59.6 13.5-10.7 37.3-34.5 48-47.9 34.2-43.1 55.2-92 63.7-148.6 2.2-15.1 2.5-62.7.5-77.4-3.6-25.2-10.1-51.4-17.8-71.2-10.1-26.2-29.4-59.7-47-81.8-9.7-12.1-35-37.2-47.4-47-47.8-37.9-104.5-60.1-165.4-65-14.7-1.1-34.7-1.1-48.6.1zm174.7 138.6c-.3.5-30.9 49.2-68.1 108.3L772 814.5l67.9.5 68 .5-30.1 48.8-30 48.7h-131c-104.4 0-130.9-.3-130.5-1.3.2-.6 32.7-51.1 72.1-112.1L730 687.9c0-.5-29.5-1-66.5-1.1l-66.6-.3 27.7-44.3 27.6-44.2h128l127.5.7z\"\n />\n </svg>\n );\n}\n\nfunction ZigBeeIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 48 48\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M32.042,9.792c4.595,1.238,4.88,3.165,5.524,5.048C34.841,17.664,17.35,35.7,17.35,35.7 s10.901,1.177,23.487-1.003c-0.001,0.029-0.002,0.048-0.003,0.076C42.829,31.661,44,27.97,44,24c0-11.046-8.954-20-20-20 c-5.634,0-10.715,2.338-14.35,6.087C15.489,9.124,26.89,8.403,32.042,9.792z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.724,37.285c-1.982-0.347-4.212-2.131-4.707-5.302c1.437-1.239,19.994-20.507,19.994-20.507 c-7.008-0.424-14.569-0.465-22.237,0.864C5.408,15.625,4,19.644,4,24c0,11.046,8.954,20,20,20c6.173,0,11.689-2.8,15.358-7.195 C35.486,37.33,23.257,38.769,14.724,37.285z\"\n />\n </svg>\n );\n}\n\ninterface DeviceStatusProps {\n socket: Connection;\n status: DeviceStatus | null;\n deviceId: DeviceId;\n connectionType?: ConfigConnectionType;\n statusAction?: DeviceAction;\n enabled?: boolean;\n disableEnableAction?: DeviceAction;\n /** Update information of the device (firmware/software) */\n update?: DeviceInfo['update'];\n /** Reserved \"update\" action. If provided, the update indicator becomes a clickable button */\n updateAction?: DeviceAction;\n /** Reserved \"battery\" action. If provided, the battery indicator becomes a clickable button */\n batteryAction?: DeviceAction;\n deviceHandler: (deviceId: DeviceId, action: ActionBase) => () => void;\n theme: IobTheme;\n stateOrObjectHandler: StateOrObjectHandler;\n}\n\nfunction rssiColor(signal: number, themeType: ThemeType): string {\n if (signal < -80) {\n return themeType === 'dark' ? '#ff5c5c' : '#aa0000';\n }\n if (signal < -60) {\n return themeType === 'dark' ? '#fa8547' : '#ae5c00';\n }\n if (signal < -50) {\n return themeType === 'dark' ? '#cdff4f' : '#7b9500';\n }\n\n return themeType === 'dark' ? '#5cff5c' : '#008500';\n}\n\nconst iconStyleOK = {\n fill: '#00ac00',\n color: '#00ac00',\n};\nconst iconStyleNotOK = {\n fill: '#ff0000',\n color: '#ff0000',\n};\nconst iconStyleWarning = {\n fill: '#da8200',\n color: '#da8200',\n};\nconst iconStyleUnknown = {\n fill: '#8a8a8a',\n color: '#8a8a8a',\n};\nconst iconStylePreWarning = {\n fill: '#ffcc00',\n color: '#ffcc00',\n};\nconst iconStyleUpdate = {\n fill: '#2196f3',\n color: '#2196f3',\n};\n\nfunction getBatteryIcon(battery: number): React.ReactNode {\n if (battery > 95) {\n return <BatteryFullIcon style={iconStyleOK} />;\n }\n if (battery > 85 && battery <= 95) {\n return <Battery90Icon style={iconStyleOK} />;\n }\n if (battery > 70 && battery <= 85) {\n return <Battery80Icon style={iconStyleOK} />;\n }\n if (battery > 55 && battery <= 70) {\n return <Battery60Icon style={iconStyleOK} />;\n }\n if (battery > 40 && battery <= 55) {\n return <Battery50Icon style={iconStylePreWarning} />;\n }\n if (battery > 25 && battery <= 40) {\n return <Battery30Icon style={iconStylePreWarning} />;\n }\n if (battery > 10 && battery <= 25) {\n return <Battery20Icon style={iconStyleWarning} />;\n }\n\n return <BatteryAlertIcon style={iconStyleNotOK} />;\n}\n\n/**\n * Device Status component\n *\n * @param props - Parameters\n * @param props.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }\n */\nexport default function DeviceStatus(props: DeviceStatusProps): React.JSX.Element | null {\n let status: DeviceStatus;\n if (!props.status) {\n status = {};\n } else if (typeof props.status === 'string') {\n status = {\n connection: props.status,\n };\n } else {\n status = props.status;\n }\n\n const connection = useStateOrObject(status.connection, props.stateOrObjectHandler);\n const rssi = useStateOrObject(status.rssi, props.stateOrObjectHandler);\n const battery = useStateOrObject(status.battery, props.stateOrObjectHandler);\n const warning = useStateOrObject(status.warning, props.stateOrObjectHandler);\n const updateAvailable = useStateOrObject(props.update?.available, props.stateOrObjectHandler);\n const updateVersion = useStateOrObject(props.update?.version, props.stateOrObjectHandler);\n const updateNewVersion = useStateOrObject(props.update?.newVersion, props.stateOrObjectHandler);\n\n const batteryIconTooltip = useMemo<React.ReactNode>(() => {\n if (typeof battery === 'number') {\n return getBatteryIcon(battery);\n }\n return null;\n }, [battery]);\n\n const disability =\n typeof props.enabled === 'boolean' ? (\n <>\n <div style={{ flexGrow: 1 }} />\n {\n <Tooltip\n title={\n props.enabled ? getTranslation('disableIconTooltip') : getTranslation('enableIconTooltip')\n }\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n <Switch\n size=\"small\"\n checked={props.enabled}\n disabled={!props.disableEnableAction}\n onChange={() =>\n props.disableEnableAction &&\n props.deviceHandler(props.deviceId, props.disableEnableAction)()\n }\n theme={props.theme}\n />\n </div>\n </Tooltip>\n }\n </>\n ) : null;\n let connectionSymbol: React.JSX.Element | null;\n if (props.connectionType === 'wifi') {\n connectionSymbol =\n connection === 'connected' ? (\n <IconConnectionWifi style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <IconConnectionNoWifi style={iconStyleNotOK} />\n ) : (\n <IconConnectionWifi style={iconStyleUnknown} />\n );\n } else if (props.connectionType === 'bluetooth') {\n connectionSymbol =\n connection === 'connected' ? (\n <IconConnectionBluetooth style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <IconConnectionNoBluetooth style={iconStyleNotOK} />\n ) : (\n <IconConnectionBluetooth style={iconStyleUnknown} />\n );\n } else if (props.connectionType === 'lan') {\n connectionSymbol =\n connection === 'connected' ? (\n <IconConnectionLan style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <IconConnectionLan style={iconStyleNotOK} />\n ) : (\n <IconConnectionLan style={iconStyleUnknown} />\n );\n } else if (props.connectionType === 'thread') {\n connectionSymbol =\n connection === 'connected' ? (\n <ThreadIcon style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <ThreadIcon style={iconStyleNotOK} />\n ) : (\n <ThreadIcon style={iconStyleUnknown} />\n );\n } else if (props.connectionType === 'z-wave') {\n connectionSymbol =\n connection === 'connected' ? (\n <ZWaveIcon style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <ZWaveIcon style={iconStyleNotOK} />\n ) : (\n <ZWaveIcon style={iconStyleUnknown} />\n );\n } else if (props.connectionType === 'zigbee') {\n connectionSymbol =\n connection === 'connected' ? (\n <ZigBeeIcon style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <ZigBeeIcon style={iconStyleNotOK} />\n ) : (\n <ZigBeeIcon style={iconStyleUnknown} />\n );\n } else {\n connectionSymbol =\n connection === 'connected' ? (\n <LinkIcon style={iconStyleOK} />\n ) : connection === 'disconnected' ? (\n <LinkOffIcon style={iconStyleNotOK} />\n ) : null;\n }\n\n const connectionIcon =\n connection === 'connected' || connection === 'disconnected' ? (\n <Tooltip\n title={\n (connection === 'connected'\n ? getTranslation('connectedIconTooltip')\n : getTranslation('disconnectedIconTooltip')) +\n (props.statusAction\n ? `. ${getTranslation(props.statusAction.description || 'moreInformation')}`\n : '')\n }\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n {props.statusAction ? (\n <IconButton\n onClick={e => {\n if (props.statusAction) {\n e.stopPropagation();\n props.deviceHandler(props.deviceId, props.statusAction)();\n }\n }}\n >\n {connectionSymbol}\n <div style={{ position: 'absolute', top: 0, left: 0, color: 'grey' }}>*</div>\n </IconButton>\n ) : (\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n {connectionSymbol}\n </div>\n )}\n </Tooltip>\n ) : (\n connectionSymbol\n );\n\n // The battery indicator is wrapped into a button if the reserved \"battery\" action is provided by the backend,\n // so the adapter can open its own dialog (e.g. battery history or battery type) on click.\n const renderBattery = (content: React.ReactNode): React.JSX.Element => (\n <Tooltip\n title={\n getTranslation('batteryTooltip') +\n (props.batteryAction ? `. ${getTranslation(props.batteryAction.description || 'moreInformation')}` : '')\n }\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n {props.batteryAction ? (\n <IconButton\n size=\"small\"\n style={{ padding: 2, borderRadius: 4 }}\n onClick={e => {\n if (props.batteryAction) {\n e.stopPropagation();\n props.deviceHandler(props.deviceId, props.batteryAction)();\n }\n }}\n >\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>{content}</div>\n </IconButton>\n ) : (\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>{content}</div>\n )}\n </Tooltip>\n );\n\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'baseline',\n cursor: props.statusAction ? 'pointer' : undefined,\n width: props.disableEnableAction ? '100%' : undefined,\n gap: 8,\n }}\n >\n {connectionIcon}\n\n {rssi && (\n <Tooltip\n title=\"RSSI\"\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n <NetworkCheckIcon style={{ color: rssiColor(rssi, props.theme.palette.mode) }} />\n <p style={{ fontSize: 'small', margin: 0 }}>{rssi}</p>\n </div>\n </Tooltip>\n )}\n\n {typeof battery === 'number' &&\n renderBattery(\n <>\n {batteryIconTooltip}\n <p style={{ fontSize: 'small', margin: 0 }}>{battery}%</p>\n </>,\n )}\n\n {typeof battery === 'string' &&\n renderBattery(\n <>\n {battery === 'charging' ? <BatteryCharging50Icon /> : <BatteryFullIcon />}\n {battery !== 'charging' ? (\n battery.includes('V') || battery.includes('mV') ? (\n <p style={{ fontSize: 'small', margin: 0 }}>{battery}</p>\n ) : (\n <p style={{ fontSize: 'small', margin: 0 }}>\n <span style={{ marginRight: 4 }}>{battery}</span>\n mV\n </p>\n )\n ) : null}\n </>,\n )}\n\n {typeof battery === 'boolean' &&\n renderBattery(\n battery ? <BatteryFullIcon style={iconStyleOK} /> : <BatteryAlertIcon style={iconStyleNotOK} />,\n )}\n\n {warning ? (\n typeof warning === 'string' || typeof warning === 'object' ? (\n <Tooltip\n title={getTranslation(warning)}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n <WarningIcon style={iconStyleWarning} />\n </div>\n </Tooltip>\n ) : (\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n <WarningIcon style={iconStyleWarning} />\n </div>\n )\n ) : null}\n\n {updateAvailable ? (\n <Tooltip\n title={\n getTranslation('updateAvailable') +\n (updateNewVersion ? `: ${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}` : '')\n }\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n {props.updateAction ? (\n <IconButton\n size=\"small\"\n onClick={e => {\n if (!props.updateAction) {\n return;\n }\n e.stopPropagation();\n // An update is a significant operation, so always ask for confirmation\n // before triggering it. Reuse the action's own confirmation message if the\n // backend provided one; otherwise build a default one including the versions.\n // The confirmation is then handled by the standard device action flow\n // (deviceHandler -> showConfirmation -> renderConfirmationDialog).\n let confirmation: boolean | ioBroker.StringOrTranslated | undefined =\n props.updateAction.confirmation;\n if (!confirmation) {\n let message = getTranslation('updateConfirmation');\n if (updateNewVersion) {\n message += `: ${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}`;\n }\n confirmation = { [I18n.getLanguage()]: message, en: message };\n }\n props.deviceHandler(props.deviceId, { ...props.updateAction, confirmation })();\n }}\n >\n <SystemUpdateAltIcon style={iconStyleUpdate} />\n </IconButton>\n ) : (\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n <SystemUpdateAltIcon style={iconStyleUpdate} />\n </div>\n )}\n </Tooltip>\n ) : null}\n\n {disability}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DeviceStatus.js","sourceRoot":"./src/","sources":["DeviceStatus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EACH,SAAS,IAAI,uBAAuB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,iBAAiB,IAAI,yBAAyB,EAC9C,IAAI,IAAI,QAAQ,EAChB,OAAO,IAAI,WAAW,EACtB,OAAO,IAAI,WAAW,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAS3C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACnB,CAAC;AAiBF,S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AAC;IAClG,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5D,4FAA4F;QAC5F,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,UAAU,KAAK,WAAW,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,KAAK,GAAG,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC1C,KAAK,GAAG,MAAM,CAAC;IACnB,CAAC;IAED,OAAO,CACH,8BAAM,SAAS,EAAC,eAAe;QAC3B,oBAAC,aAAa,IACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,CAAC,KAAK,EAChB,SAAS,EACL,UAAU,KAAK,WAAW;gBACtB,CAAC,CAAC,cAAc,CAAC,sBAAsB,CAAC;gBACxC,CAAC,CAAC,cAAc,CAAC,yBAAyB,CAAC,GAErD,CACC,CACV,CAAC;AACN,CAAC","sourcesContent":["import { I18n, IconConnectionState, IconStatusLed } from '@iobroker/gui-components';\nimport type { Connection, IobTheme } from '@iobroker/gui-components';\nimport {\n Bluetooth as IconConnectionBluetooth,\n Cable as IconConnectionLan,\n BluetoothDisabled as IconConnectionNoBluetooth,\n Link as LinkIcon,\n LinkOff as LinkOffIcon,\n Warning as WarningIcon,\n} from '@mui/icons-material';\nimport React, { useState, type CSSProperties, type MouseEvent } from 'react';\n\nimport { IconBattery, IconSignal, IconUpdate, useValueTick } from './AnimatedIcons';\nimport { useStateOrObject } from './hooks';\nimport type {\n ActionBase,\n ConfigConnectionType,\n DeviceAction,\n DeviceId,\n DeviceInfo,\n DeviceStatus,\n} from './protocol/api';\nimport StatusPill from './StatusPill';\nimport type { StateOrObjectHandler } from './StateOrObjectHandler';\nimport { getTranslation } from './Utils';\n\nexport const ACTIONS = {\n STATUS: 'status',\n DISABLE: 'disable',\n ENABLE: 'enable',\n};\n\nexport interface IconProps {\n /** The width in pixels or percentage of the icon. */\n width?: number | string;\n /** The height in pixels or percentage of the icon. */\n height?: number | string;\n /** Click handler. */\n onClick?: (e: MouseEvent) => void;\n /** The class name for the SVG element. */\n className?: string;\n /** Styles for the SVG element. */\n style?: CSSProperties;\n /** The font size of the icon. */\n fontSize?: 'small';\n}\n\nfunction ThreadIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 165 165\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M82.498,0C37.008,0,0,37.008,0,82.496c0,45.181,36.51,81.977,81.573,82.476V82.569l-27.002-0.002 c-8.023,0-14.554,6.53-14.554,14.561c0,8.023,6.531,14.551,14.554,14.551v17.98c-17.939,0-32.534-14.595-32.534-32.531 c0-17.944,14.595-32.543,32.534-32.543l27.002,0.004v-9.096c0-14.932,12.146-27.08,27.075-27.08 c14.932,0,27.082,12.148,27.082,27.08c0,14.931-12.15,27.08-27.082,27.08l-9.097-0.001v80.641 C136.889,155.333,165,122.14,165,82.496C165,37.008,127.99,0,82.498,0z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M117.748,55.493c0-5.016-4.082-9.098-9.1-9.098c-5.015,0-9.097,4.082-9.097,9.098v9.097l9.097,0.001 C113.666,64.591,117.748,60.51,117.748,55.493z\"\n />\n </svg>\n );\n}\n\nfunction ZWaveIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 1073 1068\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M716 1.1C632.9 5.3 549.8 23.7 472 55c-66.4 26.7-132.6 65.5-188.5 110.4-43.8 35.1-85.2 76.7-120.1 120.6C72.4 400.4 16.7 539.8 3.5 686 1.8 705.1-.1 754.7.7 758c.5 2 1 2 49.7 1.8l49.1-.3.7-20c2.4-64.6 13.4-126 33.2-186 80.8-243.9 297-419.9 552.1-449.4 20.2-2.4 44.2-4.1 56.6-4.1h8.9V50 0l-9.7.1c-5.4.1-16.8.6-25.3 1zm-.8 208c-78.5 4.7-158 27.4-226.5 64.5-68.7 37.3-126.4 86.3-175.2 148.9-11 14-33.2 47.3-42.3 63.5-44 77.8-68.6 164.9-70.9 251.2l-.6 22.8h49.5 49.4l1.2-19c6.3-98.7 40-185.8 102.2-263.3 12.7-15.9 41.2-45.2 57-58.7 66.1-56.3 142.1-91.8 226-105.5 18.9-3 44.1-5.5 56.7-5.5h9.3v-50-50l-11.2.1c-6.2.1-17.3.6-24.6 1zm17.8 251c-104.5 9.2-195.2 69.7-243.6 162.4-43.9 84-45.5 184.2-4.5 270 60.3 125.9 198.1 194.2 334.9 166 46.6-9.7 89.5-29.7 127.2-59.6 13.5-10.7 37.3-34.5 48-47.9 34.2-43.1 55.2-92 63.7-148.6 2.2-15.1 2.5-62.7.5-77.4-3.6-25.2-10.1-51.4-17.8-71.2-10.1-26.2-29.4-59.7-47-81.8-9.7-12.1-35-37.2-47.4-47-47.8-37.9-104.5-60.1-165.4-65-14.7-1.1-34.7-1.1-48.6.1zm174.7 138.6c-.3.5-30.9 49.2-68.1 108.3L772 814.5l67.9.5 68 .5-30.1 48.8-30 48.7h-131c-104.4 0-130.9-.3-130.5-1.3.2-.6 32.7-51.1 72.1-112.1L730 687.9c0-.5-29.5-1-66.5-1.1l-66.6-.3 27.7-44.3 27.6-44.2h128l127.5.7z\"\n />\n </svg>\n );\n}\n\nfunction ZigBeeIcon(props: IconProps): React.JSX.Element {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n onClick={e => props.onClick && props.onClick(e)}\n viewBox=\"0 0 48 48\"\n width={props.width || (props.fontSize === 'small' ? 16 : 20)}\n height={props.height || props.width || (props.fontSize === 'small' ? 16 : 20)}\n className={props.className}\n style={props.style}\n >\n <path\n fill=\"currentColor\"\n d=\"M32.042,9.792c4.595,1.238,4.88,3.165,5.524,5.048C34.841,17.664,17.35,35.7,17.35,35.7 s10.901,1.177,23.487-1.003c-0.001,0.029-0.002,0.048-0.003,0.076C42.829,31.661,44,27.97,44,24c0-11.046-8.954-20-20-20 c-5.634,0-10.715,2.338-14.35,6.087C15.489,9.124,26.89,8.403,32.042,9.792z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.724,37.285c-1.982-0.347-4.212-2.131-4.707-5.302c1.437-1.239,19.994-20.507,19.994-20.507 c-7.008-0.424-14.569-0.465-22.237,0.864C5.408,15.625,4,19.644,4,24c0,11.046,8.954,20,20,20c6.173,0,11.689-2.8,15.358-7.195 C35.486,37.33,23.257,38.769,14.724,37.285z\"\n />\n </svg>\n );\n}\n\n/** The status as an object, also if the device gives only the connection as a string */\nfunction normalizeStatus(status: DeviceStatus | null | undefined): Exclude<DeviceStatus, string> {\n if (!status) {\n return {};\n }\n if (typeof status === 'string') {\n return { connection: status };\n }\n return status;\n}\n\n/** The symbol of the connection type; `null` if there is nothing to show */\nfunction getConnectionSymbol(\n connectionType: ConfigConnectionType | undefined,\n connection: string | undefined,\n): React.JSX.Element | null {\n const disconnected = connection === 'disconnected';\n switch (connectionType) {\n case 'wifi':\n // The waves are crossed out when the connection is lost\n return <IconConnectionState state={disconnected ? 'disconnected' : 'connected'} />;\n case 'bluetooth':\n return disconnected ? <IconConnectionNoBluetooth /> : <IconConnectionBluetooth />;\n case 'lan':\n return <IconConnectionLan />;\n case 'thread':\n return <ThreadIcon />;\n case 'z-wave':\n return <ZWaveIcon />;\n case 'zigbee':\n return <ZigBeeIcon />;\n default:\n if (connection === 'connected') {\n return <LinkIcon />;\n }\n return disconnected ? <LinkOffIcon /> : null;\n }\n}\n\ninterface DeviceStatusProps {\n socket: Connection;\n status: DeviceStatus | null;\n deviceId: DeviceId;\n connectionType?: ConfigConnectionType;\n statusAction?: DeviceAction;\n /** Update information of the device (firmware/software) */\n update?: DeviceInfo['update'];\n /** Reserved \"update\" action. If provided, the update indicator becomes a clickable button */\n updateAction?: DeviceAction;\n /** Reserved \"battery\" action. If provided, the battery indicator becomes a clickable button */\n batteryAction?: DeviceAction;\n deviceHandler: (deviceId: DeviceId, action: ActionBase) => () => void;\n theme: IobTheme;\n stateOrObjectHandler: StateOrObjectHandler;\n}\n\n/**\n * Device Status component: connection, signal, battery, warning and update as pills of the status line.\n *\n * A pill is neutral while the value is fine and tinted with its color when it needs attention, so that\n * the problems stand out in a list of many devices.\n *\n * @param props - Parameters\n * @param props.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }\n */\nexport default function DeviceStatusComponent(props: DeviceStatusProps): React.JSX.Element | null {\n const status = normalizeStatus(props.status);\n\n const connection = useStateOrObject(status.connection, props.stateOrObjectHandler);\n const rssi = useStateOrObject(status.rssi, props.stateOrObjectHandler);\n const battery = useStateOrObject(status.battery, props.stateOrObjectHandler);\n const warning = useStateOrObject(status.warning, props.stateOrObjectHandler);\n const updateAvailable = useStateOrObject(props.update?.available, props.stateOrObjectHandler);\n const updateVersion = useStateOrObject(props.update?.version, props.stateOrObjectHandler);\n const updateNewVersion = useStateOrObject(props.update?.newVersion, props.stateOrObjectHandler);\n\n // The new value slides in when it changes\n const rssiRef = useValueTick<HTMLSpanElement>(rssi);\n const batteryRef = useValueTick<HTMLSpanElement>(battery);\n\n const pills: React.JSX.Element[] = [];\n\n // Connection\n const connectionSymbol = getConnectionSymbol(props.connectionType, connection);\n if (connectionSymbol) {\n const known = connection === 'connected' || connection === 'disconnected';\n const tooltip = known\n ? (connection === 'connected'\n ? getTranslation('connectedIconTooltip')\n : getTranslation('disconnectedIconTooltip')) +\n (props.statusAction ? `. ${getTranslation(props.statusAction.description || 'moreInformation')}` : '')\n : undefined;\n pills.push(\n <StatusPill\n key=\"connection\"\n tone={connection === 'disconnected' ? 'err' : undefined}\n tooltip={tooltip}\n onClick={\n known && props.statusAction\n ? () => props.deviceHandler(props.deviceId, props.statusAction!)()\n : undefined\n }\n >\n {known ? connectionSymbol : <span style={{ display: 'flex', opacity: 0.55 }}>{connectionSymbol}</span>}\n </StatusPill>,\n );\n }\n\n // Signal strength\n const rssiNumber = rssi === undefined || rssi === null || (rssi as unknown) === '' ? NaN : Number(rssi);\n if (!isNaN(rssiNumber) && rssiNumber !== 0) {\n pills.push(\n <StatusPill\n key=\"rssi\"\n tone={rssiNumber < -80 ? 'warn' : undefined}\n tooltip={`RSSI: ${rssiNumber} dBm`}\n >\n <IconSignal rssi={rssiNumber} />\n <span ref={rssiRef}>{rssiNumber}</span>\n </StatusPill>,\n );\n }\n\n // Battery. A button if the backend offers the reserved \"battery\" action (e.g. for the battery history)\n if (battery !== undefined && battery !== null && (battery as unknown) !== '') {\n let icon: React.JSX.Element;\n let text: string | null = null;\n let tone: 'warn' | 'err' | undefined;\n if (typeof battery === 'number') {\n icon = <IconBattery level={battery} />;\n text = `${battery}%`;\n tone = battery <= 10 ? 'err' : battery <= 25 ? 'warn' : undefined;\n } else if (typeof battery === 'boolean') {\n icon = <IconBattery level={battery ? 100 : 0} />;\n tone = battery ? undefined : 'err';\n } else if (battery === 'charging') {\n icon = <IconBattery charging />;\n } else {\n icon = <IconBattery />;\n text = battery.includes('V') ? battery : `${battery} mV`;\n }\n pills.push(\n <StatusPill\n key=\"battery\"\n tone={tone}\n tooltip={\n getTranslation('batteryTooltip') +\n (props.batteryAction\n ? `. ${getTranslation(props.batteryAction.description || 'moreInformation')}`\n : '')\n }\n onClick={\n props.batteryAction ? () => props.deviceHandler(props.deviceId, props.batteryAction!)() : undefined\n }\n >\n {icon}\n {text ? <span ref={batteryRef}>{text}</span> : null}\n </StatusPill>,\n );\n }\n\n // Warning: it pulses when it appears or changes\n if (warning) {\n const text = typeof warning === 'string' || typeof warning === 'object' ? getTranslation(warning) : '';\n pills.push(\n <StatusPill\n key=\"warning\"\n tone=\"warn\"\n tooltip={text || undefined}\n >\n <IconStatusLed\n color=\"var(--dm-warn)\"\n beat={typeof warning === 'object' ? JSON.stringify(warning) : warning}\n >\n <WarningIcon fontSize=\"inherit\" />\n </IconStatusLed>\n </StatusPill>,\n );\n }\n\n // Update\n if (updateAvailable) {\n const versions = updateNewVersion ? `${updateVersion ? `${updateVersion} → ` : ''}${updateNewVersion}` : '';\n pills.push(\n <StatusPill\n key=\"update\"\n tone=\"info\"\n tooltip={getTranslation('updateAvailable') + (versions ? `: ${versions}` : '')}\n onClick={\n props.updateAction\n ? () => {\n // An update is a significant operation, so always ask for confirmation\n // before triggering it. Reuse the action's own confirmation message if the\n // backend provided one; otherwise build a default one including the versions.\n // The confirmation is then handled by the standard device action flow\n // (deviceHandler -> showConfirmation -> renderConfirmationDialog).\n let confirmation: boolean | ioBroker.StringOrTranslated | undefined =\n props.updateAction!.confirmation;\n if (!confirmation) {\n let message = getTranslation('updateConfirmation');\n if (versions) {\n message += `: ${versions}`;\n }\n confirmation = { [I18n.getLanguage()]: message, en: message };\n }\n props.deviceHandler(props.deviceId, { ...props.updateAction!, confirmation })();\n }\n : undefined\n }\n >\n <IconUpdate />\n </StatusPill>,\n );\n }\n\n return pills.length ? <>{pills}</> : null;\n}\n\ninterface DeviceLedProps {\n status?: DeviceStatus | null;\n stateOrObjectHandler: StateOrObjectHandler;\n /** The instance runs. If not, the LED is grey. */\n alive: boolean;\n /** The device is switched off: the LED is grey */\n enabled?: boolean;\n}\n\n/**\n * The LED on the device symbol: green while the device is connected, red without connection.\n *\n * It sends a pulse each time the device reports a new signal strength, like the LED of a real device\n * that blinks on traffic. Nothing is shown while the connection is unknown.\n */\nexport function DeviceLed(props: DeviceLedProps): React.JSX.Element | null {\n const status = normalizeStatus(props.status);\n const connection = useStateOrObject(status.connection, props.stateOrObjectHandler);\n const rssi = useStateOrObject(status.rssi, props.stateOrObjectHandler);\n\n // Only a change of a known value is a beat, not the first value after the (re)mount of the card\n const [beat, setBeat] = useState<{ rssi: unknown; count: number }>({ rssi: undefined, count: 0 });\n if (rssi !== undefined && rssi !== null && rssi !== beat.rssi) {\n // Adjusting the state while rendering, as React recommends for values derived from a change\n setBeat({ rssi, count: beat.rssi === undefined ? 0 : beat.count + 1 });\n }\n\n if (connection !== 'connected' && connection !== 'disconnected') {\n return null;\n }\n\n let color = connection === 'connected' ? 'green' : 'red';\n if (!props.alive || props.enabled === false) {\n color = 'grey';\n }\n\n return (\n <span className=\"dm-avatar-led\">\n <IconStatusLed\n color={color}\n beat={beat.count}\n ariaLabel={\n connection === 'connected'\n ? getTranslation('connectedIconTooltip')\n : getTranslation('disconnectedIconTooltip')\n }\n />\n </span>\n );\n}\n"]}
|
package/build/StatusIndicator.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
3
2
|
import { useStateOrObject } from './hooks';
|
|
3
|
+
import StatusPill from './StatusPill';
|
|
4
4
|
import { getIndicatorColor, getTranslation, renderIcon } from './Utils';
|
|
5
5
|
const styles = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
content: {
|
|
10
|
-
display: 'flex',
|
|
11
|
-
flexDirection: 'column',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
lineHeight: 1,
|
|
14
|
-
},
|
|
15
|
-
text: {
|
|
16
|
-
fontSize: 'small',
|
|
17
|
-
margin: 0,
|
|
18
|
-
whiteSpace: 'nowrap',
|
|
6
|
+
tooltipText: {
|
|
7
|
+
whiteSpace: 'pre-line',
|
|
19
8
|
},
|
|
20
9
|
row: {
|
|
21
10
|
display: 'flex',
|
|
22
11
|
alignItems: 'center',
|
|
23
12
|
flexWrap: 'wrap',
|
|
24
|
-
gap:
|
|
13
|
+
gap: 4,
|
|
25
14
|
},
|
|
26
15
|
};
|
|
27
16
|
/**
|
|
@@ -88,30 +77,13 @@ export default function StatusIndicator(props) {
|
|
|
88
77
|
}
|
|
89
78
|
const tooltipSource = level?.tooltip ?? indicator.tooltip;
|
|
90
79
|
const tooltip = tooltipSource ? getTranslation(tooltipSource) : '';
|
|
80
|
+
// An indicator in the color "error" or "warning" needs attention: its pill is tinted like the built-in ones
|
|
81
|
+
const tone = colorName === 'error' ? 'err' : colorName === 'warning' ? 'warn' : undefined;
|
|
91
82
|
// Only fall back to the "question mark" icon if the indicator shows nothing else at all
|
|
92
|
-
const iconElement = iconName || !label ? renderIcon(iconName, resolvedColor) : null;
|
|
93
|
-
|
|
83
|
+
const iconElement = iconName || !label ? renderIcon(iconName, tone ? undefined : resolvedColor) : null;
|
|
84
|
+
return (React.createElement(StatusPill, { tone: tone, color: tone ? undefined : resolvedColor, tooltip: tooltip ? React.createElement("span", { style: styles.tooltipText }, tooltip) : undefined, href: props.url, onClick: props.url ? undefined : props.onClick, disabled: props.disabled },
|
|
94
85
|
iconElement,
|
|
95
|
-
label ? React.createElement("
|
|
96
|
-
let element;
|
|
97
|
-
if (props.url) {
|
|
98
|
-
element = (React.createElement(IconButton, { size: "small", style: { padding: 2, borderRadius: 4 }, href: props.url, target: "_blank", disabled: props.disabled }, content));
|
|
99
|
-
}
|
|
100
|
-
else if (props.onClick) {
|
|
101
|
-
element = (React.createElement(IconButton, { size: "small", style: { padding: 2, borderRadius: 4 }, disabled: props.disabled, onClick: e => {
|
|
102
|
-
// The card itself may react on clicks, so the event must not bubble
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
props.onClick?.();
|
|
105
|
-
} }, content));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
element = content;
|
|
109
|
-
}
|
|
110
|
-
if (!tooltip) {
|
|
111
|
-
return element;
|
|
112
|
-
}
|
|
113
|
-
return (React.createElement(Tooltip, { title: React.createElement("span", { style: { whiteSpace: 'pre-line' } }, tooltip), slotProps: { popper: { sx: styles.tooltip } } },
|
|
114
|
-
React.createElement("span", { style: { display: 'inline-flex' } }, element)));
|
|
86
|
+
label ? React.createElement("span", null, label) : null));
|
|
115
87
|
}
|
|
116
88
|
/**
|
|
117
89
|
* The line of custom status indicators.
|