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

fix: fix timeline updating before new range is selected (#449 from ac… #219

Merged
merged 7 commits into from
Jul 30, 2020

Conversation

billangli
Copy link
Contributor

Hello! This is my first pull request, please feel free to let me know if you have feedback. I found this issue on the activitywatch repo (ActivityWatch/activitywatch#449) and I thought that the pull request should go here.

Before My Changes

Timeline View
Screenshot from 2020-07-15 13-41-58
Bucket View
Screenshot from 2020-07-15 13-42-22

My Changes

I added a "Show Timeline" button that will send a request to the server if pressed. The default timeline range will still be showed when the page loads in the beginning. I also made the select boxes and the button horizontal because I thought that was better use of space.
Screenshot from 2020-07-15 14-30-16
In Range mode, the "Show Timeline" button will be disabled (grey) until the user has selected both dates.
Screenshot from 2020-07-15 14-30-40
Red text telling the user that the date range is invalid will also show if the first date is less than or equal to the second, the button is also greyed out.
Screenshot from 2020-07-15 14-30-58
Screenshot from 2020-07-15 14-31-24
The following two images are the new Bucket view.
Screenshot from 2020-07-15 14-57-30
Screenshot from 2020-07-15 14-58-00

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Nice work! 💪

I think shying away from v-model might be the wrong call though, I suggest reading up on it (https://vuejs.org/v2/guide/forms.html and https://vuejs.org/v2/guide/components.html#Using-v-model-on-Components) and addressing my comments.

I realize now how this code was far from perfect to begin with (sorry about that, lol), so I took the liberty of adding some comments on the original code as well to highlight issues with it. Hopefully they are helpful to you, just don't get put off by me spamming comments on my own shitty code 🙂.

src/components/InputTimeInterval.vue Show resolved Hide resolved
src/components/InputTimeInterval.vue Outdated Show resolved Hide resolved
src/components/InputTimeInterval.vue Show resolved Hide resolved
src/views/Timeline.vue Outdated Show resolved Hide resolved
src/components/InputTimeInterval.vue Outdated Show resolved Hide resolved
src/components/InputTimeInterval.vue Show resolved Hide resolved
src/components/InputTimeInterval.vue Outdated Show resolved Hide resolved
src/components/InputTimeInterval.vue Outdated Show resolved Hide resolved
src/components/InputTimeInterval.vue Outdated Show resolved Hide resolved
@ErikBjare
Copy link
Member

Oh, and it looks like GitHub Actions picked up some minor formatting issues. You can easily fix them with make lint-fix.

@billangli
Copy link
Contributor Author

Thank you for the detailed comments 👍, it really helps especially because I'm new to Vue! Yeah I think it would be much easier if I kept the v-model and started from scratch.

@ErikBjare
Copy link
Member

@billangli Starting from scratch sounds like overkill, just fix the things and then clean it up with rebase after :)

@ErikBjare
Copy link
Member

ErikBjare commented Jul 17, 2020

@billangli Oh, and if you're interested in getting paid for your contributions, let me know.

See ActivityWatch/activitywatch#458 for more info.

Edit: I also saw you'd been involved with some BCI stuff at UofT. I'd love to chat with you about that if you have time, since I'm doing my MSc thesis on it (see ActivityWatch/activitywatch#422)

@billangli
Copy link
Contributor Author

billangli commented Jul 18, 2020

Haha thanks for the offer! I don't think I've done enough yet so I'll pass on that. I just thought of this as a good opportunity to learn some full-stack development.

You probably saw my Bella repo, it was a silly hackathon project but I'd be happy to tell you about the idea. I also have a friend who is working on a research project that analyses speech patterns for diseases. It's signal processing so you might find it useful, let me see if he's available too.

Edit: He's available!

@ErikBjare
Copy link
Member

I also have a friend who is working on a research project that analyses speech patterns for diseases

Small world. I've worked for a startup that does the same thing 🙂

Not my focus right now though so I'll pass on the intro for now, but thank you for the offer!

@billangli
Copy link
Contributor Author

@ErikBjare no worries! I totally get it, my friend mentioned to me that your areas are not as related as I thought haha.

@billangli billangli changed the base branch from master to dev/calendar July 25, 2020 02:06
@billangli billangli changed the base branch from dev/calendar to master July 25, 2020 02:07
@billangli
Copy link
Contributor Author

I made the changes that you suggested. I also changed the warnings to be more consistent with the rest of the UI. Let me know what you think.

Screenshot from 2020-07-24 22-59-18
Screenshot from 2020-07-24 22-59-38

@billangli billangli requested a review from ErikBjare July 25, 2020 03:15
Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Looks great! Just one comment.

@@ -40,7 +40,8 @@ export default {
},
},
mounted: function () {
this.getBuckets();
(this.daterange = [moment().subtract(this.timeintervalDefaultDuration, 'seconds'), moment()]),
Copy link
Member

@ErikBjare ErikBjare Jul 25, 2020

Choose a reason for hiding this comment

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

Looks like the parentheses here are unnecessary. Might be that prettier found a , that should have been a ; and decided it needed wrapping.

Copy link
Member

Choose a reason for hiding this comment

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

Edit: Ignore this particular subcomment, just thinking out loud and I think the way you did it makes sense.

Also, can't you move this initialization of daterange up into data? Looks like you should have everything you need there.

Or maybe that causes the "now" moment() to become stale? I'm a bit fuzzy on when data is actually run and it was hard to search for (surprisingly). Perhaps a comment for why it's there (// Initialized here to make sure moment() doesn't get stale in data) might suffice.

Copy link
Member

Choose a reason for hiding this comment

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

If you set this.daterange which has a watch, shouldn't this.getBuckets() (which also doesn't take any arguments) run automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ErikBjare I think I might have just forgot to check this and I wasn't being careful enough with the rebase, my bad. My intention was to look out for the case where timeintervalDefaultDuration is null because localStorage.durationDefault is null. I now removed this mounted function in Timeline.vue and made similar changes in Bucket.vue. The initial request will be called by valueChanged in a mounted function in InputTimelineInterval.vue.

@nicolae-stroncea
Copy link
Member

I just realized that Bucket Views (Raw Data->Open(any bucket)) has the same view and therefore the same problem. Are the same components used? If yes, then i think your PR will automatically solve the issue there too

@billangli
Copy link
Contributor Author

@nicolae-stroncea yep, Bucket view also uses the same component.

@ErikBjare ErikBjare added this to In progress in Road to 1.0 via automation Jul 27, 2020
@billangli billangli requested a review from ErikBjare July 29, 2020 23:28
Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Very nice! Merging.

Road to 1.0 automation moved this from In progress to Reviewer approved Jul 30, 2020
@ErikBjare ErikBjare merged commit 02a37cc into ActivityWatch:master Jul 30, 2020
Road to 1.0 automation moved this from Reviewer approved to Done Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Road to 1.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants