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

How to go for a flask-admin "kind of" interface? #260

Open
aprilmay opened this issue Jun 25, 2018 · 13 comments
Open

How to go for a flask-admin "kind of" interface? #260

aprilmay opened this issue Jun 25, 2018 · 13 comments
Labels
discussion A community discussion managed by the topic starter.

Comments

@aprilmay
Copy link

It's a very generic question, so i leave it open for comments and suggestions.

Many web frameworks propose a customizable "admin" interface, eg. Flask-admin, Django admin, etc.
So, with a typical Sanic/Gino tool stack, what options do we have for such a facility?

@fantix
Copy link
Member

fantix commented Jun 25, 2018

#167 provided some ideas on this topic.

@aprilmay
Copy link
Author

Thanks!
I also did some research, and also came to the conclusion that it's a long way, indeed.
A solution based on GraphQL or plain REST, and Vue.js (or another web frontend) sounds like the way to go.
That implies a Gino module exposing metadata and data with GraphQL or JSON REST, possibly with Sanic, Tornado and/or aiohttp.
Do you have any kind of starting point in mind for that?

@fantix
Copy link
Member

fantix commented Jun 26, 2018

Yeah I was actually trying to do that too, with iView Admin, for company projects. The login API barely worked, and I didn't find time to continue yet. Graphene was planned, but it was too much to include at a time.

@gyermolenko
Copy link
Contributor

don't know if it helps, but aiohttp_admin uses ng-admin but is migrating to admin-on-rest

@fantix
Copy link
Member

fantix commented Jun 26, 2018

@gyermolenko looks interesting! ..and familiar 😈

@fantix fantix added the question A community question, closed when inactive. label Jun 26, 2018
@aprilmay
Copy link
Author

@gyermolenko and @fantix: thanks for the inputs.

This currently leaves us with a lot of choices in the architecture: rest vs graphQL, sanic vs aiohttp, react vs angular... emacs vs vi ;)

I think i'll try some options, and hopefully give some feedbacks.

@aprilmay
Copy link
Author

Just a quick update (i've been diverted to many other works, and also a switch from sanic to aiohttp).

I started learning and experimenting with GraphQL, and grabbed the structure of graphene-sqlalchemy to create a graphene-gino package. Nothing that i can publish now, just a basic working proof of concept.
The front end runs with Angular/Material and Apollo. A lot of work pending, but i find it's encouraging.

@amirouche
Copy link

@gyermolenko https://github.com/marmelab/admin-on-rest is archived, any update on where is going forward https://github.com/aio-libs/aiohttp_admin ?

@amirouche
Copy link

@aprilmay what is the rational for using graphql instead of REST. Can you (quickly) explain how you made your choice?

@aprilmay
Copy link
Author

First, Graphql has metadata capabilities (schema description), which allows higher level operations (eg. relationships, types, caching) without too much hassle.
Fantix mentioned graphene in this thread, so i had a try and i found the learning curve worth the effort. Apollo is also a popular and robust library, so all the bricks for a graphql based architecture are in place.

Compared to Django admin where the logic is mostly server side, i find Graphql more appropriate with modern web applications (Angular, React, etc).

So, it sounds like a reasonable choice compared to plain REST for starting such a project as of today.

@amirouche: are you planning to work on it?

@amirouche
Copy link

@aprilmay I am investigating the use of GINO / aiohttp for a new project and stumbled upon this conversation. I very keen to build "my own castles in the sky" (ref) so take what I say with a grain of salt.

Apollo is also a popular

I don't buy popularity by default.

and robust library

See this example extracted from the official apollo getting started:

const Feed = () => (
  <Query query={GET_DOGS}>
    {({ loading, error, data }) => {
      if (error) return <Error />
      if (loading || !data) return <Fetching />;

      return <DogList dogs={data.dogs} />
    }}
  </Query>
)

See the second if says something like:

If (it is not a not error, because handled previously and) it is loading or there is no data render a spinner

If it's not an error and it's not loading then why there is no data ? It might be because the query was not fired yet but the apollo documentation doesn't explain it and if it was that why isn't that "query not already fired" not part of the "loading" state?

Compared to Django admin where the logic is mostly server side

I agree.

i find Graphql more appropriate with modern web applications (Angular, React, etc).

Mind the fact that GraphQL is around for almost as much time as ReactJS and did not gain as much adoption.

I like the idea of GraphQL as standard way to query the backend but I think it is missing some bits. As of yet, with GraphQL, I don't know:

  • how to query "graphical data" like trees (think of hierarchical menu, user / group hierarchy, whatever...).
  • how to enforce access rights (ACL)

it sounds like a reasonable choice compared to plain REST for starting such a project as of today.

IMHO it only looks reasonable. From a marketing point of view, I see that it will be possible to sell that experience. From an engineering point of view, I am not buying... yet!

@aprilmay
Copy link
Author

Very valid points. Don't buy anything from me either ;)

I can give some information, from my experience with a prototype (Angular/Apollo and Aiohttp/Gino):

  • handling of the request states is not really an issue, imho (at least, i didn't have to go to such detail, Angular and rxjs give abstractions over an async producer/consumer model, i assume reactJS would do the same)
  • ACLs: Graphene gives a "info" parameter where you find the request object from aiohttp. So, ACLs are no different from any other HTTP request (eg. "from aiohttp_security import check_permission")
  • complex structures like trees: i don't think that Graphql deals with such data structures natively. I implemented a menu with 2 levels (category -> model) quite easily. A generalization would require more work, eventually. If i understood your point correctly, it would also depend on defining a tree structure for models on Gino's side. Afaik, Flask-admin or Django admin don't go that far.

@aprilmay aprilmay reopened this Jan 28, 2019
@fantix fantix added discussion A community discussion managed by the topic starter. and removed question A community question, closed when inactive. labels Apr 20, 2020
@ShahriyarR
Copy link
Contributor

I saw this project recently:
https://github.com/xnuinside/gino-admin

Maybe it can be mentioned in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion A community discussion managed by the topic starter.
Projects
None yet
Development

No branches or pull requests

5 participants