-
-
Notifications
You must be signed in to change notification settings - Fork 212
[monitoring/js] Consistent datetime format in RADIUS sessions tab #662 #665
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
base: master
Are you sure you want to change the base?
[monitoring/js] Consistent datetime format in RADIUS sessions tab #662 #665
Conversation
183d10f to
aa60f50
Compare
…nwisp#662 Use Django locale for date formatting in device page RADIUS sessions tab JS, matching Django admin and localization settings. Fixes openwisp#662
aa60f50 to
830d07e
Compare
pandafy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is working as expected.
The created/modified timestamp of the Device is in different format from the "Start Time" of the RADIUS session
Check the formatting of "Created" and "Modified" datetime of the Device object:

Check the formatting of "Start time" field in the "RADIUS Sessions" tab:
Check if something like this will solve the problem:
|
Hey @Eeshu-Yadav, sorry for any confusion. I didn’t start working on this. Since the CI failure was fixed, I just updated the branch earlier to keep it in sync and just as a check. |
i though first , yaa ci failed previously , i thought , i will fix in next commit |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe pull request modifies the date-time formatting logic in the RADIUS sessions tab to align with Django's localization framework. The change replaces a plain locale string formatting with an explicit locale derived from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js`:
- Around line 23-31: The options object in device-change.js contains hour12:
false which forces 24-hour time; remove the hour12 property from the options
constant so toLocaleString() can honor the user's locale preferences (locate and
edit the options declaration in device-change.js where the options object with
year/month/day/hour/minute/second is defined and delete the hour12: false
entry).
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js
🔇 Additional comments (1)
openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js (1)
22-22: No guard needed;djangoLocaleis always defined.The template explicitly sets
const djangoLocale = "{{ LANGUAGE_CODE }}"(line 39 ofchange_form.html) before this script loads, sodjangoLocaleis guaranteed to exist. A guard is unnecessary.The concern about
replace("_", "-")replacing only the first underscore is technically valid but low-impact: Django'sLANGUAGE_CODEsetting uses hyphens by convention (e.g.,"en-gb"), andIntl.DateTimeFormatgracefully falls back if an invalid locale string is provided.Likely an incorrect or invalid review comment.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| const options = { | ||
| year: "numeric", | ||
| month: "short", | ||
| day: "numeric", | ||
| hour: "2-digit", | ||
| minute: "2-digit", | ||
| second: "2-digit", | ||
| hour12: false, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find the file mentioned in the review
find . -name "device-change.js" -type fRepository: openwisp/openwisp-radius
Length of output: 154
🏁 Script executed:
#!/bin/bash
# Let's also check the structure of the monitoring module
find . -path "*monitoring/static/radius-monitoring*" -type f | head -20Repository: openwisp/openwisp-radius
Length of output: 243
🏁 Script executed:
cat -n ./openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.jsRepository: openwisp/openwisp-radius
Length of output: 5156
🏁 Script executed:
#!/bin/bash
# Search for djangoLocale definition/usage
rg "djangoLocale" --type js
# Search for where this JS file is included/rendered
rg "device-change.js"
# Look for locale configuration in Django templates
fd -e "html" -e "py" | xargs rg -l "djangoLocale" 2>/dev/null | head -10Repository: openwisp/openwisp-radius
Length of output: 412
🏁 Script executed:
cat -n ./openwisp_radius/integrations/monitoring/templates/admin/config/radius-monitoring/device/change_form.htmlRepository: openwisp/openwisp-radius
Length of output: 2286
🏁 Script executed:
#!/bin/bash
# Search for other toLocaleString usages
rg "toLocaleString"
# Search for hour12 settings in the codebase
rg "hour12"
# Check the admin.py for any additional context
head -50 ./openwisp_radius/integrations/monitoring/admin.pyRepository: openwisp/openwisp-radius
Length of output: 1543
Remove hour12: false to respect locale preferences.
hour12: false forces 24-hour format regardless of locale, preventing Django's locale setting from taking full effect. Different locales have different time conventions (e.g., en-US prefers 12-hour, en-GB prefers 24-hour). Removing this option allows toLocaleString() to use the locale's natural preference.
🔧 Proposed fix
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
- hour12: false,
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const options = { | |
| year: "numeric", | |
| month: "short", | |
| day: "numeric", | |
| hour: "2-digit", | |
| minute: "2-digit", | |
| second: "2-digit", | |
| hour12: false, | |
| }; | |
| const options = { | |
| year: "numeric", | |
| month: "short", | |
| day: "numeric", | |
| hour: "2-digit", | |
| minute: "2-digit", | |
| second: "2-digit", | |
| }; |
🤖 Prompt for AI Agents
In
`@openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js`
around lines 23 - 31, The options object in device-change.js contains hour12:
false which forces 24-hour time; remove the hour12 property from the options
constant so toLocaleString() can honor the user's locale preferences (locate and
edit the options declaration in device-change.js where the options object with
year/month/day/hour/minute/second is defined and delete the hour12: false
entry).
Checklist
Use Django locale for date formatting in device page RADIUS sessions tab JS, matching Django admin and localization settings.
Fixes #662