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 #1473: Add navigation and create feeds page #1475

Conversation

KatunaNorbert
Copy link
Member

@KatunaNorbert KatunaNorbert commented Jul 30, 2024

Fixes #1474

@KatunaNorbert KatunaNorbert marked this pull request as ready for review July 30, 2024 10:27
@KatunaNorbert KatunaNorbert requested review from calina-c and kdetry July 30, 2024 10:27
)


def layout(app):
Copy link
Contributor

@calina-c calina-c Jul 30, 2024

Choose a reason for hiding this comment

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

I would suggest converting all of these to a class, now. Since we evolved the knowledge required by each component, I would suggest creating Page/AppPage objects which take in app in the constructor. Functions that use knowledge from app or any other common structures can therefore be independent and parameter passing reduced. We can define a light interface using abc that requires all pages to have a layout() function. And maybe a main container and a nav which knows its own location.

In time, the procedural approach will get too complicated to manage so it's better to do this now.

Copy link
Contributor

@kdetry kdetry left a comment

Choose a reason for hiding this comment

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

We can deal with its style later


selected_predictoors = list(range(len(app.favourite_addresses)))

if app.favourite_addresses:
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is my work, but seeing it moved helped me realise we can simplify the ifs a bit. If we move app as a class attribute and it's easier to separate, let's retrieve the selected feeds in a separate function and keep the functional part away from the layout part. i.e. have a function "get_feeds_for_predictoors" instead of this block here (58-71)

return html.Div(
[
html.Div(
get_table(
Copy link
Contributor

Choose a reason for hiding this comment

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

I also think by this point we can have get_predictoors_table and get_feeds_table. The "get_table" function used to be simpler buy now it's reached 7 parameters and is almost a pass-through to the table itself

Copy link
Member Author

Choose a reason for hiding this comment

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

In my opinion, the get_table method has too many components and it's worth generalizing them rather than repeating them, it also contains other components beside the table, like inputs

@@ -38,8 +41,8 @@ def predictoor_dash(ppss: PPSS, debug_mode: bool):
Full error: {e}"""
)
return

get_callbacks(app)
get_callbacks_home(app)
Copy link
Contributor

Choose a reason for hiding this comment

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

having a Page-like OOP structure would also help in these cases here. Maybe we can have callbacks autoregistered by each page instead of calling these functions. This comment you can ignore, if you think it's too "science-fiction" :)

Copy link
Contributor

@kdetry kdetry Jul 30, 2024

Choose a reason for hiding this comment

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

Do you want a structure similar to a modern framework's (Laravel, Django etc) controller?

@KatunaNorbert
Copy link
Member Author

Do you think a Class is needed?
It will probably have 1 or 2 methods and there will most likely be just 3 pages

@KatunaNorbert KatunaNorbert merged commit b667ac4 into issue-1473-PdrDashboard-v04 Jul 30, 2024
4 checks passed
@KatunaNorbert KatunaNorbert deleted the issue-1474-PdrDashboard-add-navigation-menu branch July 30, 2024 13:02
calina-c pushed a commit that referenced this pull request Aug 19, 2024
* Fix #1473:  Add navigation and create feeds page (#1475)
* separated callbacks to be page specific, views by page
* [Fix #1481] PdrDashboard v0.4 Improve multipage DRY (#1482)
* Fix #1478: The Feeds Table  (#1487)
* [Fix #1491] PdrDashboard v0.4 - Split utils.py into concerns (#1493)
* [Fix #1490] PdrDashboard v0.4 Fixes predictoor addresses bug if invalid addresses in ppss. (#1492)
* [Fix #1485] PdrDashboard v0.4 - Feeds page metrics (#1486)
* Fix #1484: Create filters section (#1488)
* Fix #1508: Add WS buyer address (#1509)
* Fix #1501: Implement Numerize and format helpers (#1505)
* [Pdr Dashboard v0.4] Expendable rows (#1507)
* Fix #1515: Fix the legend (#1516)
* Fix #1520: Add search bar component (#1521)
* Fix #1519: Dashduo tests and the "sample_etl" structure (#1522)
* tests and architecture fixes
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.

3 participants