41
41
@ Controller
42
42
public class IndexController extends BaseController {
43
43
44
- private static final String PROXY_LANDING_PAGE_AUTO_OPTION = "auto" ;
44
+ /**
45
+ * Allows users on a ShinyProxy deployment <b>with only one app defined</b> to be redirected straight
46
+ * to the only existing app, without going through the Index page.
47
+ */
48
+ private static final String PROXY_LANDING_PAGE_SINGLE_APP_OPTION = "SingleApp" ;
49
+ /**
50
+ * Allows users on any ShinyProxy deployment to be redirected straight to the first available app,
51
+ * without going through the Index page.
52
+ */
53
+ private static final String PROXY_LANDING_PAGE_FIRST_APP_OPTION = "FirstApp" ;
54
+
55
+ /**
56
+ * Redirects users on a ShinyProxy deployment to the index page.
57
+ */
58
+ private static final String PROXY_LANDING_PAGE_INDEX_OPTION = "/" ;
45
59
46
60
@ Inject
47
61
private ShinyProxySpecProvider shinyProxySpecProvider ;
@@ -59,7 +73,10 @@ public void init() {
59
73
@ RequestMapping ("/" )
60
74
private Object index (ModelMap map , HttpServletRequest request ) {
61
75
String landingPage = environment .getProperty ("proxy.landing-page" , "/" );
62
- if (!landingPage .equals ("/" ) && !landingPage .equals (PROXY_LANDING_PAGE_AUTO_OPTION )) {
76
+
77
+ if (!landingPage .equals (PROXY_LANDING_PAGE_INDEX_OPTION )
78
+ && !landingPage .equals (PROXY_LANDING_PAGE_SINGLE_APP_OPTION )
79
+ && !landingPage .equals (PROXY_LANDING_PAGE_FIRST_APP_OPTION )) {
63
80
return new RedirectView (landingPage );
64
81
}
65
82
@@ -68,10 +85,14 @@ private Object index(ModelMap map, HttpServletRequest request) {
68
85
ProxySpec [] apps = proxyService .getProxySpecs (null , false ).toArray (new ProxySpec [0 ]);
69
86
map .put ("apps" , apps );
70
87
71
- // If set to `auto`, redirect to the first available app in the list
72
- // See https://github.com/openanalytics/shinyproxy/issues/269
73
- if (apps .length > 0 && landingPage .equals (PROXY_LANDING_PAGE_AUTO_OPTION ))
88
+ // If set to `FirstApp`, redirect to the first app available to the logged-in user
89
+ if (apps .length > 0 && landingPage .equals (PROXY_LANDING_PAGE_FIRST_APP_OPTION )) {
90
+ return new RedirectView ("/app/" + apps [0 ].getId ());
91
+ }
92
+ // If set to `SingleApp` and only one app is available to the logged-in user, redirect to it
93
+ if (apps .length == 1 && landingPage .equals (PROXY_LANDING_PAGE_SINGLE_APP_OPTION )) {
74
94
return new RedirectView ("/app/" + apps [0 ].getId ());
95
+ }
75
96
76
97
Map <ProxySpec , String > appLogos = new HashMap <>();
77
98
map .put ("appLogos" , appLogos );
0 commit comments