40
40
@ Controller
41
41
public class IndexController extends BaseController {
42
42
43
+ /**
44
+ * Allows users on a ShinyProxy deployment <b>with only one app defined</b> to be redirected straight
45
+ * to the only existing app, without going through the Index page.
46
+ */
47
+ private static final String PROXY_LANDING_PAGE_SINGLE_APP_OPTION = "SingleApp" ;
48
+
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 = "/" ;
59
+
43
60
@ Inject
44
61
private ShinyProxySpecProvider shinyProxySpecProvider ;
45
62
@@ -58,11 +75,25 @@ public void init() {
58
75
59
76
@ RequestMapping ("/" )
60
77
private Object index (ModelMap map , HttpServletRequest request ) {
61
- if (!landingPage .equals ("/" )) return new RedirectView (landingPage );
78
+ if (!landingPage .equals (PROXY_LANDING_PAGE_INDEX_OPTION )
79
+ && !landingPage .equals (PROXY_LANDING_PAGE_SINGLE_APP_OPTION )
80
+ && !landingPage .equals (PROXY_LANDING_PAGE_FIRST_APP_OPTION )) {
81
+ return new RedirectView (landingPage , true );
82
+ }
83
+
84
+ List <ProxySpec > apps = proxyService .getUserSpecs ();
85
+
86
+ // If set to `FirstApp`, redirect to the first app available to the logged-in user
87
+ if (!apps .isEmpty () && landingPage .equals (PROXY_LANDING_PAGE_FIRST_APP_OPTION )) {
88
+ return new RedirectView ("/app/" + apps .get (0 ).getId (), true );
89
+ }
90
+ // If set to `SingleApp` and only one app is available to the logged-in user, redirect to it
91
+ if (apps .size () == 1 && landingPage .equals (PROXY_LANDING_PAGE_SINGLE_APP_OPTION )) {
92
+ return new RedirectView ("/app/" + apps .get (0 ).getId (), true );
93
+ }
62
94
63
95
prepareMap (map , request );
64
96
65
- List <ProxySpec > apps = proxyService .getUserSpecs ();
66
97
map .put ("apps" , apps );
67
98
68
99
// app logos
0 commit comments