updates play to read output from build dir and serve content inline for serveAsset action. sets the rootURL for Ember to assets on prod. overrides ESA to redirect to / rather than default rootURL for an environment.

This commit is contained in:
Seyi Adebajo 2017-04-07 09:11:40 -07:00 committed by Mars Lan
parent ae9162aa86
commit 12f2bc9ec5
4 changed files with 29 additions and 12 deletions

View File

@ -41,13 +41,18 @@ public class Application extends Controller
private static String PIWIK_SITE_ID = "tracking.piwik.siteid"; private static String PIWIK_SITE_ID = "tracking.piwik.siteid";
/** /**
* Serves the index view for any given path * Serves the build output index.html for any given path
* @param path takes a path string, which essentially is ignored * @param path takes a path string, which essentially is ignored
* routing is managed client side * routing is managed client side
* @return {Result} * @return {Result} build output index.html resource
*/ */
public static Result serveAsset(String path) { public static Result serveAsset(String path) {
return ok(index.render()); // Get the build output Html file
java.io.File indexHtml = new java.io.File("build/assets/index.html");
// Sets the Content-Disposition to inline to indicate that the browser should
// not treat this as an attachment to be downloaded
response().setHeader("Content-Disposition", "inline");
return ok(indexHtml);
} }
public static Result healthcheck() public static Result healthcheck()

View File

@ -6,7 +6,8 @@ const {
Route, Route,
run, run,
get, get,
inject: { service } inject: { service },
testing,
} = Ember; } = Ember;
export default Route.extend(ApplicationRouteMixin, { export default Route.extend(ApplicationRouteMixin, {
@ -30,6 +31,19 @@ export default Route.extend(ApplicationRouteMixin, {
this._loadCurrentUser(); this._loadCurrentUser();
}, },
/**
* __It reloads the Ember.js application__ by redirecting the browser
* to the application's root URL so that all in-memory data (such as Ember
* Data stores etc.) gets cleared.
* @override ApplicationRouteMixin.sessionInvalidated
* @link https://github.com/simplabs/ember-simple-auth/issues/1048
*/
sessionInvalidated() {
if (!testing) {
window.location.replace('/');
}
},
/** /**
* Internal method to invoke the currentUser service's load method * Internal method to invoke the currentUser service's load method
* If an exception occurs during the load for the current user, * If an exception occurs during the load for the current user,

View File

@ -69,13 +69,11 @@ const ldapResolver = (userNameQuery, syncResults, asyncResults) => {
* @param {String} userName the unique userName * @param {String} userName the unique userName
* @return {Promise.<TResult|null>} resolves with the userEntity or null otherwise * @return {Promise.<TResult|null>} resolves with the userEntity or null otherwise
*/ */
const getPartyEntityWithUserName = userName => { const getPartyEntityWithUserName = userName => getLDAPUsers()
return getLDAPUsers() .then(
.then( ({ userEntities }) => userEntities.find(({ label }) => label === userName) ||
({ userEntities }) => userEntities.find(({ label }) => label === userName) || null
null );
);
};
export default Service.extend({ export default Service.extend({
getPartyEntityWithUserName, getPartyEntityWithUserName,

View File

@ -61,7 +61,7 @@ module.exports = function(environment) {
} }
if (environment === 'production') { if (environment === 'production') {
ENV.rootURL = '/assets';
} }
return ENV; return ENV;