|
33 | 33 | import eu.openanalytics.containerproxy.service.hearbeat.HeartbeatService;
|
34 | 34 | import eu.openanalytics.containerproxy.util.ContextPathHelper;
|
35 | 35 | import eu.openanalytics.shinyproxy.AppRequestInfo;
|
| 36 | +import eu.openanalytics.shinyproxy.ShinyProxySpecExtension; |
36 | 37 | import eu.openanalytics.shinyproxy.ShinyProxySpecProvider;
|
37 | 38 | import eu.openanalytics.shinyproxy.UserAndAppNameAndInstanceNameProxyIndex;
|
38 | 39 | import jakarta.servlet.http.HttpServletRequest;
|
|
50 | 51 | import org.springframework.util.StreamUtils;
|
51 | 52 | import org.springframework.web.context.request.RequestContextHolder;
|
52 | 53 | import org.springframework.web.context.request.ServletRequestAttributes;
|
| 54 | +import org.springframework.web.servlet.view.RedirectView; |
53 | 55 |
|
54 | 56 | import javax.annotation.PostConstruct;
|
55 | 57 | import javax.inject.Inject;
|
56 | 58 | import java.io.IOException;
|
57 | 59 | import java.io.InputStream;
|
58 | 60 | import java.net.URL;
|
59 | 61 | import java.net.URLConnection;
|
| 62 | +import java.util.ArrayList; |
60 | 63 | import java.util.Base64;
|
| 64 | +import java.util.HashMap; |
| 65 | +import java.util.List; |
| 66 | +import java.util.Map; |
61 | 67 | import java.util.Objects;
|
62 | 68 |
|
63 | 69 | public abstract class BaseController {
|
@@ -156,6 +162,35 @@ protected void prepareMap(ModelMap map, HttpServletRequest request) {
|
156 | 162 | map.put("allowTransferApp", allowTransferApp);
|
157 | 163 | map.put("notificationMessage", environment.getProperty("proxy.notification-message"));
|
158 | 164 |
|
| 165 | + List<ProxySpec> apps = proxyService.getUserSpecs(); |
| 166 | + map.put("apps", apps); |
| 167 | + |
| 168 | + // app logos |
| 169 | + Map<ProxySpec, LogoInfo> appLogos = new HashMap<>(); |
| 170 | + for (ProxySpec app : apps) { |
| 171 | + appLogos.put(app, getAppLogoInfo(app)); |
| 172 | + } |
| 173 | + map.put("appLogos", appLogos); |
| 174 | + |
| 175 | + // template groups |
| 176 | + HashMap<String, ArrayList<ProxySpec>> groupedApps = new HashMap<>(); |
| 177 | + List<ProxySpec> ungroupedApps = new ArrayList<>(); |
| 178 | + |
| 179 | + for (ProxySpec app : apps) { |
| 180 | + String groupId = app.getSpecExtension(ShinyProxySpecExtension.class).getTemplateGroup(); |
| 181 | + if (groupId != null) { |
| 182 | + groupedApps.putIfAbsent(groupId, new ArrayList<>()); |
| 183 | + groupedApps.get(groupId).add(app); |
| 184 | + } else { |
| 185 | + ungroupedApps.add(app); |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | + List<ShinyProxySpecProvider.TemplateGroup> templateGroups = shinyProxySpecProvider.getTemplateGroups().stream().filter((g) -> groupedApps.containsKey(g.getId())).toList(); |
| 190 | + map.put("templateGroups", templateGroups); |
| 191 | + map.put("groupedApps", groupedApps); |
| 192 | + map.put("ungroupedApps", ungroupedApps); |
| 193 | + |
159 | 194 | ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
|
160 | 195 | HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();
|
161 | 196 | HttpServletResponse httpServletResponse = servletRequestAttributes.getResponse();
|
|
0 commit comments