Skip to content
This repository has been archived by the owner on Feb 23, 2018. It is now read-only.

Commit

Permalink
#17 add metadata to model for normal/advanced view
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Nov 30, 2017
1 parent f3e13a1 commit e724ce2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@
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;
import org.springframework.security.core.context.SecurityContextHolder;
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;

/**
Expand All @@ -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 {
Expand All @@ -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());
Expand All @@ -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;
}

}

0 comments on commit e724ce2

Please sign in to comment.