Merge remote-tracking branch 'eclipse/master' into harmonize-test-documentation
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Properties for Management UI customization.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.server.ui")
|
||||
public class UiProperties {
|
||||
|
||||
private final Links links = new Links();
|
||||
private final Login login = new Login();
|
||||
private final Demo demo = new Demo();
|
||||
|
||||
public Login getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public Links getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public Demo getDemo() {
|
||||
return demo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo account login information.
|
||||
*
|
||||
*/
|
||||
public static class Demo {
|
||||
|
||||
/**
|
||||
* Demo tenant.
|
||||
*/
|
||||
private String tenant = "DEFAULT";
|
||||
/**
|
||||
* Demo user name.
|
||||
*/
|
||||
private String user = "admin";
|
||||
|
||||
/**
|
||||
* Demo user password.
|
||||
*/
|
||||
private String password = "admin";
|
||||
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public void setTenant(final String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(final String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Links to potentially other systems (e.g. support, user management etc.).
|
||||
*
|
||||
*/
|
||||
public static class Links {
|
||||
/**
|
||||
* Link to product support.
|
||||
*/
|
||||
private String support = "";
|
||||
|
||||
/**
|
||||
* Link to request a system account, access.
|
||||
*/
|
||||
private String requestAccount = "";
|
||||
|
||||
/**
|
||||
* Link to user management.
|
||||
*/
|
||||
private String userManagement = "";
|
||||
|
||||
public String getSupport() {
|
||||
return support;
|
||||
}
|
||||
|
||||
public void setSupport(final String support) {
|
||||
this.support = support;
|
||||
}
|
||||
|
||||
public String getRequestAccount() {
|
||||
return requestAccount;
|
||||
}
|
||||
|
||||
public void setRequestAccount(final String requestAccount) {
|
||||
this.requestAccount = requestAccount;
|
||||
}
|
||||
|
||||
public String getUserManagement() {
|
||||
return userManagement;
|
||||
}
|
||||
|
||||
public void setUserManagement(final String userManagement) {
|
||||
this.userManagement = userManagement;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration of login view.
|
||||
*
|
||||
*/
|
||||
public static class Login {
|
||||
|
||||
private final Cookie cookie = new Cookie();
|
||||
|
||||
public Cookie getCookie() {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie configuration for login credential cookie.
|
||||
*
|
||||
*/
|
||||
public static class Cookie {
|
||||
/**
|
||||
* Secure cookie enabled.
|
||||
*/
|
||||
private boolean secure = true;
|
||||
|
||||
public boolean isSecure() {
|
||||
return secure;
|
||||
}
|
||||
|
||||
public void setSecure(final boolean secure) {
|
||||
this.secure = secure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,16 +15,14 @@ import javax.servlet.http.Cookie;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.MultitenancyIndicator;
|
||||
import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.documentation.DocumentationPageLink;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.util.SPInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
@@ -61,7 +59,7 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
*/
|
||||
@SpringView(name = "")
|
||||
@UIScope
|
||||
public class LoginView extends VerticalLayout implements View, EnvironmentAware {
|
||||
public class LoginView extends VerticalLayout implements View {
|
||||
private static final String LOGIN_TEXTFIELD = "login-textfield";
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class);
|
||||
@@ -76,7 +74,7 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
private I18N i18n;
|
||||
|
||||
@Autowired
|
||||
private transient SPInfo spInfo;
|
||||
private transient UiProperties uiProperties;
|
||||
|
||||
@Autowired
|
||||
private transient MultitenancyIndicator multiTenancyIndicator;
|
||||
@@ -86,9 +84,6 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
private PasswordField password;
|
||||
private Button signin;
|
||||
|
||||
private Boolean secureCookie = Boolean.TRUE;
|
||||
private String userManagementLoginUrl;
|
||||
|
||||
void loginAuthenticationFailedNotification() {
|
||||
final Notification notification = new Notification(i18n.get("notification.login.failed.title"));
|
||||
notification.setDescription(i18n.get("notification.login.failed.description"));
|
||||
@@ -119,7 +114,8 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
final URI spURI = Page.getCurrent().getLocation();
|
||||
final String lookForDemoFragment = spURI.toString();
|
||||
if (lookForDemoFragment.contains("?demo")) {
|
||||
login(spInfo.getDemoTenant(), spInfo.getDemoUser(), spInfo.getDemoPassword(), false);
|
||||
login(uiProperties.getDemo().getTenant(), uiProperties.getDemo().getUser(),
|
||||
uiProperties.getDemo().getPassword(), false);
|
||||
}
|
||||
|
||||
final Component loginForm = buildLoginForm();
|
||||
@@ -243,18 +239,18 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
links.addComponent(demoLink);
|
||||
demoLink.addStyleName(ValoTheme.LINK_SMALL);
|
||||
|
||||
if (spInfo.getRequestAccountEmail() != null) {
|
||||
if (!uiProperties.getLinks().getRequestAccount().isEmpty()) {
|
||||
final Link requestAccountLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_REQUESTACCOUNT,
|
||||
i18n.get("link.requestaccount.name"), spInfo.getRequestAccountEmail(), FontAwesome.SHOPPING_CART,
|
||||
"", linkStyle, true);
|
||||
i18n.get("link.requestaccount.name"), uiProperties.getLinks().getRequestAccount(),
|
||||
FontAwesome.SHOPPING_CART, "", linkStyle, true);
|
||||
links.addComponent(requestAccountLink);
|
||||
requestAccountLink.addStyleName(ValoTheme.LINK_SMALL);
|
||||
}
|
||||
|
||||
if (userManagementLoginUrl != null) {
|
||||
if (!uiProperties.getLinks().getUserManagement().isEmpty()) {
|
||||
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_USERMANAGEMENT,
|
||||
i18n.get("link.usermanagement.name"), userManagementLoginUrl, FontAwesome.USERS, "_blank",
|
||||
linkStyle, true);
|
||||
i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(),
|
||||
FontAwesome.USERS, "_blank", linkStyle, true);
|
||||
links.addComponent(userManagementLink);
|
||||
userManagementLink.addStyleName(ValoTheme.LINK_SMALL);
|
||||
}
|
||||
@@ -315,7 +311,7 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
// 100 days
|
||||
tenantCookie.setMaxAge(3600 * 24 * 100);
|
||||
tenantCookie.setHttpOnly(true);
|
||||
tenantCookie.setSecure(secureCookie);
|
||||
tenantCookie.setSecure(uiProperties.getLogin().getCookie().isSecure());
|
||||
VaadinService.getCurrentResponse().addCookie(tenantCookie);
|
||||
}
|
||||
|
||||
@@ -324,7 +320,7 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
// 100 days
|
||||
usernameCookie.setMaxAge(3600 * 24 * 100);
|
||||
usernameCookie.setHttpOnly(true);
|
||||
usernameCookie.setSecure(secureCookie);
|
||||
usernameCookie.setSecure(uiProperties.getLogin().getCookie().isSecure());
|
||||
VaadinService.getCurrentResponse().addCookie(usernameCookie);
|
||||
}
|
||||
|
||||
@@ -368,16 +364,4 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
||||
loginAuthenticationFailedNotification();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.context.EnvironmentAware#setEnvironment(org.
|
||||
* springframework.core.env. Environment)
|
||||
*/
|
||||
@Override
|
||||
public void setEnvironment(final Environment environment) {
|
||||
secureCookie = environment.getProperty("hawkbit.server.ui.login.cookie.secure", Boolean.class, Boolean.TRUE);
|
||||
userManagementLoginUrl = environment.getProperty("hawkbit.server.im.login.url", String.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.StringJoiner;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -43,6 +44,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -417,10 +420,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
|
||||
final org.eclipse.hawkbit.repository.model.Action action = deploymentManagement
|
||||
.findActionWithDetails(actionId);
|
||||
final Pageable pageReq = new PageRequest(0, 1000);
|
||||
final Page<ActionStatus> actionStatusList = deploymentManagement
|
||||
.findActionStatusMessagesByActionInDescOrder(pageReq, action,
|
||||
managementUIState.isActionHistoryMaximized());
|
||||
final Pageable pageReq = new PageRequest(0, 1000,
|
||||
new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName()));
|
||||
final Page<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action,
|
||||
managementUIState.isActionHistoryMaximized());
|
||||
final List<ActionStatus> content = actionStatusList.getContent();
|
||||
/*
|
||||
* Since the recent action status and messages are already
|
||||
|
||||
@@ -18,17 +18,16 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.HawkbitServerProperties;
|
||||
import org.eclipse.hawkbit.im.authentication.PermissionService;
|
||||
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.documentation.DocumentationPageLink;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.util.SPInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
||||
@@ -42,7 +41,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.UIScope;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.Button.ClickListener;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
@@ -50,7 +48,6 @@ import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.MenuBar;
|
||||
import com.vaadin.ui.MenuBar.Command;
|
||||
import com.vaadin.ui.MenuBar.MenuItem;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
@@ -61,11 +58,17 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
*/
|
||||
@SpringComponent
|
||||
@UIScope
|
||||
public final class DashboardMenu extends CustomComponent implements EnvironmentAware {
|
||||
public final class DashboardMenu extends CustomComponent {
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@Autowired
|
||||
private transient UiProperties uiProperties;
|
||||
|
||||
@Autowired
|
||||
private transient HawkbitServerProperties serverProperties;
|
||||
|
||||
private static final long serialVersionUID = 5394474618559481462L;
|
||||
|
||||
public static final String ID = "dashboard-menu";
|
||||
@@ -74,16 +77,12 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
private static final String STYLE_VISIBLE = "valo-menu-visible";
|
||||
|
||||
// this should be resolved when we introduce event bus on UI to just inform
|
||||
// the buttons directly
|
||||
// via events
|
||||
// the buttons directly via events
|
||||
private final List<ValoMenuItemButton> menuButtons = new ArrayList<>();
|
||||
|
||||
@Autowired
|
||||
private transient PermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private transient SPInfo spInfo;
|
||||
|
||||
@Autowired
|
||||
private final List<DashboardMenuItem> dashboardVaadinViews = new ArrayList<>();
|
||||
|
||||
@@ -91,12 +90,10 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
|
||||
private boolean accessibleViewsEmpty;
|
||||
|
||||
private String userManagementLoginUrl;
|
||||
|
||||
/**
|
||||
* initializing the view and creating the layout, cannot be done in the
|
||||
* custructor because the constructor will be called by spring and the
|
||||
* dashabord must be initialized when the dashboard UI is creating.
|
||||
* constructor because the constructor will be called by spring and the
|
||||
* dashboard must be initialized when the dashboard UI is creating.
|
||||
*/
|
||||
public void init() {
|
||||
initialViewName = "";
|
||||
@@ -162,20 +159,20 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
links.addComponent(docuLink);
|
||||
links.setComponentAlignment(docuLink, Alignment.BOTTOM_CENTER);
|
||||
|
||||
if (userManagementLoginUrl != null) {
|
||||
if (!uiProperties.getLinks().getUserManagement().isEmpty()) {
|
||||
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_USERMANAGEMENT,
|
||||
i18n.get("link.usermanagement.name"), userManagementLoginUrl, FontAwesome.USERS, "_blank",
|
||||
linkStyle, true);
|
||||
i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(),
|
||||
FontAwesome.USERS, "_blank", linkStyle, true);
|
||||
userManagementLink.setDescription(i18n.get("link.usermanagement.name"));
|
||||
links.addComponent(userManagementLink);
|
||||
userManagementLink.setSizeFull();
|
||||
links.setComponentAlignment(userManagementLink, Alignment.BOTTOM_CENTER);
|
||||
}
|
||||
|
||||
if (spInfo.getSupportEmail() != null) {
|
||||
if (!uiProperties.getLinks().getSupport().isEmpty()) {
|
||||
final Link supportLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_SUPPORT,
|
||||
i18n.get("link.support.name"), spInfo.getSupportEmail(), FontAwesome.ENVELOPE_O, "", linkStyle,
|
||||
true);
|
||||
i18n.get("link.support.name"), uiProperties.getLinks().getSupport(), FontAwesome.ENVELOPE_O, "",
|
||||
linkStyle, true);
|
||||
supportLink.setDescription(i18n.get("link.support.name"));
|
||||
supportLink.setSizeFull();
|
||||
links.addComponent(supportLink);
|
||||
@@ -222,12 +219,7 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
settingsItem.setDescription(user.getUsername());
|
||||
}
|
||||
|
||||
settingsItem.addItem("Sign Out", new Command() {
|
||||
@Override
|
||||
public void menuSelected(final MenuItem selectedItem) {
|
||||
Page.getCurrent().setLocation("/UI/logout");
|
||||
}
|
||||
});
|
||||
settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation("/UI/logout"));
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -254,14 +246,11 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
}
|
||||
|
||||
private Component buildToggleButton() {
|
||||
final Button valoMenuToggleButton = new Button("Menu", new ClickListener() {
|
||||
@Override
|
||||
public void buttonClick(final ClickEvent event) {
|
||||
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
|
||||
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
|
||||
} else {
|
||||
getCompositionRoot().addStyleName(STYLE_VISIBLE);
|
||||
}
|
||||
final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> {
|
||||
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
|
||||
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
|
||||
} else {
|
||||
getCompositionRoot().addStyleName(STYLE_VISIBLE);
|
||||
}
|
||||
});
|
||||
valoMenuToggleButton.setIcon(FontAwesome.LIST);
|
||||
@@ -307,7 +296,7 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
final Label label = new Label();
|
||||
label.setSizeFull();
|
||||
label.setStyleName("version-layout");
|
||||
label.setValue(spInfo.getVersion());
|
||||
label.setValue(serverProperties.getBuild().getVersion());
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -341,11 +330,6 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
menuButtons.forEach(button -> button.postViewChange(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(final Environment environment) {
|
||||
userManagementLoginUrl = environment.getProperty("hawkbit.server.im.login.url", String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dashboard view type by a given view name.
|
||||
*
|
||||
@@ -411,12 +395,7 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA
|
||||
setDescription(view.getDashboardCaptionLong());
|
||||
/* Avoid double click */
|
||||
setDisableOnClick(true);
|
||||
addClickListener(new ClickListener() {
|
||||
@Override
|
||||
public void buttonClick(final ClickEvent event) {
|
||||
event.getComponent().getUI().getNavigator().navigateTo(view.getViewName());
|
||||
}
|
||||
});
|
||||
addClickListener(event -> event.getComponent().getUI().getNavigator().navigateTo(view.getViewName()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user