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

Adds Time info to message feed header #192

Merged
merged 8 commits into from
Oct 31, 2024
12 changes: 12 additions & 0 deletions process_manager/templates/process_manager/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
end
end
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var timezoneElement = document.getElementById('timezone');
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var offset = new Date().getTimezoneOffset();
var offsetHours = Math.abs(offset / 60);
var offsetSign = offset <= 0 ? '+' : '-';
var offsetString = offsetSign + String(offsetHours).padStart(2, '0')
timezoneElement.textContent = timezone + ' (UTC' + offsetString + ')';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My JS knowledge is non-existent, so just to confirm I get this right, this line here will update the HTML element below with id="timezone" giving it the value TIMEZONE (UTC + OFFSET_HOURS), both TIMEZONE and OFFSET calculated here, right?

I'd add h to the string. Not sure if standard, but makes it clearer.

Suggested change
timezoneElement.textContent = timezone + ' (UTC' + offsetString + ')';
timezoneElement.textContent = timezone + ' (UTC' + offsetString + 'h)';

Also, there are some fractional timezones which I'm not sure if will be handled properly with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly it will update the element with that ID.
I did not take into account the fractional timezones will amend this.

Copy link
Contributor Author

@Sahil590 Sahil590 Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, it shows this if it is a fractional timezone but it's not that useful
image

});
</script>
{% endblock extra_js %}
{% block content %}
<div class="container-fluid no-padding no-margin">
Expand Down Expand Up @@ -126,6 +137,7 @@ <h5>Process Control</h5>
<div class="card shadow-sm">
<div class="card-header bg-info text-white">
<h5 class="d-inline">Messages</h5>
<span class="d-inline"id="timezone"></span>
<!-- Updated Hide Messages Button as a close icon -->
<button id="hide-messages-button"
type="button"
Expand Down