Merge remote-tracking branch 'origin/master' into

fix_Consitent_table_muliselect

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java


Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
Melanie Retter
2016-06-07 15:06:39 +02:00
752 changed files with 26474 additions and 17636 deletions

View File

@@ -11,17 +11,18 @@ package org.eclipse.hawkbit.ui;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.eventbus.event.Event;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
/**
* The default hawkbit event provider.
@@ -39,6 +40,7 @@ public class HawkbitEventProvider implements UIEventProvider {
SINGLE_EVENTS.add(DistributionSetTagUpdateEvent.class);
SINGLE_EVENTS.add(RolloutGroupChangeEvent.class);
SINGLE_EVENTS.add(RolloutChangeEvent.class);
SINGLE_EVENTS.add(TargetTagUpdateEvent.class);
BULK_EVENTS.add(TargetCreatedEvent.class);
BULK_EVENTS.add(TargetInfoUpdateEvent.class);

View File

@@ -37,6 +37,8 @@ public class UiProperties {
/**
* Demo user password.
*/
// Exception squid:S2068 - Empty password
@SuppressWarnings({ "squid:S2068" })
private String password = "";
public String getPassword() {
@@ -64,6 +66,7 @@ public class UiProperties {
}
}
/**
* Links to potentially other systems (e.g. support, user management,
* documentation etc.).
@@ -227,6 +230,7 @@ public class UiProperties {
}
}
/**
* Configuration of login view.
*

View File

@@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -37,6 +38,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
private static final long serialVersionUID = -333786310371208962L;
private Sort sort = new Sort(Direction.DESC, "filename");
private transient ArtifactManagement artifactManagement = null;
private transient EntityFactory entityFactory;
private transient Page<LocalArtifact> firstPagetArtifacts = null;
private Long baseSwModuleId = null;
@@ -72,7 +74,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
@Override
protected LocalArtifact constructBean() {
return new LocalArtifact();
return entityFactory.generateLocalArtifact();
}
@Override
@@ -115,4 +117,11 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
}
return artifactManagement;
}
private EntityFactory getEntityFactory() {
if (entityFactory == null) {
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
return entityFactory;
}
}

View File

@@ -31,7 +31,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
@@ -260,7 +260,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
.getItemProperty(PROVIDED_FILE_NAME).getValue();
final Button deleteIcon = SPUIComponentProvider.getButton(
fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "",
fileName + "-" + SPUIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true,
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId);
@@ -344,7 +344,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
detailsTable.setImmediate(true);
detailsTable.setSizeFull();
detailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
detailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
detailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
detailsTable.addStyleName(ValoTheme.TABLE_SMALL);
return detailsTable;
@@ -385,7 +385,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
*/
public void createMaxArtifactDetailsTable() {
maxArtifactDetailsTable = createArtifactDetailsTable();
maxArtifactDetailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
maxArtifactDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource());
addGeneratedColumn(maxArtifactDetailsTable);
if (!readOnly) {

View File

@@ -15,6 +15,5 @@ package org.eclipse.hawkbit.ui.artifacts.event;
*
*/
public enum UploadArtifactUIEvent {
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, ENABLE_PROCESS_BUTTON, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISABLE_PROCESS_BUTTON, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE, MINIMIZED_STATUS_POPUP, MAXIMIZED_STATUS_POPUP, UPLOAD_IN_PROGESS, ARTIFACT_RESULT_POPUP_CLOSED
}

View File

@@ -0,0 +1,70 @@
/**
* 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.artifacts.event;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
*
* Holds file and upload status details.Meta data sent with upload events.
*
*/
public class UploadFileStatus implements Serializable {
private static final long serialVersionUID = -3599629192216760811L;
private String fileName;
private long contentLength;
private long bytesRead;
private String failureReason;
private SoftwareModule softwareModule;
public UploadFileStatus(String fileName) {
this.fileName = fileName;
}
public UploadFileStatus(String fileName, long bytesRead, long contentLength,SoftwareModule softwareModule) {
this.fileName = fileName;
this.contentLength = contentLength;
this.bytesRead = bytesRead;
this.softwareModule = softwareModule;
}
public UploadFileStatus(String fileName, String failureReason,SoftwareModule selectedSw) {
this.failureReason = failureReason;
this.fileName = fileName;
this.softwareModule = selectedSw;
}
public String getFileName() {
return fileName;
}
public long getContentLength() {
return contentLength;
}
public long getBytesRead() {
return bytesRead;
}
public String getFailureReason() {
return failureReason;
}
public SoftwareModule getSoftwareModule() {
return softwareModule;
}
}

View File

@@ -0,0 +1,42 @@
/**
* 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.artifacts.event;
/**
*
* Holds the upload file status.
*
*/
public class UploadStatusEvent {
public enum UploadStatusEventType {
UPLOAD_FAILED, UPLOAD_IN_PROGRESS, UPLOAD_STARTED, UPLOAD_FINISHED, UPLOAD_SUCCESSFUL, UPLOAD_STREAMING_FAILED, UPLOAD_STREAMING_FINISHED, ABORT_UPLOAD
}
private UploadStatusEventType uploadProgressEventType;
private UploadFileStatus uploadStatus;
public UploadStatusEvent(UploadStatusEventType eventType, UploadFileStatus entity) {
this.uploadProgressEventType = eventType;
this.uploadStatus = entity;
}
public UploadFileStatus getUploadStatus() {
return uploadStatus;
}
public void setUploadStatus(UploadFileStatus uploadStatus) {
this.uploadStatus = uploadStatus;
}
public UploadStatusEventType getUploadProgressEventType() {
return uploadProgressEventType;
}
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -37,8 +37,8 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
if (id != null && id.startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
id = SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
if (id != null && id.startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
id = SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
}
return id;
}
@@ -56,16 +56,16 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static Map<String, List<String>> createDropConfigurations() {
final Map<String, List<String>> config = new HashMap<>();
// Delete drop area droppable components
config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
return config;
}
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = new HashMap<>();
config.put(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
config.put(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
return config;
}
}

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
@@ -114,7 +114,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected String getDeleteAreaId() {
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
}
@Override
@@ -130,10 +130,10 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
addToDeleteList(sourceTable, (TableTransferable) event.getTransferable());
updateSWActionCount();
}
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
if (sourceComponent.getId().startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
final String swModuleTypeName = sourceComponent.getId()
.replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
.replace(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) {

View File

@@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -77,7 +77,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private ConfirmationTab createSMDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setId(SPUIComponentIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
@@ -181,7 +181,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));

View File

@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -101,8 +102,8 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
proxy.setVersion(bean.getVersion());
proxy.setVendor(bean.getVendor());
proxy.setDescription(bean.getDescription());
proxy.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy()));
proxy.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy()));
proxy.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean));
proxy.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean));
return proxy;
}

View File

@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import java.security.SecureRandom;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
*
* Proxy for software module to display details in Software modules table.
@@ -19,7 +17,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
*
*
*/
public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
public class ProxyBaseSoftwareModuleItem {
private static final long serialVersionUID = -1555306616599140635L;
@@ -39,6 +37,11 @@ public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
private String modifiedByUser;
private String name;
private String version;
private String vendor;
private String description;
/**
* Default constructor.
*/
@@ -47,6 +50,38 @@ public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
swId = RANDOM_OBJ.nextLong();
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getVersion() {
return version;
}
public void setVersion(final String version) {
this.version = version;
}
public String getVendor() {
return vendor;
}
public void setVendor(final String vendor) {
this.vendor = vendor;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
public String getCreatedByUser() {
return createdByUser;
}

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -19,7 +20,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -66,6 +67,9 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
@Autowired
private transient SoftwareManagement softwareManagement;
@Autowired
private transient EntityFactory entityFactory;
private Label madatoryLabel;
private TextField nameTextField;
@@ -130,21 +134,21 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
/* name textfield */
nameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
nameTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_NAME);
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
/* version text field */
versionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
versionTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_VERSION);
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
/* Vendor text field */
vendorTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
vendorTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_VENDOR);
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponetIdProvider.ADD_SW_MODULE_DESCRIPTION);
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
addDescriptionTextChangeListener();
addVendorTextChangeListener();
@@ -155,7 +159,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
typeComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, null,
i18n.get("upload.swmodule.type"));
typeComboBox.setId(SPUIComponetIdProvider.SW_MODULE_TYPE);
typeComboBox.setId(SPUIComponentIdProvider.SW_MODULE_TYPE);
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
typeComboBox.setImmediate(Boolean.TRUE);
@@ -163,7 +167,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
populateTypeNameCombo();
/* save or update button */
saveSoftware = SPUIComponentProvider.getButton(SPUIComponetIdProvider.SOFT_MODULE_SAVE, "", "", "", true,
saveSoftware = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SOFT_MODULE_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
saveSoftware.addClickListener(event -> {
if (editSwModule) {
@@ -175,7 +179,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
});
/* close button */
closeWindow = SPUIComponentProvider.getButton(SPUIComponetIdProvider.SOFT_MODULE_DISCARD, "", "", "", true,
closeWindow = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SOFT_MODULE_DISCARD, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
/* Just close this window when this button is clicked */
closeWindow.addClickListener(event -> closeThisWindow());
@@ -240,6 +244,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
SPUIDefinitions.CREATE_UPDATE_WINDOW);
window.setContent(mainLayout);
window.setModal(true);
nameTextField.focus();
}
private void addDescriptionTextChangeListener() {
@@ -276,8 +281,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
uiNotifcation.displayValidationError(
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
} else {
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(name, version, vendor,
softwareManagement.findSoftwareModuleTypeByName(type), description);
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
if (newBaseSoftwareModule != null) {
/* display success message */
uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] {

View File

@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -47,7 +47,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
}
@Override
@@ -90,19 +90,19 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
vendorLabel.setId(SPUIComponentIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
assignLabel.setId(SPUIComponentIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);
}
@@ -139,6 +139,6 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected String getDetailsHeaderCaptionId() {
return SPUIComponetIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
}
}

View File

@@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
@@ -76,7 +76,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Override
protected String getTableId() {
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
}
@Override

View File

@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -58,17 +58,17 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override
protected String getSearchBoxId() {
return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
return SPUIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
}
@Override
protected String getSearchRestIconId() {
return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON;
return SPUIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON;
}
@Override
protected String getAddIconId() {
return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON;
return SPUIComponentIdProvider.SW_MODULE_ADD_BUTTON;
}
@Override
@@ -124,7 +124,7 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override
protected String getMaxMinIconId() {
return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON;
return SPUIComponentIdProvider.SW_MAX_MIN_TABLE_ICON;
}
@Override

View File

@@ -13,6 +13,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -25,7 +26,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -93,6 +94,9 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
@Autowired
private transient SoftwareManagement swTypeManagementService;
@Autowired
private transient EntityFactory entityFactory;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@@ -189,7 +193,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
tagColorPreviewBtn = new Button();
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
getPreviewButtonColor(DEFAULT_COLOR);
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
@@ -257,6 +261,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout);
setCompositionRoot(mainLayout);
typeName.focus();
}
private void addListeners() {
@@ -553,7 +558,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
.findSoftwareModuleTypeByName(typeName.getValue());
if (createOptiongroup.getValue().equals(createTypeStr)) {
if (!checkIsKeyDuplicate(typeKey.getValue()) && !checkIsDuplicate(existingType)) {
crateNewSWModuleType();
createNewSWModuleType();
}
} else {
@@ -610,9 +615,9 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
/**
* Create new tag.
*/
private void crateNewSWModuleType() {
private void createNewSWModuleType() {
int assignNumber = 0;
final String colorPicked = getColorPickedSting();
final String colorPicked = getColorPickedString();
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeName.getValue());
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
@@ -624,8 +629,10 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
}
if (null != typeNameValue && null != typeKeyValue) {
SoftwareModuleType newSWType = new SoftwareModuleType(typeKeyValue, typeNameValue, typeDescValue,
assignNumber, colorPicked);
SoftwareModuleType newSWType = entityFactory.generateSoftwareModuleType(typeKeyValue, typeNameValue,
typeDescValue, assignNumber);
newSWType.setColour(colorPicked);
if (null != typeDescValue) {
newSWType.setDescription(typeDescValue);
}
@@ -649,7 +656,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
*
* @return String of color picked value.
*/
private String getColorPickedSting() {
private String getColorPickedString() {
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
+ getSelPreview().getColor().getBlue() + ")";
}
@@ -675,7 +682,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
existingType.setColour(getColorPickedSting());
existingType.setColour(getColorPickedString());
swTypeManagementService.updateSoftwareModuleType(existingType);
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
closeWindow();

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -63,7 +63,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
}
@Override
@@ -80,7 +80,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String createButtonId(final String name) {
return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name;
return SPUIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name;
}
@Override
@@ -102,7 +102,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String getButttonWrapperIdPrefix() {
return SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
return SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
}
@Override

View File

@@ -13,7 +13,7 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -86,7 +86,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
@Override
protected String getHideButtonId() {
return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID;
return SPUIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID;
}
@Override

View File

@@ -9,14 +9,18 @@
package org.eclipse.hawkbit.ui.artifacts.state;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.upload.UploadStatusObject;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,8 +62,61 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
private final Set<String> selectedDeleteSWModuleTypes = new HashSet<>();
private boolean noDataAvilableSoftwareModule = Boolean.FALSE;
private boolean isStatusPopupMinimized = Boolean.FALSE;
private boolean isUploadCompleted = Boolean.FALSE;
private List<UploadStatusObject> uploadedFileStatusList = new ArrayList<>();
private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger();
/**
private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger();
private final AtomicInteger numberOfFileUploadsFailed = new AtomicInteger();
public AtomicInteger getNumberOfFileUploadsFailed() {
return numberOfFileUploadsFailed;
}
public AtomicInteger getNumberOfFilesActuallyUpload() {
return numberOfFilesActuallyUpload;
}
public AtomicInteger getNumberOfFileUploadsExpected() {
return numberOfFileUploadsExpected;
}
public List<UploadStatusObject> getUploadedFileStatusList() {
return uploadedFileStatusList;
}
public void setUploadedFileStatusList(List<UploadStatusObject> uploadedFileStatusList) {
this.uploadedFileStatusList = uploadedFileStatusList;
}
public boolean isUploadCompleted() {
return isUploadCompleted;
}
public void setUploadCompleted(boolean isUploadCompleted) {
this.isUploadCompleted = isUploadCompleted;
}
public void setStatusPopupMinimized(boolean isStatusPopupMinimized) {
this.isStatusPopupMinimized = isStatusPopupMinimized;
}
public boolean isStatusPopupMinimized() {
return isStatusPopupMinimized;
}
/**
* Set software.
*
* @return

View File

@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -151,10 +151,10 @@ public class UploadConfirmationwindow implements Button.ClickListener {
}
private void createRequiredComponents() {
uploadBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT,
uploadBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT,
SPUILabelDefinitions.SUBMIT, ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
uploadBtn.addClickListener(this);
cancelBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON,
cancelBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON,
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
SPUIButtonStyleTiny.class);
cancelBtn.addClickListener(this);
@@ -162,7 +162,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
uploadDetailsTable = new Table();
uploadDetailsTable.addStyleName("artifact-table");
uploadDetailsTable.setSizeFull();
uploadDetailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
uploadDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
uploadDetailsTable.addStyleName(ValoTheme.TABLE_SMALL);
@@ -238,7 +238,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
newItem.getItemProperty(SW_MODULE_NAME).setValue(HawkbitCommonUtil.getFormatedLabel(swNameVersion));
newItem.getItemProperty(SIZE).setValue(customFile.getFileSize());
final Button deleteIcon = SPUIComponentProvider.getButton(
SPUIComponetIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
SPUIComponentIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O,
SPUIButtonStyleSmallNoBorder.class);
deleteIcon.addClickListener(this);
@@ -541,16 +541,16 @@ public class UploadConfirmationwindow implements Button.ClickListener {
@Override
public void buttonClick(final ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) {
uploadConfrimationWindow.close();
} else if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) {
uploadLayout.clearFileList();
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) {
uploadLayout.clearUploadedFileDetails();
uploadConfrimationWindow.close();
} else if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_BUTTON)) {
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_BUTTON)) {
processArtifactUpload();
}
else if (event.getComponent().getId().startsWith(SPUIComponetIdProvider.UPLOAD_DELETE_ICON)) {
else if (event.getComponent().getId().startsWith(SPUIComponentIdProvider.UPLOAD_DELETE_ICON)) {
final String itemId = ((Button) event.getComponent()).getData().toString();
final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData());
final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
@@ -568,10 +568,10 @@ public class UploadConfirmationwindow implements Button.ClickListener {
uploadDetailsTable.removeItem(((Button) event.getComponent()).getData());
uploadLayout.getFileSelected().remove(customFile);
uploadLayout.updateActionCount();
uploadLayout.updateUploadCounts();
if (uploadDetailsTable.getItemIds().isEmpty()) {
uploadLayout.clearFileList();
uploadConfrimationWindow.close();
uploadLayout.clearUploadedFileDetails();
}
}

View File

@@ -11,13 +11,21 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
import java.io.IOException;
import java.io.OutputStream;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.server.StreamVariable;
import com.vaadin.ui.Upload;
@@ -37,48 +45,65 @@ import com.vaadin.ui.Upload.SucceededListener;
* {@link StreamVariable} upload variants.
*
* The handler manages the output to the user and at the same time ensures that
* the upload does not exceed the configued max file size.
*
*
*
*
*
* the upload does not exceed the configured max file size.
*
*/
public class UploadHandler implements StreamVariable, Receiver, SucceededListener, FailedListener, FinishedListener,
ProgressListener, StartedListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(UploadHandler.class);
private final long fileSize;
private final UploadLayout view;
private final UploadStatusInfoWindow infoWindow;
private final long maxSize;
private final Upload upload;
private volatile String fileName = null;
private volatile String mimeType = null;
private volatile boolean interrupted = false;
private volatile boolean streamingInterrupted = false;
private volatile boolean uploadInterrupted = false;
private volatile boolean aborted = false;
private String failureReason;
private final I18N i18n;
private transient EventBus.SessionEventBus eventBus;
private final SoftwareModule selectedSw;
private SoftwareModule selectedSwForUpload;
private ArtifactUploadState artifactUploadState;
UploadHandler(final String fileName, final long fileSize, final UploadLayout view,
final UploadStatusInfoWindow infoWindow, final long maxSize, final Upload upload, final String mimeType) {
UploadHandler(final String fileName, final long fileSize, final UploadLayout view, final long maxSize,
final Upload upload, final String mimeType, SoftwareModule selectedSw) {
super();
this.aborted = false;
this.fileName = fileName;
this.fileSize = fileSize;
this.view = view;
this.infoWindow = infoWindow;
this.maxSize = maxSize;
this.upload = upload;
this.mimeType = mimeType;
this.selectedSw = selectedSw;
this.i18n = SpringContextHelper.getBean(I18N.class);
this.eventBus = SpringContextHelper.getBean(EventBus.SessionEventBus.class);
this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class);
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadStatusEventType event) {
if (event == UploadStatusEventType.ABORT_UPLOAD) {
aborted = true;
}
}
/**
@@ -89,11 +114,13 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public final OutputStream getOutputStream() {
try {
return view.saveUploadedFileDetails(fileName, fileSize, mimeType);
streamingInterrupted = false;
failureReason = null;
return view.saveUploadedFileDetails(fileName, fileSize, mimeType, selectedSw);
} catch (final ArtifactUploadFailedException e) {
LOG.error("Atifact upload failed {} ", e);
failureReason = e.getMessage();
interrupted = true;
streamingInterrupted = true;
return new NullOutputStream();
}
}
@@ -106,23 +133,22 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public OutputStream receiveUpload(final String fileName, final String mimeType) {
aborted = false;
failureReason = null;
this.fileName = fileName;
this.mimeType = mimeType;
//reset has directory flag before upload
// reset has directory flag before upload
view.setHasDirectory(false);
try {
if (view.checkIfSoftwareModuleIsSelected()) {
if (view.checkForDuplicate(fileName)) {
view.showDuplicateMessage();
} else {
view.increaseNumberOfFileUploadsExpected();
return view.saveUploadedFileDetails(fileName, 0, mimeType);
}
if (view.checkIfSoftwareModuleIsSelected() && !view.checkForDuplicate(fileName, selectedSwForUpload)) {
view.increaseNumberOfFileUploadsExpected();
return view.saveUploadedFileDetails(fileName, 0, mimeType, selectedSwForUpload);
}
} catch (final ArtifactUploadFailedException e) {
LOG.error("Atifact upload failed {} ", e);
failureReason = e.getMessage();
upload.interruptUpload();
uploadInterrupted = true;
}
// if final validation fails ,final no upload ,return NullOutputStream
return new NullOutputStream();
@@ -137,13 +163,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public void uploadSucceeded(final SucceededEvent event) {
LOG.debug("Streaming finished for file :{}", event.getFilename());
view.updateFileSize(event.getFilename(), event.getLength());
// recorded that we now one more uploaded
view.increaseNumberOfFilesActuallyUpload();
// inform upload status window
infoWindow.uploadSucceeded(event.getFilename());
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_SUCCESSFUL, new UploadFileStatus(
event.getFilename(), 0, event.getLength(), selectedSwForUpload)));
}
/**
@@ -156,20 +177,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public void streamingFinished(final StreamingEndEvent event) {
LOG.debug("Streaming finished for file :{}", event.getFileName());
// record that we now one more uploaded
view.increaseNumberOfFilesActuallyUpload();
// inform upload status window
infoWindow.uploadSucceeded(event.getFileName());
// check if we are finished
if (view.enableProcessBtn()) {
infoWindow.uploadSessionFinished();
}
view.updateActionCount();
// display the duplicate message after streaming all files
view.displayDuplicateValidationMessage();
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STREAMING_FINISHED,
new UploadFileStatus(event.getFileName(), 0, event.getContentLength(), selectedSw)));
}
/**
@@ -181,12 +190,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public void uploadFinished(final FinishedEvent event) {
LOG.debug("Upload finished for file :{}", event.getFilename());
// check if we are finished
if (view.enableProcessBtn()) {
infoWindow.uploadSessionFinished();
}
view.updateActionCount();
eventBus.publish(this,
new UploadStatusEvent(UploadStatusEventType.UPLOAD_FINISHED, new UploadFileStatus(event.getFilename())));
}
/**
@@ -197,7 +202,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public void streamingStarted(final StreamingStartEvent event) {
LOG.debug("Streaming started for file :{}", fileName);
infoWindow.uploadStarted(fileName);
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STARTED, new UploadFileStatus(
fileName, 0, 0, selectedSw)));
}
/**
@@ -207,14 +213,24 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public void uploadStarted(final StartedEvent event) {
// single file session
if (view.isSoftwareModuleSelected() && !view.checkIfFileIsDuplicate(event.getFilename())) {
infoWindow.uploadSessionStarted();
LOG.debug("Upload started for file :{}", event.getFilename());
infoWindow.uploadStarted(event.getFilename());
} else {
uploadInterrupted = false;
selectedSwForUpload = artifactUploadState.getSelectedBaseSoftwareModule().isPresent() ? artifactUploadState
.getSelectedBaseSoftwareModule().get() : null;
if (view.isSoftwareModuleSelected()) {
// single file session
if (!view.checkIfFileIsDuplicate(event.getFilename(), selectedSwForUpload)) {
LOG.debug("Upload started for file :{}", event.getFilename());
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STARTED,
new UploadFileStatus(event.getFilename(), 0, 0, selectedSwForUpload)));
}
}
else {
failureReason = i18n.get("message.upload.failed");
upload.interruptUpload();
// actual interrupt will happen a bit late so setting the below
// flag
uploadInterrupted = true;
}
}
@@ -235,21 +251,25 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public void updateProgress(final long readBytes, final long contentLength) {
if (readBytes > maxSize || contentLength > maxSize) {
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
view.decreaseNumberOfFileUploadsExpected();
final SoftwareModule sw = view.getSoftwareModuleSelected();
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
view.updateActionCount();
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
infoWindow.uploadFailed(fileName, failureReason);
upload.interruptUpload();
interrupted = true;
return;
// Update progress is called event after upload interrupted in
// uploadStarted method
if (!uploadInterrupted) {
if (aborted) {
LOG.info("User aborted file upload for file : {}", fileName);
failureReason = i18n.get("message.uploadedfile.aborted");
interruptFileUpload();
return;
}
if (readBytes > maxSize || contentLength > maxSize) {
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
interruptFileUpload();
return;
}
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_IN_PROGRESS,
new UploadFileStatus(fileName, readBytes, contentLength, selectedSwForUpload)));
LOG.info("Update progress - {} : {}", fileName, (double) readBytes / (double) contentLength);
}
infoWindow.updateProgress(fileName, readBytes, contentLength);
LOG.info("Update progress - {} : {}", fileName, (double) readBytes / (double) contentLength);
}
/**
@@ -259,19 +279,20 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public void onProgress(final StreamingProgressEvent event) {
if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) {
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
view.decreaseNumberOfFileUploadsExpected();
final SoftwareModule sw = view.getSoftwareModuleSelected();
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
view.updateActionCount();
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
infoWindow.uploadFailed(event.getFileName(), failureReason);
interrupted = true;
if (aborted) {
LOG.info("User aborted the upload for file : {}", event.getFileName());
failureReason = i18n.get("message.uploadedfile.aborted");
interruptFileStreaming();
return;
}
infoWindow.updateProgress(event.getFileName(), event.getBytesReceived(), event.getContentLength());
if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) {
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
interruptFileStreaming();
return;
}
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_IN_PROGRESS, new UploadFileStatus(
fileName, event.getBytesReceived(), event.getContentLength(), selectedSw)));
// Logging to solve sonar issue
LOG.trace("Streaming in progress for file :{}", event.getFileName());
}
@@ -284,19 +305,16 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public void streamingFailed(final StreamingErrorEvent event) {
LOG.info("Streaming failed for file :{}", event.getFileName());
view.decreaseNumberOfFileUploadsExpected();
final SoftwareModule sw = view.getSoftwareModuleSelected();
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
view.updateActionCount();
infoWindow.uploadFailed(event.getFileName(), failureReason);
// check if we are finished
if (view.enableProcessBtn()) {
infoWindow.uploadSessionFinished();
if (failureReason == null) {
failureReason = event.getException().getMessage();
}
view.displayDuplicateValidationMessage();
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STREAMING_FAILED,
new UploadFileStatus(fileName, failureReason, selectedSw)));
LOG.info("Streaming failed due to :{}", event.getException());
if (!aborted) {
LOG.info("Streaming failed for file :{}", event.getFileName());
LOG.info("Streaming failed due to :{}", event.getException());
}
}
/**
@@ -306,20 +324,21 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public void uploadFailed(final FailedEvent event) {
LOG.info("Upload failed for file :{}", event.getFilename());
view.decreaseNumberOfFileUploadsExpected();
/**
* If upload interrupted because of duplicate file,do not remove the
* file already in upload list
**/
if (!view.getDuplicateFileNamesList().isEmpty()) {
final SoftwareModule sw = view.getSoftwareModuleSelected();
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
* If upload failed due to no selected software UPLOAD_FAILED event need
* not be published.
*/
if (selectedSwForUpload != null) {
if (failureReason == null) {
failureReason = event.getReason().getMessage();
}
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_FAILED, new UploadFileStatus(
fileName, failureReason, selectedSwForUpload)));
if (!aborted) {
LOG.info("Upload failed for file :{}", event.getFilename());
LOG.info("Upload failed for file :{}", event.getReason());
}
}
view.updateActionCount();
infoWindow.uploadFailed(event.getFilename(), failureReason);
LOG.info("Upload failed for file :{}", event.getReason());
}
/**
@@ -327,7 +346,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
*/
@Override
public boolean isInterrupted() {
return interrupted;
return streamingInterrupted;
}
private static class NullOutputStream extends OutputStream {
@@ -343,39 +362,43 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (fileName == null ? 0 : fileName.hashCode());
result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof UploadHandler)) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final UploadHandler other = (UploadHandler) obj;
if (fileName == null && other.fileName != null) {
return false;
if (fileName == null) {
if (other.fileName != null) {
return false;
}
} else if (!fileName.equals(other.fileName)) {
return false;
}
return true;
}
private void interruptFileStreaming() {
streamingInterrupted = true;
}
private void interruptFileUpload() {
upload.interruptUpload();
uploadInterrupted = true;
}
}

View File

@@ -16,7 +16,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -26,13 +25,15 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -97,10 +98,6 @@ public class UploadLayout extends VerticalLayout {
@Autowired
private transient SPInfo spInfo;
private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger();
private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger();
private final List<String> duplicateFileNamesList = new ArrayList<>();
private Button processBtn;
@@ -119,6 +116,8 @@ public class UploadLayout extends VerticalLayout {
private Boolean hasDirectory = Boolean.FALSE;
private Button uploadStatusButton;
/**
* Initialize the upload layout.
*/
@@ -126,13 +125,52 @@ public class UploadLayout extends VerticalLayout {
void init() {
createComponents();
buildLayout();
updateActionCount();
restoreState();
eventBus.subscribe(this);
ui = UI.getCurrent();
}
private void createComponents() {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
ui.access(() -> updateActionCount());
} else if (event == UploadArtifactUIEvent.MINIMIZED_STATUS_POPUP) {
ui.access(() -> showUploadStatusButton());
} else if (event == UploadArtifactUIEvent.MAXIMIZED_STATUS_POPUP) {
ui.access(() -> maximizeStatusPopup());
} else if (event == UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED) {
ui.access(() -> closeUploadStatusPopup());
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadStatusEvent event) {
if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) {
ui.access(() -> onStartOfUpload());
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FAILED) {
ui.access(() -> onUploadFailure(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FINISHED) {
ui.access(() -> onUploadCompletion());
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) {
ui.access(() -> onUploadSuccess(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) {
ui.access(() -> onUploadStreamingFailure(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) {
ui.access(() -> onUploadStreamingSuccess());
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
private void createComponents() {
createUploadStatusButton();
createProcessButton();
createDiscardBtn();
}
@@ -140,8 +178,8 @@ public class UploadLayout extends VerticalLayout {
private void buildLayout() {
final Upload upload = new Upload();
final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), upload, null);
final UploadHandler uploadHandler = new UploadHandler(null, 0, this, spInfo.getMaxArtifactFileSize(), upload,
null, null);
upload.setButtonCaption(i18n.get("upload.file"));
upload.setImmediate(true);
upload.setReceiver(uploadHandler);
@@ -154,12 +192,15 @@ public class UploadLayout extends VerticalLayout {
fileUploadLayout = new HorizontalLayout();
fileUploadLayout.setSpacing(true);
fileUploadLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
fileUploadLayout.addComponent(upload);
fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
fileUploadLayout.addComponent(processBtn);
fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT);
fileUploadLayout.addComponent(discardBtn);
fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT);
fileUploadLayout.addComponent(uploadStatusButton);
fileUploadLayout.setComponentAlignment(uploadStatusButton, Alignment.MIDDLE_RIGHT);
setMargin(false);
/* create drag-drop wrapper for drop area */
@@ -167,7 +208,25 @@ public class UploadLayout extends VerticalLayout {
dropAreaWrapper.setDropHandler(new DropAreahandler());
setSizeFull();
setSpacing(true);
}
private void restoreState() {
updateActionCount();
if (!artifactUploadState.getFileSelected().isEmpty() && artifactUploadState.isUploadCompleted()) {
processBtn.setEnabled(true);
}
if (artifactUploadState.isStatusPopupMinimized()) {
showUploadStatusButton();
if (artifactUploadState.isUploadCompleted()) {
setUploadStatusButtonIconToFinished();
}
}
if (artifactUploadState.isUploadCompleted()) {
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
}
}
public DragAndDropWrapper getDropAreaWrapper() {
@@ -187,15 +246,16 @@ public class UploadLayout extends VerticalLayout {
public void drop(final DragAndDropEvent event) {
if (validate(event)) {
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
// selected software module at the time of file drop is
// considered for upload
SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get();
// reset the flag
hasDirectory = Boolean.FALSE;
for (final Html5File file : files) {
processFile(file);
processFile(file, selectedSw);
}
if (numberOfFileUploadsExpected.get() > 0) {
if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) {
processBtn.setEnabled(false);
// reset before we start
uploadInfoWindow.uploadSessionStarted();
} else {
// If the upload is not started, it signifies all
// dropped files as either duplicate or directory.So
@@ -205,20 +265,20 @@ public class UploadLayout extends VerticalLayout {
}
}
private void processFile(final Html5File file) {
private void processFile(final Html5File file, SoftwareModule selectedSw) {
if (!isDirectory(file)) {
if (!checkForDuplicate(file.getFileName())) {
numberOfFileUploadsExpected.incrementAndGet();
file.setStreamVariable(createStreamVariable(file));
if (!checkForDuplicate(file.getFileName(), selectedSw)) {
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
file.setStreamVariable(createStreamVariable(file, selectedSw));
}
} else {
hasDirectory = Boolean.TRUE;
}
}
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
private StreamVariable createStreamVariable(final Html5File file, SoftwareModule selectedSw) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this,
spInfo.getMaxArtifactFileSize(), null, file.getType(), selectedSw);
}
private boolean isDirectory(final Html5File file) {
@@ -263,20 +323,18 @@ public class UploadLayout extends VerticalLayout {
}
private void createProcessButton() {
processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON,
processBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON,
SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null,
SPUIButtonStyleSmall.class);
processBtn.setIcon(FontAwesome.BELL);
processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
processBtn.addClickListener(event -> displayConfirmWindow(event));
processBtn.setHtmlContentAllowed(true);
if (artifactUploadState.getFileSelected().isEmpty()) {
processBtn.setEnabled(false);
}
processBtn.setEnabled(false);
}
private void createDiscardBtn() {
discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON,
discardBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_BUTTON,
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
SPUIButtonStyleSmall.class);
discardBtn.setIcon(FontAwesome.TRASH_O);
@@ -284,23 +342,14 @@ public class UploadLayout extends VerticalLayout {
discardBtn.addClickListener(event -> discardUploadData(event));
}
boolean checkForDuplicate(final String filename) {
final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
boolean checkForDuplicate(final String filename, final SoftwareModule selectedSw) {
final Boolean isDuplicate = checkIfFileIsDuplicate(filename, selectedSw);
if (isDuplicate) {
getDuplicateFileNamesList().add(filename);
}
return isDuplicate;
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void toggleProcessButton(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) {
processBtn.setEnabled(true);
} else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) {
processBtn.setEnabled(false);
}
}
/**
* Save uploaded file details.
*
@@ -312,29 +361,29 @@ public class UploadLayout extends VerticalLayout {
* file size
* @param mimeType
* the mimeType of the file
* @param selectedSw
* @throws IOException
* in case of upload errors
*/
OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) {
OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType,
SoftwareModule selectedSw) {
File tempFile = null;
try {
tempFile = File.createTempFile("spUiArtifactUpload", null);
final OutputStream out = new FileOutputStream(tempFile);
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(selectedSw.getName(),
selectedSw.getVersion());
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(),
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType);
final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), selectedSw.getName(),
selectedSw.getVersion(), mimeType);
artifactUploadState.getFileSelected().add(customFile);
processBtn.setEnabled(false);
if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) {
artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule);
artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSw);
}
return out;
} catch (final FileNotFoundException e) {
@@ -344,6 +393,7 @@ public class UploadLayout extends VerticalLayout {
LOG.error("Upload failed {}", e);
throw new ArtifactUploadFailedException(i18n.get("message.upload.failed"));
}
}
Boolean validate(final DragAndDropEvent event) {
@@ -378,13 +428,6 @@ public class UploadLayout extends VerticalLayout {
return true;
}
SoftwareModule getSoftwareModuleSelected() {
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
return artifactUploadState.getSelectedBaseSoftwareModule().get();
}
return null;
}
Boolean isSoftwareModuleSelected() {
if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
return false;
@@ -400,11 +443,10 @@ public class UploadLayout extends VerticalLayout {
* file name
* @return Boolean
*/
public Boolean checkIfFileIsDuplicate(final String name) {
public Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
Boolean isDuplicate = false;
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
@@ -418,7 +460,7 @@ public class UploadLayout extends VerticalLayout {
}
void decreaseNumberOfFileUploadsExpected() {
numberOfFileUploadsExpected.decrementAndGet();
artifactUploadState.getNumberOfFileUploadsExpected().decrementAndGet();
}
List<String> getDuplicateFileNamesList() {
@@ -439,8 +481,10 @@ public class UploadLayout extends VerticalLayout {
void displayDuplicateValidationMessage() {
// check if streaming of all dropped files are completed
if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) {
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == artifactUploadState
.getNumberOfFileUploadsExpected().intValue()) {
displayCompositeMessage();
duplicateFileNamesList.clear();
}
}
@@ -454,7 +498,6 @@ public class UploadLayout extends VerticalLayout {
} else if (duplicateFileNamesList.size() > 1) {
message.append(i18n.get("message.no.duplicateFiles"));
}
duplicateFileNamesList.clear();
}
return message.toString();
}
@@ -464,13 +507,12 @@ public class UploadLayout extends VerticalLayout {
}
void increaseNumberOfFileUploadsExpected() {
numberOfFileUploadsExpected.incrementAndGet();
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
}
void updateFileSize(final String name, final long size) {
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
void updateFileSize(final String name, final long size, SoftwareModule selectedSoftwareModule) {
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
@@ -483,17 +525,22 @@ public class UploadLayout extends VerticalLayout {
}
void increaseNumberOfFilesActuallyUpload() {
numberOfFilesActuallyUpload.incrementAndGet();
artifactUploadState.getNumberOfFilesActuallyUpload().incrementAndGet();
}
void increaseNumberOfFileUploadsFailed() {
artifactUploadState.getNumberOfFileUploadsFailed().incrementAndGet();
}
/**
* Enable process button once upload is completed.
*/
boolean enableProcessBtn() {
if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) {
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() >= artifactUploadState
.getNumberOfFileUploadsExpected().intValue() && !getFileSelected().isEmpty()) {
processBtn.setEnabled(true);
numberOfFileUploadsExpected.set(0);
numberOfFilesActuallyUpload.set(0);
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
return true;
}
return false;
@@ -507,13 +554,23 @@ public class UploadLayout extends VerticalLayout {
if (event.getButton().equals(discardBtn)) {
if (artifactUploadState.getFileSelected().isEmpty()) {
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
} else {
clearFileList();
clearUploadedFileDetails();
}
}
}
protected void clearUploadedFileDetails() {
clearFileList();
closeUploadStatusPopup();
}
private void closeUploadStatusPopup() {
uploadInfoWindow.clearWindow();
hideUploadStatusButton();
artifactUploadState.setStatusPopupMinimized(false);
}
/**
* Clear details.
*/
@@ -529,19 +586,20 @@ public class UploadLayout extends VerticalLayout {
processBtn.setCaption(SPUILabelDefinitions.PROCESS);
/* disable when there is no files to upload. */
processBtn.setEnabled(false);
numberOfFileUploadsExpected.set(0);
numberOfFilesActuallyUpload.set(0);
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
duplicateFileNamesList.clear();
}
private void setConfirmationPopupHeightWidth(final float newWidth, final float newHeight) {
if (currentUploadConfirmationwindow != null) {
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(HawkbitCommonUtil
.getArtifactUploadPopupWidth(newWidth, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH),
Unit.PIXELS);
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(HawkbitCommonUtil
.getArtifactUploadPopupHeight(newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT),
Unit.PIXELS);
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
}
}
@@ -558,22 +616,24 @@ public class UploadLayout extends VerticalLayout {
&& currentUploadConfirmationwindow.getCurrentUploadResultWindow() != null) {
final UploadResultWindow uploadResultWindow = currentUploadConfirmationwindow
.getCurrentUploadResultWindow();
uploadResultWindow.getUploadResultsWindow().setWidth(HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
uploadResultWindow.getUploadResultTable().setHeight(HawkbitCommonUtil.getArtifactUploadPopupHeight(
newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
uploadResultWindow.getUploadResultsWindow().setWidth(
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
uploadResultWindow.getUploadResultTable().setHeight(
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
}
}
private void displayConfirmWindow(final Button.ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON)) {
if (artifactUploadState.getFileSelected().isEmpty()) {
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
} else {
currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState);
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
Page.getCurrent().getBrowserWindowHeight());
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent()
.getBrowserWindowHeight());
}
}
}
@@ -599,25 +659,101 @@ public class UploadLayout extends VerticalLayout {
/**
* @return
*/
VerticalLayout getDropAreaLayout() {
return dropAreaLayout;
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
ui.access(() -> updateActionCount());
private void onStartOfUpload() {
setUploadStatusButtonIconToInProgress();
if (artifactUploadState.isStatusPopupMinimized()) {
updateStatusButtonCount();
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
private void onUploadStreamingSuccess() {
increaseNumberOfFilesActuallyUpload();
updateUploadCounts();
enableProcessBtn();
if (isUploadComplete()) {
uploadInfoWindow.uploadSessionFinished();
setUploadStatusButtonIconToFinished();
}
// display the duplicate message after streaming all files
displayDuplicateValidationMessage();
}
private void onUploadStreamingFailure(UploadStatusEvent event) {
/**
* If upload interrupted because of duplicate file,do not remove the
* file already in upload list
**/
if (getDuplicateFileNamesList().isEmpty()
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
if (sw != null) {
getFileSelected().remove(
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
}
// failed reason to be updated only if there is error other than
// duplicate file error
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
increaseNumberOfFileUploadsFailed();
}
decreaseNumberOfFileUploadsExpected();
updateUploadCounts();
enableProcessBtn();
// check if we are finished
if (isUploadComplete()) {
uploadInfoWindow.uploadSessionFinished();
setUploadStatusButtonIconToFinished();
}
displayDuplicateValidationMessage();
}
private void onUploadSuccess(UploadStatusEvent event) {
updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(), event
.getUploadStatus().getSoftwareModule());
// recorded that we now one more uploaded
increaseNumberOfFilesActuallyUpload();
}
private void onUploadCompletion() {
// check if we are finished
if (isUploadComplete()) {
uploadInfoWindow.uploadSessionFinished();
setUploadStatusButtonIconToFinished();
displayDuplicateValidationMessage();
}
updateUploadCounts();
enableProcessBtn();
}
private boolean isUploadComplete() {
int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue();
int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue();
return uploadedCount == expectedUploadsCount;
}
private void onUploadFailure(final UploadStatusEvent event) {
/**
* If upload interrupted because of duplicate file,do not remove the
* file already in upload list
**/
if (getDuplicateFileNamesList().isEmpty()
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
if (sw != null) {
getFileSelected().remove(
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
}
// failed reason to be updated only if there is error other than
// duplicate file error
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
increaseNumberOfFileUploadsFailed();
decreaseNumberOfFileUploadsExpected();
}
}
/**
@@ -637,8 +773,8 @@ public class UploadLayout extends VerticalLayout {
* @param selectedBaseSoftwareModule
*/
public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule));
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED,
selectedBaseSoftwareModule));
}
/**
@@ -655,4 +791,79 @@ public class UploadLayout extends VerticalLayout {
public void setHasDirectory(final Boolean hasDirectory) {
this.hasDirectory = hasDirectory;
}
private void createUploadStatusButton() {
uploadStatusButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_STATUS_BUTTON, "", "", "",
false, null, SPUIButtonStyleSmall.class);
uploadStatusButton.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
uploadStatusButton.setWidth("100px");
uploadStatusButton.setHtmlContentAllowed(true);
uploadStatusButton.addClickListener(event -> onClickOfUploadStatusButton());
uploadStatusButton.setVisible(false);
}
void updateStatusButtonCount() {
int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get()
- artifactUploadState.getNumberOfFilesActuallyUpload().get();
int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get();
StringBuilder builder = new StringBuilder("");
if (uploadsFailed != 0) {
if (uploadsPending != 0) {
builder.append("<div class='error-count error-count-color'>" + uploadsFailed + "</div>");
} else {
builder.append("<div class='unread error-count-color'>" + uploadsFailed + "</div>");
}
}
if (uploadsPending != 0) {
builder.append("<div class='unread'>" + uploadsPending + "</div>");
}
uploadStatusButton.setCaption(builder.toString());
}
private void onClickOfUploadStatusButton() {
artifactUploadState.setStatusPopupMinimized(false);
eventBus.publish(this, UploadArtifactUIEvent.MAXIMIZED_STATUS_POPUP);
}
private void showUploadStatusButton() {
if (uploadStatusButton == null) {
return;
}
uploadStatusButton.setVisible(true);
updateStatusButtonCount();
}
protected void hideUploadStatusButton() {
if (uploadStatusButton == null) {
return;
}
uploadStatusButton.setVisible(false);
}
private void maximizeStatusPopup() {
hideUploadStatusButton();
uploadInfoWindow.maximizeStatusPopup();
}
private void setUploadStatusButtonIconToFinished() {
if (uploadStatusButton == null) {
return;
}
uploadStatusButton.removeStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
uploadStatusButton.setIcon(FontAwesome.UPLOAD);
}
private void setUploadStatusButtonIconToInProgress() {
if (uploadStatusButton == null) {
return;
}
uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
uploadStatusButton.setIcon(null);
}
protected void updateUploadCounts() {
updateActionCount();
updateStatusButtonCount();
}
}

View File

@@ -11,14 +11,17 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
@@ -63,6 +66,9 @@ public class UploadResultWindow implements Button.ClickListener {
private static final String UPLOAD_RESULT = "uploadResult";
private static final String REASON = "reason";
private transient EventBus.SessionEventBus eventBus;
/**
* Initialize upload status popup.
@@ -75,12 +81,13 @@ public class UploadResultWindow implements Button.ClickListener {
public UploadResultWindow(final List<UploadStatus> uploadResultList, final I18N i18n) {
this.uploadResultList = uploadResultList;
this.i18n = i18n;
eventBus = SpringContextHelper.getBean( EventBus.SessionEventBus.class);
createComponents();
createLayout();
}
private void createComponents() {
closeBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE,
closeBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE,
SPUILabelDefinitions.CLOSE, SPUILabelDefinitions.CLOSE, ValoTheme.BUTTON_PRIMARY, false, null,
SPUIButtonStyleTiny.class);
closeBtn.addClickListener(this);
@@ -89,7 +96,7 @@ public class UploadResultWindow implements Button.ClickListener {
uploadResultTable.addStyleName("artifact-table");
uploadResultTable.setSizeFull();
uploadResultTable.setImmediate(true);
uploadResultTable.setId(SPUIComponetIdProvider.UPLOAD_RESULT_TABLE);
uploadResultTable.setId(SPUIComponentIdProvider.UPLOAD_RESULT_TABLE);
uploadResultTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
uploadResultTable.addStyleName(ValoTheme.TABLE_SMALL);
uploadResultTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
@@ -121,7 +128,7 @@ public class UploadResultWindow implements Button.ClickListener {
reasonLabel = HawkbitCommonUtil.getFormatedLabel(uploadResult.getReason());
reasonLabel.setDescription(uploadResult.getReason());
final String idStr = SPUIComponetIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/"
final String idStr = SPUIComponentIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/"
+ uploadResult.getFileName();
reasonLabel.setId(idStr);
newItem.getItemProperty(REASON).setValue(reasonLabel);
@@ -180,9 +187,11 @@ public class UploadResultWindow implements Button.ClickListener {
@Override
public void buttonClick(final ClickEvent event) {
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|| event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|| event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
uploadResultsWindow.close();
//close upload status popup if open
eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED);
}
}

View File

@@ -8,20 +8,49 @@
*/
package org.eclipse.hawkbit.ui.artifacts.upload;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container.Indexed;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.renderers.HtmlRenderer;
import com.vaadin.ui.renderers.ProgressBarRenderer;
import com.vaadin.ui.themes.ValoTheme;
import elemental.json.JsonValue;
@@ -34,7 +63,16 @@ import elemental.json.JsonValue;
@ViewScope
@SpringComponent
public class UploadStatusInfoWindow extends Window implements Window.CloseListener, Window.WindowModeChangeListener {
public class UploadStatusInfoWindow extends Window {
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private I18N i18n;
private static final String PROGRESS = "Progress";
@@ -46,52 +84,173 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
private static final long serialVersionUID = 1L;
private final Grid grid;
private Grid grid;
private final IndexedContainer uploads;
private IndexedContainer uploads;
private volatile boolean errorOccured = false;
private volatile boolean uploadAborted = false;
private Button minimizeButton;
private VerticalLayout mainLayout;
private Label windowCaption;
private Button closeButton;
private Button resizeButton;
private UI ui;
private ConfirmationDialog confirmDialog;
/**
* Default Constructor.
*/
UploadStatusInfoWindow() {
super("Upload Status");
@PostConstruct
void init() {
addStyleName(SPUIStyleDefinitions.UPLOAD_INFO);
center();
setImmediate(true);
setResizable(true);
setDraggable(true);
setClosable(true);
uploads = new IndexedContainer();
uploads.addContainerProperty(STATUS, String.class, "Active");
uploads.addContainerProperty(FILE_NAME, String.class, null);
uploads.addContainerProperty(PROGRESS, Double.class, 0D);
uploads.addContainerProperty(REASON, String.class, "");
setPopupProperties();
createStatusPopupHeaderComponents();
grid = new Grid(uploads);
grid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
grid.setSelectionMode(SelectionMode.NONE);
grid.getColumn(STATUS).setRenderer(new StatusRenderer());
grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
setColumnWidth();
grid.setFrozenColumnCount(4);
grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, REASON);
grid.setHeaderVisible(true);
grid.setImmediate(true);
mainLayout = new VerticalLayout();
mainLayout.setSpacing(Boolean.TRUE);
mainLayout.setSizeUndefined();
setPopupSizeInMinMode();
setContent(grid);
addCloseListener(this);
addWindowModeChangeListener(this);
uploads = getGridContainer();
grid = createGrid();
setGridColumnProperties();
mainLayout.addComponents(getCaptionLayout(), grid);
mainLayout.setExpandRatio(grid, 1.0F);
setContent(mainLayout);
eventBus.subscribe(this);
ui = UI.getCurrent();
createConfirmDialog();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadStatusEvent event) {
if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_IN_PROGRESS) {
UI.getCurrent().access(
() -> updateProgress(event.getUploadStatus().getFileName(), event.getUploadStatus().getBytesRead(),
event.getUploadStatus().getContentLength(), event.getUploadStatus().getSoftwareModule()));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) {
UI.getCurrent().access(() -> onStartOfUpload(event));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) {
ui.access(() -> uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
.getFailureReason(), event.getUploadStatus().getSoftwareModule()));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) {
UI.getCurrent().access(
() -> uploadSucceeded(event.getUploadStatus().getFileName(), event.getUploadStatus()
.getSoftwareModule()));
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) {
ui.access(() -> uploadSucceeded(event.getUploadStatus().getFileName(), event.getUploadStatus()
.getSoftwareModule()));
}
}
private void onStartOfUpload(UploadStatusEvent event) {
uploadSessionStarted();
uploadStarted(event.getUploadStatus().getFileName(), event.getUploadStatus().getSoftwareModule());
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
private void restoreState() {
Indexed container = grid.getContainerDataSource();
if (container.getItemIds().isEmpty()) {
container.removeAllItems();
for (UploadStatusObject statusObject : artifactUploadState.getUploadedFileStatusList()) {
Item item = container.addItem(getItemid(statusObject.getFilename(),
statusObject.getSelectedSoftwareModule()));
item.getItemProperty(REASON).setValue(statusObject.getReason() != null ? statusObject.getReason() : "");
item.getItemProperty(STATUS).setValue(statusObject.getStatus());
item.getItemProperty(PROGRESS).setValue(statusObject.getProgress());
item.getItemProperty(FILE_NAME).setValue(statusObject.getFilename());
SoftwareModule sw = statusObject.getSelectedSoftwareModule();
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(
HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()));
}
if (artifactUploadState.isUploadCompleted()) {
minimizeButton.setEnabled(false);
}
}
}
private void setPopupProperties() {
setId(SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_ID);
addStyleName(SPUIStyleDefinitions.UPLOAD_INFO);
setImmediate(true);
setResizable(false);
setDraggable(true);
setClosable(false);
setModal(true);
}
private void setGridColumnProperties() {
grid.getColumn(STATUS).setRenderer(new StatusRenderer());
grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, SPUILabelDefinitions.NAME_VERSION, REASON);
setColumnWidth();
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setHeaderCaption(i18n.get("upload.swModuleTable.header"));
grid.setFrozenColumnCount(5);
}
private Grid createGrid() {
Grid statusGrid = new Grid(uploads);
statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
statusGrid.setSelectionMode(SelectionMode.NONE);
statusGrid.setHeaderVisible(true);
statusGrid.setImmediate(true);
statusGrid.setSizeFull();
return statusGrid;
}
private IndexedContainer getGridContainer() {
IndexedContainer uploadContainer = new IndexedContainer();
uploadContainer.addContainerProperty(STATUS, String.class, "Active");
uploadContainer.addContainerProperty(FILE_NAME, String.class, null);
uploadContainer.addContainerProperty(PROGRESS, Double.class, 0D);
uploadContainer.addContainerProperty(REASON, String.class, "");
uploadContainer.addContainerProperty(SPUILabelDefinitions.NAME_VERSION, String.class, "");
return uploadContainer;
}
private HorizontalLayout getCaptionLayout() {
final HorizontalLayout captionLayout = new HorizontalLayout();
captionLayout.setSizeFull();
captionLayout.setHeight("36px");
captionLayout.addComponents(windowCaption, minimizeButton, resizeButton, closeButton);
captionLayout.setExpandRatio(windowCaption, 1.0F);
captionLayout.addStyleName("v-window-header");
return captionLayout;
}
private void createStatusPopupHeaderComponents() {
minimizeButton = getMinimizeButton();
windowCaption = new Label("Upload status");
closeButton = getCloseButton();
resizeButton = getResizeButton();
}
private void setColumnWidth() {
grid.getColumn(STATUS).setWidth(70);
grid.getColumn(STATUS).setWidth(60);
grid.getColumn(PROGRESS).setWidth(150);
grid.getColumn(FILE_NAME).setWidth(280);
grid.getColumn(REASON).setWidth(300);
grid.getColumn(FILE_NAME).setWidth(200);
grid.getColumn(REASON).setWidth(290);
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidth(200);
}
private void resetColumnWidth() {
@@ -99,15 +258,16 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
grid.getColumn(PROGRESS).setWidthUndefined();
grid.getColumn(FILE_NAME).setWidthUndefined();
grid.getColumn(REASON).setWidthUndefined();
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidthUndefined();
}
private static class StatusRenderer extends HtmlRenderer {
private static final long serialVersionUID = -5365795450234970943L;
@Override
public JsonValue encode(final String value) {
String result = "";
String result;
switch (value) {
case "Finished":
result = "<div class=\"statusIconGreen\">" + FontAwesome.CHECK_CIRCLE.getHtml() + "</div>";
@@ -127,30 +287,66 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
* Automatically close if not error has occured.
*/
void uploadSessionFinished() {
if (!errorOccured) {
close();
uploadAborted = false;
if (!errorOccured && !artifactUploadState.isStatusPopupMinimized()) {
clearWindow();
}
artifactUploadState.setUploadCompleted(true);
minimizeButton.setEnabled(false);
closeButton.setEnabled(true);
confirmDialog.getWindow().close();
UI.getCurrent().removeWindow(confirmDialog.getWindow());
}
void uploadSessionStarted() {
close();
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == 0
&& artifactUploadState.getNumberOfFileUploadsFailed().intValue() == 0
&& !artifactUploadState.isStatusPopupMinimized()) {
openWindow();
}
if (!uploadAborted) {
minimizeButton.setEnabled(true);
closeButton.setEnabled(true);
artifactUploadState.setUploadCompleted(false);
}
}
void openWindow() {
UI.getCurrent().addWindow(this);
center();
}
void uploadStarted(final String filename) {
final Item item = uploads.addItem(filename);
item.getItemProperty(FILE_NAME).setValue(filename);
grid.scrollToEnd();
void maximizeStatusPopup() {
openWindow();
restoreState();
}
void updateProgress(final String filename, final long readBytes, final long contentLength) {
final Item item = uploads.getItem(filename);
void uploadStarted(final String filename, final SoftwareModule softwareModule) {
final Item item = uploads.addItem(getItemid(filename, softwareModule));
if (item != null) {
item.getItemProperty(PROGRESS).setValue((double) readBytes / (double) contentLength);
item.getItemProperty(FILE_NAME).setValue(filename);
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()));
}
grid.scrollToEnd();
UploadStatusObject uploadStatus = new UploadStatusObject(filename, softwareModule);
uploadStatus.setStatus("Active");
artifactUploadState.getUploadedFileStatusList().add(uploadStatus);
}
void updateProgress(final String filename, final long readBytes, final long contentLength,
final SoftwareModule softwareModule) {
final Item item = uploads.getItem(getItemid(filename, softwareModule));
double progress = (double) readBytes / (double) contentLength;
if (item != null) {
item.getItemProperty(PROGRESS).setValue(progress);
}
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
.collect(Collectors.toList());
if (!uploadStatusObjectList.isEmpty()) {
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
uploadStatusObject.setProgress(progress);
}
}
@@ -159,67 +355,142 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
*
* @param filename
* of the uploaded file.
* @param softwareModule
* selected software module
*/
public void uploadSucceeded(final String filename) {
final Item item = uploads.getItem(filename);
public void uploadSucceeded(final String filename, SoftwareModule softwareModule) {
final Item item = uploads.getItem(getItemid(filename, softwareModule));
String status = "Finished";
if (item != null) {
item.getItemProperty(STATUS).setValue("Finished");
item.getItemProperty(STATUS).setValue(status);
}
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
.collect(Collectors.toList());
if (!uploadStatusObjectList.isEmpty()) {
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
uploadStatusObject.setStatus(status);
uploadStatusObject.setProgress(1d);
}
}
void uploadFailed(final String filename, final String errorReason) {
final Item item = uploads.getItem(filename);
void uploadFailed(final String filename, final String errorReason, SoftwareModule softwareModule) {
errorOccured = true;
String status = "Failed";
final Item item = uploads.getItem(getItemid(filename, softwareModule));
if (item != null) {
if (!errorOccured) {
errorOccured = true;
}
item.getItemProperty(REASON).setValue(errorReason);
item.getItemProperty(STATUS).setValue("Failed");
item.getItemProperty(STATUS).setValue(status);
}
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
.collect(Collectors.toList());
if (!uploadStatusObjectList.isEmpty()) {
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
uploadStatusObject.setStatus(status);
uploadStatusObject.setReason(errorReason);
}
}
/*
* (non-Javadoc)
*
* @see com.vaadin.ui.Window.CloseListener#windowClose(com.vaadin.ui.Window.
* CloseEvent)
*/
@Override
public void windowClose(final CloseEvent e) {
clearWindow();
}
private void clearWindow() {
protected void clearWindow() {
errorOccured = false;
uploads.removeAllItems();
setWindowMode(WindowMode.NORMAL);
setColumnWidth();
setPopupSizeInMinMode();
resizeButton.setIcon(FontAwesome.EXPAND);
this.close();
artifactUploadState.getUploadedFileStatusList().clear();
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.ui.Window.WindowModeChangeListener#windowModeChanged(com.
* vaadin.ui.Window. WindowModeChangeEvent)
*/
@Override
public void windowModeChanged(final WindowModeChangeEvent event) {
if (event.getWindow().getWindowMode() == WindowMode.MAXIMIZED) {
private void setPopupSizeInMinMode() {
mainLayout.setWidth(900, Unit.PIXELS);
mainLayout.setHeight(510, Unit.PIXELS);
}
private Button getMinimizeButton() {
final Button minimizeBtn = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_MINIMIZE_BUTTON_ID, "", "", "", true, FontAwesome.MINUS,
SPUIButtonStyleSmallNoBorder.class);
minimizeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
minimizeBtn.addClickListener(event -> minimizeWindow());
minimizeBtn.setEnabled(true);
return minimizeBtn;
}
private Button getResizeButton() {
final Button resizeBtn = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_RESIZE_BUTTON_ID, "", "", "", true, FontAwesome.EXPAND,
SPUIButtonStyleSmallNoBorder.class);
resizeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
resizeBtn.addClickListener(event -> resizeWindow(event));
return resizeBtn;
}
private void resizeWindow(ClickEvent event) {
if (event.getButton().getIcon() == FontAwesome.EXPAND) {
event.getButton().setIcon(FontAwesome.COMPRESS);
setWindowMode(WindowMode.MAXIMIZED);
resetColumnWidth();
grid.getColumn(STATUS).setExpandRatio(0);
grid.getColumn(PROGRESS).setExpandRatio(1);
grid.getColumn(FILE_NAME).setExpandRatio(2);
grid.getColumn(REASON).setExpandRatio(3);
grid.setSizeFull();
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setExpandRatio(4);
mainLayout.setSizeFull();
} else {
event.getButton().setIcon(FontAwesome.EXPAND);
setWindowMode(WindowMode.NORMAL);
setColumnWidth();
setPopupSizeInMinMode();
}
}
private void setPopupSizeInMinMode() {
grid.setWidth(800, Unit.PIXELS);
grid.setHeight(510, Unit.PIXELS);
private void minimizeWindow() {
this.close();
artifactUploadState.setStatusPopupMinimized(true);
eventBus.publish(this, UploadArtifactUIEvent.MINIMIZED_STATUS_POPUP);
}
private Button getCloseButton() {
final Button closeBtn = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_CLOSE_BUTTON_ID, "", "", "", true, FontAwesome.TIMES,
SPUIButtonStyleSmallNoBorder.class);
closeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
closeBtn.addClickListener(event -> onClose());
return closeBtn;
}
private void onClose() {
if (!artifactUploadState.isUploadCompleted()) {
confirmAbortAction();
} else {
clearWindow();
}
}
private void confirmAbortAction() {
UI.getCurrent().addWindow(confirmDialog.getWindow());
confirmDialog.getWindow().bringToFront();
}
private void createConfirmDialog() {
confirmDialog = new ConfirmationDialog(i18n.get("caption.confirm.abort.action"),
i18n.get("message.abort.upload"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
if (ok) {
eventBus.publish(this, UploadStatusEventType.ABORT_UPLOAD);
uploadAborted = true;
errorOccured = true;
minimizeButton.setEnabled(false);
closeButton.setEnabled(false);
}
});
}
private String getItemid(final String filename, final SoftwareModule softwareModule) {
return new StringBuilder(filename).append(
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()))
.toString();
}
}

View File

@@ -0,0 +1,86 @@
/**
* 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.artifacts.upload;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
*
* Holds uploaded file status.Used to display the details in upload status
* popup.
*
*/
public class UploadStatusObject {
private String status;
private Double progress;
private String filename;
private String reason;
private SoftwareModule selectedSoftwareModule;
public UploadStatusObject(final String status, final Double progress, final String fileName, final String reason,
final SoftwareModule selectedSoftwareModule) {
this(fileName,selectedSoftwareModule);
this.status = status;
this.progress = progress;
this.reason = reason;
}
public UploadStatusObject(String fileName, SoftwareModule selectedSoftwareModule) {
this.filename = fileName;
this.selectedSoftwareModule = selectedSoftwareModule;
}
public SoftwareModule getSelectedSoftwareModule() {
return selectedSoftwareModule;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getProgress() {
return progress;
}
public void setProgress(Double progress) {
this.progress = progress;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
@Override
public boolean equals(Object obj) {
if (this == null || obj == null) {
return false;
}
if (obj instanceof UploadStatusObject && this.getFilename() == ((UploadStatusObject) obj).getFilename()) {
return true;
}
return false;
}
}

View File

@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.server.Resource;
@@ -82,7 +82,7 @@ public class ConfirmationDialog implements Button.ClickListener {
window.setIcon(icon);
}
okButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.OK_BUTTON, okLabel, "",
okButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.OK_BUTTON, okLabel, "",
ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
okButton.addClickListener(this);

View File

@@ -0,0 +1,100 @@
/**
* 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.common;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.model.DistributionSet;
/**
*
*
*/
public class DistributionSetIdName implements Serializable {
private static final long serialVersionUID = 1L;
private final Long id;
private final String name;
private final String version;
public static DistributionSetIdName generate(final DistributionSet distributionSet) {
return new DistributionSetIdName(distributionSet.getId(), distributionSet.getName(),
distributionSet.getVersion());
}
public static DistributionSetIdName generate(final Long id, final String name, final String version) {
return new DistributionSetIdName(id, name, version);
}
/**
* @param id
* the {@link DistributionSet#getId()}
* @param name
* the {@link DistributionSet#getName()}
* @param version
* the {@link DistributionSet#getVersion()}
*
*/
public DistributionSetIdName(final Long id, final String name, final String version) {
this.id = id;
this.name = name;
this.version = version;
}
public Long getId() {
return id;
}
public String getVersion() {
return version;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (id == null ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DistributionSetIdName)) {
return false;
}
final DistributionSetIdName other = (DistributionSetIdName) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return id.toString();
}
}

View File

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -41,6 +42,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
private final Sort sort = new Sort(Direction.ASC, "name");
private transient Page<DistributionSetType> firstPageDistSetType = null;
private transient DistributionSetManagement distributionSetManagement;
private transient EntityFactory entityFactory;
/**
* Parametric constructor.
@@ -57,8 +59,9 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
@Override
protected DistributionSetType constructBean() {
return new DistributionSetType("", "", "", "");
final DistributionSetType result = getEntityFactory().generateDistributionSetType("", "", "");
result.setColour("");
return result;
}
@Override
@@ -80,6 +83,13 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
return distributionSetManagement;
}
private EntityFactory getEntityFactory() {
if (entityFactory == null) {
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
return entityFactory;
}
@Override
protected List<DistributionSetType> loadBeans(final int startIndex, final int count) {
Page<DistributionSetType> typeBeans;

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.common;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -31,6 +32,7 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
private final Sort sort = new Sort(Direction.ASC, "name");
private transient Page<SoftwareModuleType> firstPageSwModuleType = null;
private transient SoftwareManagement softwareManagement;
private transient EntityFactory entityFactory;
/**
* Parametric constructor.
@@ -47,7 +49,14 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
@Override
protected SoftwareModuleType constructBean() {
return new SoftwareModuleType();
return getEntityFactory().generateSoftwareModuleType();
}
private EntityFactory getEntityFactory() {
if (entityFactory == null) {
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
return entityFactory;
}
@Override

View File

@@ -0,0 +1,187 @@
/**
* 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.common;
import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import com.vaadin.server.VaadinService;
/**
* A Utility class to user details e.g. username
*/
public final class UserDetailsFormatter {
private static final String TRIM_APPENDIX = "...";
private static final String DETAIL_SEPERATOR = ", ";
private UserDetailsFormatter() {
}
/**
* Load user details by the user name and format the user name to max 100
* characters.
*
* @see {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
*
* @param username
* the user name
* @return the formatted user name (max 100 characters) cannot be <null>
*/
public static String loadAndFormatUsername(final String username) {
return loadAndFormatUsername(username, 100);
}
/**
* Load user details by {@link BaseEntity#getCreatedBy()} and format the
* user name. Use {@link UserDetailsFormatter#loadAndFormatUsername(String)}
*
* @param baseEntity
* the entity
* @return the formatted 'created at user name' (max 100 characters) cannot
* be <null>
*/
public static String loadAndFormatCreatedBy(final BaseEntity baseEntity) {
if (baseEntity == null || baseEntity.getCreatedBy() == null) {
return StringUtils.EMPTY;
}
return loadAndFormatUsername(baseEntity.getCreatedBy());
}
/**
* Load user details by {@link BaseEntity#getLastModifiedBy()} and format
* the user name. Use
* {@link UserDetailsFormatter#loadAndFormatUsername(String)}
*
* @param baseEntity
* the entity
* @return the formatted 'last modefied by user name' (max 100 characters)
* cannot be <null>
*/
public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
if (baseEntity == null || baseEntity.getLastModifiedBy() == null) {
return StringUtils.EMPTY;
}
return loadAndFormatUsername(baseEntity.getLastModifiedBy());
}
/**
* Load user details by the current session information and format the user
* name to max 12 characters. @see
* {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
*
* @return the formatted user name (max 12 characters) cannot be <null>
*/
public static String formatCurrentUsername() {
return loadAndFormatUsername(getCurrentUser().getUsername(), 5);
}
/**
* Load user details by the user name and format the user name. If the
* loaded {@link UserDetails} is not an instance of a {@link UserPrincipal},
* then just the {@link UserDetails#getUsername()} will return.
*
* If first and last name available, they will combined. Otherwise the
* {@link UserPrincipal#getLoginname()} will formatted. The formatted name
* is reduced to 100 characters.
*
* @param username
* the user name
* @param expectedNameLength
* the name size of each name part
* @return the formatted user name (max expectedNameLength characters)
* cannot be <null>
*/
public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
final UserDetails userDetails = loadUserByUsername(username);
return formatUserName(expectedNameLength, userDetails);
}
private static String formatUserName(final int expectedNameLength, final UserDetails userDetails) {
if (!(userDetails instanceof UserPrincipal)) {
return userDetails.getUsername();
}
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
String firstname = StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), StringUtils.EMPTY);
if (!StringUtils.isEmpty(firstname)) {
firstname += DETAIL_SEPERATOR;
}
final String firstAndLastname = firstname
+ StringUtils.defaultIfEmpty(userPrincipal.getLastname(), StringUtils.EMPTY);
final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength);
if (StringUtils.isEmpty(trimmedUsername)) {
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
}
return trimmedUsername;
}
/**
* Format the current tenant. The information is loaded by the current
* session information.
*
* @return the formatted user name (max 8 characters) can be <null>
*/
public static String formatCurrentTenant() {
final UserDetails userDetails = getCurrentUser();
if (!(userDetails instanceof UserPrincipal)) {
return null;
}
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
return trimAndFormatDetail(userPrincipal.getTenant(), 8);
}
private static UserDetails getCurrentUser() {
final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession()
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
return (UserDetails) context.getAuthentication().getPrincipal();
}
private static String trimAndFormatDetail(final String formatString, final int expectedDetailLength) {
final String detail = StringUtils.defaultIfEmpty(formatString, StringUtils.EMPTY);
final String trimmedDetail = StringUtils.substring(detail, 0, expectedDetailLength);
if (StringUtils.length(detail) > expectedDetailLength) {
return trimmedDetail + TRIM_APPENDIX;
}
return trimmedDetail;
}
// Exception squid:S1166 - exception has to be hidden
@SuppressWarnings({ "squid:S1166" })
private static UserDetails loadUserByUsername(final String username) {
final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
try {
final UserDetails loadUserByUsername = userDetailsService.loadUserByUsername(username);
if (loadUserByUsername == null) {
throw new UsernameNotFoundException("User not found " + username);
}
return loadUserByUsername;
} catch (final UsernameNotFoundException e) {
return new User(username, "", Collections.emptyList());
}
}
}

View File

@@ -16,7 +16,7 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -67,7 +67,7 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
private void createActionMessgaeLabel() {
actionMessage = SPUIComponentProvider.getLabel("", null);
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
actionMessage.setId(SPUIComponetIdProvider.ACTION_LABEL);
actionMessage.setId(SPUIComponentIdProvider.ACTION_LABEL);
actionMessage.setVisible(false);
}

View File

@@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -150,20 +150,20 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private void buildLayout() {
final HorizontalLayout nameEditLayout = new HorizontalLayout();
nameEditLayout.setWidth(100.0f, Unit.PERCENTAGE);
nameEditLayout.setWidth(100.0F, Unit.PERCENTAGE);
nameEditLayout.addComponent(caption);
nameEditLayout.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);
nameEditLayout.setComponentAlignment(caption, Alignment.TOP_LEFT);
if (hasEditPermission()) {
nameEditLayout.addComponent(editButton);
nameEditLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT);
nameEditLayout.setComponentAlignment(editButton, Alignment.TOP_RIGHT);
}
nameEditLayout.setExpandRatio(caption, 1.0f);
nameEditLayout.setExpandRatio(caption, 1.0F);
nameEditLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
addComponent(nameEditLayout);
setComponentAlignment(nameEditLayout, Alignment.MIDDLE_CENTER);
setComponentAlignment(nameEditLayout, Alignment.TOP_CENTER);
addComponent(detailsTab);
setComponentAlignment(nameEditLayout, Alignment.MIDDLE_CENTER);
setComponentAlignment(nameEditLayout, Alignment.TOP_CENTER);
setSizeFull();
setHeightUndefined();
@@ -171,9 +171,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
}
private Label createHeaderCaption() {
final Label captionLabel = SPUIComponentProvider.getLabel(getDefaultCaption(),
SPUILabelDefinitions.SP_WIDGET_CAPTION);
return captionLabel;
return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
}
protected VerticalLayout getTabLayout() {
@@ -213,22 +211,22 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
populateDetailsWidget();
}
protected void updateLogLayout(final VerticalLayout changeLogLayout, final Long lastModifiedAt,
final String lastModifiedBy, final Long createdAt, final String createdBy, final I18N i18n) {
changeLogLayout.removeAllComponents();
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
createdAt == null ? "" : SPDateTimeUtil.getFormattedDate(createdAt)));
protected void populateLog() {
logLayout.removeAllComponents();
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"),
createdBy == null ? "" : HawkbitCommonUtil.getIMUser(createdBy)));
logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
SPDateTimeUtil.formatCreatedAt(selectedBaseEntity)));
if (null != lastModifiedAt) {
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"),
SPDateTimeUtil.getFormattedDate(lastModifiedAt)));
logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity));
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"),
lastModifiedBy == null ? "" : HawkbitCommonUtil.getIMUser(lastModifiedBy)));
if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) {
return;
}
logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"),
SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity)));
logLayout.addComponent(SPUIComponentProvider.createLastModifiedByLabel(i18n, selectedBaseEntity));
}
protected void updateDescriptionLayout(final String descriptionLabel, final String description) {
@@ -240,7 +238,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
* it as we need full description.
*/
descLabel.removeStyleName("label-style");
descLabel.setId(SPUIComponetIdProvider.DETAILS_DESCRIPTION_LABEL_ID);
descLabel.setId(SPUIComponentIdProvider.DETAILS_DESCRIPTION_LABEL_ID);
descriptionLayout.addComponent(descLabel);
}
@@ -320,19 +318,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
return detailsLayout;
}
public VerticalLayout getLogLayout() {
return logLayout;
}
private void populateLog() {
if (selectedBaseEntity == null) {
updateLogLayout(getLogLayout(), null, StringUtils.EMPTY, null, null, i18n);
return;
}
updateLogLayout(getLogLayout(), selectedBaseEntity.getLastModifiedAt(), selectedBaseEntity.getLastModifiedBy(),
selectedBaseEntity.getCreatedAt(), selectedBaseEntity.getCreatedBy(), i18n);
}
private void populateDescription() {
if (selectedBaseEntity != null) {
updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription());

View File

@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.exception.EntityLockedException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -214,7 +215,7 @@ public class SoftwareModuleDetailsTable extends Table {
.getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules);
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
unAssignedSw);
manageDistUIState.setLastSelectedEntity(newDistributionSet.getDistributionSetIdName());
manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet));
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -130,7 +130,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
addComponent(hLayout);
setComponentAlignment(hLayout, Alignment.BOTTOM_CENTER);
}
setStyleName("footer-layout");
setStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
setWidth("100%");
}
@@ -154,7 +154,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
private Button createActionsButton() {
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.PENDING_ACTION_BUTTON,
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.PENDING_ACTION_BUTTON,
getNoActionsButtonLabel(), "", "", false, FontAwesome.BELL, SPUIButtonStyleSmall.class);
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
button.addStyleName("del-action-button");
@@ -165,10 +165,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
private Button createBulkUploadStatusButton() {
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "",
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "",
"", false, null, SPUIButtonStyleSmall.class);
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
button.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
button.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
button.setWidth("100px");
button.setHtmlContentAllowed(true);
button.addClickListener(event -> onClickBulkUploadNotificationButton());
@@ -199,7 +199,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
}
@@ -207,7 +207,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(null);
}
@@ -216,10 +216,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
return;
}
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
SPUIComponetIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
SPUIComponentIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
unsavedActionsWindow.setId(SPUIComponetIdProvider.CONFIRMATION_POPUP_ID);
unsavedActionsWindow.setId(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID);
UI.getCurrent().addWindow(unsavedActionsWindow);
}

View File

@@ -8,7 +8,8 @@
*/
package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
@@ -70,9 +71,9 @@ public abstract class AbstractGridLayout extends VerticalLayout {
private HorizontalLayout createCountMessageComponent() {
final HorizontalLayout rolloutGroupTargetsCountLayout = new HorizontalLayout();
final Label countMessageLabel = getCountMessageLabel();
countMessageLabel.setId(SPUIComponetIdProvider.ROLLOUT_GROUP_TARGET_LABEL);
countMessageLabel.setId(SPUIComponentIdProvider.ROLLOUT_GROUP_TARGET_LABEL);
rolloutGroupTargetsCountLayout.addComponent(getCountMessageLabel());
rolloutGroupTargetsCountLayout.setStyleName("footer-layout");
rolloutGroupTargetsCountLayout.setStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
rolloutGroupTargetsCountLayout.setWidth("100%");
return rolloutGroupTargetsCountLayout;

View File

@@ -20,7 +20,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -213,9 +213,9 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getCreatedBy()));
.setValue(UserDetailsFormatter.loadAndFormatCreatedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getLastModifiedBy()));
.setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
@@ -330,6 +330,17 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
setItemDescriptionGenerator((source, itemId, propertyId) -> {
if (SPUILabelDefinitions.VAR_CREATED_BY.equals(propertyId)) {
return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).getValue().toString();
}
if (SPUILabelDefinitions.VAR_LAST_MODIFIED_BY.equals(propertyId)) {
return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).getValue().toString();
}
return null;
});
return columnList;
}

View File

@@ -44,7 +44,7 @@ import com.vaadin.ui.VerticalLayout;
public abstract class AbstractTableHeader extends VerticalLayout {
private static final long serialVersionUID = 4881626370291837175L;
@Autowired
protected I18N i18n;
@@ -53,7 +53,6 @@ public abstract class AbstractTableHeader extends VerticalLayout {
@Autowired
protected transient EventBus.SessionEventBus eventbus;
private Label headerCaption;
@@ -83,7 +82,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
restoreState();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
@@ -171,8 +170,8 @@ public abstract class AbstractTableHeader extends VerticalLayout {
}
titleFilterIconsLayout.addComponent(maxMinIcon);
titleFilterIconsLayout.setComponentAlignment(maxMinIcon, Alignment.TOP_RIGHT);
titleFilterIconsLayout.setExpandRatio(headerCaption, 0.4f);
titleFilterIconsLayout.setExpandRatio(searchField, 0.6f);
titleFilterIconsLayout.setExpandRatio(headerCaption, 0.4F);
titleFilterIconsLayout.setExpandRatio(searchField, 0.6F);
addComponent(titleFilterIconsLayout);
@@ -192,10 +191,10 @@ public abstract class AbstractTableHeader extends VerticalLayout {
dropHintDropFilterLayout.addComponent(dropFilterLayout);
dropHintDropFilterLayout.setComponentAlignment(dropFilterLayout, Alignment.TOP_CENTER);
dropHintDropFilterLayout.setExpandRatio(dropFilterLayout, 1.0f);
dropHintDropFilterLayout.setExpandRatio(dropFilterLayout, 1.0F);
}
addComponent(dropHintDropFilterLayout);
setComponentAlignment(dropHintDropFilterLayout, Alignment.MIDDLE_CENTER);
setComponentAlignment(dropHintDropFilterLayout, Alignment.TOP_CENTER);
addStyleName("bordered-layout");
addStyleName("no-border-bottom");
}

View File

@@ -8,9 +8,9 @@
*/
package org.eclipse.hawkbit.ui.common.tagdetails;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -14,12 +14,12 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;

View File

@@ -14,9 +14,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;

View File

@@ -9,13 +9,14 @@
package org.eclipse.hawkbit.ui.components;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
/**
* Proxy for {@link DistributionSet}.
*
*
*/
public class ProxyDistribution extends DistributionSet {
public class ProxyDistribution {
private static final long serialVersionUID = -8891449133620645310L;
@@ -33,6 +34,11 @@ public class ProxyDistribution extends DistributionSet {
private String nameVersion;
private Long id;
private String name;
private String version;
private String description;
/**
* @return the nameVersion
*/
@@ -40,6 +46,10 @@ public class ProxyDistribution extends DistributionSet {
return nameVersion;
}
public DistributionSetIdName getDistributionSetIdName() {
return DistributionSetIdName.generate(id, name, version);
}
/**
* @param nameVersion
* the nameVersion to set
@@ -96,4 +106,36 @@ public class ProxyDistribution extends DistributionSet {
this.modifiedByUser = modifiedByUser;
}
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getVersion() {
return version;
}
public void setVersion(final String version) {
this.version = version;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
}

View File

@@ -8,34 +8,39 @@
*/
package org.eclipse.hawkbit.ui.components;
import java.io.Serializable;
import java.net.URI;
import java.security.SecureRandom;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
/**
* Proxy for {@link Target}.
*
*
*
*
*/
/**
* @author kaizimmerm
*
*/
public class ProxyTarget extends Target {
public class ProxyTarget implements Serializable {
private static final long serialVersionUID = -8891449133620645310L;
private String controllerId;
private URI address = null;
private Long lastTargetQuery = null;
private Long installationDate;
private Long id;
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
private DistributionSet installedDistributionSet;
private DistributionSet assignedDistributionSet;
private TargetIdName targetIdName;
private String assignedDistNameVersion;
@@ -54,11 +59,58 @@ public class ProxyTarget extends Target {
private Status status;
private String name;
private String description;
private Long createdAt;
private TargetInfo targetInfo;
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
public Long getCreatedAt() {
return createdAt;
}
public void setCreatedAt(final Long createdAt) {
this.createdAt = createdAt;
}
public TargetInfo getTargetInfo() {
return targetInfo;
}
public void setTargetInfo(final TargetInfo targetInfo) {
this.targetInfo = targetInfo;
}
/**
* @param controllerId
*/
public ProxyTarget() {
super(null);
final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE;
targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString());
}
@@ -158,7 +210,6 @@ public class ProxyTarget extends Target {
*
* @return String as ID.
*/
@Override
public String getControllerId() {
return controllerId;
}
@@ -169,7 +220,6 @@ public class ProxyTarget extends Target {
* @param controllerId
* as ID
*/
@Override
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
@@ -249,14 +299,25 @@ public class ProxyTarget extends Target {
this.installedDistributionSet = installedDistributionSet;
}
/**
* @return the assignedDistributionSet
*/
public DistributionSet getAssignedDistributionSet() {
return assignedDistributionSet;
}
/**
* @param assignedDistributionSet
* the assignedDistributionSet to set
*/
public void setAssignedDistributionSet(final DistributionSet assignedDistributionSet) {
this.assignedDistributionSet = assignedDistributionSet;
}
/**
* @return the targetIdName
*/
@Override
public TargetIdName getTargetIdName() {
if (this.targetIdName == null) {
return super.getTargetIdName();
}
return this.targetIdName;
}
@@ -297,4 +358,5 @@ public class ProxyTarget extends Target {
public void setStatus(final Status status) {
this.status = status;
}
}

View File

@@ -8,14 +8,12 @@
*/
package org.eclipse.hawkbit.ui.components;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/**
*
*
*
*/
public class ProxyTargetFilter extends TargetFilterQuery {
public class ProxyTargetFilter {
private static final long serialVersionUID = 6622060929679084419L;
@@ -23,6 +21,12 @@ public class ProxyTargetFilter extends TargetFilterQuery {
private String modifiedDate;
private String name;
private Long id;
private String createdBy;
private String lastModifiedBy;
private String query;
public String getCreatedDate() {
return createdDate;
}
@@ -46,4 +50,44 @@ public class ProxyTargetFilter extends TargetFilterQuery {
this.modifiedDate = modifiedDate;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(final String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public String getQuery() {
return query;
}
public void setQuery(final String query) {
this.query = query;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(final String createdBy) {
this.createdBy = createdBy;
}
}

View File

@@ -12,7 +12,9 @@ import java.util.Arrays;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIHeaderLayoutDecorator;
@@ -20,6 +22,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -328,6 +331,50 @@ public final class SPUIComponentProvider {
return nameValueLabel;
}
private static Label createUsernameLabel(final String label, final String username) {
String loadAndFormatUsername = StringUtils.EMPTY;
if (!StringUtils.isEmpty(username)) {
loadAndFormatUsername = UserDetailsFormatter.loadAndFormatUsername(username);
}
final Label nameValueLabel = new Label(getBoldHTMLText(label) + loadAndFormatUsername, ContentMode.HTML);
nameValueLabel.setSizeFull();
nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
nameValueLabel.addStyleName("label-style");
nameValueLabel.setDescription(loadAndFormatUsername);
return nameValueLabel;
}
/**
* Create label which represents the {@link BaseEntity#getCreatedBy()} by
* user name
*
* @param i18n
* the i18n
* @param baseEntity
* the entity
* @return the label
*/
public static Label createCreatedByLabel(final I18N i18n, final BaseEntity baseEntity) {
return createUsernameLabel(i18n.get("label.created.by"),
baseEntity == null ? StringUtils.EMPTY : baseEntity.getCreatedBy());
}
/**
* Create label which represents the
* {@link BaseEntity#getLastModifiedBy()()} by user name
*
* @param i18n
* the i18n
* @param baseEntity
* the entity
* @return the label
*/
public static Label createLastModifiedByLabel(final I18N i18n, final BaseEntity baseEntity) {
return createUsernameLabel(i18n.get("label.modified.by"),
baseEntity == null ? StringUtils.EMPTY : baseEntity.getLastModifiedBy());
}
/**
* Get Bold Text.
*

View File

@@ -1,29 +0,0 @@
/**
* 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.customrenderers.client;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import com.vaadin.client.connectors.ButtonRendererConnector;
import com.vaadin.shared.ui.Connect;
/**
*
* A connector for {@link LinkRenderer}.
*
*/
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer.class)
public class LinkRendererConnector extends ButtonRendererConnector {
private static final long serialVersionUID = 7987417436367399331L;
@Override
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.LinkRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.LinkRenderer) super.getRenderer();
}
}

View File

@@ -0,0 +1,37 @@
/**
* 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.customrenderers.client;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.client.connectors.ClickableRendererConnector;
import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler;
import com.vaadin.shared.ui.Connect;
import elemental.json.JsonObject;
/**
* A connector for {@link CustomObjectRenderer }.
*
*/
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer.class)
public class RolloutRendererConnector extends ClickableRendererConnector<RolloutRendererData> {
private static final long serialVersionUID = 7734682321931830566L;
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
}
@Override
protected HandlerRegistration addClickHandler(
RendererClickHandler<JsonObject> handler) {
return getRenderer().addClickHandler(handler);
}
}

View File

@@ -1,42 +0,0 @@
/**
* 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.customrenderers.client.renderers;
import com.google.gwt.user.client.ui.Button;
import com.vaadin.client.renderers.ButtonRenderer;
import com.vaadin.client.ui.VButton;
import com.vaadin.client.widget.grid.RendererCellReference;
/**
*
* Renders link with provided text.
*
*/
public class LinkRenderer extends ButtonRenderer {
@Override
public void render(RendererCellReference cell, String text, Button button) {
button.setText(text);
applystyle(button);
// this is to allow the button to disappear, if the text is null
button.setVisible(text != null);
button.getElement().setId(new StringBuilder("link").append(".").append(text).toString());
}
private void applystyle(Button button) {
button.setStyleName(VButton.CLASSNAME);
button.addStyleName(getStyle("borderless"));
button.addStyleName(getStyle("small"));
button.addStyleName(getStyle("on-focus-no-border"));
button.addStyleName(getStyle("link"));
}
private String getStyle(final String style) {
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
}
}

View File

@@ -0,0 +1,65 @@
/**
* 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.customrenderers.client.renderers;
import com.google.gwt.core.shared.GWT;
import com.vaadin.client.renderers.ClickableRenderer;
import com.vaadin.client.ui.VButton;
import com.vaadin.client.widget.grid.RendererCellReference;
/**
* Renders button with provided CustomObject.
* Used to display button with link.
*
*/
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData, VButton> {
@Override
public VButton createWidget() {
VButton b = GWT.create(VButton.class);
b.addClickHandler(this);
b.setStylePrimaryName("v-nativebutton");
return b;
}
@Override
public void render(RendererCellReference cell, RolloutRendererData text, VButton button) {
final String creating = "CREATING";
button.setText(text.getName());
applystyle(button);
// this is to allow the button to disappear, if the text is null
button.setVisible(text.getName() != null);
button.getElement().setId(new StringBuilder("link").append(".").append(text.getName()).toString());
/*
* checking Rollout Status for applying button style. If Rollout status
* is not "CREATING", then the Rollout button is applying hyperlink
* style
*/
final boolean isStatusCreate = text.getStatus() != null && creating.equalsIgnoreCase(text.getStatus());
if (isStatusCreate) {
button.addStyleName(getStyle("boldhide"));
button.setEnabled(false);
} else {
button.setEnabled(true);
}
}
private void applystyle(VButton button) {
button.setStyleName(VButton.CLASSNAME);
button.addStyleName(getStyle("borderless"));
button.addStyleName(getStyle("small"));
button.addStyleName(getStyle("on-focus-no-border"));
button.addStyleName(getStyle("link"));
}
private String getStyle(final String style) {
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
}
}

View File

@@ -0,0 +1,62 @@
/**
* 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.customrenderers.client.renderers;
import java.io.Serializable;
/**
* RendererData class with Name and Status.
*
*/
public class RolloutRendererData implements Serializable {
private static final long serialVersionUID = -5018181529953620263L;
private String name;
private String status;
/**
* Initialize the RendererData.
*/
public RolloutRendererData() {
}
/**
* Initialize the RendererData.
*
* @param name
* Name of the Rollout.
* @param status
* Status of Rollout.
*/
public RolloutRendererData(String name, String status) {
super();
this.name = name;
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}

View File

@@ -1,37 +0,0 @@
/**
* 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.customrenderers.renderers;
import com.vaadin.ui.renderers.ButtonRenderer;
/**
*
* Renders link with provided text.
*
*/
public class LinkRenderer extends ButtonRenderer {
private static final long serialVersionUID = -1242995370043404892L;
/**
* Intialise link renderer.
*/
public LinkRenderer() {
super();
}
/**
* Intialise link renderer with {@link RendererClickListener}
*
* @param listener
* RendererClickListener
*/
public LinkRenderer(RendererClickListener listener) {
super(listener);
}
}

View File

@@ -0,0 +1,61 @@
/**
* 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.customrenderers.renderers;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.ui.renderers.ClickableRenderer;
import elemental.json.JsonValue;
/**
* Renders button with provided CustomObject.
* Used to display button with link.
*
*/
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
private static final long serialVersionUID = -8754180585906263554L;
/**
* Creates a new custom object renderer.
*/
public RolloutRenderer() {
super(RolloutRendererData.class, null);
}
/**
* Initialize custom object renderer with {@link Class<CustomObject>}
*
* @param presentationType
* Class<CustomObject>
*/
public RolloutRenderer(Class<RolloutRendererData> presentationType) {
super(presentationType);
}
/**
* Creates a new custom object renderer and adds the given click listener to it.
*
* @param listener
* the click listener to register
*/
public RolloutRenderer(RendererClickListener listener) {
this();
addClickListener(listener);
}
@Override
public JsonValue encode(RolloutRendererData resource) {
return super.encode(resource, RolloutRendererData.class);
}
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetRepository;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.Distr
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -114,7 +114,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
private transient DistributionSetManagement distributionSetManagement;
@Autowired
private transient DistributionSetRepository distributionSetRepository;
private transient EntityFactory entityFactory;
/**
* Instance of ColorPickerPreview.
@@ -205,7 +205,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
tagColorPreviewBtn = new Button();
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
getPreviewButtonColor(DEFAULT_COLOR);
tagColorPreviewBtn.setStyleName("tag-color-preview");
@@ -299,6 +299,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
mainWindowLayout.addComponent(colorLayout);
mainWindowLayout.addComponent(buttonLayout);
setCompositionRoot(mainWindowLayout);
typeName.focus();
}
private HorizontalLayout createTwinColumnLayout() {
@@ -653,7 +654,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
if (null != typeNameValue && null != typeKeyValue && null != itemIds && !itemIds.isEmpty()) {
DistributionSetType newDistType = new DistributionSetType(typeKeyValue, typeNameValue, typeDescValue);
DistributionSetType newDistType = entityFactory.generateDistributionSetType(typeKeyValue, typeNameValue,
typeDescValue);
for (final Long id : itemIds) {
final Item item = selectedTable.getItem(id);
final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue();
@@ -703,7 +705,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
updateDistSetType.setKey(typeKeyValue);
updateDistSetType.setDescription(null != typeDescValue ? typeDescValue : null);
if (distributionSetRepository.countByType(existingType) <= 0 && null != itemIds && !itemIds.isEmpty()) {
if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds
&& !itemIds.isEmpty()) {
for (final Long id : itemIds) {
final Item item = selectedTable.getItem(id);
final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue();
@@ -1039,7 +1042,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
typeDesc.setValue(selectedTypeTag.getDescription());
typeKey.setValue(selectedTypeTag.getKey());
if (distributionSetRepository.countByType(selectedTypeTag) <= 0) {
if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag) <= 0) {
distTypeSelectLayout.setEnabled(true);
selectedTable.setEnabled(true);
saveDistSetType.setEnabled(true);

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteri
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -50,7 +50,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.DISTRIBUTION_SET_TYPE_TABLE_ID;
return SPUIComponentIdProvider.DISTRIBUTION_SET_TYPE_TABLE_ID;
}
@Override
@@ -68,7 +68,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String createButtonId(final String name) {
return SPUIComponetIdProvider.DS_TYPE_FILTER_BTN_ID + name;
return SPUIComponentIdProvider.DS_TYPE_FILTER_BTN_ID + name;
}
@Override

View File

@@ -16,11 +16,11 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
@@ -32,7 +32,7 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -246,7 +246,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
@@ -268,7 +268,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
return SPUIComponentIdProvider.DS_EDIT_BUTTON;
}
@Override
@@ -358,7 +358,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Override
protected String getDetailsHeaderCaptionId() {
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
}
}

View File

@@ -21,13 +21,12 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -41,7 +40,7 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -123,7 +122,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
protected String getTableId() {
return SPUIComponetIdProvider.DIST_TABLE_ID;
return SPUIComponentIdProvider.DIST_TABLE_ID;
}
@Override
@@ -325,11 +324,11 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
if (!validateSoftwareModule(sm, ds)) {
return false;
}
try {
distributionSetManagement.checkDistributionSetAlreadyUse(ds);
} catch (final EntityLockedException exception) {
LOG.error("Unable to update distribution : ", exception);
notification.displayValidationError(exception.getMessage());
if (distributionSetManagement.isDistributionSetInUse(ds)) {
notification.displayValidationError(
String.format("Distribution set %s:%s is already assigned to targets and cannot be changed",
ds.getName(), ds.getVersion()));
return false;
}
return true;
@@ -395,7 +394,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
final Component compsource = dragEvent.getTransferable().getSourceComponent();
final Table source = (Table) compsource;
if (compsource instanceof Table) {
if (!source.getId().equals(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
if (!source.getId().equals(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
notification.displayValidationError(i18n.get("message.action.not.allowed"));
return false;
}
@@ -457,7 +456,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
}
select(baseEntity.getDistributionSetIdName());
select(DistributionSetIdName.generate(baseEntity));
return item;
}

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -57,17 +57,17 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
@Override
protected String getSearchBoxId() {
return SPUIComponetIdProvider.DIST_SEARCH_TEXTFIELD;
return SPUIComponentIdProvider.DIST_SEARCH_TEXTFIELD;
}
@Override
protected String getSearchRestIconId() {
return SPUIComponetIdProvider.DIST_SEARCH_ICON;
return SPUIComponentIdProvider.DIST_SEARCH_ICON;
}
@Override
protected String getAddIconId() {
return SPUIComponetIdProvider.DIST_ADD_ICON;
return SPUIComponentIdProvider.DIST_ADD_ICON;
}
@Override
@@ -119,7 +119,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
@Override
protected String getMaxMinIconId() {
return SPUIComponetIdProvider.DS_MAX_MIN_TABLE_ICON;
return SPUIComponentIdProvider.DS_MAX_MIN_TABLE_ICON;
}
@Override

View File

@@ -14,12 +14,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetFilter;
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -94,8 +95,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
distBeans = firstPageDistributionSets;
} else if (Strings.isNullOrEmpty(searchText)) {
// if no search filters available
distBeans = getDistributionSetManagement()
.findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, null);
distBeans = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
new OffsetBasedPageRequest(startIndex, count, sort), false, null);
} else {
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build();
@@ -112,9 +113,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
proxyDistribution.setVersion(distributionSet.getVersion());
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistributions.add(proxyDistribution);
}
@@ -131,8 +131,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
public int size() {
if (Strings.isNullOrEmpty(searchText) && null == distributionSetType) {
// if no search filters available
firstPageDistributionSets = getDistributionSetManagement()
.findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null);
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null);
} else {
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build();

View File

@@ -1,60 +1,60 @@
package org.eclipse.hawkbit.ui.distributions.event;
/**
* 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
*/
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class DistributionSetTableEvent extends BaseEntityEvent<DistributionSet> {
/**
* DistributionSet table components events.
*
*/
public enum DistributionSetComponentEvent {
SELECT_ALL
}
private DistributionSetComponentEvent distributionSetComponentEvent;
/**
* Constructor.
*
* @param eventType
* the event type.
* @param entity
* the entity
*/
public DistributionSetTableEvent(final BaseEntityEventType eventType, final DistributionSet entity) {
super(eventType, entity);
}
/**
* The component event.
*
* @param DistributionSetTableEvent
* the distributionSet component event.
*/
public DistributionSetTableEvent(final DistributionSetComponentEvent distributionSetComponentEvent) {
super(null, null);
this.distributionSetComponentEvent = distributionSetComponentEvent;
}
public DistributionSetComponentEvent getDistributionSetComponentEvent() {
return distributionSetComponentEvent;
}
}
package org.eclipse.hawkbit.ui.distributions.event;
/**
* 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
*/
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class DistributionSetTableEvent extends BaseEntityEvent<DistributionSet> {
/**
* DistributionSet table components events.
*
*/
public enum DistributionSetComponentEvent {
SELECT_ALL
}
private DistributionSetComponentEvent distributionSetComponentEvent;
/**
* Constructor.
*
* @param eventType
* the event type.
* @param entity
* the entity
*/
public DistributionSetTableEvent(final BaseEntityEventType eventType, final DistributionSet entity) {
super(eventType, entity);
}
/**
* The component event.
*
* @param DistributionSetTableEvent
* the distributionSet component event.
*/
public DistributionSetTableEvent(final DistributionSetComponentEvent distributionSetComponentEvent) {
super(null, null);
this.distributionSetComponentEvent = distributionSetComponentEvent;
}
public DistributionSetComponentEvent getDistributionSetComponentEvent() {
return distributionSetComponentEvent;
}
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import com.vaadin.spring.annotation.SpringComponent;
@@ -69,14 +69,14 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
final Map<String, List<String>> config = new HashMap<>();
// Delete drop area droppable components
config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, SPUIComponetIdProvider.DIST_TABLE_ID,
SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, SPUIComponentIdProvider.DIST_TABLE_ID,
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS));
// Distribution table drop components
config.put(SPUIComponetIdProvider.DIST_TABLE_ID,
Arrays.asList(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));
config.put(SPUIComponentIdProvider.DIST_TABLE_ID,
Arrays.asList(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));
return config;
}
@@ -84,8 +84,8 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = new HashMap<>();
config.put(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, DragEvent.DISTRIBUTION_TYPE_DRAG);
config.put(SPUIComponetIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
config.put(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS, DragEvent.SOFTWAREMODULE_TYPE_DRAG);
return config;
}

View File

@@ -8,7 +8,7 @@
*/
package org.eclipse.hawkbit.ui.distributions.event;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
/**
* Event fired on discard of software module assignment.

View File

@@ -1,51 +1,51 @@
package org.eclipse.hawkbit.ui.distributions.event;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class SoftwareModuleTableEvent extends BaseEntityEvent<SoftwareModule> {
/**
* SoftwareModule table components events.
*
*/
public enum SoftwareModuleComponentEvent {
SELECT_ALL
}
private SoftwareModuleComponentEvent softwareModuleComponentEvent;
/**
* Constructor.
*
* @param eventType
* the event type.
* @param entity
* the entity
*/
public SoftwareModuleTableEvent(final BaseEntityEventType eventType, final SoftwareModule entity) {
super(eventType, entity);
}
/**
* The component event.
*
* @param SoftwareModuleComponentEvent
* the softwareModule component event.
*/
public SoftwareModuleTableEvent(final SoftwareModuleComponentEvent softwareModuleComponentEvent) {
super(null, null);
this.softwareModuleComponentEvent = softwareModuleComponentEvent;
}
public SoftwareModuleComponentEvent getSoftwareModuleComponentEvent() {
return softwareModuleComponentEvent;
}
}
package org.eclipse.hawkbit.ui.distributions.event;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class SoftwareModuleTableEvent extends BaseEntityEvent<SoftwareModule> {
/**
* SoftwareModule table components events.
*
*/
public enum SoftwareModuleComponentEvent {
SELECT_ALL
}
private SoftwareModuleComponentEvent softwareModuleComponentEvent;
/**
* Constructor.
*
* @param eventType
* the event type.
* @param entity
* the entity
*/
public SoftwareModuleTableEvent(final BaseEntityEventType eventType, final SoftwareModule entity) {
super(eventType, entity);
}
/**
* The component event.
*
* @param SoftwareModuleComponentEvent
* the softwareModule component event.
*/
public SoftwareModuleTableEvent(final SoftwareModuleComponentEvent softwareModuleComponentEvent) {
super(null, null);
this.softwareModuleComponentEvent = softwareModuleComponentEvent;
}
public SoftwareModuleComponentEvent getSoftwareModuleComponentEvent() {
return softwareModuleComponentEvent;
}
}

View File

@@ -16,9 +16,9 @@ import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
@@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -115,7 +115,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected String getDeleteAreaId() {
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
}
@Override
@@ -262,11 +262,11 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private boolean isDistributionTable(final Component source) {
return SPUIComponetIdProvider.DIST_TABLE_ID.equals(source.getId());
return SPUIComponentIdProvider.DIST_TABLE_ID.equals(source.getId());
}
private boolean isSoftwareModuleTable(final Component source) {
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
}
@Override

View File

@@ -19,9 +19,9 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -124,7 +124,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab createSMDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setId(SPUIComponentIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
@@ -232,13 +232,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_SW_MODULE_TYPE);
tab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_SW_MODULE_TYPE);
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
// Add items container to the table.
@@ -324,7 +324,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab createDistDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setId(SPUIComponentIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistAll(tab));
@@ -423,13 +423,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab createDistSetTypeDeleteConfirmationTab() {
final ConfirmationTab tab = new ConfirmationTab();
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_DIST_SET_TYPE);
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_DIST_SET_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistSetTypeAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_DIST_SET_TYPE);
tab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_DIST_SET_TYPE);
tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab));
// Add items container to the table.
@@ -511,13 +511,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
assignmnetTab = new ConfirmationTab();
assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab));
// Add items container to the table.

View File

@@ -14,9 +14,10 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -74,20 +75,20 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
@Override
protected List<ProxyBaseSwModuleItem> loadBeans(final int startIndex, final int count) {
final Slice<CustomSoftwareModule> swModuleBeans;
final Slice<AssignedSoftwareModule> swModuleBeans;
final List<ProxyBaseSwModuleItem> proxyBeans = new ArrayList<>();
swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type);
for (final CustomSoftwareModule swModule : swModuleBeans) {
for (final AssignedSoftwareModule swModule : swModuleBeans) {
proxyBeans.add(getProxyBean(swModule));
}
return proxyBeans;
}
private ProxyBaseSwModuleItem getProxyBean(final CustomSoftwareModule customSoftwareModule) {
private ProxyBaseSwModuleItem getProxyBean(final AssignedSoftwareModule customSoftwareModule) {
final SoftwareModule bean = customSoftwareModule.getSoftwareModule();
final ProxyBaseSwModuleItem proxyItem = new ProxyBaseSwModuleItem();
proxyItem.setSwId(bean.getId());
@@ -99,8 +100,8 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
proxyItem.setVersion(bean.getVersion());
proxyItem.setVendor(bean.getVendor());
proxyItem.setDescription(bean.getDescription());
proxyItem.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy()));
proxyItem.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy()));
proxyItem.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean));
proxyItem.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean));
proxyItem.setAssigned(customSoftwareModule.isAssigned());
proxyItem.setColour(bean.getType().getColour());
proxyItem.setTypeId(bean.getType().getId());

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityT
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -61,7 +61,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
}
@Override
@@ -119,19 +119,19 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
vendorLabel.setId(SPUIComponentIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
assignLabel.setId(SPUIComponentIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);
}
@@ -143,7 +143,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
@Override
protected String getDetailsHeaderCaptionId() {
return SPUIComponetIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
}
}

View File

@@ -30,7 +30,7 @@ import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleTableEvent;
import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleTableEvent.SoftwareModuleComponentEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -130,7 +130,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
@Override
protected String getTableId() {
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
}
@Override
@@ -313,7 +313,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
private Button createShowArtifactDtlsButton(final String nameVersionStr) {
final Button showArtifactDtlsBtn = SPUIComponentProvider.getButton(
SPUIComponetIdProvider.SW_TABLE_ATRTIFACT_DETAILS_ICON + "." + nameVersionStr, "", "", null, false,
SPUIComponentIdProvider.SW_TABLE_ATRTIFACT_DETAILS_ICON + "." + nameVersionStr, "", "", null, false,
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
showArtifactDtlsBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON);
showArtifactDtlsBtn.setDescription(i18n.get("tooltip.artifact.icon"));

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -57,17 +57,17 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override
protected String getSearchBoxId() {
return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
return SPUIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
}
@Override
protected String getSearchRestIconId() {
return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON;
return SPUIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON;
}
@Override
protected String getAddIconId() {
return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON;
return SPUIComponentIdProvider.SW_MODULE_ADD_BUTTON;
}
@Override
@@ -116,7 +116,7 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override
protected String getMaxMinIconId() {
return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON;
return SPUIComponentIdProvider.SW_MAX_MIN_TABLE_ICON;
}
@Override

View File

@@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +51,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
}
@Override
@@ -76,7 +76,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String createButtonId(final String name) {
return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name;
return SPUIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name;
}
@Override

View File

@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +51,7 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
@Override
protected String getHideButtonId() {
return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID;
return SPUIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID;
}
@Override

View File

@@ -16,8 +16,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -3,6 +3,8 @@
*/
package org.eclipse.hawkbit.ui.filter.target;
import java.net.URI;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.filter.FilterExpression;
@@ -56,9 +58,10 @@ public class TargetSearchTextFilter implements FilterExpression {
}
private boolean ipAddressIgnoreCase() {
if (target.getTargetInfo().getAddress() == null) {
final URI targetAddress = target.getTargetInfo().getAddress();
if (targetAddress == null || targetAddress.getHost() == null) {
return false;
}
return target.getTargetInfo().getAddress().getHost().toUpperCase().contains(searchTextUpper);
return targetAddress.getHost().toUpperCase().contains(searchTextUpper);
}
}

View File

@@ -13,6 +13,7 @@ import java.util.concurrent.Executor;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@@ -23,7 +24,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -68,6 +69,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private static final long serialVersionUID = 7474232427119031474L;
private static final String breadcrumbCustomFilters = "breadcrumb.target.filter.custom.filters";
@Autowired
private I18N i18n;
@@ -93,6 +96,15 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
@Qualifier("uiExecutor")
private transient Executor executor;
@Autowired
private transient EntityFactory entityFactory;
private HorizontalLayout breadcrumbLayout;
private Button breadcrumbButton;
private Label breadcrumbName;
private Label headerCaption;
private TextField queryTextField;
@@ -169,6 +181,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
oldFilterName = filterManagementUIState.getTfQuery().get().getName();
oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery();
}
breadcrumbName.setValue(nameLabel.getValue());
showValidationSuccesIcon();
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
headerCaption.setVisible(false);
@@ -177,6 +190,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private void resetComponents() {
headerCaption.setVisible(true);
breadcrumbName.setValue(headerCaption.getValue());
nameLabel.setValue("");
queryTextField.setValue("");
setInitialStatusIconStyle(validationIcon);
@@ -191,7 +205,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
statusIcon.setContentMode(ContentMode.HTML);
statusIcon.setSizeFull();
setInitialStatusIconStyle(statusIcon);
statusIcon.setId(SPUIComponetIdProvider.VALIDATION_STATUS_ICON_ID);
statusIcon.setId(SPUIComponentIdProvider.VALIDATION_STATUS_ICON_ID);
return statusIcon;
}
@@ -201,11 +215,14 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void createComponents() {
breadcrumbButton = createBreadcrumbButton();
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
SPUILabelDefinitions.SP_WIDGET_CAPTION);
nameLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
nameLabel.setId(SPUIComponetIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
nameTextField = createNameTextField();
nameTextField.setWidth(380, Unit.PIXELS);
@@ -221,12 +238,23 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
closeIcon = createSearchResetIcon();
}
private Button createBreadcrumbButton() {
final Button createFilterViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
SPUIButtonStyleSmallNoBorder.class);
createFilterViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
createFilterViewLink.setDescription(i18n.get(breadcrumbCustomFilters));
createFilterViewLink.setCaption(i18n.get(breadcrumbCustomFilters));
createFilterViewLink.addClickListener(value -> showCustomFiltersView());
return createFilterViewLink;
}
private TextField createNameTextField() {
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
nameField.setId(SPUIComponetIdProvider.CUSTOM_FILTER_ADD_NAME);
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
nameField.setPropertyDataSource(nameLabel);
nameField.addTextChangeListener(event -> onFiterNameChange(event));
nameField.addTextChangeListener(event -> onFilterNameChange(event));
return nameField;
}
@@ -256,7 +284,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
};
}
private void onFiterNameChange(final TextChangeEvent event) {
private void onFilterNameChange(final TextChangeEvent event) {
if (isNameAndQueryEmpty(event.getText(), queryTextField.getValue())
|| (event.getText().equals(oldFilterName) && queryTextField.getValue().equals(oldFilterQuery))) {
saveButton.setEnabled(false);
@@ -270,12 +298,19 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private void buildLayout() {
captionLayout = new HorizontalLayout();
captionLayout.setDescription(i18n.get("tooltip.click.to.edit"));
captionLayout.setId(SPUIComponetIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID);
captionLayout.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID);
titleFilterIconsLayout = new HorizontalLayout();
titleFilterIconsLayout.addComponents(headerCaption, captionLayout);
titleFilterIconsLayout.setSpacing(true);
breadcrumbLayout = new HorizontalLayout();
breadcrumbLayout.addComponent(breadcrumbButton);
breadcrumbLayout.addComponent(new Label(">"));
breadcrumbName = SPUIComponentProvider.getLabel(null, SPUILabelDefinitions.SP_WIDGET_CAPTION);
breadcrumbLayout.addComponent(breadcrumbName);
breadcrumbName.addStyleName("breadcrumbPaddingLeft");
final HorizontalLayout titleFilterLayout = new HorizontalLayout();
titleFilterLayout.setSizeFull();
titleFilterLayout.addComponents(titleFilterIconsLayout, closeIcon);
@@ -290,7 +325,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
searchLayout.setSpacing(false);
searchLayout.addComponents(validationIcon, queryTextField);
searchLayout.addStyleName("custom-search-layout");
searchLayout.setComponentAlignment(validationIcon, Alignment.MIDDLE_CENTER);
searchLayout.setComponentAlignment(validationIcon, Alignment.TOP_CENTER);
final HorizontalLayout iconLayout = new HorizontalLayout();
iconLayout.setSizeUndefined();
@@ -302,10 +337,12 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
queryLayout.setSpacing(true);
queryLayout.addComponents(searchLayout, iconLayout);
addComponent(breadcrumbLayout);
addComponent(titleFilterLayout);
addComponent(queryLayout);
setSpacing(true);
addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
addStyleName("bordered-layout");
}
private void setUpCaptionLayout(final boolean isCreateView) {
@@ -435,8 +472,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private Button createSaveButton() {
saveButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON,
SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON, "Save", null, false, FontAwesome.SAVE,
saveButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON,
SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON, "Save", null, false, FontAwesome.SAVE,
SPUIButtonStyleSmallNoBorder.class);
saveButton.addClickListener(this);
saveButton.setEnabled(false);
@@ -451,7 +488,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
*/
@Override
public void buttonClick(final ClickEvent event) {
if (SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
if (SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
&& manadatoryFieldsPresent()) {
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
if (!doesAlreadyExists()) {
@@ -470,7 +507,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void createTargetFilterQuery() {
final TargetFilterQuery targetFilterQuery = new TargetFilterQuery();
final TargetFilterQuery targetFilterQuery = entityFactory.generateTargetFilterQuery();
targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
@@ -524,4 +561,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
}
private void showCustomFiltersView() {
eventBus.publish(this, CustomFilterUIEvent.SHOW_FILTER_MANAGEMENT);
}
}

View File

@@ -17,12 +17,14 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
@@ -69,6 +71,10 @@ public class CreateOrUpdateFilterTable extends Table {
private static final int PROPERTY_DEPT = 3;
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
/**
* Initialize the Action History Table.
*/
@@ -84,9 +90,10 @@ public class CreateOrUpdateFilterTable extends Table {
addCustomGeneratedColumns();
restoreOnLoad();
populateTableData();
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setId(SPUIComponentIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
eventBus.subscribe(this);
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
}
@PreDestroy
@@ -160,6 +167,9 @@ public class CreateOrUpdateFilterTable extends Table {
private void setCollapsibleColumns() {
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
setColumnCollapsed(ASSIGN_DIST_SET, true);
setColumnCollapsed(INSTALL_DIST_SET, true);
}
/**
@@ -172,10 +182,13 @@ public class CreateOrUpdateFilterTable extends Table {
container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "");
container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "");
container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null);
}
private List<TableColumn> getVisbleColumns() {
@@ -186,12 +199,9 @@ public class CreateOrUpdateFilterTable extends Table {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList;
}
@@ -244,4 +254,5 @@ public class CreateOrUpdateFilterTable extends Table {
populateTableData();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
}
}

View File

@@ -13,8 +13,8 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTarget;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -118,22 +118,9 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt());
prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy()));
prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy()));
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
if (null != assignedDistributionSet) {
prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
assignedDistributionSet.getName(), assignedDistributionSet.getVersion()));
}
if (null != installedDistributionSet) {
prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
installedDistributionSet.getName(), installedDistributionSet.getVersion()));
}
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setTargetInfo(targ.getTargetInfo());

View File

@@ -14,6 +14,7 @@ import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.footer.TargetFilterCountMessageLabel;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -96,7 +97,8 @@ public class FilterManagementView extends VerticalLayout implements View {
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|| custFilterUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> viewCreateTargetFilterLayout());
} else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) {
} else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW
|| custFilterUIEvent == CustomFilterUIEvent.SHOW_FILTER_MANAGEMENT) {
UI.getCurrent().access(() -> viewListView());
}
}
@@ -121,11 +123,11 @@ public class FilterManagementView extends VerticalLayout implements View {
tableHeaderLayout.setComponentAlignment(createNewFilterHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(createNewFilterTable);
tableHeaderLayout.setComponentAlignment(createNewFilterTable, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(createNewFilterTable, 1.0f);
tableHeaderLayout.setExpandRatio(createNewFilterTable, 1.0F);
addComponent(tableHeaderLayout);
setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER);
setExpandRatio(tableHeaderLayout, 1.0f);
setExpandRatio(tableHeaderLayout, 1.0F);
final HorizontalLayout targetsCountmessageLabelLayout = addTargetFilterMessageLabel();
addComponent(targetsCountmessageLabelLayout);
@@ -135,23 +137,23 @@ public class FilterManagementView extends VerticalLayout implements View {
private void viewListView() {
removeAllComponents();
final VerticalLayout tableHeaderLayout = new VerticalLayout();
tableHeaderLayout.setSizeFull();
tableHeaderLayout.setSpacing(false);
tableHeaderLayout.setMargin(false);
tableHeaderLayout.setStyleName("table-layout");
tableHeaderLayout.addComponent(targetFilterHeader);
tableHeaderLayout.setComponentAlignment(targetFilterHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(targetFilterTable);
tableHeaderLayout.setComponentAlignment(targetFilterTable, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(targetFilterTable, 1.0f);
addComponent(tableHeaderLayout);
final VerticalLayout tableListViewLayout = new VerticalLayout();
tableListViewLayout.setSizeFull();
tableListViewLayout.setSpacing(false);
tableListViewLayout.setMargin(false);
tableListViewLayout.setStyleName("table-layout");
tableListViewLayout.addComponent(targetFilterHeader);
tableListViewLayout.setComponentAlignment(targetFilterHeader, Alignment.TOP_CENTER);
tableListViewLayout.addComponent(targetFilterTable);
tableListViewLayout.setComponentAlignment(targetFilterTable, Alignment.TOP_CENTER);
tableListViewLayout.setExpandRatio(targetFilterTable, 1.0F);
addComponent(tableListViewLayout);
}
private HorizontalLayout addTargetFilterMessageLabel() {
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
messageLabelLayout.addStyleName("footer-layout");
messageLabelLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
return messageLabelLayout;
}

View File

@@ -17,8 +17,8 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.TargetFields;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.rsql.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.rsql.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,10 +31,7 @@ import cz.jirutka.rsql.parser.RSQLParserException;
*
* Validates the target filter query.
*
*
*
*/
public final class FilterQueryValidation {
private static final Logger LOGGER = LoggerFactory.getLogger(FilterQueryValidation.class);
@@ -103,6 +100,9 @@ public final class FilterQueryValidation {
* @param expectedTokens
* @return
*/
// Exception squid:S2095 - see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "squid:S2095" })
public static List<String> processExpectedTokens(final List<Integer> expectedTokens) {
final List<String> expectToken = new ArrayList<>();
if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) {

View File

@@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTargetFilter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -93,9 +94,9 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
proxyTarFilter.setName(tarFilterQuery.getName());
proxyTarFilter.setId(tarFilterQuery.getId());
proxyTarFilter.setCreatedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getCreatedAt()));
proxyTarFilter.setCreatedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getCreatedBy()));
proxyTarFilter.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(tarFilterQuery));
proxyTarFilter.setModifiedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getLastModifiedAt()));
proxyTarFilter.setLastModifiedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getLastModifiedBy()));
proxyTarFilter.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(tarFilterQuery));
proxyTarFilter.setQuery(tarFilterQuery.getQuery());
proxyTargetFilter.add(proxyTarFilter);
}

View File

@@ -13,11 +13,10 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -79,9 +78,8 @@ public class TargetFilterHeader extends VerticalLayout {
}
private Label createHeaderCaption() {
final Label captionLabel = SPUIComponentProvider.getLabel("Custom Filters",
return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION,
SPUILabelDefinitions.SP_WIDGET_CAPTION);
return captionLabel;
}
private void buildLayout() {
@@ -110,10 +108,9 @@ public class TargetFilterHeader extends VerticalLayout {
}
private Button createAddButton() {
final Button button = SPUIComponentProvider.getButton("camp.search.add.Id", "Create Filter", "Create Filter",
"", false, null, SPUIButtonStyleSmall.class);
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.TARGET_FILTER_ADD_ICON_ID, "", "",
null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class);
button.addClickListener(event -> addNewFilter());
button.addStyleName("on-focus-no-border link");
return button;
}
@@ -179,7 +176,7 @@ public class TargetFilterHeader extends VerticalLayout {
}
private String getSearchRestIconId() {
return SPUIComponetIdProvider.TARGET_FILTER_TBL_SEARCH_RESET_ID;
return SPUIComponentIdProvider.TARGET_FILTER_TBL_SEARCH_RESET_ID;
}
protected void resetSearchText() {

View File

@@ -25,7 +25,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
@@ -94,7 +94,7 @@ public class TargetFilterTable extends Table {
populateTableData();
setColumnCollapsingAllowed(true);
setColumnProperties();
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
setId(SPUIComponentIdProvider.TAEGET_FILTER_TABLE_ID);
eventBus.subscribe(this);
}
@@ -172,7 +172,7 @@ public class TargetFilterTable extends Table {
}
private String getDeleteIconId(final String targetFilterName) {
return new StringBuilder(SPUIComponetIdProvider.CUSTOM_FILTER_DELETE_ICON).append('.').append(targetFilterName)
return new StringBuilder(SPUIComponentIdProvider.CUSTOM_FILTER_DELETE_ICON).append('.').append(targetFilterName)
.toString();
}
@@ -241,7 +241,7 @@ public class TargetFilterTable extends Table {
}
private static String getDetailLinkId(final String filterName) {
return new StringBuilder(SPUIComponetIdProvider.CUSTOM_FILTER_DETAIL_LINK).append('.').append(filterName)
return new StringBuilder(SPUIComponentIdProvider.CUSTOM_FILTER_DETAIL_LINK).append('.').append(filterName)
.toString();
}

View File

@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
*
*/
public enum CustomFilterUIEvent {
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, UPDATE_TARGET_FILTER_SEARCH_ICON
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, UPDATE_TARGET_FILTER_SEARCH_ICON, SHOW_FILTER_MANAGEMENT
}

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -79,7 +79,7 @@ public class TargetFilterCountMessageLabel extends Label {
private void applyStyle() {
addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
setContentMode(ContentMode.HTML);
setId(SPUIComponetIdProvider.COUNT_LABEL);
setId(SPUIComponentIdProvider.COUNT_LABEL);
}
private void displayTargetFilterMessage() {

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.login;
import java.net.URI;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.servlet.http.Cookie;
@@ -18,13 +19,14 @@ import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationTok
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.CredentialsExpiredException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.util.AntPathMatcher;
import org.vaadin.spring.security.VaadinSecurity;
import com.vaadin.event.ShortcutAction.KeyCode;
@@ -56,6 +58,12 @@ import com.vaadin.ui.themes.ValoTheme;
@SpringView(name = "")
@UIScope
public class LoginView extends VerticalLayout implements View {
private static final String TENANT_PATTERN_PLACEHOLDER = "tenant";
private static final String USER_PATTERN_PLACEHOLDER = "user";
private static final String LOGIN_TENANT_USER_URL_PATTERN = "**/#/{" + TENANT_PATTERN_PLACEHOLDER + "}/{"
+ USER_PATTERN_PLACEHOLDER + "}";
private static final String LOGIN_USER_URL_PATTERN = "**/#/{" + USER_PATTERN_PLACEHOLDER + "}";
private static final String LOGIN_TEXTFIELD = "login-textfield";
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class);
@@ -75,6 +83,9 @@ public class LoginView extends VerticalLayout implements View {
@Autowired
private transient MultitenancyIndicator multiTenancyIndicator;
private final transient AntPathMatcher matcher = new AntPathMatcher();
private boolean useCookie = true;
private TextField username;
private TextField tenant;
private PasswordField password;
@@ -106,17 +117,45 @@ public class LoginView extends VerticalLayout implements View {
*/
@PostConstruct
public void render() {
final URI spURI = Page.getCurrent().getLocation();
final String lookForDemoFragment = spURI.toString();
if (lookForDemoFragment.contains("?demo")) {
final String uriPath = spURI.toString();
if (uriPath.contains("?demo")) {
login(uiProperties.getDemo().getTenant(), uiProperties.getDemo().getUser(),
uiProperties.getDemo().getPassword(), false);
}
final Component loginForm = buildLoginForm();
addComponent(loginForm);
setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
readCredentialsFromUriPath(uriPath);
}
private void readCredentialsFromUriPath(final String uriPath) {
String urlTenant = null;
String urlUser = null;
if (matcher.match(LOGIN_USER_URL_PATTERN, uriPath)) {
urlUser = matcher.extractUriTemplateVariables(LOGIN_USER_URL_PATTERN, uriPath)
.get(USER_PATTERN_PLACEHOLDER);
} else if (matcher.match(LOGIN_TENANT_USER_URL_PATTERN, uriPath)) {
final Map<String, String> extractUriTemplateVariables = matcher
.extractUriTemplateVariables(LOGIN_TENANT_USER_URL_PATTERN, uriPath);
urlTenant = extractUriTemplateVariables.get(TENANT_PATTERN_PLACEHOLDER);
urlUser = extractUriTemplateVariables.get(USER_PATTERN_PLACEHOLDER);
}
if (urlUser != null) {
useCookie = false;
filloutUsernameTenantFields(urlTenant, urlUser);
}
}
private void filloutUsernameTenantFields(final String tenantValue, final String userValue) {
if (tenant != null && tenantValue != null) {
tenant.setValue(tenantValue);
}
if (userValue != null) {
username.setValue(userValue);
}
}
private Component buildLoginForm() {
@@ -225,7 +264,7 @@ public class LoginView extends VerticalLayout implements View {
final String linkStyle = "v-link";
if (!uiProperties.getLinks().getDocumentation().getRoot().isEmpty()) {
final Link docuLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_DOCUMENATION,
final Link docuLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_DOCUMENTATION,
i18n.get("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(),
FontAwesome.QUESTION_CIRCLE, "_blank", linkStyle, true);
links.addComponent(docuLink);
@@ -233,14 +272,14 @@ public class LoginView extends VerticalLayout implements View {
}
if (!uiProperties.getDemo().getUser().isEmpty()) {
final Link demoLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_DEMO,
final Link demoLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_DEMO,
i18n.get("link.demo.name"), "?demo", FontAwesome.DESKTOP, "_top", linkStyle, true);
links.addComponent(demoLink);
demoLink.addStyleName(ValoTheme.LINK_SMALL);
}
if (!uiProperties.getLinks().getRequestAccount().isEmpty()) {
final Link requestAccountLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_REQUESTACCOUNT,
final Link requestAccountLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_REQUESTACCOUNT,
i18n.get("link.requestaccount.name"), uiProperties.getLinks().getRequestAccount(),
FontAwesome.SHOPPING_CART, "", linkStyle, true);
links.addComponent(requestAccountLink);
@@ -248,7 +287,7 @@ public class LoginView extends VerticalLayout implements View {
}
if (!uiProperties.getLinks().getUserManagement().isEmpty()) {
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_USERMANAGEMENT,
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_USERMANAGEMENT,
i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(),
FontAwesome.USERS, "_blank", linkStyle, true);
links.addComponent(userManagementLink);
@@ -281,6 +320,9 @@ public class LoginView extends VerticalLayout implements View {
*/
@Override
public void enter(final ViewChangeEvent event) {
if (!useCookie) {
return;
}
final Cookie usernameCookie = getCookieByName(SP_LOGIN_USER);
@@ -348,7 +390,7 @@ public class LoginView extends VerticalLayout implements View {
vaadinSecurity.login(new UsernamePasswordAuthenticationToken(user, password));
}
/* set success login cookies */
if (setCookies) {
if (setCookies && useCookie) {
setCookies();
}

View File

@@ -34,7 +34,7 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -69,14 +69,15 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
*
* Table for {@link Target#getActions()} history.
*
*/
@SpringComponent
@ViewScope
public class ActionHistoryTable extends TreeTable implements Handler {
private static final String BUTTON_CANCEL = "button.cancel";
private static final String BUTTON_OK = "button.ok";
private static final long serialVersionUID = -1631514704696786653L;
@Autowired
private I18N i18n;
@@ -158,7 +159,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void initializeTableSettings() {
setId(SPUIComponetIdProvider.ACTION_HISTORY_TABLE_ID);
setId(SPUIComponentIdProvider.ACTION_HISTORY_TABLE_ID);
setSelectable(false);
setMultiSelect(false);
setSortEnabled(true);
@@ -241,11 +242,14 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void getcontainerData() {
hierarchicalContainer.removeAllItems();
/* service method to create action history for target */
final List<ActionWithStatusCount> actionHistory = deploymentManagement
if (target != null) {
/* service method to create action history for target */
final List<ActionWithStatusCount> actionHistory = deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
addDetailsToContainer(actionHistory);
addDetailsToContainer(actionHistory);
}
}
/**
@@ -268,51 +272,51 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final Action action = actionWithStatusCount.getAction();
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getAction().getId());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.setValue(actionWithStatusCount.getActionStatus());
.setValue(actionWithStatusCount.getAction().getStatus());
/*
* add action id.
*/
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID)
.setValue(actionWithStatusCount.getActionId().toString());
.setValue(actionWithStatusCount.getAction().getId().toString());
/*
* add active/inactive status to the item which will be used in
* Column generator to generate respective icon
*/
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue(
actionWithStatusCount.isActionActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE);
actionWithStatusCount.getAction().isActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE);
/*
* add action Id to the item which will be used for fetching child
* items ( previous action status ) during expand
*/
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
.setValue(actionWithStatusCount.getActionId());
.setValue(actionWithStatusCount.getAction().getId());
/*
* add distribution name to the item which will be displayed in the
* table. The name should not exceed certain limit.
*/
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(HawkbitCommonUtil
.getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion()));
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(actionWithStatusCount.getDsName() + ":" +
actionWithStatusCount.getDsVersion());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
/* Default no child */
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), false);
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null)
? actionWithStatusCount.getActionLastModifiedAt()
: actionWithStatusCount.getActionCreatedAt()));
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getAction().getLastModifiedAt() != null)
? actionWithStatusCount.getAction().getLastModifiedAt()
: actionWithStatusCount.getAction().getLastModifiedAt()));
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME)
.setValue(actionWithStatusCount.getRolloutName());
if (actionWithStatusCount.getActionStatusCount() > 0) {
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), true);
}
}
}
@@ -422,8 +426,12 @@ public class ActionHistoryTable extends TreeTable implements Handler {
.findActionWithDetails(actionId);
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 Page<ActionStatus> actionStatusList;
if (managementUIState.isActionHistoryMaximized()) {
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action);
} else {
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action);
}
final List<ActionStatus> content = actionStatusList.getContent();
/*
* Since the recent action status and messages are already
@@ -442,8 +450,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue("");
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST)
.setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":"
+ action.getDistributionSet().getVersion()));
.setValue(action.getDistributionSet().getName() + ":"
+ action.getDistributionSet().getVersion());
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
.setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
@@ -747,7 +755,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void confirmAndForceAction(final Long actionId) {
/* Display the confirmation */
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.force.action.confirmbox"),
i18n.get("message.force.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
i18n.get("message.force.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
if (ok) {
/* cancel the action */
deploymentManagement.forceTargetAction(actionId);
@@ -769,7 +777,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void confirmAndForceQuitAction(final Long actionId) {
/* Display the confirmation */
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"),
i18n.get("message.forcequit.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
i18n.get("message.forcequit.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
if (ok) {
final boolean cancelResult = forceQuitActiveAction(actionId);
if (cancelResult) {
@@ -797,7 +805,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void confirmAndCancelAction(final Long actionId) {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.cancel.action.confirmbox"),
i18n.get("message.cancel.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
i18n.get("message.cancel.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
if (ok) {
final boolean cancelResult = cancelActiveAction(actionId);
if (cancelResult) {

View File

@@ -16,8 +16,8 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantMetaDataRepository;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -30,7 +30,7 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -92,7 +92,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private transient SystemManagement systemManagement;
@Autowired
private transient TenantMetaDataRepository tenantMetaDataRepository;
private transient EntityFactory entityFactory;
private Button saveDistributionBtn;
private Button discardDistributionBtn;
@@ -148,6 +148,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
addComponent(buttonsLayout);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
distNameTextField.focus();
}
@@ -157,23 +158,23 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private void createRequiredComponents() {
distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distNameTextField.setId(SPUIComponetIdProvider.DIST_ADD_NAME);
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
distNameTextField.setNullRepresentation("");
distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distVersionTextField.setId(SPUIComponetIdProvider.DIST_ADD_VERSION);
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
distVersionTextField.setNullRepresentation("");
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
i18n.get("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponetIdProvider.DIST_ADD_DESC);
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
descTextArea.setNullRepresentation("");
/* Label for mandatory symbol */
@@ -183,15 +184,15 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, "");
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
/* save or update button */
saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.DIST_ADD_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
saveDistributionBtn.addClickListener(event -> saveDistribution());
/* close button */
discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.DIST_ADD_DISCARD, "", "", "",
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardDistributionBtn.addClickListener(event -> discardDistribution());
}
@@ -220,8 +221,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private DistributionSetType getDefaultDistributionSetType() {
final TenantMetaData tenantMetaData = tenantMetaDataRepository
.findByTenantIgnoreCase(systemManagement.currentTenant());
final TenantMetaData tenantMetaData = systemManagement.getTenantMetadata();
return tenantMetaData.getDefaultDsType();
}
@@ -296,7 +296,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
DistributionSet newDist = new DistributionSet();
DistributionSet newDist = entityFactory.generateDistributionSet();
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
newDist = distributionSetManagement.createDistributionSet(newDist);

View File

@@ -13,11 +13,12 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetFilter;
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -41,11 +42,11 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
private static final long serialVersionUID = 5862679853949173536L;
private Sort sort = new Sort(Direction.ASC, "name", "version");
private Collection<String> distributionTags = null;
private String searchText = null;
private String pinnedControllerId = null;
private Collection<String> distributionTags;
private String searchText;
private String pinnedControllerId;
private transient DistributionSetManagement distributionSetManagement;
private transient Page<DistributionSet> firstPageDistributionSets = null;
private transient Page<DistributionSet> firstPageDistributionSets;
private Boolean noTagClicked = Boolean.FALSE;
/**
@@ -109,8 +110,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
pinnedControllerId);
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
// if no search filters available
distBeans = getDistributionSetManagement()
.findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true);
distBeans = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
new OffsetBasedPageRequest(startIndex, count, sort), false, true);
} else {
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
@@ -128,9 +129,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
proxyDistribution.setVersion(distributionSet.getVersion());
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setNameVersion(
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistributions.add(proxyDistribution);
@@ -151,8 +151,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
pinnedControllerId);
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
// if no search filters available
firstPageDistributionSets = getDistributionSetManagement()
.findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
} else {
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -86,7 +86,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
return SPUIComponentIdProvider.DS_EDIT_BUTTON;
}
@Override
@@ -107,7 +107,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected String getTabSheetId() {
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_TABSHEET;
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_TABSHEET;
}
@Override
@@ -132,7 +132,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
@@ -158,7 +158,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected String getDetailsHeaderCaptionId() {
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
}
}

View File

@@ -21,10 +21,10 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -177,7 +177,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
@Override
protected String getTableId() {
return SPUIComponetIdProvider.DIST_TABLE_ID;
return SPUIComponentIdProvider.DIST_TABLE_ID;
}
@Override
@@ -394,7 +394,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
notification.displayValidationError(i18n.get("message.permission.insufficient"));
return false;
} else {
if (compsource instanceof Table && !compsource.getId().equals(SPUIComponetIdProvider.TARGET_TABLE_ID)) {
if (compsource instanceof Table && !compsource.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
notification.displayValidationError(notAllowedMsg);
return false;
}
@@ -608,7 +608,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
private String getPinButtonId(final String distName, final String distVersion) {
final StringBuilder pinBtnId = new StringBuilder(SPUIComponetIdProvider.DIST_PIN_BUTTON);
final StringBuilder pinBtnId = new StringBuilder(SPUIComponentIdProvider.DIST_PIN_BUTTON);
pinBtnId.append('.');
pinBtnId.append(distName);
pinBtnId.append('.');

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -59,17 +59,17 @@ public class DistributionTableHeader extends AbstractTableHeader {
@Override
protected String getSearchBoxId() {
return SPUIComponetIdProvider.DIST_SEARCH_TEXTFIELD;
return SPUIComponentIdProvider.DIST_SEARCH_TEXTFIELD;
}
@Override
protected String getSearchRestIconId() {
return SPUIComponetIdProvider.DIST_SEARCH_ICON;
return SPUIComponentIdProvider.DIST_SEARCH_ICON;
}
@Override
protected String getAddIconId() {
return SPUIComponetIdProvider.DIST_ADD_ICON;
return SPUIComponentIdProvider.DIST_ADD_ICON;
}
@Override
@@ -121,7 +121,7 @@ public class DistributionTableHeader extends AbstractTableHeader {
@Override
protected String getMaxMinIconId() {
return SPUIComponetIdProvider.DS_MAX_MIN_TABLE_ICON;
return SPUIComponentIdProvider.DS_MAX_MIN_TABLE_ICON;
}
@Override

View File

@@ -11,9 +11,10 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
@@ -43,15 +44,14 @@ import com.vaadin.ui.themes.ValoTheme;
@SpringComponent
@VaadinSessionScope
public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayout {
/**
*
*/
private static final long serialVersionUID = 444276149954167545L;
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EntityFactory entityFactory;
private static final String MISSING_TAG_NAME = "message.error.missing.tagname";
private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name";
private static final String MSG_TEXTFIELD_NAME = "textfield.name";
@@ -102,14 +102,13 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
if (null != tagNameValue) {
DistributionSetTag newDistTag = new DistributionSetTag(tagNameValue);
if (null != tagDescValue) {
newDistTag.setDescription(tagDescValue);
}
newDistTag.setColour(new Color(0, 146, 58).getCSS());
DistributionSetTag newDistTag = entityFactory.generateDistributionSetTag(tagNameValue, tagDescValue,
new Color(0, 146, 58).getCSS());
if (colorPicked != null) {
newDistTag.setColour(colorPicked);
}
newDistTag = tagManagement.createDistributionSetTag(newDistTag);
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistTag.getName() }));
resetDistTagValues();
@@ -288,16 +287,22 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
populateTagNameCombo();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
populateTagNameCombo();
}

View File

@@ -11,9 +11,10 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
@@ -22,7 +23,7 @@ import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -54,23 +55,32 @@ public class DistributionTagButtons extends AbstractFilterButtons {
@Autowired
private ManagementUIState managementUIState;
@Autowired
private transient EntityFactory entityFactory;
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
addNewTag(new DistributionSetTag("NO TAG"));
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
refreshTagTable();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
refreshTagTable();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
refreshTagTable();
}
@@ -86,7 +96,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.DISTRIBUTION_TAG_TABLE_ID;
return SPUIComponentIdProvider.DISTRIBUTION_TAG_TABLE_ID;
}
@Override
@@ -133,7 +143,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private void refreshTagTable() {
((LazyQueryContainer) getContainerDataSource()).refresh();
removeGeneratedColumn(FILTER_BUTTON_COLUMN);
addNewTag(new DistributionSetTag("NO TAG"));
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
addColumn();
}

View File

@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -87,7 +87,7 @@ public class DistributionTagHeader extends AbstractFilterHeader {
@Override
protected String getConfigureFilterButtonId() {
return SPUIComponetIdProvider.ADD_DISTRIBUTION_TAG;
return SPUIComponentIdProvider.ADD_DISTRIBUTION_TAG;
}
@Override

View File

@@ -14,13 +14,13 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -74,7 +74,7 @@ public class DistributionTagDropEvent implements DropHandler {
final TableTransferable tbl = (TableTransferable) event.getTransferable();
final Table source = tbl.getSourceComponent();
if (source.getId().equals(SPUIComponetIdProvider.DIST_TABLE_ID)) {
if (source.getId().equals(SPUIComponentIdProvider.DIST_TABLE_ID)) {
processDistributionDrop(event);
}
@@ -118,7 +118,7 @@ public class DistributionTagDropEvent implements DropHandler {
}
private boolean validateIfSourceIsDs(final Table source) {
if (!source.getId().equals(SPUIComponetIdProvider.DIST_TABLE_ID)) {
if (!source.getId().equals(SPUIComponentIdProvider.DIST_TABLE_ID)) {
notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
return false;
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import com.vaadin.spring.annotation.SpringComponent;
@@ -70,34 +70,34 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
final Map<String, List<String>> config = new HashMap<>();
// Delete drop area acceptable components
config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, SPUIComponetIdProvider.TARGET_TABLE_ID,
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, SPUIComponetIdProvider.DIST_TABLE_ID));
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, SPUIComponentIdProvider.TARGET_TABLE_ID,
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, SPUIComponentIdProvider.DIST_TABLE_ID));
// Target Tag acceptable components
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, Arrays.asList(SPUIComponetIdProvider.TARGET_TABLE_ID));
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, Arrays.asList(SPUIComponentIdProvider.TARGET_TABLE_ID));
// Target table acceptable components
config.put(SPUIComponetIdProvider.TARGET_TABLE_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, SPUIComponetIdProvider.DIST_TABLE_ID));
config.put(SPUIComponentIdProvider.TARGET_TABLE_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, SPUIComponentIdProvider.DIST_TABLE_ID));
// Target table header acceptable components
config.put(SPUIComponetIdProvider.TARGET_DROP_FILTER_ICON, Arrays.asList(SPUIComponetIdProvider.DIST_TABLE_ID));
config.put(SPUIComponentIdProvider.TARGET_DROP_FILTER_ICON, Arrays.asList(SPUIComponentIdProvider.DIST_TABLE_ID));
// Distribution table acceptable components
config.put(SPUIComponetIdProvider.DIST_TABLE_ID, Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS,
SPUIComponetIdProvider.TARGET_TABLE_ID, SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS));
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS,
SPUIComponentIdProvider.TARGET_TABLE_ID, SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS));
// Distribution tag acceptable components.
config.put(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, Arrays.asList(SPUIComponetIdProvider.DIST_TABLE_ID));
config.put(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, Arrays.asList(SPUIComponentIdProvider.DIST_TABLE_ID));
return config;
}
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = new HashMap<>();
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, DragEvent.TARGET_TAG_DRAG);
config.put(SPUIComponetIdProvider.TARGET_TABLE_ID, DragEvent.TARGET_DRAG);
config.put(SPUIComponetIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(SPUIComponentIdProvider.TARGET_TABLE_ID, DragEvent.TARGET_DRAG);
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, DragEvent.DISTRIBUTION_TAG_DRAG);
return config;
}

View File

@@ -14,9 +14,9 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
@@ -26,7 +26,7 @@ import org.eclipse.hawkbit.ui.management.state.TargetTableFilters;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -125,7 +125,7 @@ public class CountMessageLabel extends Label {
/* Create label for Targets count message displaying below the table */
addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
setContentMode(ContentMode.HTML);
setId(SPUIComponetIdProvider.COUNT_LABEL);
setId(SPUIComponentIdProvider.COUNT_LABEL);
}
private void displayTargetCountStatus() {

View File

@@ -11,8 +11,8 @@ package org.eclipse.hawkbit.ui.management.footer;
import java.util.Set;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
@@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventScope;
@@ -152,7 +152,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected String getDeleteAreaId() {
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
}
@Override

View File

@@ -8,7 +8,7 @@
*/
package org.eclipse.hawkbit.ui.management.footer;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import com.vaadin.ui.Component;
@@ -68,7 +68,7 @@ public final class DeleteActionsLayoutHelper {
* @return true if it component is target table
*/
public static boolean isTargetTable(final Component source) {
return SPUIComponetIdProvider.TARGET_TABLE_ID.equalsIgnoreCase(source.getId());
return SPUIComponentIdProvider.TARGET_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**
@@ -79,7 +79,7 @@ public final class DeleteActionsLayoutHelper {
* @return true if it component is distribution table
*/
public static boolean isDistributionTable(final Component source) {
return SPUIComponetIdProvider.DIST_TABLE_ID.equalsIgnoreCase(source.getId());
return SPUIComponentIdProvider.DIST_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**

View File

@@ -23,10 +23,10 @@ import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.RepositoryModelConstants;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
@@ -34,7 +34,7 @@ import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -105,13 +105,13 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
private ConfirmationTab createAssignmentTab() {
assignmnetTab = new ConfirmationTab();
assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllAssignments(assignmnetTab));
// Add items container to the table.
@@ -148,7 +148,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
final long forcedTimeStamp = (((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout
.getActionTypeOptionGroup().getValue()) == ActionTypeOption.AUTO_FORCED)
? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime()
: Action.NO_FORCE_TIME;
: RepositoryModelConstants.NO_FORCE_TIME;
final Map<Long, ArrayList<TargetIdName>> saveAssignedList = new HashMap<>();
@@ -275,7 +275,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
final ConfirmationTab tab = new ConfirmationTab();
// TobeDone ? y to set caption every time??
tab.getConfirmAll().setId(SPUIComponetIdProvider.TARGET_DELETE_ALL);
tab.getConfirmAll().setId(SPUIComponentIdProvider.TARGET_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteAllTargets(tab));
@@ -308,7 +308,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
final ConfirmationTab tab = new ConfirmationTab();
// TobeDone ? y to set caption every time??
tab.getConfirmAll().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setId(SPUIComponentIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteAllDistributions(tab));

View File

@@ -17,8 +17,8 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -12,7 +12,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
/**
* Hold details for target bulk upload window.

Some files were not shown because too many files have changed in this diff Show More