Skip to content

Commit

Permalink
feat: added pid filtering searchbox in snapshot download popup
Browse files Browse the repository at this point in the history
Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani committed Dec 19, 2024
1 parent e060bbe commit 241091a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,6 +53,8 @@ interface SnapshotDownloadModalUiBinder extends UiBinder<Widget, SnapshotDownloa
@UiField
Paragraph formatModalHint;
@UiField
TextBox pidSearch;
@UiField
ScrollPanel pidSelectionScrollPanel;
@UiField
Anchor selectOrRemoveAllAnchor;
Expand All @@ -76,6 +80,7 @@ public SnapshotDownloadModal() {

initWidget(uiBinder.createAndBindUi(this));

this.pidSearch.setVisible(false);
this.pidSelectionScrollPanel.setVisible(false);
this.selectOrRemoveAllAnchor.setVisible(false);
this.noPidSelectedError.setVisible(false);
Expand All @@ -97,6 +102,7 @@ public void show(Consumer<SnapshotDownloadOptions> consumer, List<String> availa
this.noPidSelectedError.setVisible(false);
this.modal.setTitle(MSGS.deviceSnapshotDownloadModalTitle());
this.downloadModalDescription.setText(MSGS.deviceSnapshotDownloadModalHint());
initPidSearch();
initSnapshotPidList(availablePids);
initSnapshotSelectAllAnchor();
initSnapshotScrollPanel();
Expand All @@ -108,6 +114,12 @@ public void show(Consumer<SnapshotDownloadOptions> consumer, List<String> availa
* Snapshot Download Inits
*/

private void initPidSearch() {
this.pidSearch.clear();
this.pidSearch.setVisible(true);
this.pidSearch.addKeyUpHandler(this::onSearchBoxEvent);
}

private void initSnapshotPidList(List<String> snapshotConfigs) {

this.pidPanel.clear();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
font-size: 0.35cm;
font-weight: normal;
}
.small-spacing {
padding-bottom: 10px;
}
.big-spacing {
padding-bottom: 20px;
}
</ui:style>

<b:Modal closable="false" fade="true" dataBackdrop="STATIC" ui:field="modal">
Expand All @@ -38,6 +44,10 @@
<b:FormGroup>
<b.html:Paragraph ui:field="downloadModalDescription" />
<b.html:Paragraph ui:field="formatModalHint" text="{msgs.formatDownloadHint}" />
<g:Label addStyleNames="{style.small-spacing}"/>
<b:TextBox placeholder="{msgs.snapshotDownloadSearchBoxPlaceholder}"
ui:field="pidSearch" addStyleNames="services-search" />
<g:Label addStyleNames="{style.big-spacing}"/>
<g:ScrollPanel ui:field="pidSelectionScrollPanel"></g:ScrollPanel>
<b:FormLabel addStyleNames="{style.channel-name-validation-label}" ui:field="noPidSelectedError" text="{msgs.downloadSnapshotError}" />
</b:FormGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 241091a

Please sign in to comment.