Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from Acrotrend/master
Template functionality added
- Loading branch information
Showing
38 changed files
with
1,109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* ShinyProxy | ||
* | ||
* Copyright (C) 2016-2017 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; | ||
|
||
import org.springframework.core.env.Environment; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
import javax.inject.Inject; | ||
|
||
@Configuration | ||
public class StaticResourceConfig extends WebMvcConfigurerAdapter { | ||
|
||
@Inject | ||
Environment environment; | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("/thumbnail/**") | ||
.addResourceLocations("file:../thumbnail/"); | ||
|
||
// External templates static dir | ||
registry.addResourceHandler("/assets/**") | ||
.addResourceLocations("file:"+environment.getProperty("shiny.proxy.template_path")+"/assets/"); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/eu/openanalytics/TemplateResolverConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* ShinyProxy | ||
* | ||
* Copyright (C) 2016-2017 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; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
import org.thymeleaf.spring4.SpringTemplateEngine; | ||
import org.thymeleaf.templateresolver.FileTemplateResolver; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.inject.Inject; | ||
|
||
@Configuration | ||
public class TemplateResolverConfig { | ||
|
||
@Inject | ||
Environment environment; | ||
|
||
@Autowired | ||
private SpringTemplateEngine templateEngine; | ||
|
||
@PostConstruct | ||
public void extension() { | ||
FileTemplateResolver resolver = new FileTemplateResolver(); | ||
resolver.setPrefix(environment.getProperty("shiny.proxy.template_path")+"/"); | ||
resolver.setSuffix(".html"); | ||
resolver.setTemplateMode("HTML5"); | ||
resolver.setOrder(templateEngine.getTemplateResolvers().size()); | ||
resolver.setCacheable(false); | ||
templateEngine.addTemplateResolver(resolver); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!-- | ||
ShinyProxy | ||
Copyright (C) 2016-2017 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/> | ||
--> | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> | ||
<head lang="en"> | ||
<title th:text="${title}"></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<link rel="stylesheet" media="screen" th:href="@{/assets/css/bootstrap.min.css}"/> | ||
<link rel="stylesheet" media="screen" th:href="@{/assets/css/default.css}"/> | ||
<script th:src="@{/assets/js/jquery.min.js}"></script> | ||
<script th:src="@{/assets/js/bootstrap.min.js}"></script> | ||
</head> | ||
<body> | ||
<!-- navigation bar --> | ||
<div th:replace="../fragments/navbar :: navbar"></div> | ||
|
||
<!-- content --> | ||
<div id="admin"> | ||
<h3>Container Activity</h3> | ||
<table border="1"> | ||
<tr> | ||
<th>Name</th> | ||
<th>Port</th> | ||
<th>Username</th> | ||
<th>Appname</th> | ||
<th>Container Id</th> | ||
<th>Uptime</th> | ||
</tr> | ||
<tr th:each="proxy: ${proxies}"> | ||
<td th:text="${proxy.name}"></td> | ||
<td th:text="${proxy.port}"></td> | ||
<td th:text="${proxy.userName}"></td> | ||
<td th:text="${proxy.appName}"></td> | ||
<td th:text="${proxy.containerId}"></td> | ||
<td th:text="${proxy.uptime()}"></td> | ||
</tr> | ||
</table> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
ShinyProxy | ||
Copyright (C) 2016-2017 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/> | ||
--> | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> | ||
<head lang="en"> | ||
<title th:text="${title}"></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<link rel="stylesheet" media="screen" th:href="@{/assets/css/bootstrap.min.css}"/> | ||
<link rel="stylesheet" media="screen" th:href="@{/assets/css/default.css}"/> | ||
<script th:src="@{/assets/js/jquery.min.js}"></script> | ||
<script th:src="@{/assets/js/bootstrap.min.js}"></script> | ||
</head> | ||
<body> | ||
<!-- navigation bar --> | ||
<div th:replace="../fragments/navbar :: navbar"></div> | ||
|
||
<!-- content --> | ||
<iframe id="shinyframe" th:src="${container}" width="100%"></iframe> | ||
<div class="loading"><div class="loading-txt">Launching <span th:text="${appTitle}"></span>...</div></div> | ||
|
||
<script type="text/javascript" th:inline="javascript"> | ||
function setShinyframeHeight() { | ||
$('#shinyframe').css('height', ($(window).height()-6)+'px'); | ||
} | ||
window.addEventListener("load", setShinyframeHeight); | ||
window.addEventListener("resize", setShinyframeHeight); | ||
|
||
function heartbeat() { | ||
setTimeout(function() { | ||
$.ajax([[${heartbeatPath}]] + window.location.pathname).success(function(data) { | ||
heartbeat(); | ||
}); | ||
}, [[${heartbeatRate}]]); | ||
}; | ||
heartbeat(); | ||
|
||
$(window).load(function() { | ||
var source = $("#shinyframe").attr("src"); | ||
if (source == "") { | ||
$(".loading").show(); | ||
$.post(window.location.pathname, function(containerPath) { | ||
$("#shinyframe").attr("src", containerPath); | ||
$(".loading").fadeOut("slow"); | ||
}).fail(function(request) { | ||
var newDoc = document.open("text/html", "replace"); | ||
newDoc.write(request.responseText); | ||
newDoc.close(); | ||
}); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* ShinyProxy | ||
* | ||
* Copyright (C) 2016-2017 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/> | ||
*/ | ||
|
||
body { | ||
padding-top: 70px; /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */ | ||
} | ||
|
||
footer { | ||
margin: 50px 0; | ||
} | ||
.img-responsive { | ||
max-height: 300px; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.