Skip to content

Commit

Permalink
Provide default authority images as Base64 data URI to support subpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Sep 14, 2022
1 parent ba5fc91 commit 2b7034f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
16 changes: 14 additions & 2 deletions backend/src/main/java/org/cryptomator/hub/api/AuthorityDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

abstract sealed class AuthorityDto permits UserDto, GroupDto {

private static final String DEFAULT_USER_DATA_IMAGE = """
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJoLTUgdy01IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGZpbGw9ImN1cnJlbnRDb2xvciI+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkd\
Gg9IjIwIiBoZWlnaHQ9IjIwIiByeD0iMDAiIHJ5PSIwMCIgZmlsbD0id2hpdGUiIC8+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgOWEzIDMgMCAxMDAtNiAzIDMgMCAwMDAgNnptLTcgOWE3IDcgMCAxMTE0IDBIM3oiIGNsaXAt\
cnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+
""";
private static final String DEFAULT_GROUP_DATA_IMAGE = """
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzTmFtZT0iaC01IHctNSIgdmlld0JveD0iMCAwIDIwIDIwIiBmaWxsPSJjdXJyZW50Q29sb3IiPgogIDxyZWN0IHg9IjAiIHk9IjAiI\
HdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgcng9IjAwIiByeT0iMDAiIGZpbGw9IndoaXRlIiAvPgogIDxwYXRoIGQ9Ik0xMyA2YTMgMyAwIDExLTYgMCAzIDMgMCAwMTYgMHpNMTggOGEyIDIgMCAxMS00IDAgMiAyIDAgMDE0IDB6TTE0IDE1YTQgNCAw\
IDAwLTggMHYzaDh2LTN6TTYgOGEyIDIgMCAxMS00IDAgMiAyIDAgMDE0IDB6TTE2IDE4di0zYTUuOTcyIDUuOTcyIDAgMDAtLjc1LTIuOTA2QTMuMDA1IDMuMDA1IDAgMDExOSAxNXYzaC0zek00Ljc1IDEyLjA5NEE1Ljk3MyA1Ljk3MyAwIDAwNCA\
xNXYzSDF2LTNhMyAzIDAgMDEzLjc1LTIuOTA2eiIgLz4KPC9zdmc+
""";

public enum Type {
USER, GROUP
}
Expand All @@ -27,8 +39,8 @@ protected AuthorityDto(String id, Type type, String name, String pictureUrl) {
this.type = type;
this.name = name;
this.pictureUrl = Objects.requireNonNullElseGet(pictureUrl, () -> switch (type) {
case USER -> "/user-icon.svg";
case GROUP -> "/group-icon.svg";
case USER -> DEFAULT_USER_DATA_IMAGE;
case GROUP -> DEFAULT_GROUP_DATA_IMAGE;
});
}

Expand Down
4 changes: 0 additions & 4 deletions frontend/public/group-icon.svg

This file was deleted.

4 changes: 0 additions & 4 deletions frontend/public/user-icon.svg

This file was deleted.

0 comments on commit 2b7034f

Please sign in to comment.