Skip to content

Commit

Permalink
Merge branch 'gh-1422-swagger-ui-configurable-title' into gh-1424-swa…
Browse files Browse the repository at this point in the history
…gger-ui-static-banner
  • Loading branch information
m55624 committed Nov 2, 2017
2 parents 1768207 + 2847736 commit a5d8454
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
13 changes: 10 additions & 3 deletions example/road-traffic/road-traffic-demo/pom.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>road-traffic</artifactId>
Expand Down Expand Up @@ -68,9 +70,14 @@
</webapp>
</webapps>
<systemProperties>
<gaffer.properties>gaffer.properties.app.description,</gaffer.properties>
<gaffer.properties.app.description>
<gaffer.properties>
gaffer.properties.app.description,gaffer.properties.app.title
</gaffer.properties>
<gaffer.properties.app.title>
Road Traffic Example
</gaffer.properties.app.title>
<gaffer.properties.app.description>
Example using road traffic data
</gaffer.properties.app.description>
<gaffer.rest-api.basePath>
${standalone-path}
Expand Down
2 changes: 1 addition & 1 deletion rest-api/core-rest/src/main/webapp/index.html
Expand Up @@ -40,7 +40,7 @@
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="https://github.com/gchq/Gaffer"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title">Gaffer REST API</span></a>
<a id="logo" href="https://github.com/gchq/Gaffer"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span id="title" class="logo__title">Swagger</span></a>
<form id='api_selector'>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div id='auth_container'></div>
Expand Down
13 changes: 13 additions & 0 deletions rest-api/core-rest/src/main/webapp/lib/gaffer.js
Expand Up @@ -19,6 +19,18 @@ function getVersion() {
return footer.substr(footer.lastIndexOf(':') + 2, 2);
}

function updatePageUsingProperties(elementPropertiesObj) {
Object.keys(elementPropertiesObj).forEach(function(elementId){
$.get(
getVersion() + '/properties/' + elementPropertiesObj[elementId],
null,
function(propertyValue){
$('#'+ elementId).text(propertyValue);
}
)
})
}

function addExampleButtons(){

var tables = $("#resource_operations .operation-params")
Expand Down Expand Up @@ -134,6 +146,7 @@ function init(onSwaggerComplete){
onComplete: function(swaggerApi, swaggerUi){
log("Loaded swagger");
$('pre code').each(function(i,e){hljs.highlightBlock(e)});
updatePageUsingProperties({"title": "gaffer.properties.app.title"});
addExampleButtons();
if(onSwaggerComplete) {
onSwaggerComplete();
Expand Down

0 comments on commit a5d8454

Please sign in to comment.