Skip to content

Feature/keyboard shortcuts #160

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

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def create_tables(engine, psql_environment):
google_connect,
invitation,
joke,
keyboard_shortcuts,
login,
logout,
profile,
Expand Down Expand Up @@ -114,6 +115,7 @@ async def swagger_ui_redirect():
google_connect.router,
invitation.router,
joke.router,
keyboard_shortcuts.router,
login.router,
logout.router,
profile.router,
Expand Down
11 changes: 11 additions & 0 deletions app/routers/keyboard_shortcuts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from app.dependencies import templates
from fastapi import APIRouter, Request
from starlette.templating import _TemplateResponse

router = APIRouter()


@router.get("/keyboard_shortcuts")
def keyboard_shortcuts(request: Request) -> _TemplateResponse:
return templates.TemplateResponse("keyboard_shortcuts.html", {
"request": request})
Empty file.
13 changes: 13 additions & 0 deletions app/static/keyboard_shortcuts/general_shortcuts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import './mousetrap.js'
import './mousetrap_bind_dict.js'

let key_shortcuts = {
'alt+c+h': function() { window.open('/', '_self'); },
'alt+c+i': function() { window.open('/invitations/', '_self'); },
'alt+c+p': function() { window.open('/profile/', '_self'); },
'alt+c+s': function() { window.open('/search/', '_self'); },
'alt+c+a': function() { window.open('/agenda/', '_self'); },
'ctrl+.': function() { window.open('/keyboard_shortcuts/', '_self'); }
Copy link
Member

Choose a reason for hiding this comment

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

Can you open this using modal instead? It's actually not too hard :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not understand, I need to open the page itself , not?
modal open a modal not the page, I need to navigate the user to the page he wanted
Thanks :)

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better not to move the user to a whole new page, but to show him the keyboard shortcuts in the same page. Just like Jupyter Notebook does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, do you mean just the /keyboard_shortcuts to open like modal instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, I created Modal instead of page by using the button in profile page and It's definitely more beautiful, but I was not able to run it nicely by keyboard shortcut. so I removed that shortcut it for now.
All the ways that I found to do so, was by change the visibility (CSS) or using jQuery or JS but by change the button of the modal to use JS function instead.
If you know how to do so I'll be glad to hear

Copy link
Member

Choose a reason for hiding this comment

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

What have you tried?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$(#keyboard-shortcuts).modal('show') - It did not work
or just change the display of the element to block

Copy link
Member

Choose a reason for hiding this comment

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

It does not work because it assumes jQuery is imported (and also syntactically wrong - there are no quote signs wrapping #keyboard-shortcuts). Look at the relevant documentation of bootstrap 5, not 4

};

Mousetrap.bind(key_shortcuts);
Loading