aw-server-rust icon indicating copy to clipboard operation
aw-server-rust copied to clipboard

Add custom visualizations support

Open LockBlock-dev opened this issue 3 years ago • 4 comments

I struggled a bit with this since it is my first time with Rust but here it is. I used the FileServer from Rocket because that is the easiest way I found to get custom HTML per watcher.

How to use: Create a visualizations folder in your data folder. Then create a folder for your custom watcher and put your index.html here. Example: /home/USER/.local/share/activitywatch/aw-server-rust/visualizations/aw-watcher-test/index.html You can also load JavaScript from other files, just put them in the same directory.

I tested it with my custom watcher and it works with custom visualization support of aw-server web-ui (and so aw-server-rust).

LockBlock-dev avatar Sep 03 '22 19:09 LockBlock-dev

Nice, had no idea it was that easy!

Just a couple thoughts though: this behavior diverges slightly from aw-server-python, where you explicitly need to config the mappings for the directories, i.e. /pages/<custom vis> -> /home/user/somewhere/custom_vis in the config.toml (instead of one big visualizations folder where people drop/symlink their files).

I want to keep things consistent, so I think aw-server-rust should work the same way (unless there are good arguments against).

If you have time to address this, I'd be very happy. Otherwise, I'll find time for it a bit later :)

ErikBjare avatar Sep 07 '22 13:09 ErikBjare

Seems like CI agrees with me (crashes if dir doesn't exist) ;)

ErikBjare avatar Sep 07 '22 14:09 ErikBjare

Ah yes I did not implement any kind of check my bad. Also, I tried to mimic the aw-server-python implementation but failed due to my lack of Rust knowledge... I guess you'll have to implement this when you have time.

LockBlock-dev avatar Sep 07 '22 15:09 LockBlock-dev

Alright, thanks for your work so far @LockBlock-dev! :heart:

I'll try and get around to it soonish :)

ErikBjare avatar Sep 09 '22 09:09 ErikBjare

Finally got around to this! Seems to be working now :)

ErikBjare avatar Nov 23 '22 13:11 ErikBjare

Codecov Report

Base: 81.70% // Head: 72.83% // Decreases project coverage by -8.86% :warning:

Coverage data is based on head (85a41e4) compared to base (7dd382d). Patch coverage: 30.43% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
- Coverage   81.70%   72.83%   -8.87%     
==========================================
  Files          51       45       -6     
  Lines        4350     2790    -1560     
==========================================
- Hits         3554     2032    -1522     
+ Misses        796      758      -38     
Impacted Files Coverage Δ
aw-server/src/main.rs 0.00% <0.00%> (ø)
aw-server/src/endpoints/mod.rs 81.33% <71.42%> (-9.30%) :arrow_down:
aw-server/src/config.rs 50.84% <100.00%> (+5.56%) :arrow_up:
aw-transform/src/heartbeat.rs 82.75% <0.00%> (-11.19%) :arrow_down:
aw-models/src/tryvec.rs 72.91% <0.00%> (-9.03%) :arrow_down:
aw-transform/src/find_bucket.rs 87.50% <0.00%> (-8.93%) :arrow_down:
aw-models/src/timeinterval.rs 82.35% <0.00%> (-5.15%) :arrow_down:
aw-transform/src/classify.rs 93.33% <0.00%> (-3.97%) :arrow_down:
aw-transform/src/split_url.rs 90.47% <0.00%> (-3.47%) :arrow_down:
... and 25 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Nov 23 '22 13:11 codecov[bot]

Looks like it's working! Merging.

Thanks for getting this work started @LockBlock-dev! ❤️

ErikBjare avatar Nov 23 '22 14:11 ErikBjare