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
Merged

Adds Time info to message feed header #192

merged 8 commits into from
Oct 31, 2024

Conversation

Sahil590
Copy link
Contributor

@Sahil590 Sahil590 commented Oct 30, 2024

Description

uses JavaScript to get the timezone info and displays if in the message feed header.

Fixes #159 (issue)

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass (eg. python -m pytest)
  • The documentation builds and looks OK (eg. python -m sphinx -b html docs docs/build)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))

@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.16%. Comparing base (de83ae0) to head (0bed7da).

Additional details and impacted files
@@            Coverage Diff             @@
##           neater_ui     #192   +/-   ##
==========================================
  Coverage      80.16%   80.16%           
==========================================
  Files             28       28           
  Lines            353      353           
==========================================
  Hits             283      283           
  Misses            70       70           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sahil590 Sahil590 linked an issue Oct 30, 2024 that may be closed by this pull request
Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

LGTM. Just a clarification for my own benefit.

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

Copy link
Contributor

@cc-a cc-a left a comment

Choose a reason for hiding this comment

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

Unfortunately this needs to use a different approach. Message timestamps are rendered according to the django TIME_ZONE setting i.e. a fixed timezore for all users. This implementation will dynamically detect the users current timezone rather than the timezone configured on the server. As this setting is only available on the server the rendering should be performed an the server side within the template.

@Sahil590
Copy link
Contributor Author

Sahil590 commented Oct 30, 2024

I followed these docs to get the server time https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#std:templatefilter-time
but I get it in this format without the region @cc-a does this work?
image
I did also try to get the time from Django utils in the views.py, but I could not get it to appear on the template

@Sahil590 Sahil590 requested a review from cc-a October 30, 2024 15:58
Copy link
Contributor

@cc-a cc-a left a comment

Choose a reason for hiding this comment

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

Great. Needs a little visual tweak I think. Maybe it could be shown as a small grey line of text above the search bar - "All timestamps are displayed in ...".

process_manager/templates/process_manager/index.html Outdated Show resolved Hide resolved
@Sahil590 Sahil590 requested a review from cc-a October 31, 2024 09:55
@Sahil590
Copy link
Contributor Author

@cc-a should be fine now tests are failing due to #188

@cc-a cc-a mentioned this pull request Oct 31, 2024
10 tasks
Copy link
Contributor

@cc-a cc-a left a comment

Choose a reason for hiding this comment

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

Great. Thanks @Sahil590

@cc-a cc-a merged commit ef7d0c4 into neater_ui Oct 31, 2024
4 checks passed
@cc-a cc-a deleted the time_info branch October 31, 2024 11:30
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

Successfully merging this pull request may close these issues.

Add timezone to message feed header
4 participants