Fixed user search
This commit is contained in:
parent
9f2aeaa06e
commit
d1e97bf3b2
@ -8,6 +8,8 @@ import lombok.extern.log4j.Log4j2;
|
||||
import ru.dragonestia.picker.api.exception.ApiException;
|
||||
import ru.dragonestia.picker.cp.component.Notifications;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
@Log4j2
|
||||
public class ApplicationErrorHandler implements ErrorHandler {
|
||||
|
||||
@ -25,6 +27,13 @@ public class ApplicationErrorHandler implements ErrorHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorEvent.getThrowable() instanceof InvalidParameterException ex) {
|
||||
execute(() -> {
|
||||
Notifications.error(ex.getMessage());
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
execute(() -> {
|
||||
Notifications.error("Internal server error");
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ public class UserSearchPage extends VerticalLayout implements RefreshableTable {
|
||||
foundUsers = new Span();
|
||||
add(fieldUsername = createUsernameInputField());
|
||||
add(userGrid = createUserGrid());
|
||||
refresh();
|
||||
justRefresh();
|
||||
}
|
||||
|
||||
private TextField createUsernameInputField() {
|
||||
@ -91,6 +91,11 @@ public class UserSearchPage extends VerticalLayout implements RefreshableTable {
|
||||
}
|
||||
|
||||
private void search(String input) {
|
||||
System.out.println("Input: " + input);
|
||||
if (input.isEmpty()) {
|
||||
userGrid.setItems();
|
||||
}
|
||||
|
||||
userGrid.setItems(cachedUsers = userRepository.searchUsers(SearchUsers.withAllDetails(UserIdentifier.of(input)))
|
||||
.stream().map(user -> (IUser) user).toList());
|
||||
}
|
||||
@ -100,4 +105,9 @@ public class UserSearchPage extends VerticalLayout implements RefreshableTable {
|
||||
search(fieldUsername.getValue().trim());
|
||||
foundUsers.setText("Found %s users".formatted(cachedUsers.size()));
|
||||
}
|
||||
|
||||
public void justRefresh() {
|
||||
userGrid.setItems();
|
||||
foundUsers.setText("Found %s users".formatted(cachedUsers.size()));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user