From efedf9cbbdd922b9282bf230a7974adc5fb433e1 Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 00:54:37 -0600 Subject: [PATCH 1/8] Update AuthenticatedApp.jsx --- app/ui/components/app/AuthenticatedApp.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui/components/app/AuthenticatedApp.jsx b/app/ui/components/app/AuthenticatedApp.jsx index a71d641b..042a0f69 100644 --- a/app/ui/components/app/AuthenticatedApp.jsx +++ b/app/ui/components/app/AuthenticatedApp.jsx @@ -32,10 +32,19 @@ import AdminConsoleHome from '../admin-console-views/admin-console-home.jsx'; import About from '../general/About.jsx'; import NotFound from '../shared-views/NotFound.jsx'; +import uiConfig from '../../../../build/json/uiConfig.json'; + export default function AuthenticatedApp(props) { + const basePath = () => { + let path = '/' + if (typeof uiConfig.basePath !== 'undefined') { + path = uiConfig.basePath.replace(/\/$/, ""); + } + return path; + }; return ( - }/> + }/> From be7aabd07b155be6772dcbc18fbd536cb232fc01 Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 00:55:21 -0600 Subject: [PATCH 2/8] Update App.jsx --- app/ui/components/app/App.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui/components/app/App.jsx b/app/ui/components/app/App.jsx index fc399b66..3566145f 100644 --- a/app/ui/components/app/App.jsx +++ b/app/ui/components/app/App.jsx @@ -32,6 +32,7 @@ import Banner from '../general/Banner.jsx'; import { useAuth } from '../context/AuthProvider.js'; import { useApiClient } from '../context/ApiClientProvider.js'; +import uiConfig from '../../../../build/json/uiConfig.json'; export default function App(props) { const { auth, setAuth } = useAuth(); @@ -83,8 +84,16 @@ export default function App(props) { ); } + const basePath = () => { + let path = '/' + if (typeof uiConfig.basePath !== 'undefined') { + path = uiConfig.basePath.replace(/\/$/, ""); + } + return path; + }; + return ( - + { app } From 0979366f0b3ec71f9a8de8b2e5f61f453c7c4d9e Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 00:56:16 -0600 Subject: [PATCH 3/8] Update app.js --- app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.js b/app/app.js index 47a01e3f..b15805f1 100644 --- a/app/app.js +++ b/app/app.js @@ -188,7 +188,7 @@ function initApp() { app.get('/doc/flight-manual', middleware.logRoute, UIController.flightManual); - app.use('/', middleware.logRoute, (req, res) => { + app.use(M.config.server.ui.basePath, middleware.logRoute, (req, res) => { res.sendFile(path.join(M.root, 'build', 'public', 'index.html')); }); } From cc3a64e82a737e033ed670d13de6a2f1bc3daf0b Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 00:57:03 -0600 Subject: [PATCH 4/8] Update example.cfg --- config/example.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/example.cfg b/config/example.cfg index 8a4a2166..74d88776 100644 --- a/config/example.cfg +++ b/config/example.cfg @@ -351,6 +351,8 @@ "enabled": true, // Defining if the UI is in production or development mode. "mode": "production", + // Defining the base path for the UI + "basePath": "/", // The UI can display a login modal warning statement. The following parameters // are used to set up the modal message. // REQUIRED if enabled is true From 779cc159c084b3770e867cb6f2663126afa63f39 Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 00:57:56 -0600 Subject: [PATCH 5/8] Update default.cfg --- config/default.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/config/default.cfg b/config/default.cfg index 42708117..b50bc764 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -102,6 +102,7 @@ "ui": { "enabled": true, "mode": "production", + "basePath": "/mcf", "loginModal": { "on": false, "message": "This is where your login modal message gets placed.", From 1c1f561f3de9b04d7aee4f0b92b54c4c3337a28b Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 13:12:17 -0600 Subject: [PATCH 6/8] Update index_template.html --- app/ui/html/index_template.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/ui/html/index_template.html b/app/ui/html/index_template.html index ed6bc442..f594068a 100644 --- a/app/ui/html/index_template.html +++ b/app/ui/html/index_template.html @@ -5,17 +5,17 @@ - + Login | Model-Based Engineering Environment - + - - - + + + @@ -28,11 +28,11 @@ - - - - - + + + + + From fd70fff8334c065ee067ebd2f4f3a89f5dde44cf Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 13:12:45 -0600 Subject: [PATCH 7/8] Update build.js --- scripts/build.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index f9d22a07..61327926 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -41,11 +41,20 @@ const markdown = require('gulp-markdown'); const rename = require('gulp-rename'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin'); // MBEE modules const validators = M.require('lib.validators'); const utils = M.require('lib.utils'); +const basePath = () => { + let bpath = ''; + if (typeof M.config.server.ui.basePath !== 'undefined') { + bpath = M.config.server.ui.basePath.replace(/\/$/, ''); + } + return bpath; +}; + /** * @description Builds the MBEE static assets by: * - Copying dependencies to their final location @@ -201,7 +210,7 @@ function build(_args) { output: { path: path.join(M.root, 'build', 'public', 'js'), filename: 'index_bundle.js', - publicPath: '/js/' + publicPath: `${basePath()}/js/` }, devServer: { historyApiFallback: true @@ -223,7 +232,14 @@ function build(_args) { new HtmlWebpackPlugin({ template: path.join(M.root, 'app', 'ui', 'html', 'index_template.html'), filename: path.join(M.root, 'build', 'public', 'index.html') - }) + }), + new HtmlReplaceWebpackPlugin([ + { + pattern: '@@basePath', + replacement: `${basePath()}/` + } + + ]) ] }, (err, stats) => { if (err || stats.hasErrors()) { @@ -241,8 +257,9 @@ function build(_args) { .then(() => { M.log.info('Build Complete.'); }) - .catch(() => { + .catch((e) => { M.log.warn('React build FAILED'); + M.log.debug(e.stack); M.log.info('Build Complete.'); }); } From f9fd7ae7d2b44e90612caad4018289d951666c3a Mon Sep 17 00:00:00 2001 From: Enquier Date: Thu, 15 Jul 2021 13:13:52 -0600 Subject: [PATCH 8/8] Update package.json --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5f398ccd..aa33d693 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "mbee", - "version": "2.0.1", + "version": "2.1.0", "build": "NO_BUILD_NUMBER", "description": "Model-Based Engineering Environment", "main": "mbee.js", - "repository": "https://github.com/lmco/mbee.git", + "repository": "https://github.com/open-mbee/mcf.git", "author": "Lockheed Martin", "license": "Apache-2.0", "private": true, @@ -64,6 +64,7 @@ "gulp-markdown": "^5.0.0", "gulp-minify": "^3.1.0", "gulp-sass": "^4.0.1", + "html-replace-webpack-plugin": "^2.6.0", "html-webpack-plugin": "^4.3.0", "jquery": "^3.3.1", "jquery-ui-dist": "^1.12.1",