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:
parent
05e6fe2447
commit
5a9930161b
@ -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,
|
||||
]
|
||||
}
|
||||
];
|
||||
|
10
frontend/views/server-layout.ts
Normal file
10
frontend/views/server-layout.ts
Normal 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></>`;
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
@ -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")
|
||||
)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
2
src/main/resources/application-dev.yml
Normal file
2
src/main/resources/application-dev.yml
Normal file
@ -0,0 +1,2 @@
|
||||
server:
|
||||
port: 8081
|
@ -1,12 +1,11 @@
|
||||
server:
|
||||
port: ${PORT:8080}
|
||||
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
atmosphere: warn
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
active: ${APP_PROFILE:dev}
|
||||
mustache:
|
||||
check-template-location: false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user