VolkovLabs / volkovlabs-dynamictext-panel

Business Text Panel for @grafana
https://docs.volkovlabs.io
Apache License 2.0
78 stars 14 forks source link

Odd behavour with Handlebars helper #230

Closed craftzneko closed 7 months ago

craftzneko commented 8 months ago

I have this helper function that switches out glyphs based on data object

handlebars.registerHelper('getIconClass', function () {
  var chassisType = data.data[0].chassisType.toLowerCase();
  if (chassisType === 'laptop') {
    return 'fas fa-laptop fa-7x';
  } else if (chassisType === 'desktop') {
    return 'fas fa-desktop fa-7x';
  } else {
    return 'fas fa-question fa-7x'; // default icon if model doesn't match any case
  }
});

I use this in my HTML here

    <div class="top">
      <i id="device" class="{{getIconClass}}"></i>
    </div>

Elsehwere on my dashbaord i have another seperate dynamictext panel that has a glyph that doesnt call this helper but is changed whenever the helper is run. Why is that?

  <div class="onea">
    <i class="fa-solid fa-fire fa-6x"></i>
  </div>
mikhail-vl commented 7 months ago

@craftzneko Handlebars Helpers are global, they are not limited to the specific panel.

I don't really understand the questions. Could you please add details what is changing and how.

craftzneko commented 7 months ago

It actually is working now after changing the logic, I must have made a mistake.

mikhail-vl commented 7 months ago

@craftzneko Thank you for confirming.

We released a new version of the Dynamic Text which was just updated in the Grafana Catalog.