diff --git a/README.md b/README.md index 59045af7f..452b06388 100755 --- a/README.md +++ b/README.md @@ -91,6 +91,11 @@ Updated Jargon and controller code to gracefully handle no permission errors wit Add a global config to turn on/off certain features via metalnx.properties. This allows sites to globally turn off features such as tickets. +#### Add normal/advanced view niehs #17 + +Add preferences to toggle between normal/advanced view and made dataGridUser.advancedView a model attribute always available in thymeleaf pages so +that the interface can show or hide features based on normal or power users + #### NIEHS identified misc theming issues * #22 fix search text diff --git a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/interceptors/HttpResponseHandlerInterceptor.java b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/interceptors/HttpResponseHandlerInterceptor.java index 041ebbf75..33e0ad01e 100755 --- a/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/interceptors/HttpResponseHandlerInterceptor.java +++ b/src/emc-metalnx-shared/src/main/java/com/emc/metalnx/interceptors/HttpResponseHandlerInterceptor.java @@ -20,6 +20,8 @@ import javax.servlet.http.HttpServletResponse; import org.irods.jargon.core.pub.IRODSAccessObjectFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -27,9 +29,12 @@ import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import com.emc.metalnx.controller.utils.LoggedUserUtils; +import com.emc.metalnx.core.domain.entity.DataGridUser; import com.emc.metalnx.modelattribute.enums.URLMap; import com.emc.metalnx.services.auth.UserTokenDetails; import com.emc.metalnx.services.interfaces.ConfigService; +import com.emc.metalnx.services.interfaces.UserService; import com.emc.metalnx.utils.EmcMetalnxVersion; /** @@ -42,11 +47,17 @@ public class HttpResponseHandlerInterceptor extends HandlerInterceptorAdapter { private IRODSAccessObjectFactory irodsAccessObjectFactory; @Autowired private ConfigService configService; + @Autowired + private UserService userService; + @Autowired + LoggedUserUtils loggedUserUtils; private UserTokenDetails userTokenDetails; private URLMap urlMap; private EmcMetalnxVersion emcmetalnxVersion; + public final static Logger logger = LoggerFactory.getLogger(HttpResponseHandlerInterceptor.class); + @Override public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) throws Exception { @@ -64,6 +75,12 @@ public void postHandle(final HttpServletRequest request, final HttpServletRespon modelAndView.getModelMap().addAttribute("emcmetalnxVersion", emcmetalnxVersion); modelAndView.getModelMap().addAttribute("globalConfig", configService.getGlobalConfig()); + DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser(); + + logger.debug("added user prefs to model as 'dataGridUser':{}", loggedUser); + + modelAndView.getModelMap().addAttribute("dataGridUser", loggedUser); + if (auth instanceof UsernamePasswordAuthenticationToken) { userTokenDetails = (UserTokenDetails) auth.getDetails(); modelAndView.getModelMap().addAttribute("userDetails", userTokenDetails.getUser()); @@ -90,4 +107,12 @@ public void setConfigService(ConfigService configService) { this.configService = configService; } + public UserService getUserService() { + return userService; + } + + public void setUserService(UserService userService) { + this.userService = userService; + } + }