Skip to content

Commit

Permalink
GUI completed
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jul 22, 2024
1 parent c6d1f15 commit c976e7b
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 32 deletions.
4 changes: 3 additions & 1 deletion admin/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion admin/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 3 additions & 1 deletion admin/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion admin/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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é"
}
4 changes: 3 additions & 1 deletion admin/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion admin/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion admin/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion admin/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion admin/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Запись включена"
}
4 changes: 3 additions & 1 deletion admin/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Запис увімкнено"
}
4 changes: 3 additions & 1 deletion admin/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "已启用录制功能"
}
3 changes: 1 addition & 2 deletions admin/jsonConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 39 additions & 6 deletions src-admin/src/ConfigCustomInstancesSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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 <TableContainer>
{this.state.runningRequest ? <LinearProgress /> : <div style={{ height: 2, width: '100%' }} />}
<Table style={styles.table} size="small">
<TableHead>
<TableRow>
<TableCell style={styles.header}>{i18n.t('custom_kisshome_enabled')}</TableCell>
<TableCell style={styles.header}>
<Checkbox
title={allEnabled ? i18n.t('custom_kisshome_unselect_all') : i18n.t('custom_kisshome_select_all')}
checked={allEnabled}
indeterminate={!allEnabled && instanceIPs.length > 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);
}}
/>
</TableCell>
<TableCell style={styles.header}>{i18n.t('custom_kisshome_ip')}</TableCell>
<TableCell style={styles.header}>{i18n.t('custom_kisshome_mac')}</TableCell>
<TableCell style={styles.header}>{i18n.t('custom_kisshome_vendor')}</TableCell>
<TableCell style={styles.header}>{i18n.t('custom_kisshome_name')}</TableCell>
<TableCell style={styles.header} />
Expand All @@ -261,7 +294,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric {
{this.state.ips?.map((row, i) => <TableRow key={i}>
<TableCell scope="row" style={styles.td}>
<Checkbox
checked={!!row.enabled}
checked={!!instanceIPs.find(item => item.ip === row.ip)?.enabled}
onClick={() => {
const _instanceIPs = [...(ConfigGeneric.getValue(this.props.data, 'instanceIPs') || [])];
const pos = _instanceIPs.findIndex(item => item.ip === row.ip);
Expand All @@ -276,7 +309,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric {
</TableCell>
<TableCell style={styles.td}>{row.ip}</TableCell>
<TableCell style={styles.td}>{row.mac || ''}</TableCell>
<TableCell style={styles.td}>{row.vendor || ''}</TableCell>
<TableCell style={styles.td}>{this.state.vendors?.[row.mac] || ''}</TableCell>
<TableCell style={styles.td}>{row.desc}</TableCell>
<TableCell style={styles.td} />
</TableRow>)}
Expand Down Expand Up @@ -315,7 +348,7 @@ class ConfigCustomInstancesSelector extends ConfigGeneric {
variant="standard"
/>
</TableCell>
<TableCell style={styles.td}>{row.vendor || ''}</TableCell>
<TableCell style={styles.td}>{this.state.vendors?.[row.mac] || ''}</TableCell>
<TableCell style={styles.td}>
<TextField
fullWidth
Expand Down
8 changes: 6 additions & 2 deletions src-admin/src/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Aktiviert",
"custom_kisshome_ip": "IP Adresse",
"custom_kisshome_name": "Adaptername"
}
"custom_kisshome_name": "Adaptername",
"custom_kisshome_vendor": "Vendor",
"custom_kisshome_mac": "MAC-Adresse",
"custom_kisshome_select_all": "Alle aktivieren",
"custom_kisshome_unselect_all": "Alle deaktivieren"
}
7 changes: 5 additions & 2 deletions src-admin/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"custom_kisshome_enabled": "Enabled",
"custom_kisshome_ip": "IP address",
"custom_kisshome_name": "Adapter name",
"custom_kisshome_vendor": "Vendor"
}
"custom_kisshome_vendor": "Vendor",
"custom_kisshome_mac": "MAC-Address",
"custom_kisshome_unselect_all": "Disable all",
"custom_kisshome_select_all": "Enable all"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/es.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Activado",
"custom_kisshome_ip": "dirección IP",
"custom_kisshome_name": "Nombre del adaptador"
"custom_kisshome_name": "Nombre del adaptador",
"custom_kisshome_vendor": "Proveedor",
"custom_kisshome_mac": "Dirección MAC",
"custom_kisshome_select_all": "Activar todo",
"custom_kisshome_unselect_all": "Desactivar todo"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Activé",
"custom_kisshome_ip": "adresse IP",
"custom_kisshome_name": "Nom de l'adaptateur"
"custom_kisshome_name": "Nom de l'adaptateur",
"custom_kisshome_vendor": "Fournisseur",
"custom_kisshome_mac": "Adresse Mac",
"custom_kisshome_select_all": "Activer tout",
"custom_kisshome_unselect_all": "Désactiver tous les"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/it.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Abilitato",
"custom_kisshome_ip": "indirizzo IP",
"custom_kisshome_name": "Nome dell'adattatore"
"custom_kisshome_name": "Nome dell'adattatore",
"custom_kisshome_vendor": "Venditore",
"custom_kisshome_mac": "Indirizzo MAC",
"custom_kisshome_select_all": "Attiva tutto",
"custom_kisshome_unselect_all": "Disabilitare tutto"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/nl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Ingeschakeld",
"custom_kisshome_ip": "IP adres",
"custom_kisshome_name": "Adapternaam"
"custom_kisshome_name": "Adapternaam",
"custom_kisshome_vendor": "Leverancier",
"custom_kisshome_mac": "Mac adres",
"custom_kisshome_select_all": "Schakel alles in",
"custom_kisshome_unselect_all": "Schakel alles uit"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/pl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Włączony",
"custom_kisshome_ip": "adres IP",
"custom_kisshome_name": "Nazwa adaptera"
"custom_kisshome_name": "Nazwa adaptera",
"custom_kisshome_vendor": "Sprzedawca",
"custom_kisshome_mac": "Adres MAC",
"custom_kisshome_select_all": "Włącz wszystkie",
"custom_kisshome_unselect_all": "Wyłącz wszystkie"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/pt.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Habilitado",
"custom_kisshome_ip": "endereço de IP",
"custom_kisshome_name": "Nome do adaptador"
"custom_kisshome_name": "Nome do adaptador",
"custom_kisshome_vendor": "Fornecedor",
"custom_kisshome_mac": "Endereço MAC",
"custom_kisshome_select_all": "Habilitar todos",
"custom_kisshome_unselect_all": "Desativar tudo"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Включено",
"custom_kisshome_ip": "айпи адрес",
"custom_kisshome_name": "Имя адаптера"
"custom_kisshome_name": "Имя адаптера",
"custom_kisshome_vendor": "Продавец",
"custom_kisshome_mac": "MAC-адрес",
"custom_kisshome_select_all": "Включить все",
"custom_kisshome_unselect_all": "Отключить все"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/uk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "Увімкнено",
"custom_kisshome_ip": "IP-адреса",
"custom_kisshome_name": "Назва адаптера"
"custom_kisshome_name": "Назва адаптера",
"custom_kisshome_vendor": "Продавець",
"custom_kisshome_mac": "MAC-адреса",
"custom_kisshome_select_all": "Увімкнути всі",
"custom_kisshome_unselect_all": "Відключити все"
}
6 changes: 5 additions & 1 deletion src-admin/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"custom_kisshome_enabled": "已启用",
"custom_kisshome_ip": "IP地址",
"custom_kisshome_name": "适配器名称"
"custom_kisshome_name": "适配器名称",
"custom_kisshome_vendor": "小贩",
"custom_kisshome_mac": "MAC地址",
"custom_kisshome_select_all": "全部启用",
"custom_kisshome_unselect_all": "禁用所有"
}

0 comments on commit c976e7b

Please sign in to comment.