Skip to content

Update AuthenticatedApp.jsx #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
}
Expand Down
11 changes: 10 additions & 1 deletion app/ui/components/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 (
<Router>
<Router basename={basePath()}>
<Banner>
{ app }
</Banner>
Expand Down
11 changes: 10 additions & 1 deletion app/ui/components/app/AuthenticatedApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Switch>
<Route path={'/login'} component={() => <Redirect to={'/'}/>}/>
<Route path={'/login'} component={() => <Redirect to={basePath()}/>}/>
<Route path={'/orgs/:orgid/projects/:projectid'} component={ProjectHome} />
<Route path={'/orgs/:orgid'} component={OrgHome} />
<Route path={'/profile/:username'} component={ProfileHome}/>
Expand Down
20 changes: 10 additions & 10 deletions app/ui/html/index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<base href="@@basePath">
<title>
Login | Model-Based Engineering Environment
</title>

<!-- <link rel="icon" type="img/ico" href="/img/favicon.ico">-->
<!-- <link rel="icon" type="img/ico" href="@@basePathimg/favicon.ico">-->

<!-- CSS -->
<!-- <link rel="stylesheet" type="text/css" href="/css/meyer.css"/>-->
<!-- <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"/>-->
<link rel="stylesheet" type="text/css" href="/css/styles.css"/>
<!-- <link rel="stylesheet" type="text/css" href="@@basePathcss/meyer.css"/>-->
<!-- <link rel="stylesheet" type="text/css" href="@@basePathcss/bootstrap.min.css"/>-->
<link rel="stylesheet" type="text/css" href="@@basePathcss/styles.css"/>

</head>

Expand All @@ -28,11 +28,11 @@


<!-- Scripts -->
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script async type="text/javascript" src="/js/jquery-ui.min.js"></script>
<script async type="text/javascript" src="/js/popper.min.js"></script>
<script async type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/mbee.min.js"></script>
<script type="text/javascript" src="@@basePathjs/jquery.min.js"></script>
<script async type="text/javascript" src="@@basePathjs/jquery-ui.min.js"></script>
<script async type="text/javascript" src="@@basePathjs/popper.min.js"></script>
<script async type="text/javascript" src="@@basePathjs/bootstrap.min.js"></script>
<script type="text/javascript" src="@@basePathjs/mbee.min.js"></script>
<!-- Custom Scripts -->

</body>
Expand Down
1 change: 1 addition & 0 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"ui": {
"enabled": true,
"mode": "production",
"basePath": "/mcf",
"loginModal": {
"on": false,
"message": "This is where your login modal message gets placed.",
Expand Down
2 changes: 2 additions & 0 deletions config/example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 20 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()) {
Expand All @@ -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.');
});
}
Expand Down