Skip to content

Commit

Permalink
#37 Externalization of auth view and userGroups. Widgets are reused i…
Browse files Browse the repository at this point in the history
…n wizard.
  • Loading branch information
dmajirsky committed Nov 26, 2020
1 parent cff4487 commit e89c910
Show file tree
Hide file tree
Showing 19 changed files with 896 additions and 619 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.vaadin.flow.component.radiobutton.RadioButtonGroup;
import com.vaadin.flow.component.radiobutton.RadioGroupVariant;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.firitin.components.orderedlayout.VVerticalLayout;
import software.netcore.radman.buisness.service.attribute.AttributeService;
import software.netcore.radman.buisness.service.auth.AuthService;
import software.netcore.radman.buisness.service.nas.NasService;
import software.netcore.radman.buisness.service.security.SecurityService;
import software.netcore.radman.buisness.service.user.radius.RadiusUserService;
import software.netcore.radman.ui.component.wizard.DataStorage;
import software.netcore.radman.ui.component.wizard.WizardStep;

import java.util.List;
Expand All @@ -34,14 +34,20 @@ public class IntroductionStep implements WizardStep<NewEntityWizardDataStorage>
private static final String ATTRIBUTE = "Attribute";

private final NasService nasService;
private final AuthService authService;
private final AttributeService attributeService;
private final RadiusUserService radiusUserService;
private final SecurityService securityService;

public IntroductionStep(NasService nasService,
AuthService authService,
AttributeService attributeService,
RadiusUserService radiusUserService,
SecurityService securityService,
List<WizardStep<NewEntityWizardDataStorage>> steps) {
this.nasService = nasService;
this.authService = authService;
this.attributeService = attributeService;
this.radiusUserService = radiusUserService;
this.securityService = securityService;
this.steps = steps;
Expand Down Expand Up @@ -88,9 +94,10 @@ private void buildWizardSteps() {
steps.add(new NasGroupStep(nasService));
break;
case USER:
steps.add(new UserStep(radiusUserService, securityService, steps));
steps.add(new UserStep(authService, attributeService, radiusUserService, securityService, steps));
break;
case USER_GROUP:
steps.add(new UserGroupStep(steps));
break;
case ATTRIBUTE:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ private static class NasStepSecond implements WizardStep<NewEntityWizardDataStor
private final VVerticalLayout contentLayout = new VVerticalLayout();
private final Binder<NasGroupDto> binder = new Binder<>();

private RadioButtonGroup<String> radioGroup;
private ComboBox<NasGroupDto> existingGroups;
private TextField newGroupName;
private String nasIpAddress;
private final RadioButtonGroup<String> radioGroup;
private final ComboBox<NasGroupDto> existingGroups;
private final TextField newGroupName;
private final String nasIpAddress;

public NasStepSecond(NasService nasService, String nasIpAddress) {
this.nasIpAddress = nasIpAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Setter;
import software.netcore.radman.buisness.service.nas.dto.NasDto;
import software.netcore.radman.buisness.service.nas.dto.NasGroupDto;
import software.netcore.radman.buisness.service.user.radius.dto.RadiusGroupDto;
import software.netcore.radman.ui.component.wizard.DataStorage;

import java.util.HashSet;
Expand All @@ -21,4 +22,6 @@ public class NewEntityWizardDataStorage implements DataStorage {

private Set<NasGroupDto> nasGroupDtos = new HashSet<>();

private RadiusGroupDto radiusGroupDto;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package software.netcore.radman.ui.component.wizard.demo;

import com.vaadin.flow.component.Component;
import lombok.NonNull;
import org.vaadin.firitin.components.orderedlayout.VVerticalLayout;
import software.netcore.radman.buisness.service.user.radius.dto.RadiusGroupDto;
import software.netcore.radman.ui.component.wizard.WizardStep;
import software.netcore.radman.ui.view.userGroups.widget.UserGroupsForm;

import java.util.List;

public class UserGroupStep implements WizardStep<NewEntityWizardDataStorage> {

private final VVerticalLayout contentLayout = new VVerticalLayout();
private final List<WizardStep<NewEntityWizardDataStorage>> steps;
private final UserGroupsForm userGroupsForm;

public UserGroupStep(List<WizardStep<NewEntityWizardDataStorage>> steps) {
this.steps = steps;
userGroupsForm = new UserGroupsForm();
userGroupsForm.setBean(new RadiusGroupDto());
contentLayout.withComponent(userGroupsForm);
}

@Override
public Component getContent() {
steps.add(new UserGroupStepSecond());
return contentLayout;
}

@Override
public boolean isValid() {
return userGroupsForm.isValid();
}

@Override
public void writeDataToStorage(@NonNull NewEntityWizardDataStorage dataStorage) {
dataStorage.setRadiusGroupDto(userGroupsForm.getBean());
}

private class UserGroupStepSecond implements WizardStep<NewEntityWizardDataStorage> {

private final VVerticalLayout contentLayout = new VVerticalLayout();

@Override
public Component getContent() {
return contentLayout;
}

@Override
public boolean isValid() {
return true;
}

@Override
public void writeDataToStorage(@NonNull NewEntityWizardDataStorage dataStorage) {

}

@Override
public boolean hasNextStep() {
return false;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
import org.vaadin.artur.spring.dataprovider.SpringDataProviderBuilder;
import org.vaadin.firitin.components.orderedlayout.VHorizontalLayout;
import org.vaadin.firitin.components.orderedlayout.VVerticalLayout;
import software.netcore.radman.buisness.service.attribute.AttributeService;
import software.netcore.radman.buisness.service.auth.AuthService;
import software.netcore.radman.buisness.service.security.SecurityService;
import software.netcore.radman.buisness.service.user.radius.RadiusUserService;
import software.netcore.radman.buisness.service.user.radius.dto.RadiusGroupDto;
import software.netcore.radman.buisness.service.user.radius.dto.RadiusGroupFilter;
import software.netcore.radman.buisness.service.user.system.dto.RoleDto;
import software.netcore.radman.buisness.service.user.system.dto.SystemUserDto;
import software.netcore.radman.ui.component.wizard.WizardStep;
import software.netcore.radman.ui.view.auth.widget.AuthenticationGrid;
import software.netcore.radman.ui.view.auth.widget.AuthorizationGrid;
import software.netcore.radman.ui.view.systemUsers.widget.SystemUserForm;
import software.netcore.radman.ui.view.userToGroup.widget.AddUserToGroupDialog;

Expand All @@ -32,25 +36,30 @@ public class UserStep implements WizardStep<NewEntityWizardDataStorage> {
private final List<WizardStep<NewEntityWizardDataStorage>> steps;
private final SystemUserForm userForm;

private final AuthService authService;
private final AttributeService attributeService;
private final RadiusUserService radiusUserService;
private final SecurityService securityService;

public UserStep(RadiusUserService radiusUserService,
public UserStep(AuthService authService,
AttributeService attributeService,
RadiusUserService radiusUserService,
SecurityService securityService,
List<WizardStep<NewEntityWizardDataStorage>> steps) {
this.authService = authService;
this.attributeService = attributeService;
this.radiusUserService = radiusUserService;
this.securityService = securityService;
this.steps = steps;

userForm = new SystemUserForm();
userForm.setBean(new SystemUserDto());
contentLayout.withComponent(userForm);

}

@Override
public Component getContent() {
steps.add(new UserStepSecond(radiusUserService, securityService, steps));
steps.add(new UserStepSecond(steps));
return contentLayout;
}

Expand All @@ -64,16 +73,12 @@ public void writeDataToStorage(@NonNull NewEntityWizardDataStorage dataStorage)

}

private static class UserStepSecond implements WizardStep<NewEntityWizardDataStorage> {
private class UserStepSecond implements WizardStep<NewEntityWizardDataStorage> {

private final VVerticalLayout contentLayout = new VVerticalLayout();
private final List<WizardStep<NewEntityWizardDataStorage>> steps;
private final RadiusUserService radiusUserService;

UserStepSecond(RadiusUserService radiusUserService,
SecurityService securityService,
List<WizardStep<NewEntityWizardDataStorage>> steps) {
this.radiusUserService = radiusUserService;
UserStepSecond(List<WizardStep<NewEntityWizardDataStorage>> steps) {
this.steps = steps;

RadiusGroupFilter filter = new RadiusGroupFilter();
Expand Down Expand Up @@ -115,33 +120,48 @@ public Component getContent() {

@Override
public boolean isValid() {
return false;
return true;
}

@Override
public void writeDataToStorage(@NonNull NewEntityWizardDataStorage dataStorage) {

}

}

private static class UserStepThird implements WizardStep<NewEntityWizardDataStorage> {
private class UserStepThird implements WizardStep<NewEntityWizardDataStorage> {

private final VVerticalLayout contentLayout = new VVerticalLayout();

UserStepThird() {
AuthenticationGrid authGrid = new AuthenticationGrid(authService, attributeService, radiusUserService, securityService);
AuthorizationGrid autzGrid = new AuthorizationGrid(authService, attributeService, radiusUserService, securityService);

contentLayout.withComponent(authGrid)
.withComponent(autzGrid);
}

@Override
public Component getContent() {
return contentLayout;
}

@Override
public boolean isValid() {
return false;
return true;
}

@Override
public void writeDataToStorage(@NonNull NewEntityWizardDataStorage dataStorage) {

}

@Override
public boolean hasNextStep() {
return false;
}

}

}
10 changes: 10 additions & 0 deletions src/main/java/software/netcore/radman/ui/menu/MenuTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.security.core.context.SecurityContextHolder;
import software.netcore.radman.buisness.service.attribute.AttributeService;
import software.netcore.radman.buisness.service.auth.AuthService;
import software.netcore.radman.buisness.service.nas.NasService;
import software.netcore.radman.buisness.service.nas.dto.NasGroupDto;
import software.netcore.radman.buisness.service.security.SecurityService;
Expand All @@ -28,8 +30,10 @@
import software.netcore.radman.ui.component.wizard.demo.IntroductionStep;
import software.netcore.radman.ui.component.wizard.demo.NewEntityWizardDataStorage;
import software.netcore.radman.ui.view.*;
import software.netcore.radman.ui.view.auth.AuthView;
import software.netcore.radman.ui.view.nas.NasView;
import software.netcore.radman.ui.view.systemUsers.SystemUsersView;
import software.netcore.radman.ui.view.userGroups.UserGroupsView;
import software.netcore.radman.ui.view.userToGroup.UserToGroupView;

import javax.transaction.Transactional;
Expand All @@ -52,6 +56,10 @@ public class MenuTemplate extends PolymerTemplate<MenuTemplate.MenuTemplateModel
@Autowired
private NasService nasService;
@Autowired
private AuthService authService;
@Autowired
private AttributeService attributeService;
@Autowired
private RadiusUserService radiusUserService;
@Autowired
private SecurityService securityService;
Expand Down Expand Up @@ -137,6 +145,8 @@ private void add() {

additionWizard.getSteps().add(
new IntroductionStep(nasService,
authService,
attributeService,
radiusUserService,
securityService,
additionWizard.getSteps()));
Expand Down
Loading

0 comments on commit e89c910

Please sign in to comment.