Merge branch 'master' into Reduce_Duplicate_Code

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java


Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-07 12:06:11 +02:00
101 changed files with 1743 additions and 901 deletions

View File

@@ -215,13 +215,15 @@ public class UploadLayout extends VerticalLayout {
hasDirectory = Boolean.TRUE;
}
}
}
private static boolean isDirectory(final Html5File file) {
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) {
return true;
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
}
private boolean isDirectory(final Html5File file) {
return Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0;
}
return false;
}
private void displayCompositeMessage() {
@@ -282,11 +284,6 @@ public class UploadLayout extends VerticalLayout {
discardBtn.addClickListener(event -> discardUploadData(event));
}
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
}
boolean checkForDuplicate(final String filename) {
final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
if (isDuplicate) {
@@ -349,17 +346,17 @@ public class UploadLayout extends VerticalLayout {
}
}
Boolean validate(DragAndDropEvent event) {
Boolean validate(final DragAndDropEvent event) {
// check if drop is valid.If valid ,check if software module is
// selected.
if(!isFilesDropped(event)){
if (!isFilesDropped(event)) {
uiNotification.displayValidationError(i18n.get("message.action.not.allowed"));
return false;
}
return checkIfSoftwareModuleIsSelected();
}
private boolean isFilesDropped(DragAndDropEvent event) {
private boolean isFilesDropped(final DragAndDropEvent event) {
if (event.getTransferable() instanceof WrapperTransferable) {
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
// other components can also be wrapped in WrapperTransferable , so
@@ -448,7 +445,7 @@ public class UploadLayout extends VerticalLayout {
}
private String getDuplicateFileValidationMessage() {
StringBuilder message = new StringBuilder();
final StringBuilder message = new StringBuilder();
if (!duplicateFileNamesList.isEmpty()) {
final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList);
if (duplicateFileNamesList.size() == 1) {
@@ -655,8 +652,7 @@ public class UploadLayout extends VerticalLayout {
return uiNotification;
}
public void setHasDirectory(Boolean hasDirectory) {
public void setHasDirectory(final Boolean hasDirectory) {
this.hasDirectory = hasDirectory;
}
}

View File

@@ -196,18 +196,25 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
}
}
}
private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml()
+ "</span>" + " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
}
private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml() + "</span>"
+ " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
}
private void onTokenSearch(final Object tokenId) {
assignTag(getItemNameProperty(tokenId).getValue().toString());
removeTagAssignedFromCombo((Long) tokenId);
}
private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
private void onTokenSearch(final Object tokenId) {
assignTag(getItemNameProperty(tokenId).getValue().toString());
removeTagAssignedFromCombo((Long) tokenId);
}
private Property getItemNameProperty(final Object tokenId) {
@@ -229,13 +236,6 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
return (String) item.getItemProperty("name").getValue();
}
private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
protected void removePreviouslyAddedTokens() {
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
}

View File

@@ -63,14 +63,10 @@ import com.vaadin.ui.Upload.SucceededListener;
/**
* Bulk target upload handler.
*
*/
public class BulkUploadHandler extends CustomComponent
implements SucceededListener, FailedListener, Receiver, StartedListener {
/**
*
*/
private static final long serialVersionUID = -1273494705754674501L;
private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class);
@@ -149,12 +145,6 @@ public class BulkUploadHandler extends CustomComponent
setCompositionRoot(horizontalLayout);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String,
* java.lang.String)
*/
@Override
public OutputStream receiveUpload(final String filename, final String mimeType) {
try {
@@ -170,25 +160,11 @@ public class BulkUploadHandler extends CustomComponent
return new NullOutputStream();
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.FailedListener#uploadFailed(com.vaadin.ui.Upload.
* FailedEvent)
*/
@Override
public void uploadFailed(final FailedEvent event) {
LOG.info("Upload failed for file :{} due to {}", event.getFilename(), event.getReason());
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.SucceededListener#uploadSucceeded(com.vaadin.ui.
* Upload.SucceededEvent)
*/
@Override
public void uploadSucceeded(final SucceededEvent event) {
executor.execute(new UploadAsync(event));
@@ -252,6 +228,61 @@ public class BulkUploadHandler extends CustomComponent
}
}
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload()
.getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload()
.setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void doAssignments() {
final StringBuilder errorMessage = new StringBuilder();
String dsAssignmentFailedMsg = null;
@@ -267,6 +298,41 @@ public class BulkUploadHandler extends CustomComponent
displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg);
}
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
}
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (deletedTags.isEmpty()) {
return null;
}
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
}
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
private boolean ifTagsSelected() {
return targetBulkTokenTags.getTokenField().getValue() != null;
}
@@ -307,59 +373,6 @@ public class BulkUploadHandler extends CustomComponent
}
}
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void addNewTarget(final String controllerId, final String name) {
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) {
@@ -405,43 +418,6 @@ public class BulkUploadHandler extends CustomComponent
}
}
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
} else {
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (!deletedTags.isEmpty()) {
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
} else {
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
}
return null;
}
private static class NullOutputStream extends OutputStream {
/**
* null output stream.
@@ -462,13 +438,6 @@ public class BulkUploadHandler extends CustomComponent
return upload;
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.StartedListener#uploadStarted(com.vaadin.ui.Upload
* .StartedEvent)
*/
@Override
public void uploadStarted(final StartedEvent event) {
if (!event.getFilename().endsWith(".csv")) {

View File

@@ -356,7 +356,6 @@ public class RolloutListGrid extends AbstractGrid {
return context;
}
private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) {
// Add 'Update' option only if user has update permission
if (!permissionChecker.hasRolloutUpdatePermission()) {
@@ -366,17 +365,6 @@ public class RolloutListGrid extends AbstractGrid {
cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE));
}
private String convertRolloutStatusToString(final RolloutStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
private void menuItemClicked(final ContextMenuItemClickEvent event) {
final ContextMenuItem item = (ContextMenuItem) event.getSource();
final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
@@ -537,6 +525,13 @@ public class RolloutListGrid extends AbstractGrid {
public Class<String> getPresentationType() {
return String.class;
}
private String convertRolloutStatusToString(final RolloutStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
}
/**
@@ -549,14 +544,16 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = -5794528427855153924L;
@Override
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(final TotalTargetCountStatus value, final Class<? extends String> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}

View File

@@ -217,7 +217,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
createRolloutGroupStatusToFontMap();
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(),
new RolloutGroupStatusConverter());
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter());
if (permissionChecker.hasRolloutTargetsReadPermission()) {
@@ -250,18 +250,6 @@ public class RolloutGroupListGrid extends AbstractGrid {
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
private void createRolloutGroupStatusToFontMap() {
statusIconMap.put(RolloutGroupStatus.FINISHED,
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
@@ -316,14 +304,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = -9205943894818450807L;
@Override
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(final TotalTargetCountStatus value, final Class<? extends String> targetType,
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@@ -369,5 +359,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
return String.class;
}
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
}
}

View File

@@ -196,11 +196,9 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
public String convertToPresentation(final Status status, final Class<? extends String> targetType,
final Locale locale) {
if (status == null) {
// Actions are not created for targets when
// rollout's status
// is READY and when duplicate assignment is done.
// In these cases display a appropriate status with
// description
// Actions are not created for targets when rollout's status is
// READY and when duplicate assignment is done. In these cases
// display a appropriate status with description
return getStatus();
}
return processActionStatus(status);
@@ -216,16 +214,27 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
return String.class;
}
}
private String processActionStatus(final Status status) {
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
if (statusFontIcon == null) {
return null;
private String processActionStatus(final Status status) {
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
}
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
private String getStatus() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
}
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private void createRolloutStatusToFontMap() {
@@ -249,21 +258,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
}
private String getStatus() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
} else {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private String getDescription(final CellReference cell) {
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return null;
@@ -274,7 +268,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
}
return cell.getProperty().getValue().toString().toLowerCase();
}
private String getDescriptionWhenNoAction() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()

View File

@@ -30,9 +30,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* View to configure the authentication mode.
*
*
*
*/
@SpringComponent
@ViewScope

View File

@@ -14,8 +14,8 @@ import java.util.List;
import com.vaadin.ui.CustomComponent;
/**
* base class for all configuration views. This class implements the logic for
* the handling of the
* Base class for all configuration views. This class implements the logic for
* the handling of the configurations in a consistent way.
*
*/
public abstract class BaseConfigurationView extends CustomComponent implements ConfigurationGroup {

View File

@@ -11,9 +11,8 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import com.vaadin.ui.Component;
/**
*
*
*
* Interface that all system configurations have to implement to save and undo
* their customized changes.
*/
public interface ConfigurationGroup extends Component, ConfigurationItem {

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.io.Serializable;
/**
* represents an configurationItem, which can be modified by the user
* Represents an configurationItem, which can be modified by the user
*/
public interface ConfigurationItem {

View File

@@ -33,9 +33,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* Default DistributionSet Panel.
*
*
*
*/
@SpringComponent
@ViewScope

View File

@@ -0,0 +1,119 @@
/**
* 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.tenantconfiguration;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
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.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
/**
* View to enable anonymous download.
*/
@SpringComponent
@ViewScope
public class DownloadAnonymousConfigurationView extends BaseConfigurationView
implements ConfigurationItem.ConfigurationItemChangeListener {
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
private static final long serialVersionUID = 1L;
@Autowired
private I18N i18n;
@Autowired
private transient TenantConfigurationManagement tenantConfigurationManagement;
boolean anonymousDownloadEnabled;
private CheckBox downloadAnonymousCheckBox;
/**
* Initialize Default Download Anonymous layout.
*/
@PostConstruct
public void init() {
final TenantConfigurationValue<Boolean> value = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, Boolean.class);
anonymousDownloadEnabled = value.getValue();
final Panel rootPanel = new Panel();
rootPanel.setSizeFull();
rootPanel.addStyleName("config-panel");
final VerticalLayout vLayout = new VerticalLayout();
vLayout.setMargin(true);
vLayout.setSizeFull();
final Label headerDisSetType = new Label(i18n.get("enonymous.download.title"));
headerDisSetType.addStyleName("config-panel-header");
vLayout.addComponent(headerDisSetType);
final GridLayout gridLayout = new GridLayout(2, 1);
gridLayout.setSpacing(true);
gridLayout.setImmediate(true);
gridLayout.setColumnExpandRatio(1, 1.0F);
gridLayout.setSizeFull();
downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
downloadAnonymousCheckBox.setValue(anonymousDownloadEnabled);
downloadAnonymousCheckBox.addValueChangeListener(event -> configurationHasChanged());
downloadAnonymousCheckBox.setId(SPUIComponetIdProvider.SYSTEM_CONFIGURATION_ANONYMOUS_DOWNLOAD_CHECKBOX);
gridLayout.addComponent(downloadAnonymousCheckBox);
final Label configurationLabel = SPUIComponentProvider.getLabel(i18n.get("enonymous.download.label"),
SPUILabelDefinitions.SP_LABEL_SIMPLE);
gridLayout.addComponent(configurationLabel);
gridLayout.setComponentAlignment(configurationLabel, Alignment.MIDDLE_LEFT);
vLayout.addComponent(gridLayout);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
}
@Override
public void configurationHasChanged() {
anonymousDownloadEnabled = downloadAnonymousCheckBox.getValue();
notifyConfigurationChanged();
}
@Override
public void save() {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED,
downloadAnonymousCheckBox.getValue());
}
@Override
public void undo() {
final TenantConfigurationValue<Boolean> value = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, Boolean.class);
anonymousDownloadEnabled = value.getValue();
downloadAnonymousCheckBox.setValue(anonymousDownloadEnabled);
}
}

View File

@@ -29,8 +29,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* View to configure the polling interval and the overdue time.
*
*
*/
@SpringComponent
@ViewScope

View File

@@ -38,9 +38,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* Main UI for the system configuration view.
*
*
*
*/
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
@ViewScope
@@ -58,6 +55,9 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
@Autowired
private PollingConfigurationView pollingConfigurationView;
@Autowired
private DownloadAnonymousConfigurationView downloadAnonymousConfigurationView;
@Autowired
private I18N i18n;
@@ -73,13 +73,14 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
private final List<ConfigurationGroup> configurationViews = new ArrayList<>();
/**
* init method adds all Configuration Views to the list of Views.
* Init method adds all Configuration Views to the list of Views.
*/
@PostConstruct
public void init() {
configurationViews.add(defaultDistributionSetTypeLayout);
configurationViews.add(authenticationConfigurationView);
configurationViews.add(pollingConfigurationView);
configurationViews.add(downloadAnonymousConfigurationView);
}
@Override
@@ -154,13 +155,6 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
undoConfigurationBtn.setEnabled(false);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup.
* ConfigurationGroupChangeListener #configurationChanged()
*/
@Override
public void configurationHasChanged() {
saveConfigurationBtn.setEnabled(true);

View File

@@ -21,9 +21,6 @@ import com.vaadin.server.Resource;
/**
* Menu item for system configuration view.
*
*
*
*/
@Component
@Order(700)

View File

@@ -26,16 +26,13 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
*
*
* This class represents the UI item for the certificate authenticated by an
* reverse proxy in the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class CertificateAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
@@ -59,7 +56,7 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
@@ -94,12 +91,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {
@@ -110,12 +101,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
setDetailVisible(true);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configDisable()
*/
@Override
public void configDisable() {
if (configurationEnabled) {
@@ -125,11 +110,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
setDetailVisible(false);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem#save()
*/
@Override
public void save() {
if (configurationEnabledChange) {
@@ -142,11 +122,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem#undo()
*/
@Override
public void undo() {
configurationEnabledChange = false;

View File

@@ -30,16 +30,13 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
*
*
* This class represents the UI item for the gateway security token section in
* the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class GatewaySecurityTokenAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
@@ -70,7 +67,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
@@ -135,12 +132,6 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
notifyConfigurationChanged();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {

View File

@@ -19,17 +19,13 @@ import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/**
*
*
*
* This class represents the UI item for the target security token section in
* the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class TargetSecurityTokenAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
@@ -49,7 +45,7 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
@@ -57,12 +53,6 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
configurationEnabled = isConfigEnabled();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {
@@ -71,12 +61,6 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
configurationEnabled = true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configDisable()
*/
@Override
public void configDisable() {
if (configurationEnabled) {

View File

@@ -14,8 +14,6 @@ import java.util.List;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout;
@@ -50,8 +48,8 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
this.addComponent(durationField, 1, 0);
this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT);
checkBox.addValueChangeListener(event->checkBoxChange());
durationField.addValueChangeListener(event->notifyConfigurationChanged());
checkBox.addValueChangeListener(event -> checkBoxChange());
durationField.addValueChangeListener(event -> notifyConfigurationChanged());
}
private void checkBoxChange() {

View File

@@ -31,6 +31,7 @@ import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UserDetails;
@@ -89,8 +90,6 @@ public final class HawkbitCommonUtil {
private static final String COUNT_STYLE = " countStyle = document.createElement('style'); ";
private static final String COUNT_STYLE_ID = " countStyle.id=\"sp-drag-count\"; ";
private static final String APPEND_CHILD = " document.head.appendChild(countStyle);";
private static final String HEADER_VERSION = "header.version";
private static final String HEADER_NAME = "header.name";
private static final String SM_HIGHLIGHT_CREATE_SCRIPT = "smHighlight = document.createElement('style'); smHighlight.id=\"sm-table-highlight\"; document.head.appendChild(smHighlight); ";
private static final String SM_HIGHLIGHT_REMOVE_SCRIPT = "var y = document.getElementById('sm-table-highlight'); if(y) { document.head.removeChild(y); } ";
private static final String SM_HIGHLIGHT_RESET_SCRIPT = SM_HIGHLIGHT_REMOVE_SCRIPT + SM_HIGHLIGHT_CREATE_SCRIPT
@@ -1279,4 +1278,19 @@ public final class HawkbitCommonUtil {
return val.toString();
}
/**
* Receive the code point of a given StatusFontIcon.
*
* @param statusFontIcon
* the status font icon
* @return the code point of the StatusFontIcon
*/
public static String getCodePoint(final StatusFontIcon statusFontIcon) {
if (statusFontIcon == null) {
return null;
}
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
: null;
}
}

View File

@@ -501,6 +501,11 @@ public final class SPUIComponetIdProvider {
*/
public static final String SYSTEM_CONFIGURATION_CANCEL = "system.configuration.cancel";
/**
* Id of the anonymous download checkbox.
*/
public static final String SYSTEM_CONFIGURATION_ANONYMOUS_DOWNLOAD_CHECKBOX = "system.configuration.anonymous.download.checkbox";
/**
* Id of maximize/minimize icon of table - Software module table.
*/
@@ -827,7 +832,7 @@ public final class SPUIComponetIdProvider {
* Rollout status label id.
*/
public static final String ROLLOUT_STATUS_LABEL_ID = "rollout.status.id";
/**
* Rollout group status label id.
*/
@@ -867,12 +872,12 @@ public final class SPUIComponetIdProvider {
* Rollout group targets count message label.
*/
public static final String ROLLOUT_GROUP_TARGET_LABEL = "rollout.group.target.label";
/**
* Action confirmation popup id.
*/
public static final String CONFIRMATION_POPUP_ID = "action.confirmation.popup.id";
/**
* Validation status icon .
*/

View File

@@ -401,6 +401,8 @@ configuration.polling.title=Polling Configuration
configuration.polling.time=Polling Time
configuration.polling.overduetime=Polling Overdue Time
configuration.polling.custom.value=use a custom value
enonymous.download.title=Anonymous download
enonymous.download.label=Allow anonymous download. If you enable this option the download server will accept anonymous download requests.
#Calendar
calendar.year=year

View File

@@ -389,6 +389,8 @@ configuration.defaultdistributionset.select.label=Wahl des default Distribution
configuration.savebutton.tooltip=Konfigurationen speichern
configuration.cancellbutton.tooltip=Konfigurationen zur<75>cksetzen
configuration.authentication.title=Authentifikationseinstellungen
enonymous.download.title=Anonymes herunterladen
enonymous.download.label=Erlaube anonymes herunterladen. When diese option aktivert ist, wird der download server anonyme download anfragen erlauben.
#Calendar
calendar.year=Jahr
calendar.years=Jahre

View File

@@ -383,6 +383,8 @@ configuration.authentication.title=Authentication Configuration
controller.polling.title=Polling Configuration
controller.polling.time=Polling Time
controller.polling.overduetime=Polling Overdue Time
enonymous.download.title=Anonymous download
enonymous.download.label=Allow anonymous download. If you enable this option the download server will accept anonymous download requests.
#Calendar
calendar.year=year