Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI and API docs custom context path support #12923

Closed
114 changes: 114 additions & 0 deletions generators/client/templates/angular/src/main/webapp/index.html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.

This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
<!doctype html>
<html class="no-js" lang="<% if (enableTranslation) { %><%= nativeLanguage %><% } else { %>en<% } %>" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><%= baseName %></title>
<meta name="description" content="Description for <%= baseName %>"><% if (enableTranslation) { %>
<meta name="google" content="notranslate"><% } %>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="icon" href="favicon.ico" />
<link rel="stylesheet" href="content/css/loading.css">
<base href="/"/>
<!-- jhipster-needle-add-resources-to-root - JHipster will add new resources here -->
</head>
<body>
<!--[if lt IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<<%= jhiPrefixDashed %>-main>
<div class="app-loading">
<div class="lds-css ng-scope">
<div class="lds-pacman">
<div><div></div><div></div><div></div></div>
<div><div></div><div></div><div></div></div>
</div>
</div>
</div>
<div class="app-loading">
<div id="jhipster-error" style="display:none">
<!-- This content is for troubleshooting purpose and will be removed when app renders -->
<h1>An error has occurred :-(</h1>
<h2>Usual error causes</h2>
<ol>
<li>You started the application from an IDE and you didn't run <code style="color:red"><%= clientPackageManager %> start</code> or <code style="color:red"><%= clientPackageManager %> run webpack:build</code>.</li>
<li>You had a network error while running <code style="color:red"><%= clientPackageManager %> install</code>. If you are behind a corporate proxy, it is likely that this error was caused by your proxy. Have a look at the JHipster error logs, you will probably have the cause of the error.</li>
<li>You installed a Node.js version that doesn't work with JHipster: please use an LTS (long-term support) version, as it's the only version we support.</li>
</ol>
<h2>Building the client side code again</h2>
<p>If you want to go fast, run <code style="color:red"><% if (buildTool === 'maven') { %>./mvnw<% } else if (buildTool === 'gradle') { %>./gradlew<% } %></code> to build and run everything.</p>
<p>If you want to have more control, so you can debug your issue more easily, you should follow the following steps:</p>
<ol>
<li>Install npm dependencies with the command <code style="color:red"><%= clientPackageManager %> install</code></li>
<li>Build the client with the command <code style="color:red"><%= clientPackageManager %> run webpack:build</code> or <code style="color:red"><%= clientPackageManager %> start</code></li>
<li>Start the server with <code style="color:red"><% if (buildTool === 'maven') { %>./mvnw<% } else if (buildTool === 'gradle') { %>./gradlew<% } %></code> or using your IDE</li>
</ol>

<h2>Getting more help</h2>

<h3>If you have a question on how to use JHipster</h3>
<p>
Go to Stack Overflow with the <a href="http://stackoverflow.com/tags/jhipster" target="_blank" rel="noopener noreferrer">"jhipster"</a> tag.
</p>

<h3>If you have a bug or a feature request</h3>
<p>
First read our <a href="https://github.com/jhipster/generator-jhipster/blob/main/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer">contributing guidelines</a>.
</p>
<p>
Then, fill a ticket on our <a href="https://github.com/jhipster/generator-jhipster/issues/new/choose" target="_blank" rel="noopener noreferrer">bug tracker</a>, we'll be happy to resolve your issue!
</p>

<h3>If you want to chat with contributors and other users</h3>
<p>
Join our chat room on <a href="https://gitter.im/jhipster/generator-jhipster" target="_blank" rel="noopener noreferrer">Gitter.im</a>. Please note that this is a public chat room, and that we expect you to respect other people and write in a correct English language!
</p>
<!-- end of troubleshooting content -->
</div>
</div>
</<%= jhiPrefixDashed %>-main>
<noscript>
<h1>You must enable javascript to view this page.</h1>
</noscript>
<script type="text/javascript" language="javascript">
// show an error message if the app loading takes more than 5 sec
window.onload=function() {
setTimeout(showError, 4000);
}
function showError() {
var errorElm = document.getElementById("jhipster-error");
if (errorElm && errorElm.style) {
errorElm.style.display = "block";
}
}
</script>
<!-- Google Analytics: uncomment and change UA-XXXXX-X to be your site's ID.
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script>-->
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.

This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= baseName %> - Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"/>
</head>

<body>
<div id="swagger-ui"></div>

<script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script src="./axios.min.js"></script>


<script type="text/javascript">
window.onload = function () {

// Automatically click all 'Try it out' buttons
var mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
document.querySelectorAll(".btn.try-out__btn:not(.cancel)").forEach(div => { div.click(); });
});
});

mutationObserver.observe(document.documentElement, {
attributes: true,
childList: true,
subtree: true
});

<%_ if (authenticationType === 'session' || authenticationType === 'oauth2' || authenticationType === 'uaa') { _%>
function getCSRF() {
var name = "XSRF-TOKEN=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1);
if (c.indexOf(name) !== -1) return c.substring(name.length,c.length);
}
return "";
}
<%_ } _%>

var urls = [];
axios.get("../swagger-resources").then(function (response) {
response.data.forEach(function (resource) {
urls.push({"name": resource.name, "url": ".." + resource.location});
});

urls.sort(function (a, b) {
var x = a.name.toLowerCase(), y = b.name.toLowerCase();
return x < y ? -1 : x > y ? 1 : 0;
});

// Build a system
var ui = SwaggerUIBundle({
urls: urls,
dom_id: '#swagger-ui',
deepLinking: true,
filter: true,
layout: "StandaloneLayout",
withCredentials: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
<%_ if (authenticationType === 'session' || authenticationType === 'oauth2' || authenticationType === 'uaa') { _%>
requestInterceptor: function(req) {
req.headers['X-XSRF-TOKEN'] = getCSRF();
// Remove the sample Swagger UI request body if present
if (req.method === 'GET' && req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}') {
req.body = undefined;
}
return req;
}
<%_ } _%>
<%_ if (authenticationType === 'jwt') { _%>
requestInterceptor: function (req) {
var authToken = JSON.parse(localStorage.getItem("<%= jhiPrefixDashed %>-authenticationtoken")
|| sessionStorage.getItem("<%= jhiPrefixDashed %>-authenticationtoken"));
if (authToken) {
req.headers['Authorization'] = "Bearer " + authToken;
}
// Remove the sample Swagger UI request body if present
if (req.method === 'GET' && req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}') {
req.body = undefined;
}
return req;
}
<%_ } _%>
});

window.ui = ui
});

};
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import React from 'react';
const DocsPage = () => (
<div>
<iframe
src="../swagger-ui/index.html" width="100%" height="800"
src="./swagger-ui/index.html" width="100%" height="800"
title="Swagger UI" seamless style={{ border: 'none' }}
data-cy="swagger-frame"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.

This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= baseName %> - Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"/>
</head>

<body>
<div id="swagger-ui"></div>

<script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script src="./axios.min.js"></script>


<script type="text/javascript">

// Automatically click all 'Try it out' buttons
var mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
document.querySelectorAll(".btn.try-out__btn:not(.cancel)").forEach(div => { div.click(); });
});
});

mutationObserver.observe(document.documentElement, {
attributes: true,
childList: true,
subtree: true
});

<%_ if (authenticationType === 'session' || authenticationType === 'oauth2' || authenticationType === 'uaa') { _%>
function getCSRF() {
var name = "XSRF-TOKEN=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1);
if (c.indexOf(name) !== -1) return c.substring(name.length,c.length);
}
return "";
}
<%_ } _%>

window.onload = function () {
var urls = [];
axios.get("../swagger-resources").then(function (response) {
response.data.forEach(function (resource) {
urls.push({"name": resource.name, "url": ".." + resource.location});
});

urls.sort(function (a, b) {
var x = a.name.toLowerCase(), y = b.name.toLowerCase();
return x < y ? -1 : x > y ? 1 : 0;
});

// Build a system
var ui = SwaggerUIBundle({
urls: urls,
dom_id: '#swagger-ui',
deepLinking: true,
filter: true,
layout: "StandaloneLayout",
withCredentials: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
<%_ if (authenticationType === 'session' || authenticationType === 'oauth2' || authenticationType === 'uaa') { _%>
requestInterceptor: function(req) {
req.headers['X-XSRF-TOKEN'] = getCSRF();
// Remove the sample Swagger UI request body if present
if (req.method === 'GET' && req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}') {
req.body = undefined;
}
return req;
}
<%_ } _%>
<%_ if (authenticationType === 'jwt') { _%>
requestInterceptor: function(req) {
var authToken = JSON.parse(localStorage.getItem("<%= jhiPrefixDashed %>-authenticationToken")
|| sessionStorage.getItem("<%= jhiPrefixDashed %>-authenticationToken"));
if (authToken) {
req.headers['Authorization'] = "Bearer " + authToken;
}
// Remove the sample Swagger UI request body if present
if (req.method === 'GET' && req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}') {
req.body = undefined;
}
return req;
}
<%_ } _%>
});

window.ui = ui
});

};
</script>
</body>
</html>
Loading