-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from penguineer/userfunctions
Add user functions
- Loading branch information
Showing
7 changed files
with
186 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
/* GartenPlus theme */ | ||
/* GartenPlus theme */ | ||
|
||
vaadin-menu-bar-button[theme="icon"] { | ||
background: unset; | ||
color: var(--lumo-base-color) !important; | ||
height: 100%; | ||
} | ||
|
||
vaadin-menu-bar-overlay[theme="icon"] { | ||
z-index: 1000; | ||
top: 64px !important; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...lus/ui/appframe/LegalDatenschutzPage.java → ...plus/ui/content/LegalDatenschutzPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...nplus/ui/appframe/LegalImpressumPage.java → ...enplus/ui/content/LegalImpressumPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/penguineering/gartenplus/ui/content/admin/AdminLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.penguineering.gartenplus.ui.content.admin; | ||
|
||
|
||
import com.penguineering.gartenplus.ui.appframe.AppFrameLayout; | ||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.ParentLayout; | ||
import com.vaadin.flow.router.RoutePrefix; | ||
import com.vaadin.flow.router.RouterLayout; | ||
import jakarta.annotation.security.PermitAll; | ||
|
||
@ParentLayout(AppFrameLayout.class) | ||
@RoutePrefix(value = "admin") | ||
public class AdminLayout extends Div implements RouterLayout { | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/penguineering/gartenplus/ui/content/admin/LogoutPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.penguineering.gartenplus.ui.content.admin; | ||
|
||
import com.penguineering.gartenplus.ui.appframe.GartenplusPage; | ||
import com.vaadin.flow.component.UI; | ||
import com.vaadin.flow.component.button.Button; | ||
import com.vaadin.flow.component.html.Paragraph; | ||
import com.vaadin.flow.component.icon.VaadinIcon; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.router.PageTitle; | ||
import com.vaadin.flow.router.Route; | ||
import com.vaadin.flow.server.VaadinSession; | ||
import jakarta.annotation.security.PermitAll; | ||
|
||
import java.util.Arrays; | ||
|
||
@Route(value = "logout", layout = AdminLayout.class) | ||
@PermitAll | ||
@PageTitle("GartenPlus | Abmelden") | ||
public class LogoutPage extends GartenplusPage { | ||
private static final String[] descriptionText = { | ||
"Auf dieser Seite kann man sich abmelden.", | ||
"Hinweis: Durch SSO kommt es sofort zur erneuten Anmeldung.", | ||
"Die Abmeldung setzt die Session zurück und lädt Daten vom OIDC-Provider neu." | ||
}; | ||
|
||
public LogoutPage() { | ||
VerticalLayout description = new VerticalLayout(); | ||
description.setMargin(false); | ||
description.setPadding(false); | ||
description.setSpacing(false); | ||
description.getStyle() | ||
.set("margin", "0px auto"); | ||
|
||
Arrays.stream(descriptionText).map(Paragraph::new).forEach(description::add); | ||
add(description); | ||
|
||
var button = new Button("Abmelden", VaadinIcon.SIGN_OUT.create(), | ||
e -> logout()); | ||
|
||
add(button); | ||
} | ||
|
||
private void logout() { | ||
VaadinSession.getCurrent().close(); | ||
|
||
getUI() | ||
.map(UI::getPage) | ||
.ifPresent(page -> page.setLocation("/login")); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/com/penguineering/gartenplus/ui/content/admin/ProfilePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.penguineering.gartenplus.ui.content.admin; | ||
|
||
import com.penguineering.gartenplus.auth.user.UserDTO; | ||
import com.penguineering.gartenplus.ui.appframe.GartenplusPage; | ||
import com.vaadin.flow.component.grid.Grid; | ||
import com.vaadin.flow.component.html.H2; | ||
import com.vaadin.flow.component.html.Paragraph; | ||
import com.vaadin.flow.router.PageTitle; | ||
import com.vaadin.flow.router.Route; | ||
import jakarta.annotation.security.PermitAll; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
|
||
@Route(value = "profile", layout = AdminLayout.class) | ||
@PermitAll | ||
@PageTitle("GartenPlus | Benutzerprofil") | ||
public class ProfilePage extends GartenplusPage { | ||
public ProfilePage(@Qualifier("user") Supplier<UserDTO> currentUser) { | ||
Optional<UserDTO> userOpt = Optional.of(currentUser).map(Supplier::get); | ||
|
||
add(new H2("Benutzerprofil")); | ||
add(new Paragraph("Folgende Daten wurden vom OIDC-Provider übernommen:")); | ||
|
||
Grid<Map.Entry<String, String>> grid = new Grid<>(); | ||
grid.setAllRowsVisible(true); | ||
|
||
grid.addColumn(Map.Entry::getKey).setHeader("Bezeichnung").setAutoWidth(true).setFlexGrow(0); | ||
grid.addColumn(Map.Entry::getValue).setHeader("Wert").setAutoWidth(true).setFlexGrow(1); | ||
|
||
List<Map.Entry<String, String>> items = new ArrayList<>(); | ||
userOpt.ifPresent(userDTO -> { | ||
items.add(Map.entry("Name", userDTO.displayName())); | ||
items.add(Map.entry("E-Mail-Adresse", userDTO.email())); | ||
items.add(Map.entry("Avatar-URL", userDTO.avatarUrl().toASCIIString())); | ||
}); | ||
|
||
grid.setItems(items); | ||
|
||
add(grid); | ||
|
||
add(new Paragraph("Der Avatar wird oben rechts angezeigt.")); | ||
|
||
add(new Paragraph("Die Daten können beim OIDC-Provider geändert werden.")); | ||
} | ||
} |