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'),
|
imports: () => import('../target/frontend/generated-flow-imports'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
console.log("serverSideRoutes", serverSideRoutes)
|
||||||
|
|
||||||
export type ViewRoute = Route & {
|
export type ViewRoute = Route & {
|
||||||
title?: string;
|
title?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
@ -67,15 +70,6 @@ export const views: ViewRoute[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
export const routes: 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',
|
path: 'login',
|
||||||
component: 'login-view',
|
component: 'login-view',
|
||||||
@ -86,4 +80,18 @@ export const routes: ViewRoute[] = [
|
|||||||
return;
|
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.component.page.AppShellConfigurator
|
||||||
import com.vaadin.flow.server.PWA
|
import com.vaadin.flow.server.PWA
|
||||||
import com.vaadin.flow.theme.Theme
|
import com.vaadin.flow.theme.Theme
|
||||||
import org.springframework.boot.SpringApplication
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||||
|
import org.springframework.boot.runApplication
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Theme(value = "fusionmanagement")
|
@Theme(value = "fusion")
|
||||||
@PWA(name = "Fusion Management", shortName = "Fusion Management", offlineResources = ["images/logo.png"])
|
@PWA(name = "CUBETIQ Fusion", shortName = "Fusion", offlineResources = ["images/logo.png"])
|
||||||
@NpmPackage.Container(
|
@NpmPackage.Container(
|
||||||
NpmPackage(value = "@fontsource/roboto", version = "4.5.0"),
|
NpmPackage(value = "@fontsource/roboto", version = "4.5.0"),
|
||||||
NpmPackage(value = "@adobe/lit-mobx", version = "2.0.0-rc.4"),
|
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
|
class Application : SpringBootServletInitializer(), AppShellConfigurator
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
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
|
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.component.html.Div
|
||||||
import com.vaadin.flow.router.Route
|
import com.vaadin.flow.router.Route
|
||||||
|
import com.vaadin.flow.server.auth.AnonymousAllowed
|
||||||
|
|
||||||
@Route("/views/test")
|
@Route("/test")
|
||||||
|
@AnonymousAllowed
|
||||||
class TestView : Div() {
|
class TestView : Div() {
|
||||||
init {
|
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:
|
logging:
|
||||||
level:
|
level:
|
||||||
org:
|
org:
|
||||||
atmosphere: warn
|
atmosphere: warn
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: ${APP_PROFILE:dev}
|
||||||
mustache:
|
mustache:
|
||||||
check-template-location: false
|
check-template-location: false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user