From 877edb296e0ffc6687412df008475de2b0bc81fc Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Sat, 11 Jan 2025 13:46:50 +0000 Subject: [PATCH] Changed DM component --- LICENSE | 2 +- README.md | 2 +- package-lock.json | 8 +- packages/dm-gui-components/package.json | 2 +- packages/dm-gui-components/src/DeviceCard.tsx | 10 +- .../dm-gui-components/src/DeviceStatus.tsx | 91 ++++++++++--------- packages/dm-gui-components/src/Utils.tsx | 4 - packages/dm-gui-components/src/i18n/de.json | 1 + packages/dm-gui-components/src/i18n/en.json | 1 + packages/dm-gui-components/src/i18n/es.json | 1 + packages/dm-gui-components/src/i18n/fr.json | 1 + packages/dm-gui-components/src/i18n/it.json | 1 + packages/dm-gui-components/src/i18n/nl.json | 1 + packages/dm-gui-components/src/i18n/pl.json | 1 + packages/dm-gui-components/src/i18n/pt.json | 1 + packages/dm-gui-components/src/i18n/ru.json | 1 + packages/dm-gui-components/src/i18n/uk.json | 1 + .../dm-gui-components/src/i18n/zh-cn.json | 1 + 18 files changed, 72 insertions(+), 58 deletions(-) diff --git a/LICENSE b/LICENSE index 96000d182..87c3398af 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2024 bluefox +Copyright (c) 2014-2025 bluefox Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b625c9daa..aac578cf0 100644 --- a/README.md +++ b/README.md @@ -124,4 +124,4 @@ The icons may not be reused in other projects without the proper flaticon licens The MIT License (MIT) -Copyright (c) 2014-2024 bluefox +Copyright (c) 2014-2025 bluefox diff --git a/package-lock.json b/package-lock.json index bad3a27e2..f92fc10cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48258,7 +48258,7 @@ }, "devDependencies": { "@craco/craco": "^7.1.0", - "@iobroker/dm-utils": "^1.0.3" + "@iobroker/dm-utils": "^1.0.5" } }, "packages/dm-gui-components/node_modules/@craco/craco": { @@ -48323,9 +48323,9 @@ } }, "packages/dm-gui-components/node_modules/@iobroker/dm-utils": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@iobroker/dm-utils/-/dm-utils-1.0.3.tgz", - "integrity": "sha512-aCzr5fW3jdU6ffIBBhdTpp0LpH9H7jBWFES2iCteYHS2WN41qhmqnbZrCPOPRngEyI4+3Tv91Hu9VRbyxxJqWA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@iobroker/dm-utils/-/dm-utils-1.0.5.tgz", + "integrity": "sha512-q3UwDV2gMbG829kSPmHdiVpzg5s+v7FqxxA7mmTmiARQ/PqFq1uVjWShpG2Ahk3PES586k5s9nF+t7EsYMEcrQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/dm-gui-components/package.json b/packages/dm-gui-components/package.json index 8248486a9..16d8f45c6 100644 --- a/packages/dm-gui-components/package.json +++ b/packages/dm-gui-components/package.json @@ -53,6 +53,6 @@ }, "devDependencies": { "@craco/craco": "^7.1.0", - "@iobroker/dm-utils": "^1.0.3" + "@iobroker/dm-utils": "^1.0.5" } } diff --git a/packages/dm-gui-components/src/DeviceCard.tsx b/packages/dm-gui-components/src/DeviceCard.tsx index 7b629163a..75565443a 100644 --- a/packages/dm-gui-components/src/DeviceCard.tsx +++ b/packages/dm-gui-components/src/DeviceCard.tsx @@ -321,7 +321,7 @@ class DeviceCard extends Component { renderActions(): JSX.Element[] | null { const actions = this.props.device.actions?.filter( - a => a.id !== ACTIONS.STATUS && a.id !== ACTIONS.DISABLE && a.id !== ACTIONS.ENABLE, + a => a.id !== ACTIONS.STATUS && a.id !== ACTIONS.ENABLE_DISABLE, ); return actions?.length @@ -432,10 +432,11 @@ class DeviceCard extends Component { a.id === ACTIONS.STATUS)} disableEnableAction={this.props.device.actions?.find( - a => a.id === ACTIONS.DISABLE || a.id === ACTIONS.ENABLE, + a => a.id === ACTIONS.ENABLE_DISABLE, )} deviceHandler={this.props.deviceHandler} refresh={this.refresh} @@ -606,10 +607,9 @@ class DeviceCard extends Component { key={i} deviceId={this.props.device.id} status={s} + enabled={this.props.device.enabled} statusAction={this.props.device.actions?.find(a => a.id === ACTIONS.STATUS)} - disableEnableAction={this.props.device.actions?.find( - a => a.id === ACTIONS.DISABLE || a.id === ACTIONS.ENABLE, - )} + disableEnableAction={this.props.device.actions?.find(a => a.id === ACTIONS.ENABLE_DISABLE)} deviceHandler={this.props.deviceHandler} refresh={this.refresh} theme={this.props.theme} diff --git a/packages/dm-gui-components/src/DeviceStatus.tsx b/packages/dm-gui-components/src/DeviceStatus.tsx index 52dfd5225..16a512a35 100644 --- a/packages/dm-gui-components/src/DeviceStatus.tsx +++ b/packages/dm-gui-components/src/DeviceStatus.tsx @@ -39,6 +39,7 @@ interface DeviceStatusProps { status: DeviceStatus | null; deviceId: string; statusAction?: DeviceAction; + enabled?: boolean; disableEnableAction?: DeviceAction; deviceHandler: (deviceId: string, action: ActionBase, refresh: () => void) => () => void; refresh: () => void; @@ -96,48 +97,51 @@ export default function DeviceStatus(props: DeviceStatusProps): React.JSX.Elemen } } - const disability = props.disableEnableAction ? ( - <> -
- { - -
- - props.disableEnableAction && - props.deviceHandler(props.deviceId, props.disableEnableAction, props.refresh)() - } - theme={props.theme} - /> -
-
- } - - ) : null; + const disability = + typeof props.enabled === 'boolean' ? ( + <> +
+ { + +
+ + props.disableEnableAction && + props.deviceHandler(props.deviceId, props.disableEnableAction, props.refresh)() + } + theme={props.theme} + /> +
+
+ } + + ) : null; const connectionIcon = status.connection === 'connected' || status.connection === 'disconnected' ? ( - {props.statusAction && props.deviceHandler ? ( + {props.statusAction ? ( { - if (props.statusAction && props.deviceHandler) { + if (props.statusAction) { e.stopPropagation(); props.deviceHandler(props.deviceId, props.statusAction, props.refresh)(); } @@ -148,6 +152,7 @@ export default function DeviceStatus(props: DeviceStatusProps): React.JSX.Elemen ) : ( )} +
*
) : (
@@ -233,20 +238,22 @@ export default function DeviceStatus(props: DeviceStatusProps): React.JSX.Elemen )} - {status.warning && (typeof status.warning === 'string' || typeof status.warning === 'object') ? ( - + {status.warning ? ( + typeof status.warning === 'string' || typeof status.warning === 'object' ? ( + +
+ +
+
+ ) : (
-
- ) : ( -
- -
- )} + ) + ) : null} {disability}
diff --git a/packages/dm-gui-components/src/Utils.tsx b/packages/dm-gui-components/src/Utils.tsx index 3aed7c519..5397cd47d 100644 --- a/packages/dm-gui-components/src/Utils.tsx +++ b/packages/dm-gui-components/src/Utils.tsx @@ -31,7 +31,6 @@ import { Visibility, WbIncandescent, Wifi, - WifiFind, WifiOff, } from '@mui/icons-material'; @@ -224,9 +223,6 @@ function getIconByName(name: string, altName?: string, color?: string): React.JS if (name === 'qrcode' || altName === 'qrcode') { return ; } - if (name === 'identify' || altName === 'identify') { - return ; - } if (name === 'info' || altName === 'info') { return ; } diff --git a/packages/dm-gui-components/src/i18n/de.json b/packages/dm-gui-components/src/i18n/de.json index e9be7f132..71c31b095 100644 --- a/packages/dm-gui-components/src/i18n/de.json +++ b/packages/dm-gui-components/src/i18n/de.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Instanz ist nicht aktiv", "manufacturer": "Hersteller", "model": "Modell", + "moreInformation": "Klicken, um weitere Informationen zu erhalten", "noButtonText": "Nein", "noDevicesFoundText": "Keine Geräte gefunden", "noInstanceSelectedText": "Bitte Instanz auswählen", diff --git a/packages/dm-gui-components/src/i18n/en.json b/packages/dm-gui-components/src/i18n/en.json index 68d9ab420..915d3cf2c 100644 --- a/packages/dm-gui-components/src/i18n/en.json +++ b/packages/dm-gui-components/src/i18n/en.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Instance is not alive", "manufacturer": "Manufacturer", "model": "Model", + "moreInformation": "Click to get more information", "noButtonText": "No", "noDevicesFoundText": "No devices found", "noInstanceSelectedText": "Please select instance", diff --git a/packages/dm-gui-components/src/i18n/es.json b/packages/dm-gui-components/src/i18n/es.json index c4cc50960..00424f1e9 100644 --- a/packages/dm-gui-components/src/i18n/es.json +++ b/packages/dm-gui-components/src/i18n/es.json @@ -13,6 +13,7 @@ "instanceNotAlive": "La instancia no está viva.", "manufacturer": "Fabricante", "model": "Modelo", + "moreInformation": "Haga clic para obtener más información", "noButtonText": "No", "noDevicesFoundText": "No se encontraron dispositivos", "noInstanceSelectedText": "Por favor seleccione instancia", diff --git a/packages/dm-gui-components/src/i18n/fr.json b/packages/dm-gui-components/src/i18n/fr.json index 8f1debc70..2fd808b31 100644 --- a/packages/dm-gui-components/src/i18n/fr.json +++ b/packages/dm-gui-components/src/i18n/fr.json @@ -13,6 +13,7 @@ "instanceNotAlive": "L'instance n'est pas vivante", "manufacturer": "Fabricant", "model": "Modèle", + "moreInformation": "Cliquez pour obtenir plus d'informations", "noButtonText": "Non", "noDevicesFoundText": "Aucun périphérique trouvé", "noInstanceSelectedText": "Veuillez sélectionner une instance", diff --git a/packages/dm-gui-components/src/i18n/it.json b/packages/dm-gui-components/src/i18n/it.json index 161dabf51..84292f5cd 100644 --- a/packages/dm-gui-components/src/i18n/it.json +++ b/packages/dm-gui-components/src/i18n/it.json @@ -13,6 +13,7 @@ "instanceNotAlive": "L'istanza non è viva", "manufacturer": "Produttore", "model": "Modello", + "moreInformation": "Clicca per avere maggiori informazioni", "noButtonText": "NO", "noDevicesFoundText": "Nessun dispositivo trovato", "noInstanceSelectedText": "Seleziona l'istanza", diff --git a/packages/dm-gui-components/src/i18n/nl.json b/packages/dm-gui-components/src/i18n/nl.json index f55595ab3..e701108df 100644 --- a/packages/dm-gui-components/src/i18n/nl.json +++ b/packages/dm-gui-components/src/i18n/nl.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Instantie leeft niet", "manufacturer": "Fabrikant", "model": "Model", + "moreInformation": "Klik voor meer informatie", "noButtonText": "Nee", "noDevicesFoundText": "Geen apparaten gevonden", "noInstanceSelectedText": "Selecteer een exemplaar", diff --git a/packages/dm-gui-components/src/i18n/pl.json b/packages/dm-gui-components/src/i18n/pl.json index 7a6dc296b..bf5769b66 100644 --- a/packages/dm-gui-components/src/i18n/pl.json +++ b/packages/dm-gui-components/src/i18n/pl.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Instancja nie żyje", "manufacturer": "Producent", "model": "Model", + "moreInformation": "Kliknij, aby uzyskać więcej informacji", "noButtonText": "NIE", "noDevicesFoundText": "Nie znaleziono urządzeń", "noInstanceSelectedText": "Wybierz instancję", diff --git a/packages/dm-gui-components/src/i18n/pt.json b/packages/dm-gui-components/src/i18n/pt.json index d0043d122..dbf9deb1e 100644 --- a/packages/dm-gui-components/src/i18n/pt.json +++ b/packages/dm-gui-components/src/i18n/pt.json @@ -13,6 +13,7 @@ "instanceNotAlive": "A instância não está ativa", "manufacturer": "Fabricante", "model": "Modelo", + "moreInformation": "Clique para obter mais informações", "noButtonText": "Não", "noDevicesFoundText": "Nenhum dispositivo encontrado", "noInstanceSelectedText": "Selecione a instância", diff --git a/packages/dm-gui-components/src/i18n/ru.json b/packages/dm-gui-components/src/i18n/ru.json index 7433a2ae5..fd3822959 100644 --- a/packages/dm-gui-components/src/i18n/ru.json +++ b/packages/dm-gui-components/src/i18n/ru.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Экземпляр не жив", "manufacturer": "Производитель", "model": "Модель", + "moreInformation": "Нажмите, чтобы получить больше информации", "noButtonText": "Нет", "noDevicesFoundText": "Устройства не найдены", "noInstanceSelectedText": "Пожалуйста, выберите экземпляр", diff --git a/packages/dm-gui-components/src/i18n/uk.json b/packages/dm-gui-components/src/i18n/uk.json index 89c66bc53..029633cc0 100644 --- a/packages/dm-gui-components/src/i18n/uk.json +++ b/packages/dm-gui-components/src/i18n/uk.json @@ -13,6 +13,7 @@ "instanceNotAlive": "Примірник не живий", "manufacturer": "Виробник", "model": "Модель", + "moreInformation": "Натисніть, щоб отримати більше інформації", "noButtonText": "Немає", "noDevicesFoundText": "Пристроїв не знайдено", "noInstanceSelectedText": "Виберіть екземпляр", diff --git a/packages/dm-gui-components/src/i18n/zh-cn.json b/packages/dm-gui-components/src/i18n/zh-cn.json index a8dcc68ec..5201c1765 100644 --- a/packages/dm-gui-components/src/i18n/zh-cn.json +++ b/packages/dm-gui-components/src/i18n/zh-cn.json @@ -13,6 +13,7 @@ "instanceNotAlive": "实例不存在", "manufacturer": "制造商", "model": "型号", + "moreInformation": "点击获取更多信息", "noButtonText": "不", "noDevicesFoundText": "未找到设备", "noInstanceSelectedText": "请选择实例",