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

Feature: Layout table or row #63

Open
Coernel82 opened this issue Jun 21, 2023 · 0 comments
Open

Feature: Layout table or row #63

Coernel82 opened this issue Jun 21, 2023 · 0 comments

Comments

@Coernel82
Copy link

I would like to display my values in one single row. As I do not have real programming knowledge in java I consulted ChatGPT with succes. So what my idea is:

if config layout = row then display row

The code to achieve this below. Really only the config option has to be added and the if condition.
Also so far there is no space between the values. I "hacked" this with using an invisible space as suffix in the settings however I guess CSS should solve this properly.

And it looks like this (real screenshot):
row

 {
    const wrapper = document.createElement("span");
    wrapper.className = "row";

    if (subscriptions.length === 0) {
      wrapper.innerHTML = loaded ? translate("EMPTY") : translate("LOADING");
      wrapper.className = "row small dimmed";
      this.log(name + ": No values");
      return wrapper;
    }

    subscriptions
      .filter((s) => !s.hidden)
      .sort((a, b) => {
        return a.sortOrder - b.sortOrder;
      })
      .forEach(function (sub) {
        var subWrapper = doc.createElement("span");
        subWrapper.className = "column";

        let colors = getColors(sub);

        // Label
        var labelWrapper = doc.createElement("span");
        labelWrapper.innerHTML = sub.label;
        labelWrapper.className = "align-left mqtt-label";
        labelWrapper.style.color = colors.label;
        subWrapper.appendChild(labelWrapper);

        // Value
        tooOld = isValueTooOld(sub.maxAgeSeconds, sub.time);
        var valueWrapper = doc.createElement("span");
        var setValueinnerHTML = convertValue(sub);
        valueWrapper.innerHTML = setValueinnerHTML;
        valueWrapper.className =
          "align-right medium mqtt-value " + (tooOld ? "dimmed" : "bright");
        valueWrapper.style.color = tooOld
          ? valueWrapper.style.color
          : colors.value;
        subWrapper.appendChild(valueWrapper);

        // Suffix
        var suffixWrapper = doc.createElement("span");
        suffixWrapper.innerHTML = sub.suffix;
        suffixWrapper.className = "align-left mqtt-suffix";
        subWrapper.appendChild(suffixWrapper);
        subWrapper.style.color = colors.suffix;
        if (setValueinnerHTML !== "#DISABLED#") wrapper.appendChild(subWrapper);
      });

    return wrapper;




  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant