Skip to content

Commit

Permalink
feat(ui): add ability to inject some css or javascript files
Browse files Browse the repository at this point in the history
close #1009
  • Loading branch information
tchiotludo committed Jan 31, 2022
1 parent 59e78f5 commit 222618d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#33b5e5"/>
<meta name="html-head" content="replace">

<!--
The AKHQ_PREFIX_PATH placeholder magic value is replaced during serving by server
Expand Down
22 changes: 21 additions & 1 deletion docs/docs/configuration/akhq.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,24 @@ These parameters are the default values used in the topic creation page.
### Topic Data
* `akhq.ui-options.topic-data.sort`: default sort order (OLDEST, NEWEST) (default: OLDEST)


### Inject some css or javascript
* `akhq.html-head`: Append some head tags on the webserver application
Mostly useful in order to inject some css or javascript to customize the web application.

Examples, add a red banner on production environment :
```yaml
kestra:
webserver:
html-head: |
<style type="text/css">
.logo-wrapper:after {
display: block;
content: "Local";
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
margin-top: 10px;
}
</style>
```
6 changes: 5 additions & 1 deletion src/main/java/org/akhq/controllers/StaticFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class StaticFilter implements HttpServerFilter {
@Value("${micronaut.server.context-path}")
protected String basePath;

@Nullable
@Value("${akhq.html-head}")
protected String htmlHead;

@Override
public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) {
return Publishers
Expand Down Expand Up @@ -66,9 +70,9 @@ public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, Server
}

private String replace(String line) {

line = line.replace("./ui", (basePath == null ? "" : basePath) + "/ui");

line = line.replace("<meta name=\"html-head\" content=\"replace\">", this.htmlHead == null ? "" : this.htmlHead);

return line;
}
Expand Down

0 comments on commit 222618d

Please sign in to comment.