Added tenant configuration for anyonmous download and UI element to allow to configure anonymous download

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Philip Knoblauch
2016-03-22 17:01:24 +01:00
parent 3f4788d60e
commit a3295b518d
6 changed files with 137 additions and 1 deletions

View File

@@ -63,7 +63,12 @@ public enum TenantConfigurationKey {
/**
* string value which holds the polling time interval in the format HH:mm:ss
*/
POLLING_OVERDUE_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, TenantConfigurationPollingDurationValidator.class);
POLLING_OVERDUE_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, TenantConfigurationPollingDurationValidator.class),
/**
* boolean value {@code true} {@code false}.
*/
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
private final String keyName;
private final String defaultKeyName;

View File

@@ -0,0 +1,121 @@
/**
* 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.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;
/**
* @author Jonathan Knoblauch
*
*/
@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; // TODO
@Autowired
private transient TenantConfigurationManagement tenantConfigurationManagement;
boolean anonymousDownloadEnabled;
private CheckBox downloadAnonymousCheckBox;
/**
* Initialize Default Distribution Set 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.setId("TODO");
downloadAnonymousCheckBox.addValueChangeListener(event -> configurationHasChanged());
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());
// TODO notification Download server
}
@Override
public void undo() {
anonymousDownloadEnabled = tenantConfigurationManagement
.getGlobalConfigurationValue(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, Boolean.class);
downloadAnonymousCheckBox.setValue(anonymousDownloadEnabled);
}
}

View File

@@ -58,6 +58,9 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
@Autowired
private PollingConfigurationView pollingConfigurationView;
@Autowired
private DownloadAnonymousConfigurationView downloadAnonymousConfigurationView;
@Autowired
private I18N i18n;
@@ -80,6 +83,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
configurationViews.add(defaultDistributionSetTypeLayout);
configurationViews.add(authenticationConfigurationView);
configurationViews.add(pollingConfigurationView);
configurationViews.add(downloadAnonymousConfigurationView);
}
@Override

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