Task: Fixed server routes loop and add server layout for vaadin flow backend from java code design and rename theme name to fusion and updated the views and add mock users for show data grid and fixed all views

This commit is contained in:
Sambo Chea 2021-07-27 09:53:06 +07:00
parent 05e6fe2447
commit 5a9930161b
13 changed files with 71 additions and 18 deletions

View File

@ -9,6 +9,9 @@ const { serverSideRoutes } = new Flow({
imports: () => import('../target/frontend/generated-flow-imports'),
});
console.log("serverSideRoutes", serverSideRoutes)
export type ViewRoute = Route & {
title?: string;
icon?: string;
@ -67,15 +70,6 @@ export const views: ViewRoute[] = [
},
];
export const routes: ViewRoute[] = [
{
path: '',
component: 'main-layout',
children: [
...views,
// for server-side, the next magic line sends all unmatched routes:
...serverSideRoutes, // IMPORTANT: this must be the last entry in the array
],
},
{
path: 'login',
component: 'login-view',
@ -86,4 +80,18 @@ export const routes: ViewRoute[] = [
return;
},
},
{
path: '',
component: 'main-layout',
children: [
...views,
],
},
{
path: '',
component: 'server-layout',
children: [
...serverSideRoutes,
]
}
];

View File

@ -0,0 +1,10 @@
import { html } from 'lit';
import { customElement } from 'lit/decorators.js';
import {Layout} from "./view";
@customElement('server-layout')
export class AdminView extends Layout {
render() {
return html`<><slot></slot></>`;
}
}

View File

@ -4,13 +4,13 @@ import com.vaadin.flow.component.dependency.NpmPackage
import com.vaadin.flow.component.page.AppShellConfigurator
import com.vaadin.flow.server.PWA
import com.vaadin.flow.theme.Theme
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
@SpringBootApplication
@Theme(value = "fusionmanagement")
@PWA(name = "Fusion Management", shortName = "Fusion Management", offlineResources = ["images/logo.png"])
@Theme(value = "fusion")
@PWA(name = "CUBETIQ Fusion", shortName = "Fusion", offlineResources = ["images/logo.png"])
@NpmPackage.Container(
NpmPackage(value = "@fontsource/roboto", version = "4.5.0"),
NpmPackage(value = "@adobe/lit-mobx", version = "2.0.0-rc.4"),
@ -20,5 +20,5 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
class Application : SpringBootServletInitializer(), AppShellConfigurator
fun main(args: Array<String>) {
SpringApplication.run(Application::class.java, *args)
runApplication<Application>(*args)
}

View File

@ -1,11 +1,16 @@
package com.cubetiqs.fusion.frontend.views.test
import com.vaadin.flow.component.button.Button
import com.vaadin.flow.component.html.Div
import com.vaadin.flow.router.Route
import com.vaadin.flow.server.auth.AnonymousAllowed
@Route("/views/test")
@Route("/test")
@AnonymousAllowed
class TestView : Div() {
init {
add("Hello World")
add(
Button("Hello World")
)
}
}

View File

@ -0,0 +1,29 @@
package com.cubetiqs.fusion.frontend.views.user
import com.vaadin.flow.component.grid.Grid
import com.vaadin.flow.component.html.Div
import com.vaadin.flow.router.PageTitle
import com.vaadin.flow.router.Route
import com.vaadin.flow.server.auth.AnonymousAllowed
@Route("/users")
@PageTitle("All Users")
@AnonymousAllowed
class UserView : Div() {
private fun generateUsers(): Collection<User> {
val users = mutableListOf<User>()
for (i in 1..1000000) {
users.add(User(i, "user-${"$i".padStart(6, '0')}", "MY USER - $i", "$i".padEnd(9, '0')))
}
return users
}
init {
val grid = Grid(User::class.java)
grid.setItems(generateUsers())
add(grid)
}
data class User(val id: Int, val username: String, val name: String, val phone: String)
}

View File

@ -0,0 +1,2 @@
server:
port: 8081

View File

@ -1,12 +1,11 @@
server:
port: ${PORT:8080}
logging:
level:
org:
atmosphere: warn
spring:
profiles:
active: ${APP_PROFILE:dev}
mustache:
check-template-location: false