Added an option to show a footer notification (#1504)

* Added an option to show a footer notification

Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com>

* Refactoring

Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com>

---------

Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com>
This commit is contained in:
Denislav Prinov
2023-12-08 11:35:18 +02:00
committed by GitHub
parent 1ae72d4ead
commit 1ecdcc4edd
2 changed files with 33 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui;
import com.vaadin.shared.ui.ContentMode;
import org.eclipse.hawkbit.ui.components.NotificationUnreadButton;
import org.eclipse.hawkbit.ui.error.ErrorView;
import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent;
@@ -25,6 +26,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.util.ObjectUtils;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.annotations.Theme;
@@ -156,6 +158,11 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
contentVerticalLayout.addComponent(content);
contentVerticalLayout.setExpandRatio(content, 1.0F);
String footerNotification = uiProperties.getNotification().getText();
if (!ObjectUtils.isEmpty(footerNotification)) {
contentVerticalLayout.addComponent(buildFooterNotification(footerNotification));
}
rootLayout.addComponent(dashboardMenu);
rootLayout.addComponent(contentVerticalLayout);
rootLayout.setExpandRatio(contentVerticalLayout, 1.0F);
@@ -194,6 +201,14 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
LOG.debug("Current locale of the application is : {}", getLocale());
}
private static Component buildFooterNotification(String text) {
Label notification = new Label();
notification.setValue(text);
notification.setWidth("100%");
notification.setContentMode(ContentMode.HTML);
return notification;
}
private static Panel buildContent() {
final Panel content = new Panel();
content.setSizeFull();

View File

@@ -37,6 +37,8 @@ public class UiProperties implements Serializable {
private final Event event = new Event();
private final Notification notification = new Notification();
/**
* @return True if menu item has gravatar else false
*/
@@ -578,6 +580,18 @@ public class UiProperties implements Serializable {
}
}
public static class Notification implements Serializable {
private String text = "";
public String getText() {
return text;
}
public void setText(final String text) {
this.text = text;
}
}
/**
* @return Demo account details
*/
@@ -606,4 +620,8 @@ public class UiProperties implements Serializable {
return localization;
}
public Notification getNotification() {
return notification;
}
}