From 241091a8c31a7f53ddf04f022ffa2911bbc917ee Mon Sep 17 00:00:00 2001 From: SimoneFiorani Date: Thu, 19 Dec 2024 09:17:56 +0100 Subject: [PATCH] feat: added pid filtering searchbox in snapshot download popup Signed-off-by: SimoneFiorani --- .../ui/settings/SnapshotDownloadModal.java | 26 +++++++++++++++++++ .../ui/settings/SnapshotDownloadModal.ui.xml | 10 +++++++ .../web/client/messages/Messages.properties | 1 + 3 files changed, 37 insertions(+) diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.java index 8f9dbd013a..12a67071f9 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.java @@ -26,10 +26,12 @@ import org.gwtbootstrap3.client.ui.CheckBox; import org.gwtbootstrap3.client.ui.FormLabel; import org.gwtbootstrap3.client.ui.Modal; +import org.gwtbootstrap3.client.ui.TextBox; import org.gwtbootstrap3.client.ui.html.Paragraph; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -51,6 +53,8 @@ interface SnapshotDownloadModalUiBinder extends UiBinder consumer, List availa this.noPidSelectedError.setVisible(false); this.modal.setTitle(MSGS.deviceSnapshotDownloadModalTitle()); this.downloadModalDescription.setText(MSGS.deviceSnapshotDownloadModalHint()); + initPidSearch(); initSnapshotPidList(availablePids); initSnapshotSelectAllAnchor(); initSnapshotScrollPanel(); @@ -108,6 +114,12 @@ public void show(Consumer consumer, List availa * Snapshot Download Inits */ + private void initPidSearch() { + this.pidSearch.clear(); + this.pidSearch.setVisible(true); + this.pidSearch.addKeyUpHandler(this::onSearchBoxEvent); + } + private void initSnapshotPidList(List snapshotConfigs) { this.pidPanel.clear(); @@ -183,6 +195,20 @@ private void initWiregraphDownloadButtons() { * Utils */ + private void onSearchBoxEvent(KeyUpEvent event) { + TextBox searchBox = (TextBox) event.getSource(); + String searchedPid = searchBox.getValue(); + + if (searchedPid == null || searchedPid.isEmpty() || searchedPid.equals("")) { + this.pidPanel.iterator().forEachRemaining(widget -> widget.setVisible(true)); + } else { + this.pidPanel.iterator().forEachRemaining(widget -> { + CheckBox box = (CheckBox) widget; + box.setVisible(box.getText().toLowerCase().contains(searchedPid.toLowerCase())); + }); + } + } + private void onCheckboxClick(ClickEvent handler) { if (noPidSelectedError.isVisible()) { noPidSelectedError.setVisible(false); diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.ui.xml b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.ui.xml index 32fbabf909..cb43796009 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.ui.xml +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/settings/SnapshotDownloadModal.ui.xml @@ -29,6 +29,12 @@ font-size: 0.35cm; font-weight: normal; } + .small-spacing { + padding-bottom: 10px; + } + .big-spacing { + padding-bottom: 20px; + } @@ -38,6 +44,10 @@ + + + diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties index a8a4bb16ca..f78c1a0193 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties @@ -317,6 +317,7 @@ downloadSnapshotJsonButton=Download as JSON downloadSnapshotError=Please select at least one pid from the list selectAllAnchorText=Select All Pids removeAllAnchorText=Remove All Pids +snapshotDownloadSearchBoxPlaceholder=Filter pids by name... netIntro=Select a Network Interface and configure it. DHCP Server and NAT can be configured only for interfaces enabled for LAN usage. When applying your changes, your connection to the gateway may be lost depending on your network configuration changes. netInterfaceName=Interface Name