Skip to content
This repository was archived by the owner on Mar 7, 2020. It is now read-only.

Dynamic statistics on administration panel #232

Merged
merged 10 commits into from
Jan 14, 2020

Conversation

lucaball
Copy link
Contributor

@lucaball lucaball commented Dec 2, 2019

This feature allows us to dynamically create dashboard widgets that are displayed in the dashboard of the admin panel.

@loic425
Copy link
Member

loic425 commented Dec 2, 2019

First of all, welcome!
The idea is pretty cool. Could we add a position to sort statistics providers?

@loic425
Copy link
Member

loic425 commented Dec 2, 2019

@lucaball
Copy link
Contributor Author

lucaball commented Dec 2, 2019

Hi @loic425 ,

Thank you!

And that's a good idea! I just did a test with your proposed solution, but I don't think this could be used to add a sort to the statistics. Because if I want to use a int as the key for sorting, the compilerpass overwrites it with the default array keys. This solution only works when defining your keys as words. Which would require extra code to convert those to values.

I propose to use the native supported functionality to add a priority to the service.
https://symfony.com/doc/current/service_container/tags.html#reference-tagged-services (at the bottom of the page). This way you can sort the statistics by giving them a higher or lower priority?

@loic425
Copy link
Member

loic425 commented Dec 3, 2019

I propose to use the native supported functionality to add a priority to the service.
https://symfony.com/doc/current/service_container/tags.html#reference-tagged-services (at the bottom of the page). This way you can sort the statistics by giving them a higher or lower priority?

Yes you're right. It's a good solution:)

@lucaball lucaball requested a review from loic425 December 5, 2019 16:58
@loic425
Copy link
Member

loic425 commented Dec 6, 2019

@lucasballyn The build has failed.

etc/travis/suites/application/script/validate-yaml-files
replace run_command "bin/console lint:yaml config"
with run_command "bin/console lint:yaml config --parse-tags"

Do you know phpspec ? there are few errors.
If you want, I can fix this part.

@lucaball
Copy link
Contributor Author

lucaball commented Dec 6, 2019

Unfortunately I don't know phpspec :( But I wouldn't mind learning if it's necessary to contribute to oss? Maybe (if you have time) you could do it for this PR, and in meantime I start learning it?

Is that ok for you?

Thanks in advance!

@loic425
Copy link
Member

loic425 commented Dec 6, 2019

Unfortunately I don't know phpspec :( But I wouldn't mind learning if it's necessary to contribute to oss? Maybe (if you have time) you could do it for this PR, and in meantime I start learning it?

Is that ok for you?

Thanks in advance!

Deal!
lf you plan to contribute on Sylius and Monofony, yes it's necessary. I discovered it when contributing on Sylius and it's so cool to design your services (and improve/refactor it later).

@lucaball
Copy link
Contributor Author

lucaball commented Dec 9, 2019

Unfortunately I don't know phpspec :( But I wouldn't mind learning if it's necessary to contribute to oss? Maybe (if you have time) you could do it for this PR, and in meantime I start learning it?
Is that ok for you?
Thanks in advance!

Deal!
lf you plan to contribute on Sylius and Monofony, yes it's necessary. I discovered it when contributing on Sylius and it's so cool to design your services (and improve/refactor it later).

Ok! Thank you very much!

@loic425 loic425 force-pushed the feature/dynamic-statistics branch from 6949c96 to d80eed4 Compare January 9, 2020 13:42
@loic425 loic425 changed the title Feature/dynamic statistics Dynamic statistics on administration panel Jan 9, 2020
@loic425
Copy link
Member

loic425 commented Jan 9, 2020

@lchrusciel Can you make a review please. This seems to me interesting but I'd like to have your opinion.

@loic425
Copy link
Member

loic425 commented Jan 9, 2020

@lucasballyn @lchrusciel
In Symfony 4.4 we can use a priority method to sort services!
symfony/symfony#33628

Perfect for this PR!

@lucaball
Copy link
Contributor Author

lucaball commented Jan 9, 2020

Hi @loic425,

Thank you for the updates while I was a little inactive! I hope to have more time soon to contribute more actively!

Anything else I need to do for this PR? Or is this ready to merge?

Thanks in advance!

@loic425
Copy link
Member

loic425 commented Jan 10, 2020

@lucasballyn Adding a cookbook on documentation seems to be necessary.
if you have enough time, you can init this new cookbook chapter. As you can see, there's a "getDefaultPriority" to sort the statistics but you need to clear cache to apply new sorting.

]);
}

public static function getDefaultPriority(): int
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to define service priorities in service configuration rather than in php code, but still a pretty neat solution 👍

lucaball and others added 8 commits January 14, 2020 13:11
Create config & providers to process the generation
Add return type to generate function in the interface
So we know a generated (HTML) string will be returned
Instead of in the main file. So we can define per statistic how wide it
should be. And this way the statistics gets nicely arranged when adding
multiple
@loic425 loic425 force-pushed the feature/dynamic-statistics branch from e138c13 to 07cf12e Compare January 14, 2020 12:12
@loic425 loic425 merged commit 195f16a into monofony:master Jan 14, 2020
@loic425
Copy link
Member

loic425 commented Jan 14, 2020

Thank you @lucasballyn! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy