Implemented getting server version

This commit is contained in:
Andrey Terentev 2024-02-10 07:48:47 +07:00
parent 76d6d6bfed
commit 65d6e325bc
5 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,8 @@
package ru.dragonestia.picker.api.repository;
import ru.dragonestia.picker.api.repository.response.RoomPickerInfoResponse;
public interface RoomPickerRepository {
RoomPickerInfoResponse getInfo();
}

View File

@ -0,0 +1,3 @@
package ru.dragonestia.picker.api.repository.response;
public record RoomPickerInfoResponse(String version) {}

View File

@ -0,0 +1,14 @@
package ru.dragonestia.picker.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import ru.dragonestia.picker.api.repository.response.RoomPickerInfoResponse;
@RestController
public class RoomPickerController {
@GetMapping("/info")
RoomPickerInfoResponse info() {
return new RoomPickerInfoResponse("v0.0.1");
}
}

View File

@ -5,14 +5,22 @@ import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.applayout.AppLayout; import com.vaadin.flow.component.applayout.AppLayout;
import com.vaadin.flow.component.applayout.DrawerToggle; import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.Scroller; import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.component.sidenav.SideNav; import com.vaadin.flow.component.sidenav.SideNav;
import com.vaadin.flow.component.sidenav.SideNavItem; import com.vaadin.flow.component.sidenav.SideNavItem;
import org.springframework.beans.factory.annotation.Autowired;
import ru.dragonestia.picker.api.repository.RoomPickerRepository;
import ru.dragonestia.picker.api.repository.response.RoomPickerInfoResponse;
public class MainLayout extends AppLayout { public class MainLayout extends AppLayout {
public MainLayout() { private final RoomPickerInfoResponse info;
public MainLayout(RoomPickerRepository roomPickerRepository) {
info = roomPickerRepository.getInfo();
var toggle = new DrawerToggle(); var toggle = new DrawerToggle();
var scroller = new Scroller(createSideNav()); var scroller = new Scroller(createSideNav());
@ -22,8 +30,10 @@ public class MainLayout extends AppLayout {
private Component createLogo() { private Component createLogo() {
var layout = new HorizontalLayout(); var layout = new HorizontalLayout();
layout.setAlignItems(FlexComponent.Alignment.END);
layout.setPadding(true); layout.setPadding(true);
layout.add(new Html("<h2><u>RoomPicker!</u></h2>")); layout.add(new Html("<h2><u>RoomPicker!</u></h2>"));
layout.add(new Html("<sub>" + info.version() + "</sub>"));
return layout; return layout;
} }

View File

@ -0,0 +1,19 @@
package ru.dragonestia.picker.cp.repository.impl;
import com.vaadin.flow.spring.annotation.SpringComponent;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpMethod;
import ru.dragonestia.picker.api.repository.RoomPickerRepository;
import ru.dragonestia.picker.api.repository.response.RoomPickerInfoResponse;
@RequiredArgsConstructor
@SpringComponent
public class RoomPickerRepositoryImpl implements RoomPickerRepository {
private final RestUtil rest;
@Override
public RoomPickerInfoResponse getInfo() {
return rest.query("/info", HttpMethod.GET, RoomPickerInfoResponse.class, params -> {});
}
}