From 25ddf05f7fbcc7bd70ed0e79542ad0d3e01b4fd7 Mon Sep 17 00:00:00 2001 From: SimoneFiorani Date: Tue, 10 Dec 2024 12:46:30 +0100 Subject: [PATCH 1/9] feat: first ui implementation of partial snapshot download Signed-off-by: SimoneFiorani --- .../ui/settings/SnapshotDownloadModal.java | 57 +++++++++++++++++-- .../ui/settings/SnapshotDownloadModal.ui.xml | 14 ++--- .../client/ui/settings/SnapshotsTabUi.java | 23 ++++++-- .../web/server/GwtSnapshotServiceImpl.java | 25 +++++++- .../shared/service/GwtSnapshotService.java | 4 +- .../web/client/messages/Messages.properties | 5 +- 6 files changed, 106 insertions(+), 22 deletions(-) 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 821eb3cd42b..bdb844a1ded 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Eurotech and/or its affiliates and others + * Copyright (c) 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -12,44 +12,84 @@ *******************************************************************************/ package org.eclipse.kura.web.client.ui.settings; +import java.util.ArrayList; +import java.util.List; + import org.gwtbootstrap3.client.ui.Button; -import org.gwtbootstrap3.client.ui.ListBox; +import org.gwtbootstrap3.client.ui.CheckBox; import org.gwtbootstrap3.client.ui.Modal; import com.google.gwt.core.client.GWT; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; public class SnapshotDownloadModal extends Composite { private static SnapshotDownloadModalUiBinder uiBinder = GWT.create(SnapshotDownloadModalUiBinder.class); + // private static final Logger logger = Logger.getLogger(SnapshotDownloadModal.class.getSimpleName()); interface SnapshotDownloadModalUiBinder extends UiBinder { } + private List snapshotConfigs = new ArrayList<>(); + + @UiField + ScrollPanel scrollPanel; @UiField Modal modal; @UiField - ListBox formatList; + Button downloadXml; @UiField - Button download; + Button downloadJson; + + VerticalPanel pidPanel = new VerticalPanel(); private Listener listener = format -> { }; public SnapshotDownloadModal() { + initWidget(uiBinder.createAndBindUi(this)); - this.download.addClickHandler(e -> { + initPidList(); + + initScrollPanel(); + + this.downloadJson.addClickHandler(e -> { + this.modal.hide(); + this.listener.onDonwload("TEST"); + }); + + this.downloadXml.addClickHandler(e -> { this.modal.hide(); - this.listener.onDonwload(this.formatList.getSelectedValue()); + this.listener.onDonwload("TEST"); }); } + private void initPidList() { + + this.pidPanel.clear(); + + this.snapshotConfigs.forEach(pid -> { + CheckBox box = new CheckBox(pid); + this.pidPanel.add(box); + }); + } + + private void initScrollPanel() { + this.scrollPanel.setAlwaysShowScrollBars(false); + this.scrollPanel.setHeight("500px"); + this.scrollPanel.clear(); + this.scrollPanel.add(pidPanel); + } + public void show(final Listener listener) { this.listener = listener; + initPidList(); this.modal.show(); } @@ -58,4 +98,9 @@ public interface Listener { public void onDonwload(String format); } + public void setSnapshotConfigurations(List configs) { + this.snapshotConfigs = configs; + + } + } 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 abdb7b71741..a6b3d834a48 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 @@ -2,7 +2,7 @@