Added side navigation bar and header (#9)

This commit is contained in:
Andrey Terentev 2024-01-17 00:22:53 +07:00 committed by GitHub
parent 6384fd6bd5
commit 2145c39d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 11 deletions

View File

@ -4,10 +4,9 @@ import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.*;
import ru.dragonestia.picker.api.exception.NodeNotFoundException;
@Route("/")
public class HomePage extends VerticalLayout implements BeforeEnterObserver {
@Route(value = "/", layout = MainLayout.class)
public class HomePage extends VerticalLayout {
public HomePage() {
super();
@ -15,9 +14,4 @@ public class HomePage extends VerticalLayout implements BeforeEnterObserver {
add(new H1("Hello world!"));
add(new Paragraph("Hello world!"));
}
@Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
throw new NodeNotFoundException("gdfsg");
}
}

View File

@ -0,0 +1,38 @@
package ru.dragonestia.picker.cp.page;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.applayout.AppLayout;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.component.sidenav.SideNav;
import com.vaadin.flow.component.sidenav.SideNavItem;
public class MainLayout extends AppLayout {
public MainLayout() {
var toggle = new DrawerToggle();
var scroller = new Scroller(createSideNav());
addToDrawer(scroller);
addToNavbar(toggle, createLogo());
}
private Component createLogo() {
var layout = new HorizontalLayout();
layout.setPadding(true);
layout.add(new Html("<h2><u>RoomPicker!</u></h2>"));
return layout;
}
private SideNav createSideNav() {
var nav = new SideNav();
nav.addItem(new SideNavItem("Nodes list", NodesPage.class, VaadinIcon.FOLDER_O.create()));
nav.addItem(new SideNavItem("Search users", HomePage.class, VaadinIcon.SEARCH.create()));
nav.addItem(new SideNavItem("Documentation", "https://github.com/ScarletRedMan/RoomPicker", VaadinIcon.BOOK.create()));
nav.addItem(new SideNavItem("Sign-out", HomePage.class, VaadinIcon.SIGN_OUT.create()));
return nav;
}
}

View File

@ -27,7 +27,7 @@ import java.util.List;
@Getter
@RequiredArgsConstructor
@PageTitle("Rooms")
@Route("/nodes/:nodeId")
@Route(value = "/nodes/:nodeId", layout = MainLayout.class)
public class NodeDetailsPage extends VerticalLayout implements BeforeEnterObserver {
private final NodeRepository nodeRepository;

View File

@ -16,7 +16,7 @@ import ru.dragonestia.picker.cp.component.RegisterNode;
@Log4j2
@Getter
@PageTitle("Nodes")
@Route("/nodes")
@Route(value = "/nodes", layout = MainLayout.class)
public class NodesPage extends VerticalLayout {
private final NodeRepository nodeRepository;

View File

@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
@RequiredArgsConstructor
@PageTitle("Room details")
@Route("/nodes/:nodeId/rooms/:roomId")
@Route(value = "/nodes/:nodeId/rooms/:roomId", layout = MainLayout.class)
public class RoomDetailsPage extends VerticalLayout implements BeforeEnterObserver {
private final NodeRepository nodeRepository;

View File

@ -3,8 +3,11 @@ package ru.dragonestia.picker.cp.page.plug;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.ParentLayout;
import ru.dragonestia.picker.cp.component.NavPath;
import ru.dragonestia.picker.cp.page.MainLayout;
@ParentLayout(MainLayout.class)
public abstract class ErrorPlug extends VerticalLayout {
public void init(NavPath path, String title, String description) {