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

Document a way of wrapping Existing api with BaseResource #306

Closed
user753 opened this issue Feb 21, 2020 · 10 comments
Closed

Document a way of wrapping Existing api with BaseResource #306

user753 opened this issue Feb 21, 2020 · 10 comments
Labels
documentation extra small very small issue which can be done in 1-2h or less good first issue Good for newcomers

Comments

@user753
Copy link

user753 commented Feb 21, 2020

Original question:

I have my own rest crud api and I would like to use only frontend part of admin-bro.
Does admin-bro support such scenario?

Proposed solution: MVP

  • document how to wrap existing API by BaseResource

End Solution

  • extend admin-bro core that, instead of asking own API, asks external API
  • this could be a method in Action interface: externalAPI (but we have to think of how to copy this function to the 'frontend' side)
@user753 user753 changed the title Using only frontend with existed rest api similar to react-admin Using only frontend with existing rest api similar to react-admin Feb 21, 2020
@wojtek-krysiak
Copy link
Contributor

wojtek-krysiak commented Feb 25, 2020

yes, but it is not the same as in react-admin. You will have to write your custom resource adapter which extends from BaseResource class.

I recently wrote an example app in typescript which shows this approach:

Here is the adapter which wraps JIRA API for projects: https://github.com/wojtek-krysiak/admin-bro-workshop/blob/master/src/jira-projects/jira-project.adapter.ts

and here is how to add this to AdminBroOptions: https://github.com/wojtek-krysiak/admin-bro-workshop/blob/master/src/admin/router.ts#L25

Example uses the latest beta version but it should work with the 1.6.x as well.

Here you can find the documentation for all methods in BaseResource: https://softwarebrothers.github.io/admin-bro-dev/BaseResource.html (1.6v)

or:

https://softwarebrothers.github.io/admin-bro-dev/v2/BaseResource.html (2.0 v)

@wojtek-krysiak wojtek-krysiak changed the title Using only frontend with existing rest api similar to react-admin Document a way of wrapping Existing api with BaseResource Feb 27, 2020
@wojtek-krysiak wojtek-krysiak added documentation extra small very small issue which can be done in 1-2h or less good first issue Good for newcomers labels Feb 27, 2020
@user753
Copy link
Author

user753 commented Mar 6, 2020

@wojtek-krysiak Thanks. Is it possible to use AdminBro UI as SPA without any server routing? If so, how could I render root component?

@user753
Copy link
Author

user753 commented Mar 10, 2020

@wojtek-krysiak any help?

@wojtek-krysiak
Copy link
Contributor

you can reuse our design system. It is here: https://github.com/SoftwareBrothers/admin-bro/tree/master/src/frontend/components/design-system. You can copy it to your project and use all the components we build (we have plan to extract this to a separate npm package)

@user753
Copy link
Author

user753 commented Mar 11, 2020

@wojtek-krysiak No, I mean I would like if it would be possible to use auto generated UI for BaseResource as SPA application.
For example in react-admin you need to implement DataProvider and it is possible to create UI for it

render(
    <Admin dataProvider={dataProvider}>
        <Resource name="posts"/>
    </Admin>,
    document.getElementById('root')
);

Is there any plans to support something like this?

@wojtek-krysiak
Copy link
Contributor

no. we dont have this in plans unfortunately :(. but may I ask why you dont want to use react-admin?

@user753
Copy link
Author

user753 commented Mar 12, 2020

It have a pure support for typescript and also it doesn't have something like ResourceOptions so one need to configure everything through components.

@user753
Copy link
Author

user753 commented Mar 12, 2020

What is the advantages of using frontend UI through server instead of SPA approach?

@wojtek-krysiak
Copy link
Contributor

wojtek-krysiak commented Mar 12, 2020

in server version, you have everything out of the box. So, in order to build a working admin panel you just need a database connection - admin generates api routes on the backend with all the CRUD logic. In SPA version you have to maintain backend on our own.

I am leaving this task open and I will add this to a description. Maybe someone will do this.

@dziraf dziraf closed this as completed Jun 15, 2022
@Inoir
Copy link

Inoir commented Jan 22, 2023

why is this closed? this isnt documented https://docs.adminjs.co/basics/resource or do i miss something?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation extra small very small issue which can be done in 1-2h or less good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants