Skip to content

Commit 588843e

Browse files
committed
code cleanup
1 parent d5d808a commit 588843e

File tree

6 files changed

+10
-37
lines changed

6 files changed

+10
-37
lines changed

backend/src/main/java/org/cryptomator/hub/api/AuthorityDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected AuthorityDto(String id, Type type, String name, String pictureUrl) {
3333
}
3434

3535
@Inject
36-
static User.Repository userRepo; // Inject User Repository für die neue Berechnung
36+
static User.Repository userRepo;
3737

3838
static AuthorityDto fromEntity(Authority a) {
3939
return switch (a) {

backend/src/main/java/org/cryptomator/hub/api/AuthorityResource.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class AuthorityResource {
2525
Authority.Repository authorityRepo;
2626

2727
@Inject
28-
User.Repository userRepo; // UserRepo wird hier für die Gruppen-Mitgliederanzahl benötigt
28+
User.Repository userRepo;
2929

3030
@GET
3131
@Path("/search")
@@ -36,7 +36,7 @@ public class AuthorityResource {
3636
public List<AuthorityDto> search(@QueryParam("query") @NotBlank String query) {
3737
List<Authority> authorities = authorityRepo.byName(query).toList();
3838
return authorities.stream()
39-
.map(this::convertToDto) // Neue Methode für die Konvertierung mit Member-Anzahl
39+
.map(this::convertToDto)
4040
.toList();
4141
}
4242

@@ -49,14 +49,10 @@ public List<AuthorityDto> search(@QueryParam("query") @NotBlank String query) {
4949
@APIResponse(responseCode = "200")
5050
public List<AuthorityDto> getSome(@QueryParam("ids") List<String> authorityIds) {
5151
return authorityRepo.findAllInList(authorityIds)
52-
.map(this::convertToDto) // Neue Methode wird hier genutzt
52+
.map(this::convertToDto)
5353
.toList();
5454
}
5555

56-
/**
57-
* Konvertiert eine Authority-Entity in das passende DTO,
58-
* inklusive der Gruppen-Mitgliederanzahl für Gruppen.
59-
*/
6056
private AuthorityDto convertToDto(Authority a) {
6157
if (a instanceof User u) {
6258
return UserDto.justPublicInfo(u);

backend/src/main/java/org/cryptomator/hub/api/GroupsResource.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
import jakarta.annotation.security.RolesAllowed;
44
import jakarta.inject.Inject;
5+
import jakarta.ws.rs.core.Response;
56
import jakarta.ws.rs.GET;
67
import jakarta.ws.rs.Path;
78
import jakarta.ws.rs.PathParam;
89
import jakarta.ws.rs.Produces;
910
import jakarta.ws.rs.core.MediaType;
10-
1111
import org.cryptomator.hub.entities.Group;
1212
import org.cryptomator.hub.entities.User;
1313
import org.cryptomator.hub.validation.ValidId;
1414
import org.eclipse.microprofile.openapi.annotations.Operation;
1515

16-
import jakarta.ws.rs.core.Response;
17-
import java.util.Map;
18-
import java.util.HashMap;
1916
import java.util.List;
17+
import java.util.HashMap;
18+
import java.util.Map;
2019

2120
@Path("/groups")
2221
public class GroupsResource {

backend/src/main/java/org/cryptomator/hub/entities/Group.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@DiscriminatorValue("GROUP")
1414
public class Group extends Authority {
1515

16-
@ManyToMany(cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY)
16+
@ManyToMany(cascade = {CascadeType.REMOVE})
1717
@JoinTable(name = "group_membership",
1818
joinColumns = @JoinColumn(name = "group_id", referencedColumnName = "id"),
1919
inverseJoinColumns = @JoinColumn(name = "member_id", referencedColumnName = "id")
@@ -31,14 +31,12 @@ public void setMembers(Set<Authority> members) {
3131
this.members = members;
3232
}
3333

34-
3534
public int getMemberCount() {
36-
return groupRepo.countMembers(this.getId()); // Verwende das injectete Repository
35+
return groupRepo.countMembers(this.getId());
3736
}
3837

3938
@ApplicationScoped
4039
public static class Repository implements PanacheRepositoryBase<Group, String> {
41-
4240
public int countMembers(String groupId) {
4341
return getEntityManager()
4442
.createQuery("SELECT SIZE(g.members) FROM Group g WHERE g.id = :groupId", Integer.class)

frontend/src/components/SearchInputGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="relative">
66
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
77
<UsersIcon v-if="selectedItem == null" class="h-5 w-5 text-gray-400" aria-hidden="true" />
8-
<img v-else :src="selectedItem.pictureUrl ?? ''" alt="" class="w-5 h-5 rounded-full">
8+
<img v-else :src="selectedItem.pictureUrl ?? ''" alt="" class="w-5 h-5 rounded-full" >
99
</div>
1010

1111
<ComboboxInput

frontend/src/components/VaultDetails.vue

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ const groupMemberCounts = computed(() => {
347347
return counts;
348348
});
349349
350-
351350
async function loadVaultKeys(vaultKeyJwe: string): Promise<VaultKeys> {
352351
const userKeys = await userdata.decryptUserKeysWithBrowser();
353352
return VaultKeys.decryptWithUserKey(vaultKeyJwe, userKeys.ecdhKeyPair.privateKey);
@@ -496,17 +495,8 @@ function refreshVault(updatedVault: VaultDto) {
496495
emit('vaultUpdated', updatedVault);
497496
}
498497
499-
const searchQuery = ref('');
500498
const searchResults = ref<Array<AuthorityDto & { memberCount?: number }>>([]);
501499
502-
async function onSearch() {
503-
if (!searchQuery.value) {
504-
searchResults.value = [];
505-
return;
506-
}
507-
searchResults.value = await searchAuthority(searchQuery.value);
508-
}
509-
510500
async function searchAuthority(query: string): Promise<(AuthorityDto & { memberCount?: number })[]> {
511501
const results = await backend.authorities.search(query);
512502
const filtered = results.filter(authority => !members.value.has(authority.id));
@@ -527,16 +517,6 @@ async function searchAuthority(query: string): Promise<(AuthorityDto & { memberC
527517
return enhanced.sort((a, b) => a.name.localeCompare(b.name));
528518
}
529519
530-
const searchGroupMemberCounts = computed(() => {
531-
const counts = new Map<string, number>();
532-
searchResults.value.forEach((result) => {
533-
if (result.type === 'GROUP') {
534-
counts.set(result.id, result.memberCount ?? 0);
535-
}
536-
});
537-
return counts;
538-
});
539-
540520
async function updateMemberRole(member: MemberDto, role: VaultRole) {
541521
delete onUpdateVaultMembershipError.value[member.id];
542522
try {

0 commit comments

Comments
 (0)