Cachet: Customizing CachetHQ Component status

Created on 1 Mar 2017  Â·  8Comments  Â·  Source: CachetHQ/Cachet

Is there any way to modify the Component status in CachetHQ?

Components Enhancement

Most helpful comment

Because I didn't want to fiddle with the code in the Docker container, I put a script in the footer section (https://{yourcachetserver}/dashboard/settings/customization) and renamed the status. We're only browsing in English anyway, so don't mind the missing/broken translations:

<script type="text/javascript">
jQuery(document).ready(function() {
    var operational = document.getElementsByClassName('text-component-1 greens');
    var partialOutage = document.getElementsByClassName('text-component-3 yellows');
    var majorOutage = document.getElementsByClassName('text-component-4 reds');

    function renameComponentStatus(components, old_text, new_text) {
        for(i=0; i<components.length; i++) {
            components[i].innerHTML = components[i].innerHTML.replace(old_text, new_text);
        }
    }

    renameComponentStatus(operational, 'Operational', '✓ On schedule');
    renameComponentStatus(partialOutage, 'Partial Outage', 'â—” Update delayed');
    renameComponentStatus(majorOutage, 'Major Outage', 'âš¡ Not updated');
});
</script>

Code goes here:

screen shot 2017-09-22 at 12 24 28

All 8 comments

Not yet there isn't. It's something I'd like to implement, but it's not high on the list yet.

There is quite a lot of work needed to do this:

  1. Move translations for Component and Incident statuses into the database.
  2. Add a way of retrieving the database translations.
  3. Swap _all_ existing code where the status names are used for the new system.

can we expect these enhancement in next release?

Likely not, maybe the version after, it all depends as v2.4 is taking a lot longer than we originally anticipated (as there is a lot to do 😄)

Because I didn't want to fiddle with the code in the Docker container, I put a script in the footer section (https://{yourcachetserver}/dashboard/settings/customization) and renamed the status. We're only browsing in English anyway, so don't mind the missing/broken translations:

<script type="text/javascript">
jQuery(document).ready(function() {
    var operational = document.getElementsByClassName('text-component-1 greens');
    var partialOutage = document.getElementsByClassName('text-component-3 yellows');
    var majorOutage = document.getElementsByClassName('text-component-4 reds');

    function renameComponentStatus(components, old_text, new_text) {
        for(i=0; i<components.length; i++) {
            components[i].innerHTML = components[i].innerHTML.replace(old_text, new_text);
        }
    }

    renameComponentStatus(operational, 'Operational', '✓ On schedule');
    renameComponentStatus(partialOutage, 'Partial Outage', 'â—” Update delayed');
    renameComponentStatus(majorOutage, 'Major Outage', 'âš¡ Not updated');
});
</script>

Code goes here:

screen shot 2017-09-22 at 12 24 28

Neat hack! ;)

@moertel hey great hack, I tried using it but when I do i lose the footer including the dashboard and logout buttons

@Ali-zi: Yeah, I'm afraid that was the only place that allowed to enter a custom script. Maybe @jbrooksuk can give some advice here how to both add custom code and keep the default footer. Otherwise, you could copy the original HTML from the footer, then add it manually.

Unfortunately, there isn't a way currently. The footer is replaced automatically.

Was this page helpful?
0 / 5 - 0 ratings