openanalytics / shinyproxy-config-examples

Configuration examples for ShinyProxy
https://www.shinyproxy.io
147 stars 110 forks source link

Use properties of `template-groups` in custom templates #40

Open DzimitryM opened 2 months ago

DzimitryM commented 2 months ago

How can the properties defined in the template-groups be used in the HTML templates?

Let's say the properties are defined in application.yml:

proxy:
  template-groups:
    - id: tools
      properties:
        display-name: Tools
        maintainer: Tesla
        logo-url: file:////path/to/tools/templates/logo.png

To use them in index.html one can call the property with ${group.properties.get('maintainer')} according to the documentation:

<!-- Part that shows a list when none of the apps contain a logo -->
<div class="container-fluid">
    <th:block th:each="group: ${templateGroups}">
        <h2 th:text="${group.properties.get('display-name')}"></h2>
        <b>Maintainer: <th:block th:text="${group.properties.get('maintainer')}"/></b>
        <ul class="list-group">
            <th:block th:each="app: ${groupedApps.get(group.id)}" th:include="index :: app(${app})"/>
        </ul>
    </th:block>
 </div>

My question is how to call the properties in the other template files, e.g. navbar.html, modal.html, when the particular app has been loaded?

I am trying to resolve the following use case: display different logos depending on the properties of the template-group in the navbar.

LEDfan commented 3 weeks ago

Hi, starting with ShinyProxy 3.1.0, you can now use the apps, templateGroups, groupedApps and ungroupedApps variables in all templates and pages. Could you have a look whether this solves your use-case?