|
30 | 30 | import eu.openanalytics.containerproxy.service.hearbeat.HeartbeatService;
|
31 | 31 | import eu.openanalytics.containerproxy.util.ContextPathHelper;
|
32 | 32 | import eu.openanalytics.shinyproxy.AppRequestInfo;
|
| 33 | +import eu.openanalytics.shinyproxy.ShinyProxySpecExtension; |
33 | 34 | import eu.openanalytics.shinyproxy.ShinyProxySpecProvider;
|
34 | 35 | import eu.openanalytics.shinyproxy.runtimevalues.AppInstanceKey;
|
35 | 36 | import org.apache.logging.log4j.LogManager;
|
|
47 | 48 | import java.io.InputStream;
|
48 | 49 | import java.net.URL;
|
49 | 50 | import java.net.URLConnection;
|
| 51 | +import java.util.ArrayList; |
50 | 52 | import java.util.Base64;
|
51 | 53 | import java.util.HashMap;
|
| 54 | +import java.util.List; |
52 | 55 | import java.util.Map;
|
53 | 56 | import java.util.Objects;
|
| 57 | +import java.util.stream.Collectors; |
54 | 58 |
|
55 | 59 | public abstract class BaseController {
|
56 | 60 |
|
@@ -103,7 +107,7 @@ protected String getProxyEndpoint(Proxy proxy) {
|
103 | 107 | }
|
104 | 108 |
|
105 | 109 | protected void prepareMap(ModelMap map, HttpServletRequest request) {
|
106 |
| - map.put("application_name", environment.getProperty("spring.application.name")); // name of ShinyProxy, ContainerProxy etc |
| 110 | + map.put("application_name", environment.getProperty("spring.application.name")); // name of ShinyProxy, ContainerProxy etc |
107 | 111 | map.put("title", environment.getProperty("proxy.title", "ShinyProxy"));
|
108 | 112 | map.put("logo", resolveImageURI(environment.getProperty("proxy.logo-url")));
|
109 | 113 |
|
@@ -132,6 +136,41 @@ protected void prepareMap(ModelMap map, HttpServletRequest request) {
|
132 | 136 | map.put("appMaxInstances", shinyProxySpecProvider.getMaxInstances());
|
133 | 137 | map.put("pauseSupported", backend.supportsPause());
|
134 | 138 | map.put("spInstance", identifierService.instanceId);
|
| 139 | + |
| 140 | + ProxySpec[] apps = proxyService.getProxySpecs(null, false).toArray(new ProxySpec[0]); |
| 141 | + map.put("apps", apps); |
| 142 | + |
| 143 | + Map<ProxySpec, String> appLogos = new HashMap<>(); |
| 144 | + map.put("appLogos", appLogos); |
| 145 | + |
| 146 | + boolean displayAppLogos = false; |
| 147 | + for (ProxySpec app: apps) { |
| 148 | + if (app.getLogoURL() != null) { |
| 149 | + displayAppLogos = true; |
| 150 | + appLogos.put(app, resolveImageURI(app.getLogoURL())); |
| 151 | + } |
| 152 | + } |
| 153 | + map.put("displayAppLogos", displayAppLogos); |
| 154 | + |
| 155 | + // template groups |
| 156 | + HashMap<String, ArrayList<ProxySpec>> groupedApps = new HashMap<>(); |
| 157 | + List<ProxySpec> ungroupedApps = new ArrayList<>(); |
| 158 | + |
| 159 | + for (ProxySpec app: apps) { |
| 160 | + String groupId = app.getSpecExtension(ShinyProxySpecExtension.class).getTemplateGroup(); |
| 161 | + if (groupId != null) { |
| 162 | + groupedApps.putIfAbsent(groupId, new ArrayList<>()); |
| 163 | + groupedApps.get(groupId).add(app); |
| 164 | + } else { |
| 165 | + ungroupedApps.add(app); |
| 166 | + } |
| 167 | + } |
| 168 | + |
| 169 | + List<ShinyProxySpecProvider.TemplateGroup> templateGroups = shinyProxySpecProvider.getTemplateGroups().stream().filter((g) -> groupedApps.containsKey(g.getId())).collect( |
| 170 | + Collectors.toList()); |
| 171 | + map.put("templateGroups", templateGroups); |
| 172 | + map.put("groupedApps", groupedApps); |
| 173 | + map.put("ungroupedApps", ungroupedApps); |
135 | 174 | }
|
136 | 175 |
|
137 | 176 | protected String getSupportAddress() {
|
|
0 commit comments