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

Calendar #23

Closed
wants to merge 10 commits into from
Closed

Calendar #23

wants to merge 10 commits into from

Conversation

LinZhihao-723
Copy link
Member

Description

Add a new functionality in the menu bar called "Calendar" which allows users to select a timestamp (in UTC seconds). The viewer will then jump to the first event with the timestamp greater or equal to the selected one.
The UI looks like the following:

Validation performed

  1. Manually test the functionality.
  2. Add unit tests for UTC timestamp converting.

@LinZhihao-723
Copy link
Member Author

Here are two screenshots of the viewer:

  1. Menu bar

bece782480627bc9f040a9876e4bb11

  1. Calendar opened

9fee379d5dd0d1743a2119c376f1b22

Comment on lines +160 to +166
const openCalendar = () => {
handleShowCalendar();
};

const closeCalendar = () => {
handleCloseCalendar();
};

Choose a reason for hiding this comment

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

These two functions seem a bit unnecessary

Copy link
Member Author

Choose a reason for hiding this comment

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

True, I agree

Copy link

@Bill-hbrhbr Bill-hbrhbr left a comment

Choose a reason for hiding this comment

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

Leaving the rest to our protagonist Kirk,

if (!isNumeric(timestamp)) {
throw (new Error("Invalid timestamp provided."));
}
this._logFile.state.logEventIdx = this._logFile.getLogEventIdxFromTimestamp(timestamp);

Choose a reason for hiding this comment

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

I think the newest private class variable syntax is using #. I'm not sure if the _ prefix here means something should be private.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields

* @param {number} timestamp
*/
changeEventWithTimestamp (timestamp) {
if (!isNumeric(timestamp)) {

Choose a reason for hiding this comment

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

Don't wanna be that guy, but

false === isNumeric(timestamp)

@@ -51,8 +67,14 @@ export function MenuBar ({
const {theme, switchTheme} = useContext(ThemeContext);

const [eventsPerPage, setEventsPerPage] = useState(logFileState.pages);
const [calendarDateTime, setCalendarDateTime] = useState(
new Date(Math.floor(Date.now() / 1000) * 1000)

Choose a reason for hiding this comment

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

Could make the millisecond truncation into a function.


const handleCalendarChange = (newDate) => {
if (newDate instanceof Date) {
setCalendarDateTime(newDate);

Choose a reason for hiding this comment

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

use the millisecond truncation function here as well for consistent calendarDateTime state behavior (although maybe you already pass in a date value with the millisecond part removed).

Henry8192 pushed a commit to Henry8192/yscope-log-viewer that referenced this pull request Jun 23, 2024
Add Time Zone Toggle between Local and UTC.
@kirkrodrigues
Copy link
Member

Since the UI has been rewritten, can we close this PR and open a feature request for this feature?

@junhaoliao
Copy link
Member

Since the UI has been rewritten, can we close this PR and open a feature request for this feature?

Sure

@junhaoliao
Copy link
Member

The feature is now tracked by #117 & #118 . Closing this since we will have to open separate PRs when the code is ready to be submitted.

@junhaoliao junhaoliao closed this Nov 13, 2024
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.

4 participants