SoftwareModuleView small improvements (#2377)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -90,17 +90,14 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
grid.addColumn(MgmtSoftwareModule::getTypeName).setHeader(Constants.TYPE).setAutoWidth(true);
|
||||
grid.addColumn(MgmtSoftwareModule::getVendor).setHeader(Constants.VENDOR).setAutoWidth(true);
|
||||
|
||||
grid.setItemDetailsRenderer(new ComponentRenderer<>(
|
||||
() -> details, SoftwareModuleDetails::setItem));
|
||||
|
||||
grid.setItemDetailsRenderer(new ComponentRenderer<>(() -> details, SoftwareModuleDetails::setItem));
|
||||
}
|
||||
},
|
||||
(query, rsqlFilter) -> Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getSoftwareModules(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getSoftwareModules(query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getBody())
|
||||
.stream().flatMap(body -> body.getContent().stream()),
|
||||
.stream().map(PagedList::getContent).flatMap(List::stream),
|
||||
isParent ? v -> new CreateDialog(hawkbitClient).result() : null,
|
||||
isParent ? selectionGrid -> {
|
||||
selectionGrid.getSelectedItems().forEach(
|
||||
@@ -138,7 +135,8 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
type.setItems(Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody()).map(PagedList::getContent)
|
||||
.getBody())
|
||||
.map(PagedList::getContent)
|
||||
.orElseGet(Collections::emptyList));
|
||||
}
|
||||
|
||||
@@ -152,8 +150,7 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
return Filter.filter(
|
||||
Map.of(
|
||||
"name", name.getOptionalValue(),
|
||||
"type", type.getSelectedItems().stream().map(MgmtSoftwareModuleType::getKey)
|
||||
.toList()
|
||||
"type", type.getSelectedItems().stream().map(MgmtSoftwareModuleType::getKey).toList()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -174,14 +171,10 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
|
||||
description.setMinLength(2);
|
||||
artifactGrid = createArtifactGrid();
|
||||
Stream.of(
|
||||
description,
|
||||
createdBy, createdAt,
|
||||
lastModifiedBy, lastModifiedAt)
|
||||
.forEach(field -> {
|
||||
field.setReadOnly(true);
|
||||
add(field);
|
||||
});
|
||||
Stream.of(description, createdBy, createdAt, lastModifiedBy, lastModifiedAt).forEach(field -> {
|
||||
field.setReadOnly(true);
|
||||
add(field);
|
||||
});
|
||||
add(artifactGrid);
|
||||
|
||||
setResponsiveSteps(new ResponsiveStep("0", 2));
|
||||
@@ -198,10 +191,10 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
|
||||
artifactGrid.setItems(query -> Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getArtifacts(
|
||||
softwareModule.getId(), null, null)
|
||||
.getArtifacts(softwareModule.getId(), null, null)
|
||||
.getBody())
|
||||
.stream().flatMap(Collection::stream)
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.skip(query.getOffset())
|
||||
.limit(query.getPageSize()));
|
||||
artifactGrid.setSelectionMode(Grid.SelectionMode.NONE);
|
||||
@@ -230,12 +223,14 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody()).map(body -> body.getContent().toArray(new MgmtSoftwareModuleType[0]))
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtSoftwareModuleType[0]))
|
||||
.orElseGet(() -> new MgmtSoftwareModuleType[0]));
|
||||
type.setWidthFull();
|
||||
type.setRequiredIndicatorVisible(true);
|
||||
type.setItemLabelGenerator(MgmtSoftwareModuleType::getName);
|
||||
type.focus();
|
||||
|
||||
name = Utils.textField(Constants.NAME, this::readyToCreate);
|
||||
version = Utils.textField(Constants.VERSION, this::readyToCreate);
|
||||
vendor = Utils.textField(Constants.VENDOR);
|
||||
@@ -244,18 +239,7 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
description.setMinLength(2);
|
||||
enableArtifactEncryption = new Checkbox("Enable artifact encryption");
|
||||
|
||||
createDistributionSet = new Checkbox("Also create distribution set");
|
||||
createDistributionSet.setHelperText("based on this software module");
|
||||
|
||||
distType = new Select<>(
|
||||
"Distribution Set Type",
|
||||
this::readyToCreate,
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtDistributionSetType[0]))
|
||||
.orElseGet(() -> new MgmtDistributionSetType[0]));
|
||||
distType = new Select<>("Distribution Set Type", this::readyToCreate);
|
||||
distType.setWidthFull();
|
||||
distType.setRequiredIndicatorVisible(true);
|
||||
distType.setItemLabelGenerator(MgmtDistributionSetType::getName);
|
||||
@@ -264,10 +248,21 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
distRequiredMigrationStep = new Checkbox("Required Migration Step");
|
||||
distRequiredMigrationStep.setVisible(false);
|
||||
|
||||
createDistributionSet.addValueChangeListener(evt -> {
|
||||
createDistributionSet = new Checkbox("Create single software module distribution set");
|
||||
createDistributionSet.setHelperText("Create single software module distribution set with this software module");
|
||||
createDistributionSet.addValueChangeListener(e -> {
|
||||
if (Boolean.TRUE.equals(createDistributionSet.getValue()) && distType.isEmpty()) {
|
||||
distType.setItems(
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtDistributionSetType[0]))
|
||||
.orElseGet(() -> new MgmtDistributionSetType[0]));
|
||||
}
|
||||
distType.setVisible(createDistributionSet.getValue());
|
||||
distRequiredMigrationStep.setVisible(createDistributionSet.getValue());
|
||||
this.readyToCreate(evt);
|
||||
readyToCreate(e);
|
||||
});
|
||||
|
||||
create = Utils.tooltip(new Button("Create"), "Create (Enter)");
|
||||
@@ -284,7 +279,10 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
final VerticalLayout layout = new VerticalLayout();
|
||||
layout.setSizeFull();
|
||||
layout.setSpacing(false);
|
||||
layout.add(type, name, version, vendor, description, enableArtifactEncryption, createDistributionSet, distType, distRequiredMigrationStep, actions);
|
||||
layout.add(
|
||||
type, name, version, vendor, description, enableArtifactEncryption,
|
||||
createDistributionSet, distType, distRequiredMigrationStep,
|
||||
actions);
|
||||
add(layout);
|
||||
open();
|
||||
}
|
||||
@@ -316,23 +314,23 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
.getId();
|
||||
if (Boolean.TRUE.equals(createDistributionSet.getValue())) {
|
||||
final long distributionSetId = Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.createDistributionSets(
|
||||
List.of((MgmtDistributionSetRequestBodyPost) new MgmtDistributionSetRequestBodyPost()
|
||||
.setType(distType.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setRequiredMigrationStep(distRequiredMigrationStep.getValue())))
|
||||
.getBody())
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.getId();
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.createDistributionSets(
|
||||
List.of((MgmtDistributionSetRequestBodyPost) new MgmtDistributionSetRequestBodyPost()
|
||||
.setType(distType.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setRequiredMigrationStep(distRequiredMigrationStep.getValue())))
|
||||
.getBody())
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.getId();
|
||||
hawkbitClient.getDistributionSetRestApi().assignSoftwareModules(
|
||||
distributionSetId, List.of((MgmtSoftwareModuleAssignment) new MgmtSoftwareModuleAssignment()
|
||||
.setId(softwareModuleId))).getBody();
|
||||
distributionSetId, List.of((MgmtSoftwareModuleAssignment) new MgmtSoftwareModuleAssignment()
|
||||
.setId(softwareModuleId))).getBody();
|
||||
}
|
||||
new AddArtifactsDialog(softwareModuleId, hawkbitClient).open();
|
||||
});
|
||||
@@ -441,4 +439,4 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user