From c976e7b42a1c323a5a3b1d70eac87ca5e285f834 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Mon, 22 Jul 2024 11:35:46 +0900 Subject: [PATCH] GUI completed --- admin/i18n/de.json | 4 +- admin/i18n/en.json | 2 +- admin/i18n/es.json | 4 +- admin/i18n/fr.json | 4 +- admin/i18n/it.json | 4 +- admin/i18n/nl.json | 4 +- admin/i18n/pl.json | 4 +- admin/i18n/pt.json | 4 +- admin/i18n/ru.json | 4 +- admin/i18n/uk.json | 4 +- admin/i18n/zh-cn.json | 4 +- admin/jsonConfig.json | 3 +- src-admin/package.json | 1 + .../src/ConfigCustomInstancesSelector.jsx | 45 ++++++++++++++++--- src-admin/src/i18n/de.json | 8 +++- src-admin/src/i18n/en.json | 7 ++- src-admin/src/i18n/es.json | 6 ++- src-admin/src/i18n/fr.json | 6 ++- src-admin/src/i18n/it.json | 6 ++- src-admin/src/i18n/nl.json | 6 ++- src-admin/src/i18n/pl.json | 6 ++- src-admin/src/i18n/pt.json | 6 ++- src-admin/src/i18n/ru.json | 6 ++- src-admin/src/i18n/uk.json | 6 ++- src-admin/src/i18n/zh-cn.json | 6 ++- 25 files changed, 128 insertions(+), 32 deletions(-) diff --git a/admin/i18n/de.json b/admin/i18n/de.json index f479c91..e877863 100644 --- a/admin/i18n/de.json +++ b/admin/i18n/de.json @@ -10,5 +10,7 @@ "IP address": "IP Adresse", "MAC address": "MAC-Adresse", "To participate in the KISSHome research, you need to register here.": "Um an der KISSHome-Umfrage teilzunehmen, müssen Sie sich hier registrieren.", - "Known IP addresses": "Bekannte IP-Adressen" + "Known IP addresses": "Bekannte IP-Adressen", + "Recording": "Aufzeichnung", + "Recording enabled": "Aufzeichnung aktiviert" } \ No newline at end of file diff --git a/admin/i18n/en.json b/admin/i18n/en.json index 2c86f3d..b102a83 100644 --- a/admin/i18n/en.json +++ b/admin/i18n/en.json @@ -13,4 +13,4 @@ "FritzBox Password": "FritzBox Password", "To participate in the KISSHome research, you need to register here.": "To participate in the KISSHome research, you need to register here.", "Email address as registered in the KISSHome research": "Email address as registered in the KISSHome research" -} +} \ No newline at end of file diff --git a/admin/i18n/es.json b/admin/i18n/es.json index 46b4148..e3449ff 100644 --- a/admin/i18n/es.json +++ b/admin/i18n/es.json @@ -10,5 +10,7 @@ "IP address": "dirección IP", "MAC address": "Dirección MAC", "To participate in the KISSHome research, you need to register here.": "Para participar en la investigación de KISSHome, debe registrarse aquí.", - "Known IP addresses": "Direcciones IP conocidas" + "Known IP addresses": "Direcciones IP conocidas", + "Recording": "Grabación", + "Recording enabled": "Grabación habilitada" } \ No newline at end of file diff --git a/admin/i18n/fr.json b/admin/i18n/fr.json index 25a6e64..12982c0 100644 --- a/admin/i18n/fr.json +++ b/admin/i18n/fr.json @@ -10,5 +10,7 @@ "IP address": "adresse IP", "MAC address": "Adresse Mac", "To participate in the KISSHome research, you need to register here.": "Pour participer à la recherche KISSHome, vous devez vous inscrire ici.", - "Known IP addresses": "Adresses IP connues" + "Known IP addresses": "Adresses IP connues", + "Recording": "Enregistrement", + "Recording enabled": "Enregistrement activé" } \ No newline at end of file diff --git a/admin/i18n/it.json b/admin/i18n/it.json index 3040f51..77778fa 100644 --- a/admin/i18n/it.json +++ b/admin/i18n/it.json @@ -10,5 +10,7 @@ "IP address": "indirizzo IP", "MAC address": "Indirizzo MAC", "To participate in the KISSHome research, you need to register here.": "Per partecipare alla ricerca KISSHome è necessario registrarsi qui.", - "Known IP addresses": "Indirizzi IP conosciuti" + "Known IP addresses": "Indirizzi IP conosciuti", + "Recording": "Registrazione", + "Recording enabled": "Registrazione abilitata" } \ No newline at end of file diff --git a/admin/i18n/nl.json b/admin/i18n/nl.json index bf0635b..8ee7cc1 100644 --- a/admin/i18n/nl.json +++ b/admin/i18n/nl.json @@ -10,5 +10,7 @@ "IP address": "IP adres", "MAC address": "Mac adres", "To participate in the KISSHome research, you need to register here.": "Om deel te nemen aan het KISSHome-onderzoek moet u zich hier registreren.", - "Known IP addresses": "Bekende IP-adressen" + "Known IP addresses": "Bekende IP-adressen", + "Recording": "Opname", + "Recording enabled": "Opname ingeschakeld" } \ No newline at end of file diff --git a/admin/i18n/pl.json b/admin/i18n/pl.json index 6c9793d..694205c 100644 --- a/admin/i18n/pl.json +++ b/admin/i18n/pl.json @@ -10,5 +10,7 @@ "IP address": "adres IP", "MAC address": "Adres MAC", "To participate in the KISSHome research, you need to register here.": "Aby wziąć udział w badaniu KISSHome, musisz zarejestrować się tutaj.", - "Known IP addresses": "Znane adresy IP" + "Known IP addresses": "Znane adresy IP", + "Recording": "Nagranie", + "Recording enabled": "Nagrywanie włączone" } \ No newline at end of file diff --git a/admin/i18n/pt.json b/admin/i18n/pt.json index 999080e..60dcca5 100644 --- a/admin/i18n/pt.json +++ b/admin/i18n/pt.json @@ -10,5 +10,7 @@ "IP address": "endereço de IP", "MAC address": "Endereço MAC", "To participate in the KISSHome research, you need to register here.": "Para participar da pesquisa KISSHome, você precisa se cadastrar aqui.", - "Known IP addresses": "Endereços IP conhecidos" + "Known IP addresses": "Endereços IP conhecidos", + "Recording": "Gravação", + "Recording enabled": "Gravação ativada" } \ No newline at end of file diff --git a/admin/i18n/ru.json b/admin/i18n/ru.json index 7d4214f..b5da088 100644 --- a/admin/i18n/ru.json +++ b/admin/i18n/ru.json @@ -10,5 +10,7 @@ "IP address": "айпи адрес", "MAC address": "MAC-адрес", "To participate in the KISSHome research, you need to register here.": "Чтобы принять участие в исследовании KISSHome, вам необходимо зарегистрироваться здесь.", - "Known IP addresses": "Известные IP-адреса" + "Known IP addresses": "Известные IP-адреса", + "Recording": "Запись", + "Recording enabled": "Запись включена" } \ No newline at end of file diff --git a/admin/i18n/uk.json b/admin/i18n/uk.json index 9a0cd9d..a3f0859 100644 --- a/admin/i18n/uk.json +++ b/admin/i18n/uk.json @@ -10,5 +10,7 @@ "IP address": "IP-адреса", "MAC address": "MAC-адреса", "To participate in the KISSHome research, you need to register here.": "Щоб взяти участь у дослідженні KISSHome, вам необхідно зареєструватися тут.", - "Known IP addresses": "Відомі IP-адреси" + "Known IP addresses": "Відомі IP-адреси", + "Recording": "Запис", + "Recording enabled": "Запис увімкнено" } \ No newline at end of file diff --git a/admin/i18n/zh-cn.json b/admin/i18n/zh-cn.json index c01ffc4..0651ef5 100644 --- a/admin/i18n/zh-cn.json +++ b/admin/i18n/zh-cn.json @@ -10,5 +10,7 @@ "IP address": "IP地址", "MAC address": "MAC地址", "To participate in the KISSHome research, you need to register here.": "要参与 KISSHome 研究,您需要在此处注册。", - "Known IP addresses": "已知 IP 地址" + "Known IP addresses": "已知 IP 地址", + "Recording": "记录", + "Recording enabled": "已启用录制功能" } \ No newline at end of file diff --git a/admin/jsonConfig.json b/admin/jsonConfig.json index e9fb506..1761b85 100644 --- a/admin/jsonConfig.json +++ b/admin/jsonConfig.json @@ -88,8 +88,7 @@ "newLine": true, "type": "custom", "sm": 12, - "md": 6, - "lg": 6, + "lg": 9, "i18n": true, "url": "custom/customComponents.js", "name": "ConfigCustomKissHomeResearchSet/Components/ConfigCustomInstancesSelector" diff --git a/src-admin/package.json b/src-admin/package.json index f5f7a84..cd79b51 100644 --- a/src-admin/package.json +++ b/src-admin/package.json @@ -8,6 +8,7 @@ }, "dependencies": {}, "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@iobroker/adapter-react-v5": "^6.1.5", "@iobroker/json-config": "^7.0.17", "@mui/material": "^5.16.4", diff --git a/src-admin/src/ConfigCustomInstancesSelector.jsx b/src-admin/src/ConfigCustomInstancesSelector.jsx index f508459..f9815d4 100644 --- a/src-admin/src/ConfigCustomInstancesSelector.jsx +++ b/src-admin/src/ConfigCustomInstancesSelector.jsx @@ -12,13 +12,14 @@ import { TextField, LinearProgress, } from '@mui/material'; +import { Delete } from '@mui/icons-material'; + // important to make from package and not from some children. // invalid // import ConfigGeneric from '@iobroker/adapter-react-v5/ConfigGeneric'; // valid import { ConfigGeneric } from '@iobroker/json-config'; import { i18n } from '@iobroker/adapter-react-v5'; -import {Delete} from "@mui/icons-material"; const styles = { table: { @@ -243,15 +244,47 @@ class ConfigCustomInstancesSelector extends ConfigGeneric { /** @type {{mac: string; ip: string; desc: string; enabled: boolean}[]} */ const instanceIPs = ConfigGeneric.getValue(this.props.data, 'instanceIPs') || []; - const notFound = this.state.ips ? instanceIPs.filter(ip => !this.state.ips.find(item => item.ip === ip)) : instanceIPs; + const notFound = this.state.ips ? + instanceIPs.filter(iItem => !this.state.ips.find(item => item.ip === iItem.ip)) : + instanceIPs; + + const allEnabled = instanceIPs.every(item => item.enabled) && + (this.state.ips ? this.state.ips.every(item => instanceIPs.find(iItem => iItem.ip === item.ip)) : true); return {this.state.runningRequest ? :
} - {i18n.t('custom_kisshome_enabled')} + + 0} + onClick={() => { + const _instanceIPs = [...(ConfigGeneric.getValue(this.props.data, 'instanceIPs') || [])]; + if (allEnabled) { + _instanceIPs.forEach(item => item.enabled = false); + for (let i = _instanceIPs.length - 1; i >= 0; i--) { + if (this.state.ips.find(item => item.ip === _instanceIPs[i].ip)) { + _instanceIPs.splice(i, 1); + } + } + } else { + _instanceIPs.forEach(item => item.enabled = true); + this.state.ips.forEach(item => { + if (!_instanceIPs.find(iItem => item.ip === iItem.ip)) { + _instanceIPs.push({ ip: item.ip, mac: item.mac, desc: item.desc, enabled: true }); + } + }); + _instanceIPs.forEach(item => item.enabled = true); + } + this.onChange('instanceIPs', _instanceIPs); + }} + /> + {i18n.t('custom_kisshome_ip')} + {i18n.t('custom_kisshome_mac')} {i18n.t('custom_kisshome_vendor')} {i18n.t('custom_kisshome_name')} @@ -261,7 +294,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric { {this.state.ips?.map((row, i) => item.ip === row.ip)?.enabled} onClick={() => { const _instanceIPs = [...(ConfigGeneric.getValue(this.props.data, 'instanceIPs') || [])]; const pos = _instanceIPs.findIndex(item => item.ip === row.ip); @@ -276,7 +309,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric { {row.ip} {row.mac || ''} - {row.vendor || ''} + {this.state.vendors?.[row.mac] || ''} {row.desc} )} @@ -315,7 +348,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric { variant="standard" /> - {row.vendor || ''} + {this.state.vendors?.[row.mac] || ''}