Skip to content

Commit

Permalink
Added copy to clipboard button in debug dialog (#369)
Browse files Browse the repository at this point in the history
* Added copy to clipboard button in debug dialog

* Added copy to clipboard button in debug dialog
  • Loading branch information
GermanBluefox authored Jan 29, 2025
1 parent d7c77f0 commit b4306fb
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ With the ioBroker Matter Adapter, it is possible to map the following use cases:
-->

## Changelog
### **WORK IN PROGRESS**

* (@GermanBluefox) Added the "copy to clipboard" button in the debug dialog

### 0.4.11 (2025-01-28)
* (@Apollon77) Fixed caching issues in device type detection
* (@Apollon77) Added Debug info icon for Devices and Bridges
Expand Down
4 changes: 2 additions & 2 deletions src-admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 41 additions & 1 deletion src-admin/src/Tabs/BridgesAndDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,47 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
if (this.state.jsonConfig.options?.buttons) {
buttons = [];
this.state.jsonConfig.options.buttons.forEach((button: ActionButton | 'apply' | 'cancel'): void => {
if (button === 'apply' || (button as ActionButton).type === 'apply') {
if (typeof button === 'object' && button.type === 'copyToClipboard') {
buttons.push(
<Button
key="copyToClipboard"
variant={button.variant || 'outlined'}
color={
button.color === 'primary'
? 'primary'
: button.color === 'secondary'
? 'secondary'
: undefined
}
style={{
backgroundColor:
button.color && button.color !== 'primary' && button.color !== 'secondary'
? button.color
: undefined,
...(button.style || undefined),
}}
onClick={() => {
if (button.copyToClipboardAttr && this.state.jsonConfig?.options?.data) {
const val = this.state.jsonConfig.options.data[button.copyToClipboardAttr];
if (typeof val === 'string') {
Utils.copyToClipboard(val);
} else {
Utils.copyToClipboard(JSON.stringify(val, null, 2));
}
window.alert(I18n.t('copied'));
} else if (this.state.jsonConfig?.options?.data) {
Utils.copyToClipboard(JSON.stringify(this.state.jsonConfig.options.data, null, 2));
window.alert(I18n.t('copied'));
} else {
window.alert(I18n.t('nothingToCopy'));
}
}}
startIcon={button?.icon ? <Icon src={button?.icon} /> : <ContentCopy />}
>
{getTranslation(button?.label || 'ctcButtonText', button?.noTranslation)}
</Button>,
);
} else if (button === 'apply' || (button as ActionButton).type === 'apply') {
buttons.push(this.getOkButton(button));
} else {
buttons.push(this.getCancelButton(button));
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Bluetooth-Konfiguration",
"Bridge Debug information": "Bridge-Debug-Informationen",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "Brücke ist bereits in Betrieb genommen. Sie können den Namen oder die Anbieter-/Produkt-ID nicht ändern.",
"Bridge is not commissioned. Show QR Code got commissioning": "Brücke ist nicht in Betrieb genommen. QR-Code anzeigen wurde in Betrieb genommen",
"Bridges": "Bridges",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Löschen",
"Delete bridge": "Bridge löschen",
"Delete device": "Gerät löschen",
"Device Debug information": "Geräte-Debuginformationen",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "Gerät ist bereits in Betrieb genommen. Sie können den Namen oder die Anbieter-/Produkt-ID nicht ändern.",
"Device is already commissioning. Show status information": "Gerät wird bereits in Betrieb genommen. Statusinformationen anzeigen",
"Device is not commissioned. Show QR Code for commissioning": "Gerät ist nicht in Betrieb genommen. QR-Code zur Inbetriebnahme anzeigen",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "Sie müssen oben die WLAN- oder Thread-Anmeldeinformationen konfigurieren, um BLE zu aktivieren!",
"blind": "Blind",
"cancelButtonText": "Abbrechen",
"copied": "Kopiert",
"dimmer": "Dimmer",
"door": "Tür",
"fireAlarm": "Feueralarm",
Expand All @@ -210,6 +213,7 @@
"media": "Medien",
"motion": "Bewegung",
"no IPv6": "kein IPv6",
"nothingToCopy": "Nichts zu kopieren",
"okButtonText": "OK",
"rgbSingle": "RGB-Licht",
"slider": "Schieberegler",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Bluetooth configuration",
"Bridge Debug information": "Bridge Debug information",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "Bridge is already commissioned. You cannot change the name or the vendor/product ID.",
"Bridge is not commissioned. Show QR Code got commissioning": "Bridge is not commissioned. Show QR Code got commissioning",
"Bridges": "Bridges",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Delete",
"Delete bridge": "Delete bridge",
"Delete device": "Delete device",
"Device Debug information": "Device Debug information",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "Device is already commissioned. You cannot change the name or the vendor/product ID.",
"Device is already commissioning. Show status information": "Device is already commissioning. Show status information",
"Device is not commissioned. Show QR Code for commissioning": "Device is not commissioned. Show QR Code for commissioninn",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "You need to configure WLAN or Thread credentials above to activate BLE!",
"blind": "Blind",
"cancelButtonText": "Cancel",
"copied": "Copied",
"dimmer": "Dimmer",
"door": "Door",
"fireAlarm": "Fire alarm",
Expand All @@ -210,6 +213,7 @@
"media": "Media",
"motion": "Motion",
"no IPv6": "no IPv6",
"nothingToCopy": "Nothing to copy",
"okButtonText": "Ok",
"rgbSingle": "RGB Light",
"slider": "Slider",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "configuración bluetooth",
"Bridge Debug information": "Información de depuración del puente",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "El puente ya está en funcionamiento. No puede cambiar el nombre ni el ID del proveedor/producto.",
"Bridge is not commissioned. Show QR Code got commissioning": "El puente no está en servicio. Mostrar código QR puesto en marcha",
"Bridges": "Puentes",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Borrar",
"Delete bridge": "Eliminar puente",
"Delete device": "Eliminar dispositivo",
"Device Debug information": "Información de depuración del dispositivo",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "El dispositivo ya está en funcionamiento. No puede cambiar el nombre ni el ID del proveedor/producto.",
"Device is already commissioning. Show status information": "El dispositivo ya se está poniendo en marcha. Mostrar información de estado",
"Device is not commissioned. Show QR Code for commissioning": "El dispositivo no está en servicio. Mostrar código QR para commissioninn",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "¡Necesita configurar las credenciales de WLAN o Thread arriba para activar BLE!",
"blind": "Ciego",
"cancelButtonText": "Cancelar",
"copied": "Copiado",
"dimmer": "Regulador de intensidad",
"door": "Puerta",
"fireAlarm": "Alarma de incendios",
Expand All @@ -210,6 +213,7 @@
"media": "Medios de comunicación",
"motion": "Movimiento",
"no IPv6": "Sin IPv6",
"nothingToCopy": "Nada que copiar",
"okButtonText": "De acuerdo",
"rgbSingle": "Luz RGB",
"slider": "Control deslizante",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Configuration Bluetooth",
"Bridge Debug information": "Informations de débogage du pont",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "Le pont est déjà mis en service. Vous ne pouvez pas modifier le nom ou l'ID du fournisseur/produit.",
"Bridge is not commissioned. Show QR Code got commissioning": "Le pont n'est pas mis en service. Afficher le code QR mis en service",
"Bridges": "Des ponts",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Supprimer",
"Delete bridge": "Supprimer le pont",
"Delete device": "Supprimer l'appareil",
"Device Debug information": "Informations de débogage de l'appareil",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "L'appareil est déjà mis en service. Vous ne pouvez pas modifier le nom ou l'ID du fournisseur/produit.",
"Device is already commissioning. Show status information": "L'appareil est déjà en cours de mise en service. Afficher les informations d'état",
"Device is not commissioned. Show QR Code for commissioning": "L'appareil n'est pas mis en service. Afficher le code QR pour la mise en service",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "Vous devez configurer les informations d'identification WLAN ou Thread ci-dessus pour activer BLE !",
"blind": "Aveugle",
"cancelButtonText": "Annuler",
"copied": "Copié",
"dimmer": "Variateur",
"door": "Porte",
"fireAlarm": "Alarme incendie",
Expand All @@ -210,6 +213,7 @@
"media": "Médias",
"motion": "Mouvement",
"no IPv6": "pas d'IPv6",
"nothingToCopy": "Rien à copier",
"okButtonText": "D'accord",
"rgbSingle": "Lumière RVB",
"slider": "Glissière",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Configurazione Bluetooth",
"Bridge Debug information": "Informazioni di debug del bridge",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "Il ponte è già commissionato. Non è possibile modificare il nome o l'ID fornitore/prodotto.",
"Bridge is not commissioned. Show QR Code got commissioning": "Il ponte non è commissionato. Mostra il codice QR ha ricevuto la messa in servizio",
"Bridges": "Ponti",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Eliminare",
"Delete bridge": "Elimina ponte",
"Delete device": "Elimina dispositivo",
"Device Debug information": "Informazioni di debug del dispositivo",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "Il dispositivo è già messo in servizio. Non è possibile modificare il nome o l'ID fornitore/prodotto.",
"Device is already commissioning. Show status information": "Il dispositivo è già in fase di messa in servizio. Mostra informazioni sullo stato",
"Device is not commissioned. Show QR Code for commissioning": "Il dispositivo non è in funzione. Mostra il codice QR per la messa in funzione",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "È necessario configurare le credenziali WLAN o Thread sopra per attivare BLE!",
"blind": "Cieco",
"cancelButtonText": "Cancellare",
"copied": "Copiato",
"dimmer": "Dimmer",
"door": "Porta",
"fireAlarm": "Allarme antincendio",
Expand All @@ -210,6 +213,7 @@
"media": "Media",
"motion": "Movimento",
"no IPv6": "nessun IPv6",
"nothingToCopy": "Niente da copiare",
"okButtonText": "OK",
"rgbSingle": "Luce RGB",
"slider": "Dispositivo di scorrimento",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Bluetooth-configuratie",
"Bridge Debug information": "Bridge Debug-informatie",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "De brug is al in gebruik genomen. U kunt de naam of de leverancier/product-ID niet wijzigen.",
"Bridge is not commissioned. Show QR Code got commissioning": "Brug is niet in gebruik genomen. QR-code weergeven kreeg inbedrijfstelling",
"Bridges": "Bruggen",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Verwijderen",
"Delete bridge": "Brug verwijderen",
"Delete device": "Apparaat verwijderen",
"Device Debug information": "Informatie over apparaatdebuggen",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "Apparaat is al in gebruik genomen. U kunt de naam of de leverancier/product-ID niet wijzigen.",
"Device is already commissioning. Show status information": "Apparaat is al in bedrijf. Statusinformatie weergeven",
"Device is not commissioned. Show QR Code for commissioning": "Apparaat is niet in bedrijf gesteld. QR-code voor commissioninn weergeven",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "U moet hierboven WLAN- of Thread-inloggegevens configureren om BLE te activeren!",
"blind": "Blind",
"cancelButtonText": "Annuleren",
"copied": "Gekopieerd",
"dimmer": "Dimmer",
"door": "Deur",
"fireAlarm": "Brandalarm",
Expand All @@ -210,6 +213,7 @@
"media": "Media",
"motion": "Beweging",
"no IPv6": "geen IPv6",
"nothingToCopy": "Niets te kopiëren",
"okButtonText": "OK",
"rgbSingle": "RGB-licht",
"slider": "Schuifregelaar",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Konfiguracja Bluetooth",
"Bridge Debug information": "Informacje o debugowaniu mostu",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "Most jest już oddany do użytku. Nie można zmienić nazwy ani identyfikatora dostawcy/produktu.",
"Bridge is not commissioned. Show QR Code got commissioning": "Most nie jest oddany do użytku. Pokaż kod QR, który został uruchomiony",
"Bridges": "Mosty",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Usuwać",
"Delete bridge": "Usuń most",
"Delete device": "Usuń urządzenie",
"Device Debug information": "Informacje o debugowaniu urządzenia",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "Urządzenie zostało już uruchomione. Nie można zmienić nazwy ani identyfikatora dostawcy/produktu.",
"Device is already commissioning. Show status information": "Urządzenie jest już uruchamiane. Pokaż informacje o stanie",
"Device is not commissioned. Show QR Code for commissioning": "Urządzenie nie jest uruchomione. Pokaż kod QR dla commissioninn",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "Aby aktywować BLE, musisz skonfigurować dane uwierzytelniające WLAN lub wątek powyżej!",
"blind": "Ślepy",
"cancelButtonText": "Anulować",
"copied": "Skopiowano",
"dimmer": "Opornik",
"door": "Drzwi",
"fireAlarm": "Alarm przeciwpożarowy",
Expand All @@ -210,6 +213,7 @@
"media": "Głoska bezdźwięczna",
"motion": "Ruch",
"no IPv6": "brak IPv6",
"nothingToCopy": "Nic do kopiowania",
"okButtonText": "OK",
"rgbSingle": "Światło RGB",
"slider": "Suwak",
Expand Down
4 changes: 4 additions & 0 deletions src-admin/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Bluetooth": "Bluetooth",
"Bluetooth HCI ID": "Bluetooth HCI ID",
"Bluetooth configuration": "Configuração Bluetooth",
"Bridge Debug information": "Informações de depuração da ponte",
"Bridge is already commissioned. You cannot change the name or the vendor/product ID.": "A ponte já está comissionada. Você não pode alterar o nome ou o ID do fornecedor/produto.",
"Bridge is not commissioned. Show QR Code got commissioning": "A ponte não está comissionada. Mostrar QR Code foi comissionado",
"Bridges": "Pontes",
Expand Down Expand Up @@ -58,6 +59,7 @@
"Delete": "Excluir",
"Delete bridge": "Excluir ponte",
"Delete device": "Excluir dispositivo",
"Device Debug information": "Informações de depuração do dispositivo",
"Device is already commissioned. You cannot change the name or the vendor/product ID.": "O dispositivo já está comissionado. Você não pode alterar o nome ou o ID do fornecedor/produto.",
"Device is already commissioning. Show status information": "O dispositivo já está em comissionamento. Mostrar informações de status",
"Device is not commissioned. Show QR Code for commissioning": "O dispositivo não está comissionado. Mostrar QR Code para comissioninn",
Expand Down Expand Up @@ -196,6 +198,7 @@
"You need to configure WLAN or Thread credentials above to activate BLE": "Você precisa configurar as credenciais WLAN ou Thread acima para ativar o BLE!",
"blind": "Cego",
"cancelButtonText": "Cancelar",
"copied": "Copiado",
"dimmer": "Obscuro",
"door": "Porta",
"fireAlarm": "Alarme de incêndio",
Expand All @@ -210,6 +213,7 @@
"media": "meios de comunicação",
"motion": "Movimento",
"no IPv6": "sem IPv6",
"nothingToCopy": "Nada para copiar",
"okButtonText": "OK",
"rgbSingle": "Luz RGB",
"slider": "Controle deslizante",
Expand Down
Loading

0 comments on commit b4306fb

Please sign in to comment.