mihaildu / ra-resource-aggregator Goto Github PK
View Code? Open in Web Editor NEWResource aggregator for react-admin
Resource aggregator for react-admin
Currently if you have filter in params based on fields from non main resources it won't work. This should be done before sorting & pagination https://github.com/dryhten/ra-resource-aggregator/blob/master/src/index.js#L92
Right now we call the data provider from props as a function. This only works with data providers written for version 2. For version 3 we have to check if it's a function or not. If it's not, just call the appropriate function (e.g. for GET_LIST
call dataProvider.getList
).
More info here https://marmelab.com/react-admin/DataProviders.html
Right now we keep all the records in memory while we process everything (e.g. getAllRecords
in runGetQueries
). Not ideal, since we can deal with large databases in the back. Would be better to apply sorting, pagination & filter at database level. However, not sure this is possible since we only have access to other data providers.
This is a frontend package meant to be run inside the browser. However it has specified a main target instead of browser, as documented here: https://docs.npmjs.com/files/package.json#browser
Main should be replaced with browser and tested that everything still works.
Currently this packages makes the assumption that all resources have an id field. There might be cases where this is not true.
One example where this assumption is made is in getAllRecords where (since some data providers requires sort objects) it always sorts after id. Another example is in GET_ONE or even when running the accumulate queries for many-to-many relationships here.
This package was tested only with [email protected]
, [email protected]
and [email protected]
. It would be nice to see if it works with other versions of react-admin (I'm pretty sure it won't with 3.x) and add that to peerDependencies
in package.json.
It would also be nice to see what other data providers work with this out of the box.
Right now we build previousData for all resource if one of them has accumulate: true
. Not a critical operation, but would be nicer to do it per resource.
Some values get replaced by null when updating. Steps to reproduce:
example_users_profiles_groups
(make sure you have the package.json
with react-admin version 3, which is the default one or package.json.ra3
if you replaced it).GET_ONE
/ getOne
action to the data provider. The data provider will return data similar to this:{
"id": 1,
"username": "jim",
"email": "[email protected]",
"profiles_id": 1,
"first_name": "Jim",
"last_name": "Doe",
"user_id": 1
}
UPDATE
/ update
action to the data provider with the following params:params: {
"id": "1",
"data": {
"id": 1,
"username": "jim",
"email": "[email protected]",
"profiles_id": null,
"first_name": "Jim",
"last_name": "Doe",
"user_id": 1
},
"previousData": {
"id": 1,
"username": "jim",
"email": "[email protected]",
"profiles_id": 1,
"first_name": "Jim",
"last_name": "Doe",
"user_id": 1
}
}
As you can see, the profiles_id
was replaced in data
from 1 to null. You might have to try this several times as it seems it's nondeterministic, which makes the whole thing more confusing. Another thing that's confusing is that user_id
never gets replaced by null. In the edit view I have neither of them:
const UserProfilesEdit = props => (
<Edit {...props}>
<SimpleForm>
<TextInput source="username" />
<TextInput source="email" />
<TextInput source="first_name" />
<TextInput source="last_name" />
</SimpleForm>
</Edit>
);
I will try to reproduce this without the data aggregator, maybe it's a bug in react-admin. Possible solution to try is to add everything in the edit view, disabling ids.
I'm not happy with a lot of the names I used in the project. For example dataProviderMappings
(could be just mappings
), accumulate
, key
etc. A lot of these names were picked in a hurry so I can hit first MVP but it would be nice if someone goes back over them and find better names.
No props validations are done at the moment. It would be nice to have them.
Right now sorting doesn't work. I had an attempt at fixing it in #9 but actually this broke sorting completely as it currently only sorts data on current page (and not all records).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.