From ec1339c7f4264dac684ac890d62127eafe735e89 Mon Sep 17 00:00:00 2001 From: Matt Mason Date: Fri, 1 Apr 2016 11:40:05 -0700 Subject: [PATCH 1/2] Added 'route' config option for mounting dashboard --- Parse-Dashboard/app.js | 5 ++++- Parse-Dashboard/index.jade | 7 +++++++ package.json | 1 + src/components/Icon/Icon.react.js | 2 +- src/dashboard/Dashboard.js | 2 +- webpack/base.config.js | 2 +- 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 Parse-Dashboard/index.jade diff --git a/Parse-Dashboard/app.js b/Parse-Dashboard/app.js index c92f4cd851..b48824a9af 100644 --- a/Parse-Dashboard/app.js +++ b/Parse-Dashboard/app.js @@ -17,6 +17,9 @@ packageJson('parse-dashboard', 'latest').then(latestPackage => { module.exports = function(config) { var app = express(); + app.set('views', './'); + app.set('view engine', 'jade'); + // Serve public files. app.use(express.static(path.join(__dirname,'public'))); @@ -83,7 +86,7 @@ module.exports = function(config) { // For every other request, go to index.html. Let client-side handle the rest. app.get('/*', function(req, res) { - res.sendFile(__dirname + '/index.html'); + res.render('index', { route: config.route }); }); return app; diff --git a/Parse-Dashboard/index.jade b/Parse-Dashboard/index.jade new file mode 100644 index 0000000000..19dfa66833 --- /dev/null +++ b/Parse-Dashboard/index.jade @@ -0,0 +1,7 @@ +html + head + title Parse Dashboard + body + base(href=route) + #browser_mount + script(src="bundles/dashboard.bundle.js") \ No newline at end of file diff --git a/package.json b/package.json index 85307eeba3..6c485c7c6b 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "basic-auth": "^1.0.3", "commander": "^2.9.0", "express": "^4.13.4", + "jade": "^1.11.0", "json-file-plus": "^3.2.0", "package-json": "^2.3.1" }, diff --git a/src/components/Icon/Icon.react.js b/src/components/Icon/Icon.react.js index 6ab9be0100..e32e65eabb 100644 --- a/src/components/Icon/Icon.react.js +++ b/src/components/Icon/Icon.react.js @@ -18,7 +18,7 @@ let Icon = ({ name, fill, width, height }) => { } return ( - + ); }; diff --git a/src/dashboard/Dashboard.js b/src/dashboard/Dashboard.js index c79639cc66..7b9ad04505 100644 --- a/src/dashboard/Dashboard.js +++ b/src/dashboard/Dashboard.js @@ -117,7 +117,7 @@ class Dashboard extends React.Component { } componentDidMount() { - get('/parse-dashboard-config.json').then(({ apps, newFeaturesInLatestVersion = [] }) => { + get('parse-dashboard-config.json').then(({ apps, newFeaturesInLatestVersion = [] }) => { this.setState({ newFeaturesInLatestVersion }); let appInfoPromises = apps.map(app => { if (app.serverURL.startsWith('https://api.parse.com/1')) { diff --git a/webpack/base.config.js b/webpack/base.config.js index 549f6d2fdf..632b7f47ea 100644 --- a/webpack/base.config.js +++ b/webpack/base.config.js @@ -14,7 +14,7 @@ module.exports = { context: path.join(__dirname, '../src'), output: { filename: '[name].bundle.js', - publicPath: '/bundles/' + publicPath: 'bundles/' }, resolve: { root: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, 'node_modules')] From 265583c59de14a20383d5186ed8df024a65a6018 Mon Sep 17 00:00:00 2001 From: Matt Mason Date: Fri, 1 Apr 2016 11:46:27 -0700 Subject: [PATCH 2/2] Missed index in commit --- Parse-Dashboard/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Parse-Dashboard/index.js b/Parse-Dashboard/index.js index 6b4808b456..d8ffbfc3d8 100644 --- a/Parse-Dashboard/index.js +++ b/Parse-Dashboard/index.js @@ -91,11 +91,15 @@ p.then(config => { const app = express(); - app.use(parseDashboard(config.data)); + config.data.route = config.data.route || '/'; + // add trailing slash + if (config.data.route.substr(-1) != '/') config.data.route += '/'; + + app.use(config.data.route, parseDashboard(config.data)); // Start the server. app.listen(port); - console.log(`The dashboard is now available at http://localhost:${port}/`); + console.log(`The dashboard is now available at http://localhost:${port}${config.data.route}`); }, error => { if (error instanceof SyntaxError) { console.log('Your config file contains invalid JSON. Exiting.');