GithubHelp home page GithubHelp logo

aor-postgrest-client's Introduction

postgREST Client for admin-on-rest

For using postgREST with admin-on-rest, use the postgrestClient function to convert AOR's REST dialect into one compatible with postgREST.

Installation

npm install aor-postgrest-client --save

Usage

See the example in App.js.example

// in src/App.js
import React from 'react';
import { Admin, Resource } from 'react-admin';
import postgrestClient from 'aor-postgrest-client';
import { List, Datagrid, TextField, NumberField } from 'react-admin';

import { ShowButton, EditButton, Edit, SimpleForm, DisabledInput, TextInput, NumberInput } from 'react-admin';
import { Create} from 'react-admin';
import { Show, SimpleShowLayout } from 'react-admin';

const BookList = (props) => (
    <List {...props}>
        <Datagrid>
            <ShowButton />
            <EditButton />
            <TextField source="author" />
            <NumberField source="count" />
        </Datagrid>
    </List>
);
export const BookShow = (props) => (
    <Show {...props}>
        <SimpleShowLayout>
            <TextField source="author" />
            <NumberField source="count" />
        </SimpleShowLayout>
    </Show>
);
export const BookEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <DisabledInput source="id" />
            <TextInput source="author" />
            <NumberInput source="count" />
        </SimpleForm>
    </Edit>
);
export const BookCreate = (props) => (
    <Create {...props}>
        <SimpleForm>
            <TextInput source="author" />
            <NumberInput source="count" />
        </SimpleForm>
    </Create>
);
const App = () => (
    <Admin dataProvider={postgrestClient('http://localhost:3000')}>
        <Resource name="books" show={BookShow} create={BookCreate} edit={BookEdit} list={BookList} />
    </Admin>
);

export default App;

License

This library is licensed under the MIT Licence, and sponsored by tomberek.

aor-postgrest-client's People

Contributors

absurd avatar dreisel avatar fzaninotto avatar jpetitcolas avatar oskrgg avatar sebastien-cleany avatar tomberek avatar wildsurfer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aor-postgrest-client's Issues

Foreign Key Picker?

Front end dev here feeling a bit out of my depth, but...Postgrest appears to support a syntax to join or get values from the matching foreign key. I'm using a nice app on desktop called Postico which allows you to lookup the foreign key values (and filter on them in the paid version).

Postgrest docs example:
GET /films?select=title,directors(id,last_name)

If I am for instance building a plant database, I have a plant_table with a row of Broccoli of ID 5 which belongs to plant family of Brassicas (ID: 1), when I create or edit this plant I would like to be able to type in "br" and see Brassicas listed, which once selected maps to the correct foreign key of ID: 1.

The following works, obviously:

export const PlantEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <TextInput source="name" />
            <NumberInput source="plant_family_f" />
        </SimpleForm>
    </Edit>
);

This doesn't work, for various reasons.

export const PlantEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <TextInput source="name" />
            <AutocompleteInput source="plant_family_f" options="plant_family_f(id,name)"/>
        </SimpleForm>
    </Edit>
);

Is what I'm trying to do possible out of the box, or am I going to have to maintain a separate dictionary for the foreign key values or something in my front end code?

Resolves too many React dependencies when used with admin-on-rest 1.3.2

When using admin-on-rest 1.3.2 with this package, it causes admin-on-rest@^0.7.0 to be loaded with an older, conflicting version of React. This prevents the app from starting.

This does not apply to current trunk, which does not support the new REST response format, but it will once #2 is fixed -- possibly by accepting PR #3.

Module not found with admin-on-rest

Im looking forward to using this client with admin-on-rest 0.7.2 version

I'm on Fedora 25 x86_64 with npm 3.10.10 and node 6.9.4

My sec/App.js looks like -

// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import postgrestClient from 'aor-postgrest-client';
import { CityList } from './geo_city';

const App = () => (
    <Admin restClient={postgrestClient('http://localhost:3000')}>
        <Resource name="geo_city" list={CityList} />
    </Admin>
);

export default App;

and I get

Failed to compile.

Error in ./src/App.js
Module not found: 'aor-postgrest-client' in /home/xxx/src/test-admin/test-admin/src

 @ ./src/App.js 14:26-57

aor-postgrest-client is installed in node_modules/aor-postgrest-client/

Is ReferenceField not implemented?

Whenever I try to use react-admin's ReferenceField component, the client logs the error below:
"Cannot read property 'data' of undefined"

Is this feature not implemented yet & if not, is this something you're wanting a developer to work on to submit a PR?

Wrong call for GET_MANY

PostgREST expects braces around the list of ids even if it's only one (eg. "id=in.(1)"). Currently "convertRESTRequestToHTTP" creates a request without the braces. Hence, PostgREST returns an error.

Here's the fix:
case _reactAdmin.GET_MANY:
{
url = apiUrl + '/' + resource + '?id=in.(' + params.ids.join(',') + ')';
break;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.