mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Added support (and tests) for overriding the default hosted path for the material-frontend-ui
This commit is contained in:
@ -74,6 +74,7 @@ public class QApplicationJavalinServer
|
||||
|
||||
private Integer port = 8000;
|
||||
private boolean serveFrontendMaterialDashboard = true;
|
||||
private String frontendMaterialDashboardHostedPath = "/"; // TODO - Things like this should be moved into a central configuration file system, so that it can be changed in userspace without code changes.
|
||||
private boolean serveLegacyUnversionedMiddlewareAPI = true;
|
||||
private List<AbstractMiddlewareVersion> middlewareVersionList = List.of(new MiddlewareVersionV1());
|
||||
private List<QJavalinRouteProviderInterface> additionalRouteProviders = null;
|
||||
@ -145,7 +146,7 @@ public class QApplicationJavalinServer
|
||||
////////////////////////////////////////////////////////////
|
||||
// set the index page for the SPA from material dashboard //
|
||||
////////////////////////////////////////////////////////////
|
||||
config.spaRoot.addFile("/", "material-dashboard/index.html");
|
||||
config.spaRoot.addFile(this.frontendMaterialDashboardHostedPath, "material-dashboard/index.html");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
@ -470,6 +471,26 @@ public class QApplicationJavalinServer
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Sets the hosted path for the frontend Material Dashboard UI.
|
||||
*
|
||||
* This value determines the base URL path under which the static frontend
|
||||
* dashboard assets are served. It should match the path configured in your
|
||||
* frontend build or static asset router.
|
||||
*
|
||||
* @param frontendMaterialDashboardHostedPath the hosted path (e.g., "/admin" or "/dashboard"). Default is "/"
|
||||
* @return this instance for method chaining
|
||||
*
|
||||
* @see #withServeFrontendMaterialDashboard(boolean)
|
||||
*******************************************************************************/
|
||||
public QApplicationJavalinServer withFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath)
|
||||
{
|
||||
this.frontendMaterialDashboardHostedPath = frontendMaterialDashboardHostedPath;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for serveLegacyUnversionedMiddlewareAPI
|
||||
*******************************************************************************/
|
||||
@ -690,4 +711,24 @@ public class QApplicationJavalinServer
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for frontendMaterialDashboardHostedPath
|
||||
*******************************************************************************/
|
||||
public String getFrontendMaterialDashboardHostedPath()
|
||||
{
|
||||
return (this.frontendMaterialDashboardHostedPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for frontendMaterialDashboardHostedPath
|
||||
*******************************************************************************/
|
||||
public void setFrontendMaterialDashboardHostedPath(String frontendMaterialDashboardHostedPath)
|
||||
{
|
||||
this.frontendMaterialDashboardHostedPath = frontendMaterialDashboardHostedPath;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class QApplicationJavalinServerTest
|
||||
{
|
||||
javalinServer.stop();
|
||||
TestApplication.callCount = 0;
|
||||
System.clearProperty("qqq.javalin.enableStaticFilesFromJar");
|
||||
System.clearProperty(SimpleFileSystemDirectoryRouter.loadStaticFilesFromJarProperty);
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ class QApplicationJavalinServerTest
|
||||
@Test
|
||||
void testStaticRouterFilesFromExternal() throws Exception
|
||||
{
|
||||
System.setProperty("qqq.javalin.enableStaticFilesFromJar", "false");
|
||||
System.setProperty(SimpleFileSystemDirectoryRouter.loadStaticFilesFromJarProperty, "false");
|
||||
|
||||
javalinServer = new QApplicationJavalinServer(getQqqApplication())
|
||||
.withServeFrontendMaterialDashboard(false)
|
||||
@ -228,13 +228,53 @@ class QApplicationJavalinServerTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testFrontendMaterialDashboardHostedPathDefault() throws Exception
|
||||
{
|
||||
javalinServer = new QApplicationJavalinServer(getQqqApplication())
|
||||
.withServeFrontendMaterialDashboard(true)
|
||||
.withPort(PORT)
|
||||
.withFrontendMaterialDashboardHostedPath("/");
|
||||
javalinServer.start();
|
||||
|
||||
Unirest.config().setDefaultResponseEncoding("UTF-8");
|
||||
HttpResponse<String> response = Unirest.get("http://localhost:" + PORT + "/index.html").asString();
|
||||
assertEquals(200, response.getStatus());
|
||||
assertEquals("This is a mock of /material-dashboard/index.html for testing purposes.", response.getBody());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testFrontendMaterialDashboardHostedPathCustomApp() throws Exception
|
||||
{
|
||||
javalinServer = new QApplicationJavalinServer(getQqqApplication())
|
||||
.withServeFrontendMaterialDashboard(true)
|
||||
.withPort(PORT)
|
||||
.withFrontendMaterialDashboardHostedPath("/app");
|
||||
javalinServer.start();
|
||||
|
||||
Unirest.config().setDefaultResponseEncoding("UTF-8");
|
||||
HttpResponse<String> response = Unirest.get("http://localhost:" + PORT + "/app/index.html").asString();
|
||||
assertEquals(200, response.getStatus());
|
||||
assertEquals("This is a mock of /material-dashboard/index.html for testing purposes.", response.getBody());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testStaticRouterFilesFromClasspath() throws Exception
|
||||
{
|
||||
System.setProperty("qqq.javalin.enableStaticFilesFromJar", "true");
|
||||
System.setProperty(SimpleFileSystemDirectoryRouter.loadStaticFilesFromJarProperty, "true");
|
||||
|
||||
javalinServer = new QApplicationJavalinServer(new QApplicationJavalinServerTest.TestApplication())
|
||||
.withServeFrontendMaterialDashboard(false)
|
||||
|
Reference in New Issue
Block a user