Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Conflicts:
	pom.xml
  • Loading branch information
tverbeke committed May 28, 2018
2 parents 8f73ae0 + 944d3c1 commit eebddbb
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
</executions>
-->
<configuration>
<license>(c) Copyright Open Analytics NV, 2016-2017 - Apache License 2.0</license>
<license>(c) Copyright Open Analytics NV, 2016-2018 - Apache License 2.0</license>
<release>1.el7</release>
<group>Development/Tools</group>
<packager>Open Analytics</packager>
Expand Down Expand Up @@ -413,6 +413,7 @@
<exclude>**/*.json</exclude>
<exclude>.gitignore</exclude>
<exclude>src/deb/**</exclude>
<exclude>templates/**</exclude>
</excludes>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* ShinyProxy
*
* Copyright (C) 2016-2018 Open Analytics
*
* ===========================================================================
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Apache License as published by
* The Apache Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Apache License for more details.
*
* You should have received a copy of the Apache License
* along with this program. If not, see <http://www.apache.org/licenses/>
*/
package eu.openanalytics.shinyproxy;

import javax.inject.Inject;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.thymeleaf.templateresolver.FileTemplateResolver;

@Configuration
public class TemplateResolverConfig extends WebMvcConfigurerAdapter {

@Inject
private Environment environment;

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/assets/**")
.addResourceLocations("file:" + environment.getProperty("shiny.proxy.template-path") + "/assets/");
}

@Bean
public FileTemplateResolver templateResolver() {
FileTemplateResolver resolver = new FileTemplateResolver();
resolver.setPrefix(environment.getProperty("shiny.proxy.template-path") + "/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
resolver.setCacheable(false);
return resolver;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring().antMatchers("/assets/**").and()
.ignoring().antMatchers("/css/**").and()
.ignoring().antMatchers("/webjars/**");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ protected void calculateTargetURL(KubernetesContainerProxy proxy) throws Excepti

@Override
protected void doStopProxy(KubernetesContainerProxy proxy) throws Exception {
kubeClient.pods().delete(getProxy(proxy).getPod());
kubeClient.services().delete(getProxy(proxy).getService());
kubeClient.pods().delete(proxy.getPod());
if (proxy.getService() != null) kubeClient.services().delete(proxy.getService());
}

@Override
Expand All @@ -260,9 +260,4 @@ protected String getPropertyPrefix() {
protected Logger getLog() {
return log;
}

protected KubernetesContainerProxy getProxy(IContainerProxy proxy) {
if (proxy instanceof KubernetesContainerProxy) return (KubernetesContainerProxy) proxy;
else throw new IllegalArgumentException("Not a valid Kubernetes proxy: " + proxy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@ConfigurationProperties(prefix = "shiny")
@Service
Expand Down Expand Up @@ -121,8 +120,7 @@ public String[] getArray(String key) {
.filter(k -> k.startsWith(key))
.map(k -> get(k))
.forEach(v -> {
String[] fields = StringUtils.commaDelimitedListToStringArray(v);
for (String f: fields) values.add(f.trim());
values.add(v.trim());
});
return values.toArray(new String[values.size()]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ shiny:
description: Application which demonstrates the basics of a Shiny app
docker-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
docker-image: openanalytics/shinyproxy-demo
groups: scientists, mathematicians
groups: [scientists, mathematicians]
- name: 06_tabsets
docker-cmd: ["R", "-e", "shinyproxy::run_06_tabsets()"]
docker-image: openanalytics/shinyproxy-demo
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/static/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ body > div#navbar { padding-top: 0px; }
margin-top: 10px;
}

#shinyframe {
border: none;
}

#admin {
margin-left: 10px;
}
Expand All @@ -63,4 +67,4 @@ body > div#navbar { padding-top: 0px; }
text-align: center;
font-size: 24px;
margin-top: -50px;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/templates/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div th:replace="../fragments/navbar :: navbar"></div>

<!-- content -->
<iframe id="shinyframe" th:src="${container}" width="100%"></iframe>
<iframe id="shinyframe" th:src="${container}" width="100%" frameBorder="0"></iframe>
<div class="loading"><div class="loading-txt">Launching <span th:text="${appTitle}"></span>...</div></div>

<script type="text/javascript" th:inline="javascript">
Expand All @@ -59,7 +59,7 @@
var source = $("#shinyframe").attr("src");
if (source == "") {
$(".loading").show();
$.post(window.location.pathname, function(containerPath) {
$.post(window.location.pathname + window.location.search, function(containerPath) {
$("#shinyframe").attr("src", containerPath);
$(".loading").fadeOut("slow");
}).fail(function(request) {
Expand Down

0 comments on commit eebddbb

Please sign in to comment.