Feature update target attributes ui (#711)

* Added update attributes button with label for status description to target attributes details tab
* Positioned the request attributes update button to the upper right corner using absolute positioning
* DDIFinalResult enum typo fix
* PR review findings

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
Bondar Bogdan
2018-08-02 15:15:14 +02:00
committed by Stefan Behl
parent f96876afe0
commit 1aee32999f
6 changed files with 94 additions and 28 deletions

View File

@@ -58,7 +58,7 @@ public class DdiResult {
/**
* Execution was successful.
*/
SUCESS("success"),
SUCCESS("success"),
/**
* Execution terminated with errors or without the expected result.

View File

@@ -8,8 +8,6 @@
*/
package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Map;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
@@ -186,22 +184,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
descriptionLayout.addComponent(descLabel);
}
/*
* display Attributes details in Target details.
*/
protected void updateAttributesLayout(final Map<String, String> attributes) {
if (null != attributes) {
attributesLayout.removeAllComponents();
for (final Map.Entry<String, String> entry : attributes.entrySet()) {
final Label conAttributeLabel = SPUIComponentProvider.createNameValueLabel(
entry.getKey().concat(" : "), entry.getValue() == null ? "" : entry.getValue());
conAttributeLabel.setDescription(entry.getKey().concat(" : ") + entry.getValue());
conAttributeLabel.addStyleName("label-style");
attributesLayout.addComponent(conAttributeLabel);
}
}
}
protected VerticalLayout getLogLayout() {
return logLayout;
}

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.management.targettable;
import java.net.URI;
import java.util.Map;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
@@ -21,6 +22,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.tagdetails.TargetTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorder;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -32,7 +34,9 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
@@ -134,17 +138,20 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected void populateDetailsWidget() {
if (getSelectedBaseEntity() != null) {
updateAttributesLayout(targetManagement.getControllerAttributes(getSelectedBaseEntity().getControllerId()));
final String controllerId = getSelectedBaseEntity().getControllerId();
updateDetailsLayout(getSelectedBaseEntity().getControllerId(), getSelectedBaseEntity().getAddress(),
updateAttributesLayout(controllerId);
updateDetailsLayout(controllerId, getSelectedBaseEntity().getAddress(),
getSelectedBaseEntity().getSecurityToken(),
SPDateTimeUtil.getFormattedDate(getSelectedBaseEntity().getLastTargetQuery()));
populateDistributionDtls(assignedDistLayout, deploymentManagement
.getAssignedDistributionSet(getSelectedBaseEntity().getControllerId()).orElse(null));
populateDistributionDtls(installedDistLayout, deploymentManagement
.getInstalledDistributionSet(getSelectedBaseEntity().getControllerId()).orElse(null));
populateDistributionDtls(assignedDistLayout,
deploymentManagement.getAssignedDistributionSet(controllerId).orElse(null));
populateDistributionDtls(installedDistLayout,
deploymentManagement.getInstalledDistributionSet(controllerId).orElse(null));
} else {
updateAttributesLayout(null);
updateDetailsLayout(null, null, null, null);
populateDistributionDtls(installedDistLayout, null);
populateDistributionDtls(assignedDistLayout, null);
@@ -222,6 +229,68 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
}
private void updateAttributesLayout(final String controllerId) {
final VerticalLayout attributesLayout = getAttributesLayout();
attributesLayout.removeAllComponents();
if (controllerId == null) {
return;
}
final Map<String, String> attributes = targetManagement.getControllerAttributes(controllerId);
updateAttributesLabelsList(attributesLayout, attributes);
updateAttributesUpdateComponents(attributesLayout, controllerId);
}
private void updateAttributesLabelsList(final VerticalLayout attributesLayout,
final Map<String, String> attributes) {
for (final Map.Entry<String, String> entry : attributes.entrySet()) {
final Label conAttributeLabel = SPUIComponentProvider.createNameValueLabel(entry.getKey().concat(" : "),
entry.getValue() == null ? "" : entry.getValue());
conAttributeLabel.setDescription(entry.getKey().concat(" : ") + entry.getValue());
conAttributeLabel.addStyleName("label-style");
attributesLayout.addComponent(conAttributeLabel);
}
}
private void updateAttributesUpdateComponents(final VerticalLayout attributesLayout, final String controllerId) {
final boolean isRequestAttributes = targetManagement.isControllerAttributesRequested(controllerId);
if (isRequestAttributes) {
attributesLayout.addComponent(buildAttributesUpdateLabel(), 0);
}
attributesLayout.addComponent(buildRequestAttributesUpdateButton(controllerId, isRequestAttributes));
}
private Label buildAttributesUpdateLabel() {
final Label attributesUpdateLabel = new Label();
attributesUpdateLabel.setStyleName(ValoTheme.LABEL_SMALL);
attributesUpdateLabel.setValue(getI18n().getMessage("label.target.attributes.update.pending"));
return attributesUpdateLabel;
}
private Button buildRequestAttributesUpdateButton(final String controllerId, final boolean isRequestAttributes) {
final Button requestAttributesUpdateButton = SPUIComponentProvider.getButton(
UIComponentIdProvider.TARGET_ATTRIBUTES_UPDATE, "", "", "", false, FontAwesome.REFRESH,
SPUIButtonStyleNoBorder.class);
requestAttributesUpdateButton.addClickListener(e -> targetManagement.requestControllerAttributes(controllerId));
if (isRequestAttributes) {
requestAttributesUpdateButton
.setDescription(getI18n().getMessage("tooltip.target.attributes.update.requested"));
requestAttributesUpdateButton.setEnabled(false);
} else {
requestAttributesUpdateButton
.setDescription(getI18n().getMessage("tooltip.target.attributes.update.request"));
requestAttributesUpdateButton.setEnabled(true);
}
return requestAttributesUpdateButton;
}
/**
* Create Label for SW Module.
*

View File

@@ -639,6 +639,11 @@ public final class UIComponentIdProvider {
*/
public static final String TARGET_SECURITY_TOKEN = "target.security.token";
/**
* Id of attributes update button in target details.
*/
public static final String TARGET_ATTRIBUTES_UPDATE = "target.attributes.update";
/**
* Id of maximize/minimize icon of table - Software module table.
*/

View File

@@ -293,8 +293,8 @@
background-repeat: no-repeat;
}
.app-loading:before {
background: none;
.app-loading:before {
background: none;
height: 20px !important;
width: 20px !important;
-webkit-box-sizing: border-box;
@@ -313,5 +313,11 @@
position: fixed;
margin-top: 12px;
margin-left: -10px;
}
}
#target\.attributes\.update {
position: absolute;
top: 12px;
right: 6px;
}
}

View File

@@ -225,6 +225,7 @@ label.target.security.token = Security token :
label.filter.by.status = Filter by Status
label.filter.by.overdue = Filter by Overdue
label.target.controller.attrs = <b>Controller attributes</b>
label.target.attributes.update.pending = Update pending..
label.target.lastpolldate = Last poll :
label.tag.name = Tag name
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy
@@ -280,6 +281,9 @@ tooltip.artifact.icon=Show Artifact Details
tooltip.click.to.edit = Click to edit
tooltip.metadata.icon = Manage Metadata..
tooltip.next.maintenance.window = next on {0}
tooltip.target.attributes.update.request = Request attributes update
tooltip.target.attributes.update.requested = Update already requested
#rollout action
tooltip.rollout.run = Run
tooltip.rollout.approve = Approve